@nyaruka/temba-components 0.25.2 → 0.26.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/.github/workflows/build.yml +1 -1
- package/CHANGELOG.md +33 -0
- package/demo/index.html +60 -1
- package/dist/4f80c187.js +4277 -0
- package/dist/index.js +3957 -36
- package/dist/static/icons/symbol-defs.svg +29 -20
- 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 +1 -1
- package/out-tsc/src/FormElement.js.map +1 -1
- package/out-tsc/src/RapidElement.js +1 -1
- package/out-tsc/src/RapidElement.js.map +1 -1
- package/out-tsc/src/alert/Alert.js +3 -3
- package/out-tsc/src/alert/Alert.js.map +1 -1
- package/out-tsc/src/aliaseditor/AliasEditor.js +3 -3
- package/out-tsc/src/aliaseditor/AliasEditor.js.map +1 -1
- package/out-tsc/src/anchor/Anchor.js +2 -1
- package/out-tsc/src/anchor/Anchor.js.map +1 -1
- package/out-tsc/src/button/Button.js +2 -1
- package/out-tsc/src/button/Button.js.map +1 -1
- package/out-tsc/src/charcount/CharCount.js +2 -1
- package/out-tsc/src/charcount/CharCount.js.map +1 -1
- package/out-tsc/src/checkbox/Checkbox.js +3 -1
- package/out-tsc/src/checkbox/Checkbox.js.map +1 -1
- package/out-tsc/src/completion/Completion.js +2 -1
- package/out-tsc/src/completion/Completion.js.map +1 -1
- package/out-tsc/src/completion/helpers.js +27 -4
- package/out-tsc/src/completion/helpers.js.map +1 -1
- package/out-tsc/src/contacts/ContactChat.js +101 -86
- package/out-tsc/src/contacts/ContactChat.js.map +1 -1
- package/out-tsc/src/contacts/ContactDetails.js +2 -1
- package/out-tsc/src/contacts/ContactDetails.js.map +1 -1
- package/out-tsc/src/contacts/ContactHistory.js +32 -37
- package/out-tsc/src/contacts/ContactHistory.js.map +1 -1
- package/out-tsc/src/contacts/events.js +62 -76
- package/out-tsc/src/contacts/events.js.map +1 -1
- package/out-tsc/src/contactsearch/ContactSearch.js +2 -1
- package/out-tsc/src/contactsearch/ContactSearch.js.map +1 -1
- package/out-tsc/src/datepicker/DatePicker.js +2 -1
- package/out-tsc/src/datepicker/DatePicker.js.map +1 -1
- package/out-tsc/src/dialog/Dialog.js +2 -2
- package/out-tsc/src/dialog/Dialog.js.map +1 -1
- package/out-tsc/src/dialog/Modax.js +3 -6
- package/out-tsc/src/dialog/Modax.js.map +1 -1
- package/out-tsc/src/dropdown/Dropdown.js +133 -0
- package/out-tsc/src/dropdown/Dropdown.js.map +1 -0
- package/out-tsc/src/formfield/FormField.js +2 -1
- package/out-tsc/src/formfield/FormField.js.map +1 -1
- package/out-tsc/src/label/Label.js +2 -1
- package/out-tsc/src/label/Label.js.map +1 -1
- package/out-tsc/src/leafletmap/LeafletMap.js +2 -1
- package/out-tsc/src/leafletmap/LeafletMap.js.map +1 -1
- package/out-tsc/src/list/TembaList.js +7 -5
- package/out-tsc/src/list/TembaList.js.map +1 -1
- package/out-tsc/src/list/TembaMenu.js +112 -97
- package/out-tsc/src/list/TembaMenu.js.map +1 -1
- package/out-tsc/src/list/TicketList.js +2 -1
- package/out-tsc/src/list/TicketList.js.map +1 -1
- package/out-tsc/src/loading/Loading.js +2 -1
- package/out-tsc/src/loading/Loading.js.map +1 -1
- package/out-tsc/src/omnibox/Omnibox.js +2 -1
- package/out-tsc/src/omnibox/Omnibox.js.map +1 -1
- package/out-tsc/src/options/Options.js +3 -2
- package/out-tsc/src/options/Options.js.map +1 -1
- package/out-tsc/src/remote/Remote.js +2 -1
- package/out-tsc/src/remote/Remote.js.map +1 -1
- package/out-tsc/src/select/Select.js +8 -10
- package/out-tsc/src/select/Select.js.map +1 -1
- package/out-tsc/src/shadowless/Shadowless.js +2 -2
- package/out-tsc/src/shadowless/Shadowless.js.map +1 -1
- package/out-tsc/src/store/Store.js +2 -1
- package/out-tsc/src/store/Store.js.map +1 -1
- package/out-tsc/src/tabpane/Tab.js +46 -0
- package/out-tsc/src/tabpane/Tab.js.map +1 -0
- package/out-tsc/src/tabpane/TabPane.js +109 -0
- package/out-tsc/src/tabpane/TabPane.js.map +1 -0
- package/out-tsc/src/textinput/TextInput.js +3 -2
- package/out-tsc/src/textinput/TextInput.js.map +1 -1
- package/out-tsc/src/tip/Tip.js +2 -2
- package/out-tsc/src/tip/Tip.js.map +1 -1
- package/out-tsc/src/vectoricon/VectorIcon.js +18 -6
- package/out-tsc/src/vectoricon/VectorIcon.js.map +1 -1
- package/out-tsc/temba-modules.js +6 -0
- package/out-tsc/temba-modules.js.map +1 -1
- package/out-tsc/test/temba-contact-history.test.js +9 -6
- package/out-tsc/test/temba-contact-history.test.js.map +1 -1
- package/out-tsc/test/temba-dialog.test.js +3 -3
- package/out-tsc/test/temba-dialog.test.js.map +1 -1
- package/package.json +10 -9
- package/screenshots/truth/alert/error.png +0 -0
- package/screenshots/truth/alert/info.png +0 -0
- package/screenshots/truth/alert/warning.png +0 -0
- package/screenshots/truth/contacts/history-expanded.png +0 -0
- package/screenshots/truth/contacts/history.png +0 -0
- package/screenshots/truth/counter/summary.png +0 -0
- package/screenshots/truth/counter/unicode-variables.png +0 -0
- package/screenshots/truth/counter/unicode.png +0 -0
- package/screenshots/truth/dialog/focused.png +0 -0
- package/screenshots/truth/list/items-selected.png +0 -0
- package/screenshots/truth/list/items-updated.png +0 -0
- package/screenshots/truth/list/items.png +0 -0
- package/screenshots/truth/list/menu-root.png +0 -0
- package/screenshots/truth/list/menu-submenu.png +0 -0
- package/screenshots/truth/modax/form.png +0 -0
- package/screenshots/truth/modax/simple.png +0 -0
- package/screenshots/truth/options/block.png +0 -0
- package/screenshots/truth/select/embedded.png +0 -0
- package/screenshots/truth/select/expression-selected.png +0 -0
- package/screenshots/truth/select/expressions.png +0 -0
- package/screenshots/truth/select/functions.png +0 -0
- package/screenshots/truth/select/local-options.png +0 -0
- package/screenshots/truth/select/remote-options.png +0 -0
- package/screenshots/truth/select/search-enabled.png +0 -0
- package/screenshots/truth/select/search-selected-focus.png +0 -0
- package/screenshots/truth/select/search-selected.png +0 -0
- package/screenshots/truth/select/search-with-selected.png +0 -0
- package/screenshots/truth/select/searching.png +0 -0
- package/screenshots/truth/select/selected-multi.png +0 -0
- package/screenshots/truth/select/selected-single.png +0 -0
- package/screenshots/truth/select/selection-clearable.png +0 -0
- package/screenshots/truth/select/with-placeholder.png +0 -0
- package/screenshots/truth/select/without-placeholder.png +0 -0
- package/screenshots/truth/textinput/date-initialized.png +0 -0
- package/screenshots/truth/textinput/input-focused.png +0 -0
- package/screenshots/truth/textinput/textarea-focused.png +0 -0
- package/screenshots/truth/tip/bottom.png +0 -0
- package/screenshots/truth/tip/left.png +0 -0
- package/screenshots/truth/tip/right.png +0 -0
- package/screenshots/truth/tip/top.png +0 -0
- package/src/FormElement.ts +1 -1
- package/src/RapidElement.ts +1 -1
- package/src/alert/Alert.ts +3 -3
- package/src/aliaseditor/AliasEditor.ts +4 -3
- package/src/anchor/Anchor.ts +2 -1
- package/src/button/Button.ts +3 -1
- package/src/charcount/CharCount.ts +2 -1
- package/src/checkbox/Checkbox.ts +3 -1
- package/src/completion/Completion.ts +2 -1
- package/src/completion/helpers.ts +30 -4
- package/src/contacts/ContactChat.ts +115 -95
- package/src/contacts/ContactDetails.ts +2 -1
- package/src/contacts/ContactHistory.ts +64 -67
- package/src/contacts/events.ts +62 -77
- package/src/contactsearch/ContactSearch.ts +2 -1
- package/src/datepicker/DatePicker.ts +2 -7
- package/src/dialog/Dialog.ts +2 -2
- package/src/dialog/Modax.ts +4 -6
- package/src/dropdown/Dropdown.ts +136 -0
- package/src/formfield/FormField.ts +2 -1
- package/src/label/Label.ts +2 -8
- package/src/leafletmap/LeafletMap.ts +2 -2
- package/src/list/TembaList.ts +8 -5
- package/src/list/TembaMenu.ts +125 -103
- package/src/list/TicketList.ts +2 -1
- package/src/loading/Loading.ts +2 -1
- package/src/omnibox/Omnibox.ts +2 -1
- package/src/options/Options.ts +3 -2
- package/src/remote/Remote.ts +2 -7
- package/src/select/Select.ts +11 -10
- package/src/shadowless/Shadowless.ts +2 -2
- package/src/store/Store.ts +2 -1
- package/src/tabpane/Tab.ts +42 -0
- package/src/tabpane/TabPane.ts +113 -0
- package/src/textinput/TextInput.ts +3 -2
- package/src/tip/Tip.ts +2 -2
- package/src/vectoricon/VectorIcon.ts +18 -6
- package/static/css/temba-components.css +11 -0
- package/static/icons/Read Me.txt +1 -1
- package/static/icons/SVG/pause.svg +5 -0
- package/static/icons/SVG/play.svg +5 -0
- package/static/icons/SVG/{upload-cloud.svg → publish.svg} +1 -1
- package/static/icons/SVG/user-x.svg +5 -0
- package/static/icons/demo-external-svg.html +157 -142
- package/static/icons/demo-files/demo.css +3 -3
- package/static/icons/demo.html +186 -162
- package/static/icons/selection.json +390 -318
- package/static/icons/symbol-defs.svg +29 -20
- package/temba-modules.ts +6 -0
- package/test/temba-contact-history.test.ts +10 -6
- package/test/temba-dialog.test.ts +5 -6
- package/test-assets/modax/form.html +1 -1
- package/test-assets/style.css +7 -0
- package/web-test-runner.config.mjs +130 -117
- package/dist/56e0e480.js +0 -356
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
<svg aria-hidden="true" style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
2
2
|
<defs>
|
|
3
|
-
<symbol id="icon-
|
|
4
|
-
<path
|
|
3
|
+
<symbol id="icon-pause" viewBox="0 0 24 24">
|
|
4
|
+
<path d="M6 3c-0.552 0-1 0.448-1 1v16c0 0.552 0.448 1 1 1h4c0.552 0 1-0.448 1-1v-16c0-0.552-0.448-1-1-1zM7 5h2v14h-2zM14 3c-0.552 0-1 0.448-1 1v16c0 0.552 0.448 1 1 1h4c0.552 0 1-0.448 1-1v-16c0-0.552-0.448-1-1-1zM15 5h2v14h-2z"></path>
|
|
5
5
|
</symbol>
|
|
6
|
-
<symbol id="icon-
|
|
7
|
-
<path d="
|
|
6
|
+
<symbol id="icon-play" viewBox="0 0 24 24">
|
|
7
|
+
<path d="M5.541 2.159c-0.153-0.1-0.34-0.159-0.541-0.159-0.552 0-1 0.448-1 1v18c-0.001 0.182 0.050 0.372 0.159 0.541 0.299 0.465 0.917 0.599 1.382 0.3l14-9c0.114-0.072 0.219-0.174 0.3-0.3 0.299-0.465 0.164-1.083-0.3-1.382zM6 4.832l11.151 7.168-11.151 7.168z"></path>
|
|
8
8
|
</symbol>
|
|
9
|
-
<symbol id="icon-
|
|
10
|
-
<path d="
|
|
11
|
-
<path d="M5.112 12.427c0.864-0.565 1.939-0.994 3.122-1.256-0.235-0.278-0.449-0.588-0.633-0.922-0.475-0.863-0.726-1.813-0.726-2.748 0-1.344 0-2.614 0.478-3.653 0.464-1.008 1.299-1.633 2.488-1.867-0.264-1.195-0.968-1.98-2.841-1.98-3 0-3 2.015-3 4.5 0 1.548 0.898 3.095 2 3.716v0.825c-3.392 0.277-6 1.944-6 3.959h4.359c0.227-0.202 0.478-0.393 0.753-0.573z"></path>
|
|
12
|
-
</symbol>
|
|
13
|
-
<symbol id="icon-lock2" viewBox="0 0 16 16">
|
|
14
|
-
<path d="M13 7h-1v-3c0-2.209-1.791-4-4-4s-4 1.791-4 4v3h-1c-0.55 0-1 0.45-1 1v7c0 0.55 0.45 1 1 1h10c0.55 0 1-0.45 1-1v-7c0-0.55-0.45-1-1-1zM8 13c-0.552 0-1-0.448-1-1s0.448-1 1-1 1 0.448 1 1-0.448 1-1 1zM10 7h-4v-3c0-1.103 0.897-2 2-2s2 0.897 2 2v3z"></path>
|
|
15
|
-
</symbol>
|
|
16
|
-
<symbol id="icon-atom" viewBox="0 0 16 16">
|
|
17
|
-
<path d="M12.999 3.23v0 0zM13.032 8c1.631-1.56 2.423-3.087 1.896-4-0.301-0.521-0.99-0.77-1.929-0.77v0.75c0.659 0 1.137 0.148 1.28 0.395 0.113 0.195 0.050 0.496-0.023 0.713-0.139 0.417-0.442 0.917-0.876 1.444-0.263 0.32-0.567 0.643-0.904 0.963-0.465-0.402-0.982-0.801-1.544-1.188-0.055-0.679-0.142-1.327-0.257-1.93 0.878-0.26 1.675-0.397 2.323-0.397l0-0.75c-0 0-0 0-0 0-0.706 0-1.553 0.141-2.482 0.413-0.535-2.192-1.462-3.642-2.516-3.642s-1.981 1.45-2.516 3.642c-0.929-0.271-1.777-0.412-2.482-0.412-0.939 0-1.629 0.249-1.93 0.77-0.527 0.913 0.265 2.44 1.896 4-1.631 1.56-2.423 3.087-1.896 4 0.301 0.521 0.99 0.77 1.93 0.77 0.706 0 1.553-0.141 2.482-0.412 0.535 2.192 1.462 3.642 2.516 3.642s1.981-1.45 2.516-3.642c0.929 0.271 1.777 0.412 2.482 0.412 0.939 0 1.629-0.249 1.93-0.77 0.527-0.913-0.265-2.44-1.896-4zM11.915 8c-0.291 0.248-0.601 0.493-0.927 0.734 0.008-0.242 0.013-0.487 0.013-0.734s-0.004-0.492-0.013-0.734c0.327 0.241 0.637 0.486 0.927 0.734zM9.958 11.389c-0.36-0.128-0.728-0.274-1.098-0.435 0.213-0.113 0.426-0.232 0.64-0.355s0.424-0.25 0.63-0.378c-0.045 0.403-0.103 0.793-0.172 1.169zM9.125 9.949c-0.372 0.214-0.748 0.416-1.125 0.603-0.377-0.187-0.753-0.389-1.125-0.603-0.375-0.216-0.737-0.441-1.086-0.672-0.026-0.417-0.039-0.844-0.039-1.276s0.013-0.859 0.039-1.276c0.349-0.231 0.711-0.456 1.086-0.672 0.372-0.215 0.748-0.416 1.125-0.603 0.377 0.187 0.753 0.389 1.125 0.603 0.375 0.216 0.737 0.441 1.086 0.672 0.026 0.417 0.039 0.844 0.039 1.276s-0.013 0.859-0.039 1.276c-0.349 0.231-0.711 0.456-1.086 0.672zM5.87 10.22c0.205 0.128 0.415 0.254 0.63 0.378s0.427 0.242 0.64 0.355c-0.37 0.162-0.738 0.307-1.098 0.435-0.069-0.375-0.127-0.766-0.172-1.168zM5.013 8.734c-0.327-0.241-0.637-0.486-0.927-0.734 0.291-0.248 0.601-0.494 0.927-0.734-0.008 0.242-0.013 0.487-0.013 0.734s0.004 0.492 0.013 0.734zM6.042 4.612c0.36 0.128 0.728 0.274 1.098 0.435-0.213 0.113-0.426 0.232-0.64 0.355s-0.424 0.25-0.63 0.378c0.045-0.403 0.103-0.793 0.172-1.168zM9.5 5.402c-0.214-0.123-0.427-0.242-0.64-0.355 0.37-0.162 0.738-0.307 1.098-0.435 0.069 0.375 0.127 0.766 0.172 1.168-0.205-0.128-0.415-0.254-0.63-0.378zM6.581 2.607c0.24-0.639 0.521-1.151 0.813-1.48 0.152-0.172 0.381-0.376 0.607-0.376s0.454 0.205 0.607 0.376c0.292 0.329 0.573 0.841 0.813 1.48 0.146 0.388 0.273 0.812 0.382 1.265-0.58 0.202-1.185 0.45-1.801 0.743-0.616-0.292-1.221-0.541-1.801-0.743 0.109-0.453 0.237-0.877 0.382-1.265zM2.62 6.532c-0.434-0.527-0.736-1.026-0.876-1.444-0.073-0.218-0.135-0.518-0.023-0.713 0.143-0.247 0.621-0.395 1.28-0.395h0c0.648 0 1.445 0.137 2.323 0.397-0.115 0.603-0.202 1.251-0.257 1.93-0.561 0.387-1.079 0.787-1.544 1.188-0.338-0.321-0.641-0.643-0.904-0.963zM3.002 12.020c-0.659 0-1.137-0.148-1.28-0.395-0.113-0.195-0.050-0.496 0.023-0.713 0.139-0.417 0.442-0.917 0.876-1.444 0.263-0.32 0.567-0.643 0.904-0.963 0.465 0.402 0.982 0.801 1.544 1.188 0.055 0.679 0.142 1.327 0.257 1.93-0.878 0.26-1.675 0.397-2.323 0.397zM9.419 13.393c-0.24 0.639-0.521 1.151-0.813 1.48-0.152 0.172-0.381 0.376-0.607 0.376s-0.454-0.205-0.607-0.376c-0.292-0.329-0.573-0.841-0.813-1.48-0.146-0.388-0.273-0.812-0.382-1.265 0.58-0.202 1.185-0.45 1.801-0.743 0.616 0.292 1.221 0.541 1.801 0.743-0.109 0.453-0.236 0.877-0.382 1.265zM14.256 10.912c0.073 0.218 0.135 0.518 0.023 0.713-0.143 0.248-0.622 0.395-1.28 0.395-0.648 0-1.445-0.137-2.323-0.397 0.115-0.603 0.202-1.251 0.257-1.93 0.561-0.387 1.079-0.787 1.544-1.188 0.338 0.321 0.641 0.643 0.904 0.963 0.434 0.527 0.736 1.026 0.876 1.444z"></path>
|
|
18
|
-
</symbol>
|
|
19
|
-
<symbol id="icon-paperplane" viewBox="0 0 16 16">
|
|
20
|
-
<path d="M7 11l6.151 2.195 2.849-12.459zM5 10.311l11-9.575-16 7.913zM7 12.062v3.938l2.902-2.902z"></path>
|
|
21
|
-
</symbol>
|
|
22
|
-
<symbol id="icon-cancel" viewBox="0 0 16 16">
|
|
23
|
-
<path d="M11.5 0h-7l-4.5 4.5v7l4.5 4.5h7l4.5-4.5v-7l-4.5-4.5zM12.5 11l-1.5 1.5-3-3-3 3-1.5-1.5 3-3-3-3 1.5-1.5 3 3 3-3 1.5 1.5-3 3 3 3z"></path>
|
|
9
|
+
<symbol id="icon-user-x" viewBox="0 0 24 24">
|
|
10
|
+
<path d="M17 21v-2c0-1.38-0.561-2.632-1.464-3.536s-2.156-1.464-3.536-1.464h-7c-1.38 0-2.632 0.561-3.536 1.464s-1.464 2.156-1.464 3.536v2c0 0.552 0.448 1 1 1s1-0.448 1-1v-2c0-0.829 0.335-1.577 0.879-2.121s1.292-0.879 2.121-0.879h7c0.829 0 1.577 0.335 2.121 0.879s0.879 1.292 0.879 2.121v2c0 0.552 0.448 1 1 1s1-0.448 1-1zM13.5 7c0-1.38-0.561-2.632-1.464-3.536s-2.156-1.464-3.536-1.464-2.632 0.561-3.536 1.464-1.464 2.156-1.464 3.536 0.561 2.632 1.464 3.536 2.156 1.464 3.536 1.464 2.632-0.561 3.536-1.464 1.464-2.156 1.464-3.536zM11.5 7c0 0.829-0.335 1.577-0.879 2.121s-1.292 0.879-2.121 0.879-1.577-0.335-2.121-0.879-0.879-1.292-0.879-2.121 0.335-1.577 0.879-2.121 1.292-0.879 2.121-0.879 1.577 0.335 2.121 0.879 0.879 1.292 0.879 2.121zM22.293 7.293l-1.793 1.793-1.793-1.793c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414l1.793 1.793-1.793 1.793c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0l1.793-1.793 1.793 1.793c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-1.793-1.793 1.793-1.793c0.391-0.391 0.391-1.024 0-1.414s-1.024-0.391-1.414 0z"></path>
|
|
24
11
|
</symbol>
|
|
25
12
|
<symbol id="icon-cloud" viewBox="0 0 24 24">
|
|
26
13
|
<path d="M18 11c1.105 0 2.103 0.447 2.828 1.172s1.172 1.723 1.172 2.828-0.447 2.103-1.172 2.828-1.723 1.172-2.828 1.172h-8.995c-1.463-0.008-2.853-0.461-4.005-1.258-1.334-0.922-2.348-2.304-2.784-3.992-0.483-1.872-0.163-3.761 0.748-5.305s2.408-2.739 4.28-3.223 3.761-0.163 5.305 0.748 2.739 2.408 3.223 4.28c0.115 0.435 0.505 0.75 0.968 0.75zM18 9h-0.52c-0.725-2.057-2.143-3.708-3.915-4.753-1.983-1.169-4.415-1.583-6.821-0.961s-4.334 2.16-5.503 4.143-1.582 4.415-0.961 6.821c0.56 2.169 1.867 3.951 3.583 5.137 1.478 1.023 3.261 1.603 5.132 1.613h9.005c1.657 0 3.158-0.673 4.243-1.757s1.757-2.586 1.757-4.243-0.673-3.158-1.757-4.243-2.586-1.757-4.243-1.757z"></path>
|
|
@@ -103,7 +90,7 @@
|
|
|
103
90
|
<symbol id="icon-upload" viewBox="0 0 24 24">
|
|
104
91
|
<path d="M20 15v4c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-14c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-4c0-0.552-0.448-1-1-1s-1 0.448-1 1v4c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h14c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-4c0-0.552-0.448-1-1-1s-1 0.448-1 1zM11 5.414v9.586c0 0.552 0.448 1 1 1s1-0.448 1-1v-9.586l3.293 3.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-5-5c-0.092-0.092-0.202-0.166-0.324-0.217-0.245-0.101-0.521-0.101-0.766 0-0.118 0.049-0.228 0.121-0.324 0.217l-5 5c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0z"></path>
|
|
105
92
|
</symbol>
|
|
106
|
-
<symbol id="icon-
|
|
93
|
+
<symbol id="icon-publish" viewBox="0 0 24 24">
|
|
107
94
|
<path d="M11 14.414v6.586c0 0.552 0.448 1 1 1s1-0.448 1-1v-6.586l2.293 2.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-4-4c-0.092-0.092-0.202-0.166-0.324-0.217s-0.253-0.076-0.383-0.076c-0.256 0-0.512 0.098-0.707 0.293l-4 4c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0zM20.869 19.268c1.454-0.793 2.451-2.102 2.884-3.574s0.305-3.112-0.488-4.566c-0.679-1.245-1.737-2.155-2.959-2.663-0.724-0.301-1.505-0.46-2.299-0.465h-0.527c-0.725-2.057-2.144-3.708-3.917-4.752-1.983-1.168-4.415-1.581-6.821-0.959s-4.333 2.162-5.502 4.145-1.581 4.415-0.959 6.821c0.372 1.437 1.073 2.709 1.975 3.713 0.369 0.411 1.002 0.444 1.412 0.075s0.444-1.002 0.075-1.412c-0.688-0.765-1.235-1.75-1.526-2.877-0.484-1.872-0.164-3.761 0.746-5.305s2.407-2.74 4.279-3.224 3.761-0.164 5.305 0.746 2.74 2.407 3.224 4.279c0.116 0.435 0.506 0.75 0.969 0.75h1.253c0.536 0.004 1.061 0.111 1.545 0.312 0.815 0.339 1.517 0.943 1.97 1.773 0.529 0.97 0.615 2.061 0.325 3.044s-0.953 1.854-1.923 2.382c-0.485 0.264-0.664 0.872-0.399 1.357s0.872 0.664 1.357 0.399z"></path>
|
|
108
95
|
</symbol>
|
|
109
96
|
<symbol id="icon-coffee" viewBox="0 0 24 24">
|
|
@@ -349,6 +336,28 @@
|
|
|
349
336
|
<symbol id="icon-send-mobile" viewBox="0 0 24 24">
|
|
350
337
|
<path d="M17.016 17.016h1.969v3.984q0 0.844-0.586 1.43t-1.383 0.586h-10.031q-0.797 0-1.383-0.586t-0.586-1.43v-18q0-0.844 0.586-1.406t1.383-0.563l10.031-0.047q0.797 0 1.383 0.586t0.586 1.43v3.984h-1.969v-0.984h-10.031v12h10.031v-0.984zM21.984 12l-3.984-3.984v3h-5.016v1.969h5.016v3z"></path>
|
|
351
338
|
</symbol>
|
|
339
|
+
<symbol id="icon-zapier" viewBox="0 0 32 32">
|
|
340
|
+
<path fill="#ff4a00" style="fill: var(--color1, #ff4a00)" d="M20 16.005c0 1.191-0.22 2.328-0.615 3.38-1.049 0.396-2.191 0.615-3.38 0.615h-0.012c-1.191 0-2.327-0.22-3.379-0.615-0.396-1.052-0.615-2.191-0.615-3.38v-0.012c0-1.191 0.219-2.327 0.615-3.379 1.052-0.396 2.189-0.615 3.379-0.615h0.012c1.191 0 2.331 0.219 3.38 0.616 0.396 1.051 0.615 2.188 0.615 3.38zM31.78 13.333h-9.34l6.597-6.603c-0.52-0.731-1.093-1.413-1.727-2.044-0.631-0.632-1.313-1.209-2.040-1.728l-6.605 6.599v-9.337c-0.865-0.139-1.751-0.22-2.66-0.22h-0.013c-0.907 0-1.795 0.081-2.66 0.22v9.34l-6.6-6.599c-0.732 0.515-1.413 1.095-2.045 1.725-0.632 0.632-1.211 1.316-1.728 2.044l6.599 6.603h-9.337c0 0-0.22 1.755-0.22 2.66v0.012c0 0.907 0.081 1.797 0.22 2.66h9.34l-6.599 6.603c1.036 1.461 2.311 2.735 3.769 3.773l6.603-6.6v9.339c0.864 0.14 1.751 0.22 2.655 0.22h0.023c0.905 0 1.792-0.080 2.655-0.22v-9.339l6.603 6.6c0.731-0.5 1.413-1.083 2.039-1.72h0.007c0.631-0.62 1.208-1.301 1.728-2.041l-6.6-6.599h9.339c0.14-0.86 0.22-1.739 0.22-2.64v-0.041c0-0.904-0.080-1.791-0.22-2.653z"></path>
|
|
341
|
+
</symbol>
|
|
342
|
+
<symbol id="icon-channel" viewBox="0 0 16 16">
|
|
343
|
+
<path d="M0 11l5-8 5 5 6-4-5 9-5-5z"></path>
|
|
344
|
+
</symbol>
|
|
345
|
+
<symbol id="icon-users1" viewBox="0 0 18 16">
|
|
346
|
+
<path d="M12 12.041v-0.825c1.102-0.621 2-2.168 2-3.716 0-2.485 0-4.5-3-4.5s-3 2.015-3 4.5c0 1.548 0.898 3.095 2 3.716v0.825c-3.392 0.277-6 1.944-6 3.959h14c0-2.015-2.608-3.682-6-3.959z"></path>
|
|
347
|
+
<path d="M5.112 12.427c0.864-0.565 1.939-0.994 3.122-1.256-0.235-0.278-0.449-0.588-0.633-0.922-0.475-0.863-0.726-1.813-0.726-2.748 0-1.344 0-2.614 0.478-3.653 0.464-1.008 1.299-1.633 2.488-1.867-0.264-1.195-0.968-1.98-2.841-1.98-3 0-3 2.015-3 4.5 0 1.548 0.898 3.095 2 3.716v0.825c-3.392 0.277-6 1.944-6 3.959h4.359c0.227-0.202 0.478-0.393 0.753-0.573z"></path>
|
|
348
|
+
</symbol>
|
|
349
|
+
<symbol id="icon-lock2" viewBox="0 0 16 16">
|
|
350
|
+
<path d="M13 7h-1v-3c0-2.209-1.791-4-4-4s-4 1.791-4 4v3h-1c-0.55 0-1 0.45-1 1v7c0 0.55 0.45 1 1 1h10c0.55 0 1-0.45 1-1v-7c0-0.55-0.45-1-1-1zM8 13c-0.552 0-1-0.448-1-1s0.448-1 1-1 1 0.448 1 1-0.448 1-1 1zM10 7h-4v-3c0-1.103 0.897-2 2-2s2 0.897 2 2v3z"></path>
|
|
351
|
+
</symbol>
|
|
352
|
+
<symbol id="icon-atom" viewBox="0 0 16 16">
|
|
353
|
+
<path d="M12.999 3.23v0 0zM13.032 8c1.631-1.56 2.423-3.087 1.896-4-0.301-0.521-0.99-0.77-1.929-0.77v0.75c0.659 0 1.137 0.148 1.28 0.395 0.113 0.195 0.050 0.496-0.023 0.713-0.139 0.417-0.442 0.917-0.876 1.444-0.263 0.32-0.567 0.643-0.904 0.963-0.465-0.402-0.982-0.801-1.544-1.188-0.055-0.679-0.142-1.327-0.257-1.93 0.878-0.26 1.675-0.397 2.323-0.397l0-0.75c-0 0-0 0-0 0-0.706 0-1.553 0.141-2.482 0.413-0.535-2.192-1.462-3.642-2.516-3.642s-1.981 1.45-2.516 3.642c-0.929-0.271-1.777-0.412-2.482-0.412-0.939 0-1.629 0.249-1.93 0.77-0.527 0.913 0.265 2.44 1.896 4-1.631 1.56-2.423 3.087-1.896 4 0.301 0.521 0.99 0.77 1.93 0.77 0.706 0 1.553-0.141 2.482-0.412 0.535 2.192 1.462 3.642 2.516 3.642s1.981-1.45 2.516-3.642c0.929 0.271 1.777 0.412 2.482 0.412 0.939 0 1.629-0.249 1.93-0.77 0.527-0.913-0.265-2.44-1.896-4zM11.915 8c-0.291 0.248-0.601 0.493-0.927 0.734 0.008-0.242 0.013-0.487 0.013-0.734s-0.004-0.492-0.013-0.734c0.327 0.241 0.637 0.486 0.927 0.734zM9.958 11.389c-0.36-0.128-0.728-0.274-1.098-0.435 0.213-0.113 0.426-0.232 0.64-0.355s0.424-0.25 0.63-0.378c-0.045 0.403-0.103 0.793-0.172 1.169zM9.125 9.949c-0.372 0.214-0.748 0.416-1.125 0.603-0.377-0.187-0.753-0.389-1.125-0.603-0.375-0.216-0.737-0.441-1.086-0.672-0.026-0.417-0.039-0.844-0.039-1.276s0.013-0.859 0.039-1.276c0.349-0.231 0.711-0.456 1.086-0.672 0.372-0.215 0.748-0.416 1.125-0.603 0.377 0.187 0.753 0.389 1.125 0.603 0.375 0.216 0.737 0.441 1.086 0.672 0.026 0.417 0.039 0.844 0.039 1.276s-0.013 0.859-0.039 1.276c-0.349 0.231-0.711 0.456-1.086 0.672zM5.87 10.22c0.205 0.128 0.415 0.254 0.63 0.378s0.427 0.242 0.64 0.355c-0.37 0.162-0.738 0.307-1.098 0.435-0.069-0.375-0.127-0.766-0.172-1.168zM5.013 8.734c-0.327-0.241-0.637-0.486-0.927-0.734 0.291-0.248 0.601-0.494 0.927-0.734-0.008 0.242-0.013 0.487-0.013 0.734s0.004 0.492 0.013 0.734zM6.042 4.612c0.36 0.128 0.728 0.274 1.098 0.435-0.213 0.113-0.426 0.232-0.64 0.355s-0.424 0.25-0.63 0.378c0.045-0.403 0.103-0.793 0.172-1.168zM9.5 5.402c-0.214-0.123-0.427-0.242-0.64-0.355 0.37-0.162 0.738-0.307 1.098-0.435 0.069 0.375 0.127 0.766 0.172 1.168-0.205-0.128-0.415-0.254-0.63-0.378zM6.581 2.607c0.24-0.639 0.521-1.151 0.813-1.48 0.152-0.172 0.381-0.376 0.607-0.376s0.454 0.205 0.607 0.376c0.292 0.329 0.573 0.841 0.813 1.48 0.146 0.388 0.273 0.812 0.382 1.265-0.58 0.202-1.185 0.45-1.801 0.743-0.616-0.292-1.221-0.541-1.801-0.743 0.109-0.453 0.237-0.877 0.382-1.265zM2.62 6.532c-0.434-0.527-0.736-1.026-0.876-1.444-0.073-0.218-0.135-0.518-0.023-0.713 0.143-0.247 0.621-0.395 1.28-0.395h0c0.648 0 1.445 0.137 2.323 0.397-0.115 0.603-0.202 1.251-0.257 1.93-0.561 0.387-1.079 0.787-1.544 1.188-0.338-0.321-0.641-0.643-0.904-0.963zM3.002 12.020c-0.659 0-1.137-0.148-1.28-0.395-0.113-0.195-0.050-0.496 0.023-0.713 0.139-0.417 0.442-0.917 0.876-1.444 0.263-0.32 0.567-0.643 0.904-0.963 0.465 0.402 0.982 0.801 1.544 1.188 0.055 0.679 0.142 1.327 0.257 1.93-0.878 0.26-1.675 0.397-2.323 0.397zM9.419 13.393c-0.24 0.639-0.521 1.151-0.813 1.48-0.152 0.172-0.381 0.376-0.607 0.376s-0.454-0.205-0.607-0.376c-0.292-0.329-0.573-0.841-0.813-1.48-0.146-0.388-0.273-0.812-0.382-1.265 0.58-0.202 1.185-0.45 1.801-0.743 0.616 0.292 1.221 0.541 1.801 0.743-0.109 0.453-0.236 0.877-0.382 1.265zM14.256 10.912c0.073 0.218 0.135 0.518 0.023 0.713-0.143 0.248-0.622 0.395-1.28 0.395-0.648 0-1.445-0.137-2.323-0.397 0.115-0.603 0.202-1.251 0.257-1.93 0.561-0.387 1.079-0.787 1.544-1.188 0.338 0.321 0.641 0.643 0.904 0.963 0.434 0.527 0.736 1.026 0.876 1.444z"></path>
|
|
354
|
+
</symbol>
|
|
355
|
+
<symbol id="icon-paperplane" viewBox="0 0 16 16">
|
|
356
|
+
<path d="M7 11l6.151 2.195 2.849-12.459zM5 10.311l11-9.575-16 7.913zM7 12.062v3.938l2.902-2.902z"></path>
|
|
357
|
+
</symbol>
|
|
358
|
+
<symbol id="icon-cancel" viewBox="0 0 16 16">
|
|
359
|
+
<path d="M11.5 0h-7l-4.5 4.5v7l4.5 4.5h7l4.5-4.5v-7l-4.5-4.5zM12.5 11l-1.5 1.5-3-3-3 3-1.5-1.5 3-3-3-3 1.5-1.5 3 3 3-3 1.5 1.5-3 3 3 3z"></path>
|
|
360
|
+
</symbol>
|
|
352
361
|
<symbol id="icon-cord" viewBox="0 0 32 32">
|
|
353
362
|
<path d="M27.59 12.41c-0.464-0.464-1.216-0.464-1.679 0l-4.91 4.91-6.321-6.321 4.91-4.91c0.464-0.464 0.464-1.216 0-1.679s-1.216-0.464-1.679 0l-4.91 4.91-2.91-2.91c-0.464-0.464-1.216-0.464-1.679 0s-0.464 1.216 0 1.679l2.093 2.093-4.16 4.16c-2.636 2.636-3.048 6.653-1.236 9.721l-4.521 4.521c-0.781 0.781-0.781 2.047 0 2.828 0.391 0.391 0.902 0.586 1.414 0.586s1.024-0.195 1.414-0.586l4.521-4.521c3.068 1.812 7.085 1.4 9.721-1.236l4.16-4.16 2.093 2.093c0.232 0.232 0.536 0.348 0.84 0.348s0.608-0.116 0.84-0.348c0.464-0.464 0.464-1.216 0-1.679l-2.91-2.91 4.91-4.91c0.464-0.464 0.464-1.216 0-1.679z"></path>
|
|
354
363
|
</symbol>
|
package/temba-modules.ts
CHANGED
|
@@ -22,6 +22,9 @@ import { Omnibox } from './src/omnibox/Omnibox';
|
|
|
22
22
|
import { Tip } from './src/tip/Tip';
|
|
23
23
|
import { TembaMenu } from './src/list/TembaMenu';
|
|
24
24
|
import { Anchor } from './src/anchor/Anchor';
|
|
25
|
+
import { Dropdown } from './src/dropdown/Dropdown';
|
|
26
|
+
import { TabPane } from './src/tabpane/TabPane';
|
|
27
|
+
import { Tab } from './src/tabpane/Tab';
|
|
25
28
|
|
|
26
29
|
export function addCustomElement(name: string, comp: any) {
|
|
27
30
|
if (!window.customElements.get(name)) {
|
|
@@ -54,3 +57,6 @@ addCustomElement('temba-list', TembaList);
|
|
|
54
57
|
addCustomElement('temba-menu', TembaMenu);
|
|
55
58
|
addCustomElement('temba-contact-search', ContactSearch);
|
|
56
59
|
addCustomElement('temba-icon', VectorIcon);
|
|
60
|
+
addCustomElement('temba-dropdown', Dropdown);
|
|
61
|
+
addCustomElement('temba-tabs', TabPane);
|
|
62
|
+
addCustomElement('temba-tab', Tab);
|
|
@@ -14,7 +14,7 @@ export const createHistory = async (def: string) => {
|
|
|
14
14
|
const parentNode = document.createElement('div');
|
|
15
15
|
parentNode.setAttribute(
|
|
16
16
|
'style',
|
|
17
|
-
'width: 500px;height:750px;display:flex;flex-direction:column'
|
|
17
|
+
'width: 500px;height:750px;display:flex;flex-direction:column;flex-grow:1;min-height:0;'
|
|
18
18
|
);
|
|
19
19
|
const history = (await fixture(def, { parentNode })) as ContactHistory;
|
|
20
20
|
|
|
@@ -29,7 +29,8 @@ export const createHistory = async (def: string) => {
|
|
|
29
29
|
return history;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
const getHistoryHTML = (attrs: any = {}) =>
|
|
32
|
+
const getHistoryHTML = (attrs: any = {} as any) =>
|
|
33
|
+
// attrs = "min-height:0;display:flex;flex-grow:1;flex-direction:column";
|
|
33
34
|
getHTML('temba-contact-history', attrs);
|
|
34
35
|
|
|
35
36
|
const getHistoryClip = (ele: ContactHistory) => {
|
|
@@ -74,10 +75,11 @@ describe('temba-contact-history', () => {
|
|
|
74
75
|
// we should have scrolled to the bottom
|
|
75
76
|
const events = history.shadowRoot.querySelector('.events');
|
|
76
77
|
const top = events.scrollHeight - events.getBoundingClientRect().height;
|
|
77
|
-
|
|
78
|
+
|
|
79
|
+
expect(top).to.equal(539);
|
|
78
80
|
|
|
79
81
|
// make sure we actually scrolled to there
|
|
80
|
-
expect(events.scrollTop).to.equal(top -
|
|
82
|
+
expect(events.scrollTop).to.equal(top - 4);
|
|
81
83
|
|
|
82
84
|
await assertScreenshot('contacts/history', getHistoryClip(history));
|
|
83
85
|
});
|
|
@@ -90,14 +92,16 @@ describe('temba-contact-history', () => {
|
|
|
90
92
|
);
|
|
91
93
|
|
|
92
94
|
// our groups with collapsed events
|
|
93
|
-
const groups = [3,
|
|
95
|
+
const groups = [3, 5, 7];
|
|
94
96
|
for (const idx of groups) {
|
|
95
97
|
const group = history.shadowRoot.querySelector(
|
|
96
|
-
|
|
98
|
+
`.event-count[data-group-index='${idx}']`
|
|
97
99
|
) as HTMLDivElement;
|
|
98
100
|
group.click();
|
|
99
101
|
}
|
|
100
102
|
|
|
103
|
+
await waitFor(500);
|
|
104
|
+
|
|
101
105
|
await assertScreenshot(
|
|
102
106
|
'contacts/history-expanded',
|
|
103
107
|
getHistoryClip(history)
|
|
@@ -12,7 +12,7 @@ const getDialogClip = (dialog: Dialog) => {
|
|
|
12
12
|
const getDialogHTML = (hideOnClick = false) => {
|
|
13
13
|
return `
|
|
14
14
|
<temba-dialog header="Hello Dialog" ${hideOnClick ? 'hideOnClick' : ''}>
|
|
15
|
-
<
|
|
15
|
+
<input name="comment" type="text" style="margin: 10px"/>
|
|
16
16
|
</temba-dialog>
|
|
17
17
|
`;
|
|
18
18
|
};
|
|
@@ -89,8 +89,8 @@ describe('temba-dialog', () => {
|
|
|
89
89
|
const dialog: Dialog = await fixture(getDialogHTML());
|
|
90
90
|
await open(dialog);
|
|
91
91
|
|
|
92
|
-
const
|
|
93
|
-
expect(document.activeElement).to.equal(
|
|
92
|
+
const input = dialog.querySelector('input');
|
|
93
|
+
expect(document.activeElement).to.equal(input);
|
|
94
94
|
await assertScreenshot('dialog/focused', getDialogClip(dialog));
|
|
95
95
|
});
|
|
96
96
|
|
|
@@ -98,9 +98,8 @@ describe('temba-dialog', () => {
|
|
|
98
98
|
const dialog: Dialog = await fixture(getDialogHTML(true));
|
|
99
99
|
await open(dialog);
|
|
100
100
|
|
|
101
|
-
const mask: HTMLDivElement =
|
|
102
|
-
'#dialog-mask'
|
|
103
|
-
);
|
|
101
|
+
const mask: HTMLDivElement =
|
|
102
|
+
dialog.shadowRoot.querySelector('#dialog-mask');
|
|
104
103
|
mask.click();
|
|
105
104
|
|
|
106
105
|
await dialog.updateComplete;
|
package/test-assets/style.css
CHANGED
|
@@ -15,6 +15,7 @@ html input {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
html {
|
|
18
|
+
--transition-speed: 0ms !important;
|
|
18
19
|
--input-caret: transparent !important;
|
|
19
20
|
--font-family: 'Roboto';
|
|
20
21
|
--primary-rgb: 35, 135, 202;
|
|
@@ -168,6 +169,12 @@ temba-button.light.active {
|
|
|
168
169
|
--button-bg-img: linear-gradient(to bottom, transparent, rgba(0,0,0,.02));
|
|
169
170
|
}
|
|
170
171
|
|
|
172
|
+
temba-contact-history {
|
|
173
|
+
min-height:0;
|
|
174
|
+
display:flex;
|
|
175
|
+
flex-grow:1;
|
|
176
|
+
flex-direction:column;
|
|
177
|
+
}
|
|
171
178
|
|
|
172
179
|
temba-select:focus {
|
|
173
180
|
outline: none;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { puppeteerLauncher } from '@web/test-runner-puppeteer';
|
|
2
|
-
import fs from
|
|
3
|
-
import * as path from
|
|
4
|
-
import * as pngs from
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import * as pngs from 'pngjs';
|
|
5
5
|
import dynamicpixelmatch from 'dynamicpixelmatch';
|
|
6
6
|
import pixelmatch from 'pixelmatch';
|
|
7
7
|
import sizeOf from 'image-size';
|
|
8
8
|
|
|
9
|
-
import rimraf from
|
|
9
|
+
import rimraf from 'rimraf';
|
|
10
10
|
|
|
11
11
|
const SCREENSHOTS = 'screenshots';
|
|
12
12
|
const DIFF = 'diff';
|
|
13
|
-
const TEST =
|
|
14
|
-
const TRUTH =
|
|
13
|
+
const TEST = 'test';
|
|
14
|
+
const TRUTH = 'truth';
|
|
15
15
|
|
|
16
16
|
const PNG = pngs.PNG;
|
|
17
17
|
|
|
18
|
-
const fileExists =
|
|
18
|
+
const fileExists = filename => {
|
|
19
19
|
return new Promise((resolve, reject) => {
|
|
20
|
-
fs.access(filename, fs.F_OK,
|
|
20
|
+
fs.access(filename, fs.F_OK, err => {
|
|
21
21
|
if (err) {
|
|
22
22
|
resolve(false);
|
|
23
23
|
}
|
|
@@ -28,35 +28,31 @@ const fileExists = (filename) => {
|
|
|
28
28
|
|
|
29
29
|
const ensureExists = function (mydir) {
|
|
30
30
|
return new Promise((resolve, reject) => {
|
|
31
|
-
fs.mkdir(mydir, {recursive: true }, function (err) {
|
|
31
|
+
fs.mkdir(mydir, { recursive: true }, function (err) {
|
|
32
32
|
if (err) {
|
|
33
|
-
if (err.code ==
|
|
34
|
-
resolve(
|
|
33
|
+
if (err.code == 'EEXIST')
|
|
34
|
+
resolve('ignore the error if the folder already exists');
|
|
35
35
|
else reject(err); // something else went wrong
|
|
36
36
|
}
|
|
37
|
-
resolve(
|
|
37
|
+
resolve('path created');
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
|
|
43
42
|
const getPath = async (type, filename) => {
|
|
44
|
-
const file = path.resolve(SCREENSHOTS, type, filename)
|
|
43
|
+
const file = path.resolve(SCREENSHOTS, type, filename);
|
|
45
44
|
|
|
46
45
|
// make sure our directory exists
|
|
47
46
|
const parts = filename.split(path.sep);
|
|
48
47
|
let pngdir = parts.slice(0, parts.length - 1);
|
|
49
48
|
await ensureExists(path.resolve(SCREENSHOTS, type, ...pngdir));
|
|
50
|
-
|
|
51
|
-
return file;
|
|
52
|
-
}
|
|
53
49
|
|
|
50
|
+
return file;
|
|
51
|
+
};
|
|
54
52
|
|
|
55
53
|
const checkScreenshot = async (filename, excluded, threshold) => {
|
|
56
|
-
|
|
57
54
|
return new Promise(async (resolve, reject) => {
|
|
58
55
|
const doneReading = async () => {
|
|
59
|
-
|
|
60
56
|
// Wait until both files are read.
|
|
61
57
|
if (++filesRead < 2) return;
|
|
62
58
|
|
|
@@ -64,20 +60,25 @@ const checkScreenshot = async (filename, excluded, threshold) => {
|
|
|
64
60
|
if (img1.width != img2.width || img1.height !== img2.height) {
|
|
65
61
|
// resolve(`Screenshot was ${img2.width}x${img2.height} but should be ${img1.width}x${img1.height}:\n${testImg}`);
|
|
66
62
|
|
|
67
|
-
|
|
68
63
|
reject({
|
|
69
64
|
message: 'Screenshot was not the right size',
|
|
70
65
|
expected: `${img1.width}x${img1.height}`,
|
|
71
66
|
actual: `${img2.width}x${img2.height}`,
|
|
72
|
-
files: [testImg, truthImg, path.resolve(SCREENSHOTS)]
|
|
67
|
+
files: [testImg, truthImg, path.resolve(SCREENSHOTS)],
|
|
73
68
|
});
|
|
74
69
|
return;
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
// Do the visual diff.
|
|
78
73
|
const diff = new PNG({ width: img1.width, height: img2.height });
|
|
79
|
-
const matchOptions = {
|
|
80
|
-
|
|
74
|
+
const matchOptions = {
|
|
75
|
+
threshold: threshold || 0.3,
|
|
76
|
+
includeAA: false,
|
|
77
|
+
diffColor: [255, 0, 0],
|
|
78
|
+
aaColor: [0, 0, 255],
|
|
79
|
+
};
|
|
80
|
+
const numDiffPixels =
|
|
81
|
+
excluded != null && excluded.length != 0
|
|
81
82
|
? dynamicpixelmatch(
|
|
82
83
|
img1.data,
|
|
83
84
|
img2.data,
|
|
@@ -101,9 +102,12 @@ const checkScreenshot = async (filename, excluded, threshold) => {
|
|
|
101
102
|
// console.error("number of different pixels are not 0");
|
|
102
103
|
const diffImg = await getPath(DIFF, filename);
|
|
103
104
|
diff.pack().pipe(fs.createWriteStream(diffImg));
|
|
104
|
-
reject({
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
reject({
|
|
106
|
+
message: 'Pixel match failed',
|
|
107
|
+
files: [diffImg, testImg, truthImg, path.resolve(SCREENSHOTS)],
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
resolve('success');
|
|
107
111
|
};
|
|
108
112
|
|
|
109
113
|
let filesRead = 0;
|
|
@@ -114,18 +118,16 @@ const checkScreenshot = async (filename, excluded, threshold) => {
|
|
|
114
118
|
const img1 = fs
|
|
115
119
|
.createReadStream(truthImg)
|
|
116
120
|
.pipe(new PNG())
|
|
117
|
-
.on(
|
|
118
|
-
|
|
121
|
+
.on('parsed', await doneReading);
|
|
122
|
+
|
|
119
123
|
const img2 = fs
|
|
120
124
|
.createReadStream(testImg)
|
|
121
125
|
.pipe(new PNG())
|
|
122
|
-
.on(
|
|
126
|
+
.on('parsed', await doneReading);
|
|
123
127
|
});
|
|
124
128
|
};
|
|
125
129
|
|
|
126
|
-
|
|
127
130
|
const wireScreenshots = async (page, context) => {
|
|
128
|
-
|
|
129
131
|
// clear out any past tests
|
|
130
132
|
const diffs = path.resolve(SCREENSHOTS, DIFF);
|
|
131
133
|
const tests = path.resolve(SCREENSHOTS, TEST);
|
|
@@ -133,111 +135,108 @@ const wireScreenshots = async (page, context) => {
|
|
|
133
135
|
rimraf.sync(diffs);
|
|
134
136
|
rimraf.sync(tests);
|
|
135
137
|
|
|
136
|
-
await page.exposeFunction(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (wDiff < .15) {
|
|
163
|
-
clip.width = width;
|
|
164
|
-
}
|
|
138
|
+
await page.exposeFunction(
|
|
139
|
+
'matchPageSnapshot',
|
|
140
|
+
(filename, clip, excluded, threshold) => {
|
|
141
|
+
return new Promise(async (resolve, reject) => {
|
|
142
|
+
const testFile = await getPath(TEST, filename);
|
|
143
|
+
const truthFile = await getPath(TRUTH, filename);
|
|
144
|
+
|
|
145
|
+
if (!(await fileExists(truthFile))) {
|
|
146
|
+
// no truth yet, record it
|
|
147
|
+
await page.screenshot({ path: truthFile, clip });
|
|
148
|
+
} else {
|
|
149
|
+
// if its close, force our file to be the same size as our truth for pixelmatch
|
|
150
|
+
const dimensions = sizeOf(truthFile);
|
|
151
|
+
let { width, height } = dimensions;
|
|
152
|
+
|
|
153
|
+
// we should have a device ratio of 2
|
|
154
|
+
width /= 2;
|
|
155
|
+
height /= 2;
|
|
156
|
+
|
|
157
|
+
const wDiff = Math.abs((clip.width - width) / width);
|
|
158
|
+
const hDiff = Math.abs((clip.height - height) / height);
|
|
159
|
+
|
|
160
|
+
if (wDiff < 0.15) {
|
|
161
|
+
clip.width = width;
|
|
162
|
+
}
|
|
165
163
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
if (hDiff < 0.15) {
|
|
165
|
+
clip.height = height;
|
|
166
|
+
}
|
|
169
167
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
168
|
+
if (!clip.width || !clip.height) {
|
|
169
|
+
reject({ message: "Couldn't take screenshot clip is empty" });
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
174
172
|
|
|
175
|
-
|
|
176
|
-
|
|
173
|
+
// create a test screenshot to compare with our truth
|
|
174
|
+
await page.screenshot({ path: testFile, clip });
|
|
177
175
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
176
|
+
try {
|
|
177
|
+
const result = await checkScreenshot(filename);
|
|
178
|
+
resolve(result);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
reject(error);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
184
183
|
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
resolve(true);
|
|
188
|
-
|
|
189
|
-
});
|
|
190
184
|
|
|
191
|
-
|
|
185
|
+
resolve(true);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
);
|
|
192
189
|
|
|
193
|
-
await page.exposeFunction(
|
|
190
|
+
await page.exposeFunction('setViewport', async options => {
|
|
194
191
|
await page.setViewport(options);
|
|
195
192
|
});
|
|
196
|
-
|
|
197
|
-
await page.exposeFunction(
|
|
193
|
+
|
|
194
|
+
await page.exposeFunction('waitFor', millis => {
|
|
198
195
|
return new Promise(async (resolve, reject) => {
|
|
199
196
|
await page.waitForTimeout(millis);
|
|
200
197
|
resolve();
|
|
201
198
|
});
|
|
202
199
|
});
|
|
203
200
|
|
|
204
|
-
await page.exposeFunction(
|
|
201
|
+
await page.exposeFunction('moveMouse', (x, y) => {
|
|
205
202
|
return new Promise(async (resolve, reject) => {
|
|
206
|
-
await page.mouse.move(x,y);
|
|
203
|
+
await page.mouse.move(x, y);
|
|
207
204
|
resolve();
|
|
208
205
|
});
|
|
209
206
|
});
|
|
210
207
|
|
|
211
|
-
await page.exposeFunction(
|
|
212
|
-
const frame = await page.frames().find(
|
|
208
|
+
await page.exposeFunction('click', async element => {
|
|
209
|
+
const frame = await page.frames().find(f => {
|
|
213
210
|
return true;
|
|
214
211
|
});
|
|
215
212
|
const ele = await frame.$(element);
|
|
216
213
|
await ele.click({});
|
|
217
214
|
});
|
|
218
215
|
|
|
219
|
-
await page.exposeFunction(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
216
|
+
await page.exposeFunction(
|
|
217
|
+
'typeInto',
|
|
218
|
+
async (selector, text, replace = false) => {
|
|
219
|
+
// console.log("frames", page.frames().length);
|
|
220
|
+
const frame = await page.frames().find(f => {
|
|
221
|
+
return true;
|
|
222
|
+
});
|
|
223
|
+
const element = await frame.$(selector);
|
|
224
|
+
|
|
225
|
+
await element.click({ clickCount: replace ? 3 : 1 });
|
|
226
|
+
await page.keyboard.type(text);
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
229
|
|
|
230
|
-
await page.exposeFunction(
|
|
231
|
-
for (let i=0; i<times; i++) {
|
|
230
|
+
await page.exposeFunction('pressKey', async (key, times, options) => {
|
|
231
|
+
for (let i = 0; i < times; i++) {
|
|
232
232
|
await page.keyboard.press(key, options);
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
235
|
|
|
236
|
-
await page.exposeFunction(
|
|
236
|
+
await page.exposeFunction('type', async text => {
|
|
237
237
|
await page.keyboard.type(text);
|
|
238
238
|
});
|
|
239
|
-
}
|
|
240
|
-
|
|
239
|
+
};
|
|
241
240
|
|
|
242
241
|
export default {
|
|
243
242
|
rootDir: './',
|
|
@@ -248,7 +247,12 @@ export default {
|
|
|
248
247
|
name: 'add-style',
|
|
249
248
|
transform(context) {
|
|
250
249
|
if (context.response.is('html')) {
|
|
251
|
-
return {
|
|
250
|
+
return {
|
|
251
|
+
body: context.body.replace(
|
|
252
|
+
/<head>/,
|
|
253
|
+
`<head><link rel="stylesheet" href="/test-assets/style.css">`
|
|
254
|
+
),
|
|
255
|
+
};
|
|
252
256
|
}
|
|
253
257
|
},
|
|
254
258
|
},
|
|
@@ -267,32 +271,41 @@ export default {
|
|
|
267
271
|
browsers: [
|
|
268
272
|
puppeteerLauncher({
|
|
269
273
|
launchOptions: {
|
|
274
|
+
args: [
|
|
275
|
+
'--font-render-hinting=medium',
|
|
276
|
+
'--force-color-profile=srgb',
|
|
277
|
+
'--hide-scrollbars',
|
|
278
|
+
'--disable-web-security',
|
|
279
|
+
'--force-device-scale-factor=1'
|
|
280
|
+
],
|
|
270
281
|
headless: true,
|
|
271
282
|
},
|
|
272
|
-
createBrowserContext: (
|
|
283
|
+
createBrowserContext: ({ browser, config }) =>
|
|
284
|
+
browser.defaultBrowserContext(),
|
|
273
285
|
createPage: async ({ context, config }) => {
|
|
274
286
|
const page = await context.newPage();
|
|
275
|
-
await page.
|
|
287
|
+
await page.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36");
|
|
288
|
+
await page.exposeFunction('readStaticFile', filename => {
|
|
276
289
|
try {
|
|
277
|
-
var content = fs.readFileSync(
|
|
290
|
+
var content = fs.readFileSync('./' + filename, 'utf8');
|
|
278
291
|
return content;
|
|
279
|
-
} catch(err) {
|
|
292
|
+
} catch (err) {
|
|
280
293
|
console.log(err);
|
|
281
294
|
}
|
|
282
|
-
return
|
|
283
|
-
})
|
|
284
|
-
|
|
295
|
+
return 'Not Found';
|
|
296
|
+
});
|
|
297
|
+
|
|
285
298
|
await page.once('load', async () => {
|
|
286
|
-
await page.addScriptTag(
|
|
299
|
+
await page.addScriptTag({
|
|
300
|
+
content: `
|
|
287
301
|
window.watched = ${config.watch};
|
|
288
|
-
|
|
302
|
+
`,
|
|
303
|
+
});
|
|
289
304
|
await wireScreenshots(page, context);
|
|
290
305
|
});
|
|
291
|
-
|
|
306
|
+
|
|
292
307
|
return page;
|
|
293
308
|
},
|
|
294
|
-
|
|
309
|
+
}),
|
|
295
310
|
],
|
|
296
311
|
};
|
|
297
|
-
|
|
298
|
-
|