@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.
Files changed (186) hide show
  1. package/.github/workflows/build.yml +1 -1
  2. package/CHANGELOG.md +33 -0
  3. package/demo/index.html +60 -1
  4. package/dist/4f80c187.js +4277 -0
  5. package/dist/index.js +3957 -36
  6. package/dist/static/icons/symbol-defs.svg +29 -20
  7. package/dist/sw.js +1 -1
  8. package/dist/sw.js.map +1 -1
  9. package/dist/templates/components-body.html +1 -1
  10. package/dist/templates/components-head.html +1 -1
  11. package/out-tsc/src/FormElement.js +1 -1
  12. package/out-tsc/src/FormElement.js.map +1 -1
  13. package/out-tsc/src/RapidElement.js +1 -1
  14. package/out-tsc/src/RapidElement.js.map +1 -1
  15. package/out-tsc/src/alert/Alert.js +3 -3
  16. package/out-tsc/src/alert/Alert.js.map +1 -1
  17. package/out-tsc/src/aliaseditor/AliasEditor.js +3 -3
  18. package/out-tsc/src/aliaseditor/AliasEditor.js.map +1 -1
  19. package/out-tsc/src/anchor/Anchor.js +2 -1
  20. package/out-tsc/src/anchor/Anchor.js.map +1 -1
  21. package/out-tsc/src/button/Button.js +2 -1
  22. package/out-tsc/src/button/Button.js.map +1 -1
  23. package/out-tsc/src/charcount/CharCount.js +2 -1
  24. package/out-tsc/src/charcount/CharCount.js.map +1 -1
  25. package/out-tsc/src/checkbox/Checkbox.js +3 -1
  26. package/out-tsc/src/checkbox/Checkbox.js.map +1 -1
  27. package/out-tsc/src/completion/Completion.js +2 -1
  28. package/out-tsc/src/completion/Completion.js.map +1 -1
  29. package/out-tsc/src/completion/helpers.js +27 -4
  30. package/out-tsc/src/completion/helpers.js.map +1 -1
  31. package/out-tsc/src/contacts/ContactChat.js +101 -86
  32. package/out-tsc/src/contacts/ContactChat.js.map +1 -1
  33. package/out-tsc/src/contacts/ContactDetails.js +2 -1
  34. package/out-tsc/src/contacts/ContactDetails.js.map +1 -1
  35. package/out-tsc/src/contacts/ContactHistory.js +32 -37
  36. package/out-tsc/src/contacts/ContactHistory.js.map +1 -1
  37. package/out-tsc/src/contacts/events.js +62 -76
  38. package/out-tsc/src/contacts/events.js.map +1 -1
  39. package/out-tsc/src/contactsearch/ContactSearch.js +2 -1
  40. package/out-tsc/src/contactsearch/ContactSearch.js.map +1 -1
  41. package/out-tsc/src/datepicker/DatePicker.js +2 -1
  42. package/out-tsc/src/datepicker/DatePicker.js.map +1 -1
  43. package/out-tsc/src/dialog/Dialog.js +2 -2
  44. package/out-tsc/src/dialog/Dialog.js.map +1 -1
  45. package/out-tsc/src/dialog/Modax.js +3 -6
  46. package/out-tsc/src/dialog/Modax.js.map +1 -1
  47. package/out-tsc/src/dropdown/Dropdown.js +133 -0
  48. package/out-tsc/src/dropdown/Dropdown.js.map +1 -0
  49. package/out-tsc/src/formfield/FormField.js +2 -1
  50. package/out-tsc/src/formfield/FormField.js.map +1 -1
  51. package/out-tsc/src/label/Label.js +2 -1
  52. package/out-tsc/src/label/Label.js.map +1 -1
  53. package/out-tsc/src/leafletmap/LeafletMap.js +2 -1
  54. package/out-tsc/src/leafletmap/LeafletMap.js.map +1 -1
  55. package/out-tsc/src/list/TembaList.js +7 -5
  56. package/out-tsc/src/list/TembaList.js.map +1 -1
  57. package/out-tsc/src/list/TembaMenu.js +112 -97
  58. package/out-tsc/src/list/TembaMenu.js.map +1 -1
  59. package/out-tsc/src/list/TicketList.js +2 -1
  60. package/out-tsc/src/list/TicketList.js.map +1 -1
  61. package/out-tsc/src/loading/Loading.js +2 -1
  62. package/out-tsc/src/loading/Loading.js.map +1 -1
  63. package/out-tsc/src/omnibox/Omnibox.js +2 -1
  64. package/out-tsc/src/omnibox/Omnibox.js.map +1 -1
  65. package/out-tsc/src/options/Options.js +3 -2
  66. package/out-tsc/src/options/Options.js.map +1 -1
  67. package/out-tsc/src/remote/Remote.js +2 -1
  68. package/out-tsc/src/remote/Remote.js.map +1 -1
  69. package/out-tsc/src/select/Select.js +8 -10
  70. package/out-tsc/src/select/Select.js.map +1 -1
  71. package/out-tsc/src/shadowless/Shadowless.js +2 -2
  72. package/out-tsc/src/shadowless/Shadowless.js.map +1 -1
  73. package/out-tsc/src/store/Store.js +2 -1
  74. package/out-tsc/src/store/Store.js.map +1 -1
  75. package/out-tsc/src/tabpane/Tab.js +46 -0
  76. package/out-tsc/src/tabpane/Tab.js.map +1 -0
  77. package/out-tsc/src/tabpane/TabPane.js +109 -0
  78. package/out-tsc/src/tabpane/TabPane.js.map +1 -0
  79. package/out-tsc/src/textinput/TextInput.js +3 -2
  80. package/out-tsc/src/textinput/TextInput.js.map +1 -1
  81. package/out-tsc/src/tip/Tip.js +2 -2
  82. package/out-tsc/src/tip/Tip.js.map +1 -1
  83. package/out-tsc/src/vectoricon/VectorIcon.js +18 -6
  84. package/out-tsc/src/vectoricon/VectorIcon.js.map +1 -1
  85. package/out-tsc/temba-modules.js +6 -0
  86. package/out-tsc/temba-modules.js.map +1 -1
  87. package/out-tsc/test/temba-contact-history.test.js +9 -6
  88. package/out-tsc/test/temba-contact-history.test.js.map +1 -1
  89. package/out-tsc/test/temba-dialog.test.js +3 -3
  90. package/out-tsc/test/temba-dialog.test.js.map +1 -1
  91. package/package.json +10 -9
  92. package/screenshots/truth/alert/error.png +0 -0
  93. package/screenshots/truth/alert/info.png +0 -0
  94. package/screenshots/truth/alert/warning.png +0 -0
  95. package/screenshots/truth/contacts/history-expanded.png +0 -0
  96. package/screenshots/truth/contacts/history.png +0 -0
  97. package/screenshots/truth/counter/summary.png +0 -0
  98. package/screenshots/truth/counter/unicode-variables.png +0 -0
  99. package/screenshots/truth/counter/unicode.png +0 -0
  100. package/screenshots/truth/dialog/focused.png +0 -0
  101. package/screenshots/truth/list/items-selected.png +0 -0
  102. package/screenshots/truth/list/items-updated.png +0 -0
  103. package/screenshots/truth/list/items.png +0 -0
  104. package/screenshots/truth/list/menu-root.png +0 -0
  105. package/screenshots/truth/list/menu-submenu.png +0 -0
  106. package/screenshots/truth/modax/form.png +0 -0
  107. package/screenshots/truth/modax/simple.png +0 -0
  108. package/screenshots/truth/options/block.png +0 -0
  109. package/screenshots/truth/select/embedded.png +0 -0
  110. package/screenshots/truth/select/expression-selected.png +0 -0
  111. package/screenshots/truth/select/expressions.png +0 -0
  112. package/screenshots/truth/select/functions.png +0 -0
  113. package/screenshots/truth/select/local-options.png +0 -0
  114. package/screenshots/truth/select/remote-options.png +0 -0
  115. package/screenshots/truth/select/search-enabled.png +0 -0
  116. package/screenshots/truth/select/search-selected-focus.png +0 -0
  117. package/screenshots/truth/select/search-selected.png +0 -0
  118. package/screenshots/truth/select/search-with-selected.png +0 -0
  119. package/screenshots/truth/select/searching.png +0 -0
  120. package/screenshots/truth/select/selected-multi.png +0 -0
  121. package/screenshots/truth/select/selected-single.png +0 -0
  122. package/screenshots/truth/select/selection-clearable.png +0 -0
  123. package/screenshots/truth/select/with-placeholder.png +0 -0
  124. package/screenshots/truth/select/without-placeholder.png +0 -0
  125. package/screenshots/truth/textinput/date-initialized.png +0 -0
  126. package/screenshots/truth/textinput/input-focused.png +0 -0
  127. package/screenshots/truth/textinput/textarea-focused.png +0 -0
  128. package/screenshots/truth/tip/bottom.png +0 -0
  129. package/screenshots/truth/tip/left.png +0 -0
  130. package/screenshots/truth/tip/right.png +0 -0
  131. package/screenshots/truth/tip/top.png +0 -0
  132. package/src/FormElement.ts +1 -1
  133. package/src/RapidElement.ts +1 -1
  134. package/src/alert/Alert.ts +3 -3
  135. package/src/aliaseditor/AliasEditor.ts +4 -3
  136. package/src/anchor/Anchor.ts +2 -1
  137. package/src/button/Button.ts +3 -1
  138. package/src/charcount/CharCount.ts +2 -1
  139. package/src/checkbox/Checkbox.ts +3 -1
  140. package/src/completion/Completion.ts +2 -1
  141. package/src/completion/helpers.ts +30 -4
  142. package/src/contacts/ContactChat.ts +115 -95
  143. package/src/contacts/ContactDetails.ts +2 -1
  144. package/src/contacts/ContactHistory.ts +64 -67
  145. package/src/contacts/events.ts +62 -77
  146. package/src/contactsearch/ContactSearch.ts +2 -1
  147. package/src/datepicker/DatePicker.ts +2 -7
  148. package/src/dialog/Dialog.ts +2 -2
  149. package/src/dialog/Modax.ts +4 -6
  150. package/src/dropdown/Dropdown.ts +136 -0
  151. package/src/formfield/FormField.ts +2 -1
  152. package/src/label/Label.ts +2 -8
  153. package/src/leafletmap/LeafletMap.ts +2 -2
  154. package/src/list/TembaList.ts +8 -5
  155. package/src/list/TembaMenu.ts +125 -103
  156. package/src/list/TicketList.ts +2 -1
  157. package/src/loading/Loading.ts +2 -1
  158. package/src/omnibox/Omnibox.ts +2 -1
  159. package/src/options/Options.ts +3 -2
  160. package/src/remote/Remote.ts +2 -7
  161. package/src/select/Select.ts +11 -10
  162. package/src/shadowless/Shadowless.ts +2 -2
  163. package/src/store/Store.ts +2 -1
  164. package/src/tabpane/Tab.ts +42 -0
  165. package/src/tabpane/TabPane.ts +113 -0
  166. package/src/textinput/TextInput.ts +3 -2
  167. package/src/tip/Tip.ts +2 -2
  168. package/src/vectoricon/VectorIcon.ts +18 -6
  169. package/static/css/temba-components.css +11 -0
  170. package/static/icons/Read Me.txt +1 -1
  171. package/static/icons/SVG/pause.svg +5 -0
  172. package/static/icons/SVG/play.svg +5 -0
  173. package/static/icons/SVG/{upload-cloud.svg → publish.svg} +1 -1
  174. package/static/icons/SVG/user-x.svg +5 -0
  175. package/static/icons/demo-external-svg.html +157 -142
  176. package/static/icons/demo-files/demo.css +3 -3
  177. package/static/icons/demo.html +186 -162
  178. package/static/icons/selection.json +390 -318
  179. package/static/icons/symbol-defs.svg +29 -20
  180. package/temba-modules.ts +6 -0
  181. package/test/temba-contact-history.test.ts +10 -6
  182. package/test/temba-dialog.test.ts +5 -6
  183. package/test-assets/modax/form.html +1 -1
  184. package/test-assets/style.css +7 -0
  185. package/web-test-runner.config.mjs +130 -117
  186. package/dist/56e0e480.js +0 -356
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/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IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACP;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCACV;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACX;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACP;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACX;AAGjB;IADC,QAAQ,EAAE;oCACK;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACF;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACC;AAG5B;IADC,QAAQ,EAAE;8CACe;AAG1B;IADC,QAAQ,EAAE;4CACW;AAGtB;IADC,QAAQ,EAAE;qCACI;AAGf;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+CACW","sourcesContent":["import { property } from 'lit-element/lib/decorators';\nimport { TemplateResult, html, css } from 'lit-element';\nimport { Button } from '../button/Button';\nimport { RapidElement } from '../RapidElement';\nimport { CustomEventType } from '../interfaces';\nimport { styleMap } from 'lit-html/directives/style-map';\nimport { getClasses } from '../utils';\n\nexport class Dialog extends RapidElement {\n static get widths(): { [size: string]: string } {\n return {\n small: '400px',\n medium: '600px',\n large: '655px',\n };\n }\n\n static get styles() {\n return css`\n :host {\n position: absolute;\n z-index: 10000;\n font-family: var(--font-family);\n background: white;\n }\n\n .flex {\n display: flex;\n flex-direction: column;\n width: 100%;\n position: relative;\n left: 0px;\n top: 0px;\n align-items: center;\n }\n\n .flex-grow {\n flex-grow: 1;\n }\n\n .bottom-padding {\n padding: 3rem;\n }\n\n .dialog-mask {\n width: 100%;\n background: rgba(0, 0, 0, 0.5);\n opacity: 0;\n position: fixed;\n top: 0px;\n left: 0px;\n transition: opacity linear calc(var(--transition-speed) / 2ms);\n pointer-events: none;\n }\n\n .dialog-container {\n margin-top: -10000px;\n position: relative;\n transition: transform cubic-bezier(0.71, 0.18, 0.61, 1.33)\n var(--transition-speed),\n opacity ease-in-out calc(var(--transition-speed) - 50ms);\n border-radius: var(--curvature);\n box-shadow: 0px 0px 2px 4px rgba(0, 0, 0, 0.06);\n overflow: hidden;\n transform: scale(0.7);\n background: white;\n }\n\n .dialog-body {\n background: #fff;\n max-height: 75vh;\n overflow-y: auto;\n }\n\n .dialog-mask.dialog-open {\n opacity: 1;\n pointer-events: auto;\n }\n\n .dialog-mask.dialog-open .dialog-container {\n top: inherit;\n }\n\n .dialog-mask.dialog-animation-end .dialog-container {\n margin-top: 10vh;\n transform: scale(1) !important;\n }\n\n .dialog-mask.dialog-ready .dialog-container {\n margin-top: 10vh;\n transform: none;\n }\n\n .dialog-mask.dialog-loading .dialog-container {\n margin-top: -10000px;\n }\n\n .header-text {\n font-size: 20px;\n padding: 12px 20px;\n font-weight: 300;\n color: var(--header-text);\n background: var(--header-bg);\n }\n\n .dialog-footer {\n background: var(--color-primary-light);\n padding: 10px;\n display: flex;\n flex-flow: row-reverse;\n }\n\n temba-button {\n margin-left: 10px;\n }\n\n .dialog-body temba-loading {\n position: absolute;\n right: 12px;\n margin-top: -30px;\n padding-bottom: 9px;\n display: none;\n }\n\n #page-loader {\n text-align: center;\n display: block;\n position: relative;\n opacity: 0;\n margin: auto;\n margin-top: 30px;\n width: 154px;\n transition: opacity calc(var(--transition-speed) * 5ms) ease-in\n calc(var(--transition-speed * 2));\n visibility: hidden;\n }\n\n .dialog-mask.dialog-loading #page-loader {\n opacity: 1;\n visibility: visible;\n }\n\n #submit-loader {\n flex-grow: 1;\n text-align: right;\n }\n `;\n }\n\n @property({ type: Boolean })\n open: boolean;\n\n @property()\n header: string;\n\n @property()\n body: string;\n\n @property({ type: Boolean })\n submitting: boolean;\n\n @property({ type: Boolean })\n destructive: boolean;\n\n @property({ type: Boolean })\n disabled: boolean;\n\n @property({ type: Boolean })\n loading: boolean;\n\n @property({ type: Boolean })\n hideOnClick: boolean;\n\n @property({ type: Boolean })\n noFocus: boolean;\n\n @property()\n size = 'medium';\n\n @property({ type: String })\n primaryButtonName = 'Ok';\n\n @property({ type: String })\n cancelButtonName = 'Cancel';\n\n @property()\n submittingName = 'Saving';\n\n @property()\n animationEnd: boolean;\n\n @property()\n ready: boolean;\n\n @property({ attribute: false })\n onButtonClicked: (button: Button) => void;\n\n scrollOffset: any = 0;\n\n public constructor() {\n super();\n }\n\n public updated(changedProperties: Map<string, any>) {\n if (changedProperties.has('open')) {\n const body = document.querySelector('body');\n\n if (this.open) {\n this.animationEnd = true;\n window.setTimeout(() => {\n this.ready = true;\n this.animationEnd = false;\n }, 400);\n\n const scrollbarWidth = window.outerWidth - body.clientWidth;\n this.scrollOffset = -document.documentElement.scrollTop;\n body.style.position = 'fixed';\n body.style.overflowY = 'scroll';\n body.style.top = this.scrollOffset + 'px';\n body.style.width = '100%';\n body.style.overflowY = 'hidden';\n body.style.paddingRight = scrollbarWidth + 'px';\n } else {\n body.style.position = '';\n body.style.overflowY = '';\n body.style.width = '';\n body.style.marginRight = '';\n body.style.paddingRight = '0px';\n window.scrollTo(0, parseInt(this.scrollOffset || '0') * -1);\n }\n\n // make sure our buttons aren't in progress on show\n if (this.open && !changedProperties.get('open')) {\n this.shadowRoot\n .querySelectorAll('temba-button')\n .forEach((button: Button) => (button.disabled = false));\n\n if (!this.noFocus) {\n this.focusFirstInput();\n }\n } else {\n window.setTimeout(() => {\n this.ready = false;\n }, 400);\n }\n }\n }\n\n public focusFirstInput(): void {\n window.setTimeout(() => {\n let input = this.querySelector(\n 'temba-textinput, temba-completion, input[type=\"text\"], textarea'\n ) as any;\n if (input) {\n input = input.textInputElement || input.inputElement || input;\n if (!input.readOnly) {\n input.focus();\n input.click();\n }\n }\n }, 100);\n }\n\n public handleClick(evt: MouseEvent) {\n const button = evt.currentTarget as Button;\n if (!button.disabled) {\n this.fireCustomEvent(CustomEventType.ButtonClicked, { button });\n if (button.name === this.cancelButtonName) {\n this.open = false;\n }\n }\n }\n\n private getDocumentHeight(): number {\n const body = document.body;\n const html = document.documentElement;\n return Math.max(\n body.scrollHeight,\n body.offsetHeight,\n html.clientHeight,\n html.scrollHeight,\n html.offsetHeight\n );\n }\n\n private clickCancel() {\n const cancel = this.getCancelButton();\n if (cancel) {\n cancel.click();\n }\n }\n\n public getCancelButton(): Button {\n return this.shadowRoot.querySelector(\n `temba-button[name='${this.cancelButtonName}']`\n );\n }\n\n public getPrimaryButton(): Button {\n return this.shadowRoot.querySelector(`temba-button[primary]`);\n }\n\n private handleKeyUp(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n this.clickCancel();\n }\n }\n\n private handleClickMask(event: MouseEvent) {\n if (this.hideOnClick) {\n const id = (event.target as HTMLElement).id;\n if (id === 'dialog-mask' || id === 'dialog-bg') {\n this.fireCustomEvent(CustomEventType.DialogHidden);\n this.clickCancel();\n }\n }\n }\n\n public show(): void {\n this.open = true;\n }\n\n public hide(): void {\n this.open = false;\n }\n\n public render(): TemplateResult {\n const height = this.getDocumentHeight();\n\n const maskStyle = {\n height: `${height + 100}px`,\n };\n const dialogStyle = { width: Dialog.widths[this.size] };\n\n const header = this.header\n ? html`\n <div class=\"dialog-header\">\n <div class=\"header-text\">${this.header}</div>\n </div>\n `\n : null;\n\n return html`\n <div\n id=\"dialog-mask\"\n @click=${this.handleClickMask}\n class=\"dialog-mask ${getClasses({\n 'dialog-open': this.open,\n 'dialog-loading': this.loading,\n 'dialog-animation-end': this.animationEnd,\n 'dialog-ready': this.ready,\n })}\"\n style=${styleMap(maskStyle)}\n >\n <div style=\"position: absolute; width: 100%;\">\n <temba-loading\n id=\"page-loader\"\n units=\"6\"\n size=\"12\"\n color=\"#ccc\"\n ></temba-loading>\n </div>\n\n <div class=\"flex\">\n <div class=\"flex-grow\"></div>\n <div\n @keyup=${this.handleKeyUp}\n style=${styleMap(dialogStyle)}\n class=\"dialog-container\"\n >\n ${header}\n <div class=\"dialog-body\" @keypress=${this.handleKeyUp}>\n ${this.body ? this.body : html`<slot></slot>`}\n <temba-loading units=\"6\" size=\"8\"></temba-loading>\n </div>\n\n <div class=\"dialog-footer\">\n ${\n this.primaryButtonName\n ? html`\n <temba-button\n @click=${this.handleClick}\n .name=${this.primaryButtonName}\n ?destructive=${this.destructive}\n ?primary=${!this.destructive}\n ?submitting=${this.submitting}\n ?disabled=${this.disabled}\n >}</temba-button\n >\n `\n : null\n }\n <temba-button\n @click=${this.handleClick}\n name=${this.cancelButtonName}\n secondary\n ></temba-button>\n </div>\n </div>\n <div class=\"flex-grow bottom-padding\"></div>\n <div class=\"bottom-padding\"></div>\n </div>\n </div>\n </div>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/dialog/Dialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAkB,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,OAAO,MAAO,SAAQ,YAAY;IA+LtC;QACE,KAAK,EAAE,CAAC;QAvBV,SAAI,GAAG,QAAQ,CAAC;QAGhB,sBAAiB,GAAG,IAAI,CAAC;QAGzB,qBAAgB,GAAG,QAAQ,CAAC;QAG5B,mBAAc,GAAG,QAAQ,CAAC;QAW1B,iBAAY,GAAQ,CAAC,CAAC;IAItB,CAAC;IAhMD,MAAM,KAAK,MAAM;QACf,OAAO;YACL,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,OAAO;SACf,C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 'lit';\nimport { Button } from '../button/Button';\nimport { RapidElement } from '../RapidElement';\nimport { CustomEventType } from '../interfaces';\nimport { styleMap } from 'lit-html/directives/style-map';\nimport { getClasses } from '../utils';\n\nexport class Dialog extends RapidElement {\n static get widths(): { [size: string]: string } {\n return {\n small: '400px',\n medium: '600px',\n large: '655px',\n };\n }\n\n static get styles() {\n return css`\n :host {\n position: absolute;\n z-index: 10000;\n font-family: var(--font-family);\n background: white;\n }\n\n .flex {\n display: flex;\n flex-direction: column;\n width: 100%;\n position: relative;\n left: 0px;\n top: 0px;\n align-items: center;\n }\n\n .flex-grow {\n flex-grow: 1;\n }\n\n .bottom-padding {\n padding: 3rem;\n }\n\n .dialog-mask {\n width: 100%;\n background: rgba(0, 0, 0, 0.5);\n opacity: 0;\n position: fixed;\n top: 0px;\n left: 0px;\n transition: opacity linear calc(var(--transition-speed) / 2ms);\n pointer-events: none;\n }\n\n .dialog-container {\n margin-top: -10000px;\n position: relative;\n transition: transform cubic-bezier(0.71, 0.18, 0.61, 1.33)\n var(--transition-speed),\n opacity ease-in-out calc(var(--transition-speed) - 50ms);\n border-radius: var(--curvature);\n box-shadow: 0px 0px 2px 4px rgba(0, 0, 0, 0.06);\n overflow: hidden;\n transform: scale(0.7);\n background: white;\n }\n\n .dialog-body {\n background: #fff;\n max-height: 75vh;\n overflow-y: auto;\n }\n\n .dialog-mask.dialog-open {\n opacity: 1;\n pointer-events: auto;\n }\n\n .dialog-mask.dialog-open .dialog-container {\n top: inherit;\n }\n\n .dialog-mask.dialog-animation-end .dialog-container {\n margin-top: 10vh;\n transform: scale(1) !important;\n }\n\n .dialog-mask.dialog-ready .dialog-container {\n margin-top: 10vh;\n transform: none;\n }\n\n .dialog-mask.dialog-loading .dialog-container {\n margin-top: -10000px;\n }\n\n .header-text {\n font-size: 20px;\n padding: 12px 20px;\n font-weight: 300;\n color: var(--header-text);\n background: var(--header-bg);\n }\n\n .dialog-footer {\n background: var(--color-primary-light);\n padding: 10px;\n display: flex;\n flex-flow: row-reverse;\n }\n\n temba-button {\n margin-left: 10px;\n }\n\n .dialog-body temba-loading {\n position: absolute;\n right: 12px;\n margin-top: -30px;\n padding-bottom: 9px;\n display: none;\n }\n\n #page-loader {\n text-align: center;\n display: block;\n position: relative;\n opacity: 0;\n margin: auto;\n margin-top: 30px;\n width: 154px;\n transition: opacity calc(var(--transition-speed) * 5ms) ease-in\n calc(var(--transition-speed * 2));\n visibility: hidden;\n }\n\n .dialog-mask.dialog-loading #page-loader {\n opacity: 1;\n visibility: visible;\n }\n\n #submit-loader {\n flex-grow: 1;\n text-align: right;\n }\n `;\n }\n\n @property({ type: Boolean })\n open: boolean;\n\n @property()\n header: string;\n\n @property()\n body: string;\n\n @property({ type: Boolean })\n submitting: boolean;\n\n @property({ type: Boolean })\n destructive: boolean;\n\n @property({ type: Boolean })\n disabled: boolean;\n\n @property({ type: Boolean })\n loading: boolean;\n\n @property({ type: Boolean })\n hideOnClick: boolean;\n\n @property({ type: Boolean })\n noFocus: boolean;\n\n @property()\n size = 'medium';\n\n @property({ type: String })\n primaryButtonName = 'Ok';\n\n @property({ type: String })\n cancelButtonName = 'Cancel';\n\n @property()\n submittingName = 'Saving';\n\n @property()\n animationEnd: boolean;\n\n @property()\n ready: boolean;\n\n @property({ attribute: false })\n onButtonClicked: (button: Button) => void;\n\n scrollOffset: any = 0;\n\n public constructor() {\n super();\n }\n\n public updated(changedProperties: Map<string, any>) {\n if (changedProperties.has('open')) {\n const body = document.querySelector('body');\n\n if (this.open) {\n this.animationEnd = true;\n window.setTimeout(() => {\n this.ready = true;\n this.animationEnd = false;\n }, 400);\n\n const scrollbarWidth = window.outerWidth - body.clientWidth;\n this.scrollOffset = -document.documentElement.scrollTop;\n body.style.position = 'fixed';\n body.style.overflowY = 'scroll';\n body.style.top = this.scrollOffset + 'px';\n body.style.width = '100%';\n body.style.overflowY = 'hidden';\n body.style.paddingRight = scrollbarWidth + 'px';\n } else {\n body.style.position = '';\n body.style.overflowY = '';\n body.style.width = '';\n body.style.marginRight = '';\n body.style.paddingRight = '0px';\n window.scrollTo(0, parseInt(this.scrollOffset || '0') * -1);\n }\n\n // make sure our buttons aren't in progress on show\n if (this.open && !changedProperties.get('open')) {\n this.shadowRoot\n .querySelectorAll('temba-button')\n .forEach((button: Button) => (button.disabled = false));\n\n if (!this.noFocus) {\n this.focusFirstInput();\n }\n } else {\n window.setTimeout(() => {\n this.ready = false;\n }, 400);\n }\n }\n }\n\n public focusFirstInput(): void {\n window.setTimeout(() => {\n let input = this.querySelector(\n 'temba-textinput, temba-completion, input[type=\"text\"], textarea'\n ) as any;\n if (input) {\n input = input.textInputElement || input.inputElement || input;\n if (!input.readOnly) {\n input.focus();\n input.click();\n }\n }\n }, 100);\n }\n\n public handleClick(evt: MouseEvent) {\n const button = evt.currentTarget as Button;\n if (!button.disabled) {\n this.fireCustomEvent(CustomEventType.ButtonClicked, { button });\n if (button.name === this.cancelButtonName) {\n this.open = false;\n }\n }\n }\n\n private getDocumentHeight(): number {\n const body = document.body;\n const html = document.documentElement;\n return Math.max(\n body.scrollHeight,\n body.offsetHeight,\n html.clientHeight,\n html.scrollHeight,\n html.offsetHeight\n );\n }\n\n private clickCancel() {\n const cancel = this.getCancelButton();\n if (cancel) {\n cancel.click();\n }\n }\n\n public getCancelButton(): Button {\n return this.shadowRoot.querySelector(\n `temba-button[name='${this.cancelButtonName}']`\n );\n }\n\n public getPrimaryButton(): Button {\n return this.shadowRoot.querySelector(`temba-button[primary]`);\n }\n\n private handleKeyUp(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n this.clickCancel();\n }\n }\n\n private handleClickMask(event: MouseEvent) {\n if (this.hideOnClick) {\n const id = (event.target as HTMLElement).id;\n if (id === 'dialog-mask' || id === 'dialog-bg') {\n this.fireCustomEvent(CustomEventType.DialogHidden);\n this.clickCancel();\n }\n }\n }\n\n public show(): void {\n this.open = true;\n }\n\n public hide(): void {\n this.open = false;\n }\n\n public render(): TemplateResult {\n const height = this.getDocumentHeight();\n\n const maskStyle = {\n height: `${height + 100}px`,\n };\n const dialogStyle = { width: Dialog.widths[this.size] };\n\n const header = this.header\n ? html`\n <div class=\"dialog-header\">\n <div class=\"header-text\">${this.header}</div>\n </div>\n `\n : null;\n\n return html`\n <div\n id=\"dialog-mask\"\n @click=${this.handleClickMask}\n class=\"dialog-mask ${getClasses({\n 'dialog-open': this.open,\n 'dialog-loading': this.loading,\n 'dialog-animation-end': this.animationEnd,\n 'dialog-ready': this.ready,\n })}\"\n style=${styleMap(maskStyle)}\n >\n <div style=\"position: absolute; width: 100%;\">\n <temba-loading\n id=\"page-loader\"\n units=\"6\"\n size=\"12\"\n color=\"#ccc\"\n ></temba-loading>\n </div>\n\n <div class=\"flex\">\n <div class=\"flex-grow\"></div>\n <div\n @keyup=${this.handleKeyUp}\n style=${styleMap(dialogStyle)}\n class=\"dialog-container\"\n >\n ${header}\n <div class=\"dialog-body\" @keypress=${this.handleKeyUp}>\n ${this.body ? this.body : html`<slot></slot>`}\n <temba-loading units=\"6\" size=\"8\"></temba-loading>\n </div>\n\n <div class=\"dialog-footer\">\n ${\n this.primaryButtonName\n ? html`\n <temba-button\n @click=${this.handleClick}\n .name=${this.primaryButtonName}\n ?destructive=${this.destructive}\n ?primary=${!this.destructive}\n ?submitting=${this.submitting}\n ?disabled=${this.disabled}\n >}</temba-button\n >\n `\n : null\n }\n <temba-button\n @click=${this.handleClick}\n name=${this.cancelButtonName}\n secondary\n ></temba-button>\n </div>\n </div>\n <div class=\"flex-grow bottom-padding\"></div>\n <div class=\"bottom-padding\"></div>\n </div>\n </div>\n </div>\n `;\n }\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { __decorate } from "tslib";
2
- import { property } from 'lit-element/lib/decorators';
3
- import { html, css } from 'lit-element';
2
+ import { html, css } from 'lit';
3
+ import { property } from 'lit/decorators';
4
+ import { unsafeHTML } from 'lit-html/directives/unsafe-html';
4
5
  import { RapidElement } from '../RapidElement';
5
6
  import { getUrl, serialize, postUrl } from '../utils';
6
- import { unsafeHTML } from 'lit-html/directives/unsafe-html';
7
7
  import { CustomEventType } from '../interfaces';
8
8
  export class Modax extends RapidElement {
9
9
  constructor() {
@@ -311,9 +311,6 @@ __decorate([
311
311
  __decorate([
312
312
  property({ type: String })
313
313
  ], Modax.prototype, "onLoaded", void 0);
314
- __decorate([
315
- property({ type: String })
316
- ], Modax.prototype, "onSubmitted", void 0);
317
314
  __decorate([
318
315
  property({ type: Boolean })
319
316
  ], Modax.prototype, "noSubmit", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"Modax.js","sourceRoot":"","sources":["../../../src/dialog/Modax.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAkB,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAe,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,MAAM,OAAO,KAAM,SAAQ,YAAY;IAAvC;;QAuEE,WAAM,GAAG,EAAE,CAAC;QAMZ,SAAI,GAAG,KAAK,CAAC;QAGb,aAAQ,GAAG,KAAK,CAAC;QAqBjB,YAAO,GAAQ,EAAE,CAAC;QAGlB,SAAI,GAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;QAG9B,aAAQ,GAAG,KAAK,CAAC;QAGjB,kBAAa,GAAG,KAAK,CAAC;IAkPxB,CAAC;IA/VC,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiET,CAAC;IACJ,CAAC;IAgDO,iBAAiB;QACvB,IAAI,CAAC,IAAI,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AO,EAAE,CAAC;yCACR;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CACP;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACR;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CACP;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACV;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCACT;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mCACG;AAG9B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACX;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACN","sourcesContent":["import { property } from 'lit-element/lib/decorators';\nimport { TemplateResult, html, css } from 'lit-element';\nimport { RapidElement } from '../RapidElement';\nimport { getUrl, serialize, postUrl, WebResponse } from '../utils';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html';\nimport { CustomEventType } from '../interfaces';\nimport { Dialog } from './Dialog';\n\nexport class Modax extends RapidElement {\n static get styles() {\n return css`\n :host {\n }\n\n fieldset {\n border: none;\n margin: 0;\n padding: 0;\n }\n\n .control-group {\n margin-bottom: var(--control-margin-bottom);\n }\n\n .form-actions {\n display: none;\n }\n\n .modax-body {\n padding: 20px;\n display: block;\n position: relative;\n background: var(--body-bg);\n }\n\n .modax-body.submitting:before {\n display: inline-block;\n content: '';\n height: 100%;\n width: 100%;\n margin-left: -20px;\n margin-top: -20px;\n background: rgba(200, 200, 200, 0.1);\n position: absolute;\n z-index: 10000;\n }\n\n temba-dialog {\n --transition-speed: var(--transition-speed);\n }\n\n temba-loading {\n margin: 0 auto;\n display: block;\n width: 150px;\n }\n\n ul.errorlist {\n margin-top: 0px;\n list-style-type: none;\n padding-left: 0;\n padding-bottom: 7px;\n }\n\n ul.errorlist li {\n color: var(--color-error);\n background: rgba(255, 181, 181, 0.17);\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1),\n 0 1px 2px 0 rgba(0, 0, 0, 0.06);\n color: tomato;\n padding: 10px;\n margin-bottom: 10px;\n border-radius: 6px;\n font-weight: 300;\n }\n `;\n }\n\n @property({ type: String })\n header = '';\n\n @property({ type: String })\n endpoint: string;\n\n @property({ type: Boolean, reflect: true })\n open = false;\n\n @property({ type: Boolean })\n fetching = false;\n\n @property({ type: Boolean })\n submitting: boolean;\n\n @property({ type: String })\n primaryName: string;\n\n @property({ type: String })\n cancelName: string;\n\n @property({ type: String })\n onLoaded: string;\n\n @property({ type: String })\n onSubmitted: string;\n\n @property({ type: Boolean })\n noSubmit: boolean;\n\n @property({ type: Object })\n headers: any = {};\n\n @property({ type: String })\n body: any = this.getLoading();\n\n @property({ type: Boolean })\n disabled = false;\n\n @property({ type: Boolean })\n suspendSubmit = false;\n // private cancelToken: CancelTokenSource;\n\n // http promise to monitor for completeness\n public httpComplete: Promise<void | WebResponse>;\n\n private handleSlotClicked(): void {\n this.open = true;\n }\n\n public updated(changes: Map<string, any>) {\n super.updated(changes);\n\n if (changes.has('open')) {\n if (this.open) {\n this.fetchForm();\n } else {\n // open can get reflected into undefined, make sure we've been open before\n if (changes.get('open') !== undefined) {\n // hide our body after our hiding animation is done\n window.setTimeout(() => {\n this.body = this.getLoading();\n this.submitting = false;\n }, 500);\n }\n }\n }\n\n if (changes.has('body') && this.open && this.body && !this.fetching) {\n const dialog = this.shadowRoot.querySelector('temba-dialog') as Dialog;\n dialog.focusFirstInput();\n }\n }\n\n private getLoading() {\n return html`<temba-loading units=\"6\" size=\"8\"></temba-loading>`;\n }\n\n private updatePrimaryButton(): void {\n if (!this.noSubmit) {\n window.setTimeout(() => {\n const submitButton = this.shadowRoot.querySelector(\n \"input[type='submit']\"\n ) as any;\n\n if (submitButton) {\n this.primaryName = submitButton.value;\n } else {\n this.primaryName = null;\n this.cancelName = 'Ok';\n }\n\n this.submitting = false;\n }, 0);\n }\n }\n\n private setBody(body: string): boolean {\n // remove any existing on our previous body\n const scriptBlock = this.shadowRoot.querySelector('.scripts') as any;\n for (const child of scriptBlock.children) {\n child.remove();\n }\n\n // parse out any scripts in the body\n const div = this.ownerDocument.createElement('div');\n div.innerHTML = body;\n const scripts = div.getElementsByTagName('script');\n\n // IE bleeds through, avoid bootstrap form spans that breaks layout\n const spans = div.getElementsByClassName('span12') as any;\n for (const span of spans) {\n span.className = '';\n }\n\n const toAdd: any = [];\n // now add them in\n for (let i = scripts.length - 1; i >= 0; i--) {\n // for (let i = 0; i < scripts.length; i++) {\n const script = this.ownerDocument.createElement('script');\n const code = scripts[i].innerText;\n\n if (scripts[i].src) {\n script.src = scripts[i].src;\n script.type = 'text/javascript';\n script.async = true;\n\n // TODO: track and fire event once all scripts are loaded\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n script.onload = function () {};\n toAdd.push(script);\n } else if (code) {\n script.appendChild(this.ownerDocument.createTextNode(code));\n toAdd.push(script);\n // remove it from our current body text\n }\n scripts[i].remove();\n }\n\n const scriptOnly = !!div.querySelector('.success-script');\n\n if (!scriptOnly) {\n this.body = unsafeHTML(div.innerHTML);\n }\n\n window.setTimeout(() => {\n for (const script of toAdd) {\n scriptBlock.appendChild(script);\n }\n }, 0);\n\n return !scriptOnly;\n }\n\n public getHeaders(): any {\n const headers = this.headers;\n headers['X-PJAX'] = 1;\n return headers;\n }\n\n private fetchForm() {\n // const CancelToken = axios.CancelToken;\n // this.cancelToken = CancelToken.source();\n this.fetching = true;\n this.body = this.getLoading();\n this.httpComplete = getUrl(this.endpoint, null, this.getHeaders()).then(\n (response: WebResponse) => {\n this.setBody(response.body);\n this.updatePrimaryButton();\n this.fetching = false;\n window.setTimeout(() => {\n this.fireCustomEvent(CustomEventType.Loaded, {\n body: this.getBody(),\n });\n }, 0);\n }\n );\n }\n\n public submit(): void {\n this.submitting = true;\n const form = this.shadowRoot.querySelector('form');\n const postData = form ? serialize(form) : {};\n\n this.httpComplete = postUrl(\n this.endpoint,\n postData,\n this.getHeaders(),\n 'application/x-www-form-urlencoded'\n )\n .then((response: WebResponse) => {\n window.setTimeout(() => {\n let redirect = response.headers.get('temba-success');\n if (\n !redirect &&\n response.url &&\n response.url.indexOf(this.endpoint) === -1\n ) {\n redirect = response.url;\n }\n\n if (redirect) {\n if (redirect === 'hide') {\n window.setTimeout(() => {\n this.open = false;\n this.fireCustomEvent(CustomEventType.Submitted);\n }, 0);\n } else {\n this.fireCustomEvent(CustomEventType.Redirected, {\n url: redirect,\n });\n this.open = false;\n }\n } else {\n // if we set the body, update our submit button\n if (this.setBody(response.body)) {\n this.updatePrimaryButton();\n }\n }\n }, 1000);\n })\n .catch(error => {\n console.error(error);\n });\n }\n\n private handleDialogClick(evt: CustomEvent) {\n const button = evt.detail.button;\n if (!button.disabled && !button.submitting) {\n if (button.name === this.primaryName) {\n if (!this.suspendSubmit) {\n this.submit();\n }\n }\n }\n\n if (button.name === (this.cancelName || 'Cancel')) {\n this.open = false;\n this.fetching = false;\n this.cancelName = undefined;\n }\n }\n\n private handleDialogHidden() {\n // this.cancelToken.cancel();\n this.open = false;\n this.fetching = false;\n }\n\n private isDestructive(): boolean {\n return this.endpoint && this.endpoint.indexOf('delete') > -1;\n }\n\n public getBody() {\n return this.shadowRoot.querySelector('.modax-body');\n }\n\n public render(): TemplateResult {\n return html`\n <temba-dialog\n header=${this.header}\n .primaryButtonName=${this.noSubmit ? null : this.primaryName}\n .cancelButtonName=${this.cancelName || 'Cancel'}\n ?open=${this.open}\n ?loading=${this.fetching}\n ?submitting=${this.submitting}\n ?destructive=${this.isDestructive()}\n ?noFocus=${true}\n ?disabled=${this.disabled}\n @temba-button-clicked=${this.handleDialogClick.bind(this)}\n @temba-dialog-hidden=${this.handleDialogHidden.bind(this)}\n >\n <div class=\"modax-body${this.submitting ? ' submitting' : ''}\">\n ${this.body}\n </div>\n <div class=\"scripts\"></div>\n </temba-dialog>\n <div class=\"slot-wrapper\" @click=${this.handleSlotClicked}>\n <slot></slot>\n </div>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"Modax.js","sourceRoot":"","sources":["../../../src/dialog/Modax.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAe,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,MAAM,OAAO,KAAM,SAAQ,YAAY;IAAvC;;QAuEE,WAAM,GAAG,EAAE,CAAC;QAMZ,SAAI,GAAG,KAAK,CAAC;QAGb,aAAQ,GAAG,KAAK,CAAC;QAkBjB,YAAO,GAAQ,EAAE,CAAC;QAGlB,SAAI,GAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;QAG9B,aAAQ,GAAG,KAAK,CAAC;QAGjB,kBAAa,GAAG,KAAK,CAAC;IAkPxB,CAAC;IA5VC,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiET,CAAC;IACJ,CAAC;IA6CO,iBAAiB;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEM,OAAO,CAAC,OAAyB;QACtC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEvB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,C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C;yCACR;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACV;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCACT;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mCACG;AAG9B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACX;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACN","sourcesContent":["import { TemplateResult, html, css } from 'lit';\nimport { property } from 'lit/decorators';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html';\n\nimport { RapidElement } from '../RapidElement';\nimport { getUrl, serialize, postUrl, WebResponse } from '../utils';\nimport { CustomEventType } from '../interfaces';\nimport { Dialog } from './Dialog';\n\nexport class Modax extends RapidElement {\n static get styles() {\n return css`\n :host {\n }\n\n fieldset {\n border: none;\n margin: 0;\n padding: 0;\n }\n\n .control-group {\n margin-bottom: var(--control-margin-bottom);\n }\n\n .form-actions {\n display: none;\n }\n\n .modax-body {\n padding: 20px;\n display: block;\n position: relative;\n background: var(--body-bg);\n }\n\n .modax-body.submitting:before {\n display: inline-block;\n content: '';\n height: 100%;\n width: 100%;\n margin-left: -20px;\n margin-top: -20px;\n background: rgba(200, 200, 200, 0.1);\n position: absolute;\n z-index: 10000;\n }\n\n temba-dialog {\n --transition-speed: var(--transition-speed);\n }\n\n temba-loading {\n margin: 0 auto;\n display: block;\n width: 150px;\n }\n\n ul.errorlist {\n margin-top: 0px;\n list-style-type: none;\n padding-left: 0;\n padding-bottom: 7px;\n }\n\n ul.errorlist li {\n color: var(--color-error);\n background: rgba(255, 181, 181, 0.17);\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1),\n 0 1px 2px 0 rgba(0, 0, 0, 0.06);\n color: tomato;\n padding: 10px;\n margin-bottom: 10px;\n border-radius: 6px;\n font-weight: 300;\n }\n `;\n }\n\n @property({ type: String })\n header = '';\n\n @property({ type: String })\n endpoint: string;\n\n @property({ type: Boolean, reflect: true })\n open = false;\n\n @property({ type: Boolean })\n fetching = false;\n\n @property({ type: Boolean })\n submitting: boolean;\n\n @property({ type: String })\n primaryName: string;\n\n @property({ type: String })\n cancelName: string;\n\n @property({ type: String })\n onLoaded: string;\n\n @property({ type: Boolean })\n noSubmit: boolean;\n\n @property({ type: Object })\n headers: any = {};\n\n @property({ type: String })\n body: any = this.getLoading();\n\n @property({ type: Boolean })\n disabled = false;\n\n @property({ type: Boolean })\n suspendSubmit = false;\n // private cancelToken: CancelTokenSource;\n\n // http promise to monitor for completeness\n public httpComplete: Promise<void | WebResponse>;\n\n private handleSlotClicked(): void {\n this.open = true;\n }\n\n public updated(changes: Map<string, any>) {\n super.updated(changes);\n\n if (changes.has('open')) {\n if (this.open) {\n this.fetchForm();\n } else {\n // open can get reflected into undefined, make sure we've been open before\n if (changes.get('open') !== undefined) {\n // hide our body after our hiding animation is done\n window.setTimeout(() => {\n this.body = this.getLoading();\n this.submitting = false;\n }, 500);\n }\n }\n }\n\n if (changes.has('body') && this.open && this.body && !this.fetching) {\n const dialog = this.shadowRoot.querySelector('temba-dialog') as Dialog;\n dialog.focusFirstInput();\n }\n }\n\n private getLoading() {\n return html`<temba-loading units=\"6\" size=\"8\"></temba-loading>`;\n }\n\n private updatePrimaryButton(): void {\n if (!this.noSubmit) {\n window.setTimeout(() => {\n const submitButton = this.shadowRoot.querySelector(\n \"input[type='submit']\"\n ) as any;\n\n if (submitButton) {\n this.primaryName = submitButton.value;\n } else {\n this.primaryName = null;\n this.cancelName = 'Ok';\n }\n\n this.submitting = false;\n }, 0);\n }\n }\n\n private setBody(body: string): boolean {\n // remove any existing on our previous body\n const scriptBlock = this.shadowRoot.querySelector('.scripts') as any;\n for (const child of scriptBlock.children) {\n child.remove();\n }\n\n // parse out any scripts in the body\n const div = this.ownerDocument.createElement('div');\n div.innerHTML = body;\n const scripts = div.getElementsByTagName('script');\n\n // IE bleeds through, avoid bootstrap form spans that breaks layout\n const spans = div.getElementsByClassName('span12') as any;\n for (const span of spans) {\n span.className = '';\n }\n\n const toAdd: any = [];\n // now add them in\n for (let i = scripts.length - 1; i >= 0; i--) {\n // for (let i = 0; i < scripts.length; i++) {\n const script = this.ownerDocument.createElement('script');\n const code = scripts[i].innerText;\n\n if (scripts[i].src) {\n script.src = scripts[i].src;\n script.type = 'text/javascript';\n script.async = true;\n\n // TODO: track and fire event once all scripts are loaded\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n script.onload = function () {};\n toAdd.push(script);\n } else if (code) {\n script.appendChild(this.ownerDocument.createTextNode(code));\n toAdd.push(script);\n // remove it from our current body text\n }\n scripts[i].remove();\n }\n\n const scriptOnly = !!div.querySelector('.success-script');\n\n if (!scriptOnly) {\n this.body = unsafeHTML(div.innerHTML);\n }\n\n window.setTimeout(() => {\n for (const script of toAdd) {\n scriptBlock.appendChild(script);\n }\n }, 0);\n\n return !scriptOnly;\n }\n\n public getHeaders(): any {\n const headers = this.headers;\n headers['X-PJAX'] = 1;\n return headers;\n }\n\n private fetchForm() {\n // const CancelToken = axios.CancelToken;\n // this.cancelToken = CancelToken.source();\n this.fetching = true;\n this.body = this.getLoading();\n this.httpComplete = getUrl(this.endpoint, null, this.getHeaders()).then(\n (response: WebResponse) => {\n this.setBody(response.body);\n this.updatePrimaryButton();\n this.fetching = false;\n window.setTimeout(() => {\n this.fireCustomEvent(CustomEventType.Loaded, {\n body: this.getBody(),\n });\n }, 0);\n }\n );\n }\n\n public submit(): void {\n this.submitting = true;\n const form = this.shadowRoot.querySelector('form');\n const postData = form ? serialize(form) : {};\n\n this.httpComplete = postUrl(\n this.endpoint,\n postData,\n this.getHeaders(),\n 'application/x-www-form-urlencoded'\n )\n .then((response: WebResponse) => {\n window.setTimeout(() => {\n let redirect = response.headers.get('temba-success');\n if (\n !redirect &&\n response.url &&\n response.url.indexOf(this.endpoint) === -1\n ) {\n redirect = response.url;\n }\n\n if (redirect) {\n if (redirect === 'hide') {\n window.setTimeout(() => {\n this.open = false;\n this.fireCustomEvent(CustomEventType.Submitted);\n }, 0);\n } else {\n this.fireCustomEvent(CustomEventType.Redirected, {\n url: redirect,\n });\n this.open = false;\n }\n } else {\n // if we set the body, update our submit button\n if (this.setBody(response.body)) {\n this.updatePrimaryButton();\n }\n }\n }, 1000);\n })\n .catch(error => {\n console.error(error);\n });\n }\n\n private handleDialogClick(evt: CustomEvent) {\n const button = evt.detail.button;\n if (!button.disabled && !button.submitting) {\n if (button.name === this.primaryName) {\n if (!this.suspendSubmit) {\n this.submit();\n }\n }\n }\n\n if (button.name === (this.cancelName || 'Cancel')) {\n this.open = false;\n this.fetching = false;\n this.cancelName = undefined;\n }\n }\n\n private handleDialogHidden() {\n // this.cancelToken.cancel();\n this.open = false;\n this.fetching = false;\n }\n\n private isDestructive(): boolean {\n return this.endpoint && this.endpoint.indexOf('delete') > -1;\n }\n\n public getBody() {\n return this.shadowRoot.querySelector('.modax-body');\n }\n\n public render(): TemplateResult {\n return html`\n <temba-dialog\n header=${this.header}\n .primaryButtonName=${this.noSubmit ? null : this.primaryName}\n .cancelButtonName=${this.cancelName || 'Cancel'}\n ?open=${this.open}\n ?loading=${this.fetching}\n ?submitting=${this.submitting}\n ?destructive=${this.isDestructive()}\n ?noFocus=${true}\n ?disabled=${this.disabled}\n @temba-button-clicked=${this.handleDialogClick.bind(this)}\n @temba-dialog-hidden=${this.handleDialogHidden.bind(this)}\n >\n <div class=\"modax-body${this.submitting ? ' submitting' : ''}\">\n ${this.body}\n </div>\n <div class=\"scripts\"></div>\n </temba-dialog>\n <div class=\"slot-wrapper\" @click=${this.handleSlotClicked}>\n <slot></slot>\n </div>\n `;\n }\n}\n"]}
@@ -0,0 +1,133 @@
1
+ import { __decorate } from "tslib";
2
+ import { css, html } from 'lit';
3
+ import { property } from 'lit/decorators';
4
+ import { RapidElement } from '../RapidElement';
5
+ export class Dropdown extends RapidElement {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.open = false;
9
+ this.arrowSize = 6;
10
+ this.arrowOffset = this.arrowSize * 2;
11
+ this.offsetX = -10;
12
+ this.offsetY = 0;
13
+ }
14
+ static get styles() {
15
+ return css `
16
+ .toggle {
17
+ cursor: pointer;
18
+ }
19
+
20
+ .dropdown {
21
+ position: absolute;
22
+ opacity: 0;
23
+ z-index: 10;
24
+ pointer-events: none;
25
+ padding: 0;
26
+ border-radius: var(--curvature);
27
+ background: #fff;
28
+ transform: translateY(2em);
29
+ transition: all calc(0.6 * var(--transition-speed)) linear;
30
+ user-select: none;
31
+ margin-top: 0px;
32
+ margin-left: 0px;
33
+ box-shadow: var(--dropdown-shadow);
34
+ }
35
+
36
+ .dropdown:focus {
37
+ outline: none;
38
+ }
39
+
40
+ .arrow {
41
+ content: '';
42
+ width: 0px;
43
+ height: 0;
44
+ top: -6px;
45
+ z-index: 10;
46
+ position: absolute;
47
+ border-left: 6px solid transparent;
48
+ border-right: 6px solid transparent;
49
+ border-bottom: 6px solid white;
50
+ }
51
+
52
+ .open .dropdown {
53
+ opacity: 1;
54
+ pointer-events: auto;
55
+ transform: translateY(0);
56
+ }
57
+ `;
58
+ }
59
+ firstUpdated(props) {
60
+ super.firstUpdated(props);
61
+ const dropdown = this.shadowRoot.querySelector('.dropdown');
62
+ const arrow = this.shadowRoot.querySelector('.arrow');
63
+ arrow.style.borderWidth = this.arrowSize + 'px';
64
+ arrow.style.top = '-' + this.arrowSize + 'px';
65
+ if (this.arrowOffset < 0) {
66
+ arrow.style.right = Math.abs(this.arrowOffset) + 'px';
67
+ }
68
+ else {
69
+ arrow.style.left = this.arrowOffset + 'px';
70
+ }
71
+ dropdown.style.marginTop = this.offsetY + 'px';
72
+ if (dropdown.offsetLeft + dropdown.clientWidth > window.outerWidth) {
73
+ dropdown.style.marginLeft =
74
+ '-' + (dropdown.clientWidth - this.clientWidth - this.offsetX) + 'px';
75
+ }
76
+ else {
77
+ dropdown.style.marginLeft = this.offsetX + 'px';
78
+ }
79
+ dropdown.addEventListener('blur', () => {
80
+ // we nest this to deal with clicking the toggle to close
81
+ // as we don't want it to toggle an immediate open, probably
82
+ // a better way to deal with this
83
+ window.setTimeout(() => {
84
+ this.open = false;
85
+ }, 200);
86
+ });
87
+ }
88
+ updated(changedProperties) {
89
+ super.updated(changedProperties);
90
+ if (changedProperties.has('open')) {
91
+ if (this.open) {
92
+ this.classList.add('open');
93
+ }
94
+ else {
95
+ this.classList.remove('open');
96
+ }
97
+ }
98
+ }
99
+ handleOpen() {
100
+ if (!this.open) {
101
+ this.open = true;
102
+ const dropdown = this.shadowRoot.querySelector('.dropdown');
103
+ dropdown.focus();
104
+ }
105
+ }
106
+ render() {
107
+ return html `
108
+ <div class=${this.open ? 'open' : ''}>
109
+ <slot name="toggle" class="toggle" @click="${this.handleOpen}"></slot>
110
+ <div class="dropdown" tabindex="0">
111
+ <div class="arrow"></div>
112
+ <slot name="dropdown"></slot>
113
+ </div>
114
+ </div>
115
+ `;
116
+ }
117
+ }
118
+ __decorate([
119
+ property({ type: Boolean })
120
+ ], Dropdown.prototype, "open", void 0);
121
+ __decorate([
122
+ property({ type: Number })
123
+ ], Dropdown.prototype, "arrowSize", void 0);
124
+ __decorate([
125
+ property({ type: Number })
126
+ ], Dropdown.prototype, "arrowOffset", void 0);
127
+ __decorate([
128
+ property({ type: Number })
129
+ ], Dropdown.prototype, "offsetX", void 0);
130
+ __decorate([
131
+ property({ type: Number })
132
+ ], Dropdown.prototype, "offsetY", void 0);
133
+ //# sourceMappingURL=Dropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../../src/dropdown/Dropdown.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM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,CAAC;IACJ,CAAC;CACF;AAnFC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACb;AAGd;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACM;AAGjC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACb;AAGd;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACf","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators';\nimport { RapidElement } from '../RapidElement';\n\nexport class Dropdown extends RapidElement {\n static get styles() {\n return css`\n .toggle {\n cursor: pointer;\n }\n\n .dropdown {\n position: absolute;\n opacity: 0;\n z-index: 10;\n pointer-events: none;\n padding: 0;\n border-radius: var(--curvature);\n background: #fff;\n transform: translateY(2em);\n transition: all calc(0.6 * var(--transition-speed)) linear;\n user-select: none;\n margin-top: 0px;\n margin-left: 0px;\n box-shadow: var(--dropdown-shadow);\n }\n\n .dropdown:focus {\n outline: none;\n }\n\n .arrow {\n content: '';\n width: 0px;\n height: 0;\n top: -6px;\n z-index: 10;\n position: absolute;\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-bottom: 6px solid white;\n }\n\n .open .dropdown {\n opacity: 1;\n pointer-events: auto;\n transform: translateY(0);\n }\n `;\n }\n\n @property({ type: Boolean })\n open = false;\n\n @property({ type: Number })\n arrowSize = 6;\n\n @property({ type: Number })\n arrowOffset = this.arrowSize * 2;\n\n @property({ type: Number })\n offsetX = -10;\n\n @property({ type: Number })\n offsetY = 0;\n\n public firstUpdated(props: any) {\n super.firstUpdated(props);\n\n const dropdown = this.shadowRoot.querySelector(\n '.dropdown'\n ) as HTMLDivElement;\n const arrow = this.shadowRoot.querySelector('.arrow') as HTMLDivElement;\n\n arrow.style.borderWidth = this.arrowSize + 'px';\n arrow.style.top = '-' + this.arrowSize + 'px';\n\n if (this.arrowOffset < 0) {\n arrow.style.right = Math.abs(this.arrowOffset) + 'px';\n } else {\n arrow.style.left = this.arrowOffset + 'px';\n }\n\n dropdown.style.marginTop = this.offsetY + 'px';\n\n if (dropdown.offsetLeft + dropdown.clientWidth > window.outerWidth) {\n dropdown.style.marginLeft =\n '-' + (dropdown.clientWidth - this.clientWidth - this.offsetX) + 'px';\n } else {\n dropdown.style.marginLeft = this.offsetX + 'px';\n }\n\n dropdown.addEventListener('blur', () => {\n // we nest this to deal with clicking the toggle to close\n // as we don't want it to toggle an immediate open, probably\n // a better way to deal with this\n window.setTimeout(() => {\n this.open = false;\n }, 200);\n });\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n if (changedProperties.has('open')) {\n if (this.open) {\n this.classList.add('open');\n } else {\n this.classList.remove('open');\n }\n }\n }\n\n public handleOpen(): void {\n if (!this.open) {\n this.open = true;\n\n const dropdown = this.shadowRoot.querySelector(\n '.dropdown'\n ) as HTMLDivElement;\n dropdown.focus();\n }\n }\n\n public render(): TemplateResult {\n return html`\n <div class=${this.open ? 'open' : ''}>\n <slot name=\"toggle\" class=\"toggle\" @click=\"${this.handleOpen}\"></slot>\n <div class=\"dropdown\" tabindex=\"0\">\n <div class=\"arrow\"></div>\n <slot name=\"dropdown\"></slot>\n </div>\n </div>\n `;\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
- import { html, css, property, LitElement } from 'lit-element';
2
+ import { html, css, LitElement } from 'lit';
3
+ import { property } from 'lit/decorators';
3
4
  /**
4
5
  * A small wrapper to display labels and help text in a smartmin style.
5
6
  * This exists so we can display things consistently before restyling.
@@ -1 +1 @@
1
- {"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/formfield/FormField.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,a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AC,IAAI;;;;UAIN,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM;YACzC,CAAC,CAAC,IAAI,CAAA;sCACsB,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI;kBAC1D,IAAI,CAAC,QAAQ;;aAElB;YACH,CAAC,CAAC,IAAI;UACN,MAAM;;KAEX,CAAC;IACJ,CAAC;CACF;AA/DC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;4CACnC;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;6CACnC;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;yCACtB;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;2CACrC;AAGd;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;6CACpC;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCAChB;AAGX;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCACjB;AAGV;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACX","sourcesContent":["import { TemplateResult, html, css, property, LitElement } from 'lit-element';\n\n/**\n * A small wrapper to display labels and help text in a smartmin style.\n * This exists so we can display things consistently before restyling.\n */\nexport class FormField extends LitElement {\n static get styles() {\n return css`\n :host {\n font-family: var(--font-family);\n }\n\n label {\n margin-bottom: 5px;\n margin-left: 4px;\n display: block;\n font-weight: 400;\n font-size: var(--label-size);\n letter-spacing: 0.05em;\n line-height: normal;\n color: #777;\n }\n\n .help-text {\n font-size: var(--help-text-size);\n line-height: normal;\n color: var(--color-text-help);\n margin-left: var(--help-text-margin-left);\n margin-top: -16px;\n opacity: 0;\n transition: opacity ease-in-out 100ms, margin-top ease-in-out 200ms;\n pointer-events: none;\n }\n\n .help-text.help-always {\n opacity: 1;\n margin-top: 6px;\n margin-left: var(--help-text-margin-left);\n }\n\n .field:focus-within .help-text {\n margin-top: 6px;\n opacity: 1;\n }\n\n .alert-error {\n background: rgba(255, 181, 181, 0.17);\n border: none;\n border-left: 0px solid var(--color-error);\n color: var(--color-error);\n padding: 10px;\n margin: 15px 0px;\n border-radius: var(--curvature);\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1),\n 0 1px 2px 0 rgba(0, 0, 0, 0.06);\n }\n\n .disabled {\n opacity: 0.6 !important;\n pointer-events: none !important;\n }\n `;\n }\n\n @property({ type: Boolean, attribute: 'hide_label' })\n hideLabel = false;\n\n @property({ type: Boolean, attribute: 'widget_only' })\n widgetOnly = false;\n\n @property({ type: Array, attribute: false })\n errors: string[] = [];\n\n @property({ type: Boolean })\n hideErrors = false;\n\n @property({ type: String, attribute: 'help_text' })\n helpText = '';\n\n @property({ type: Boolean, attribute: 'help_always' })\n helpAlways = true;\n\n @property({ type: String })\n label = '';\n\n @property({ type: String })\n name = '';\n\n @property({ type: Boolean })\n disabled = false;\n\n public render(): TemplateResult {\n const errors = !this.hideErrors\n ? (this.errors || []).map((error: string) => {\n return html` <div class=\"alert-error\">${error}</div> `;\n })\n : [];\n\n if (this.widgetOnly) {\n return html`\n <div class=\"${this.disabled ? 'disabled' : ''}\"><slot></slot></div>\n ${errors}\n `;\n }\n\n return html`\n <div class=\"field ${this.disabled ? 'disabled' : ''}\">\n ${!!this.name && !this.hideLabel && !!this.label\n ? html`\n <label class=\"control-label\" for=\"${this.name}\"\n >${this.label}</label\n >\n `\n : null}\n <div class=\"widget\">\n <slot></slot>\n </div>\n ${this.helpText && this.helpText !== 'None'\n ? html`\n <div class=\"help-text ${this.helpAlways ? 'help-always' : null}\">\n ${this.helpText}\n </div>\n `\n : null}\n ${errors}\n </div>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/formfield/FormField.ts"],"names":[],"mappings":";AAAA,OAAO,EAAkB,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,UAAU;IAAzC;;QA4DE,cAAS,GAAG,KAAK,CAAC;QAGlB,eAAU,GAAG,KAAK,CAAC;QAGnB,WAAM,GAAa,EAAE,CAAC;QAGtB,eAAU,GAAG,KAAK,CAAC;QAGnB,aAAQ,GAAG,EAAE,CAAC;QAGd,eAAU,GAAG,IAAI,CAAC;QAGlB,UAAK,GAAG,EAAE,CAAC;QAGX,SAAI,GAAG,EAAE,CAAC;QAGV,aAAQ,GAAG,KAAK,CAAC;IAuCnB,CAAC;IA1HC,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsDT,CAAC;IACJ,CAAC;IA6BM,MAAM;QACX,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU;YAC7B,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE;gBACxC,OAAO,IAAI,CAAA,6BAA6B,KAAK,SAAS,CAAC;YACzD,CAAC,CAAC;YACJ,CAAC,CAAC,EAAE,CAAC;QAEP,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,OAAO,IAAI,CAAA;sBACK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAA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C,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCACjB;AAGV;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACX","sourcesContent":["import { TemplateResult, html, css, LitElement } from 'lit';\nimport { property } from 'lit/decorators';\n\n/**\n * A small wrapper to display labels and help text in a smartmin style.\n * This exists so we can display things consistently before restyling.\n */\nexport class FormField extends LitElement {\n static get styles() {\n return css`\n :host {\n font-family: var(--font-family);\n }\n\n label {\n margin-bottom: 5px;\n margin-left: 4px;\n display: block;\n font-weight: 400;\n font-size: var(--label-size);\n letter-spacing: 0.05em;\n line-height: normal;\n color: #777;\n }\n\n .help-text {\n font-size: var(--help-text-size);\n line-height: normal;\n color: var(--color-text-help);\n margin-left: var(--help-text-margin-left);\n margin-top: -16px;\n opacity: 0;\n transition: opacity ease-in-out 100ms, margin-top ease-in-out 200ms;\n pointer-events: none;\n }\n\n .help-text.help-always {\n opacity: 1;\n margin-top: 6px;\n margin-left: var(--help-text-margin-left);\n }\n\n .field:focus-within .help-text {\n margin-top: 6px;\n opacity: 1;\n }\n\n .alert-error {\n background: rgba(255, 181, 181, 0.17);\n border: none;\n border-left: 0px solid var(--color-error);\n color: var(--color-error);\n padding: 10px;\n margin: 15px 0px;\n border-radius: var(--curvature);\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1),\n 0 1px 2px 0 rgba(0, 0, 0, 0.06);\n }\n\n .disabled {\n opacity: 0.6 !important;\n pointer-events: none !important;\n }\n `;\n }\n\n @property({ type: Boolean, attribute: 'hide_label' })\n hideLabel = false;\n\n @property({ type: Boolean, attribute: 'widget_only' })\n widgetOnly = false;\n\n @property({ type: Array, attribute: false })\n errors: string[] = [];\n\n @property({ type: Boolean })\n hideErrors = false;\n\n @property({ type: String, attribute: 'help_text' })\n helpText = '';\n\n @property({ type: Boolean, attribute: 'help_always' })\n helpAlways = true;\n\n @property({ type: String })\n label = '';\n\n @property({ type: String })\n name = '';\n\n @property({ type: Boolean })\n disabled = false;\n\n public render(): TemplateResult {\n const errors = !this.hideErrors\n ? (this.errors || []).map((error: string) => {\n return html` <div class=\"alert-error\">${error}</div> `;\n })\n : [];\n\n if (this.widgetOnly) {\n return html`\n <div class=\"${this.disabled ? 'disabled' : ''}\"><slot></slot></div>\n ${errors}\n `;\n }\n\n return html`\n <div class=\"field ${this.disabled ? 'disabled' : ''}\">\n ${!!this.name && !this.hideLabel && !!this.label\n ? html`\n <label class=\"control-label\" for=\"${this.name}\"\n >${this.label}</label\n >\n `\n : null}\n <div class=\"widget\">\n <slot></slot>\n </div>\n ${this.helpText && this.helpText !== 'None'\n ? html`\n <div class=\"help-text ${this.helpAlways ? 'help-always' : null}\">\n ${this.helpText}\n </div>\n `\n : null}\n ${errors}\n </div>\n `;\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
- import { LitElement, html, css, customElement, property, } from 'lit-element';
2
+ import { LitElement, html, css } from 'lit';
3
+ import { property, customElement } from 'lit/decorators';
3
4
  import { getClasses } from '../utils';
4
5
  import { styleMap } from 'lit-html/directives/style-map';
5
6
  let Label = class Label extends LitElement {
@@ -1 +1 @@
1
- {"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../src/label/Label.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAEV,IAAI,EACJ,GAAG,EACH,aAAa,EACb,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGzD,IAAqB,KAAK,GAA1B,MAAqB,KAAM,SAAQ,UAAU;IAC3C,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkDT,CAAC;IACJ,CAAC;IAuBM,MAAM;QACX,MAAM,UAAU,GACd,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,SAAS;YACpC,CAAC,CAAC;gBACE,UAAU,EAAE,GAAG,IAAI,CAAC,eAAe,EAAE;gBACrC,KAAK,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE;aAC3B;YACH,CAAC,CAAC,EAAE,CAAC;QAET,OAAO,IAAI,CAAA;;uBAEQ,UAAU,CAAC;YACxB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;gBACM,QAAQ,CAAC,UAAU,CAAC;;;;;;KAM/B,CAAC;IACJ,CAAC;CACF,CAAA;AA9CC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACX;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oCACb;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mCACd;AAGd;IADC,QAAQ,EAAE;8CACa;AAGxB;IADC,QAAQ,EAAE;wCACO;AA1EC,KAAK;IADzB,aAAa,CAAC,aAAa,CAAC;GACR,KAAK,CAsGzB;eAtGoB,KAAK","sourcesContent":["import {\n LitElement,\n TemplateResult,\n html,\n css,\n customElement,\n property,\n} from 'lit-element';\nimport { getClasses } from '../utils';\nimport { styleMap } from 'lit-html/directives/style-map';\n\n@customElement('temba-label')\nexport default class Label extends LitElement {\n static get styles() {\n return css`\n :host {\n display: inline-block;\n }\n\n .mask {\n padding: 3px 6px;\n border-radius: var(--curvature);\n }\n\n .label.clickable .mask:hover {\n background: rgb(0, 0, 0, 0.05);\n }\n\n .label {\n border-radius: 2px;\n font-size: 80%;\n font-weight: 400;\n border-radius: var(--curvature);\n background: tomato;\n color: #fff;\n text-shadow: 0 0.04em 0.04em rgba(0, 0, 0, 0.35);\n }\n\n .primary {\n background: var(--color-label-primary);\n color: var(--color-label-primary-text);\n }\n\n .secondary {\n background: var(--color-label-secondary);\n color: var(--color-label-secondary-text);\n text-shadow: none;\n }\n\n .light {\n background: var(--color-overlay-light);\n color: var(--color-overlay-light-text);\n text-shadow: none;\n }\n\n .dark {\n background: var(--color-overlay-dark);\n color: var(--color-overlay-dark-text);\n text-shadow: none;\n }\n\n .clickable {\n cursor: pointer;\n }\n `;\n }\n\n @property({ type: Boolean })\n clickable: boolean;\n\n @property({ type: Boolean })\n primary: boolean;\n\n @property({ type: Boolean })\n secondary: boolean;\n\n @property({ type: Boolean })\n light: boolean;\n\n @property({ type: Boolean })\n dark: boolean;\n\n @property()\n backgroundColor: string;\n\n @property()\n textColor: string;\n\n public render(): TemplateResult {\n const labelStyle =\n this.backgroundColor && this.textColor\n ? {\n background: `${this.backgroundColor}`,\n color: `${this.textColor}`,\n }\n : {};\n\n return html`\n <div\n class=\"label ${getClasses({\n clickable: this.clickable,\n primary: this.primary,\n secondary: this.secondary,\n light: this.light,\n dark: this.dark,\n })}\"\n style=${styleMap(labelStyle)}\n >\n <div class=\"mask\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../src/label/Label.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGzD,IAAqB,KAAK,GAA1B,MAAqB,KAAM,SAAQ,UAAU;IAC3C,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkDT,CAAC;IACJ,CAAC;IAuBM,MAAM;QACX,MAAM,UAAU,GACd,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,SAAS;YACpC,CAAC,CAAC;gBACE,UAAU,EAAE,GAAG,IAAI,CAAC,eAAe,EAAE;gBACrC,KAAK,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE;aAC3B;YACH,CAAC,CAAC,EAAE,CAAC;QAET,OAAO,IAAI,CAAA;;uBAEQ,UAAU,CAAC;YACxB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;gBACM,QAAQ,CAAC,UAAU,CAAC;;;;;;KAM/B,CAAC;IACJ,CAAC;CACF,CAAA;AA9CC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACX;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oCACb;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mCACd;AAGd;IADC,QAAQ,EAAE;8CACa;AAGxB;IADC,QAAQ,EAAE;wCACO;AA1EC,KAAK;IADzB,aAAa,CAAC,aAAa,CAAC;GACR,KAAK,CAsGzB;eAtGoB,KAAK","sourcesContent":["import { LitElement, TemplateResult, html, css } from 'lit';\nimport { property, customElement } from 'lit/decorators';\nimport { getClasses } from '../utils';\nimport { styleMap } from 'lit-html/directives/style-map';\n\n@customElement('temba-label')\nexport default class Label extends LitElement {\n static get styles() {\n return css`\n :host {\n display: inline-block;\n }\n\n .mask {\n padding: 3px 6px;\n border-radius: var(--curvature);\n }\n\n .label.clickable .mask:hover {\n background: rgb(0, 0, 0, 0.05);\n }\n\n .label {\n border-radius: 2px;\n font-size: 80%;\n font-weight: 400;\n border-radius: var(--curvature);\n background: tomato;\n color: #fff;\n text-shadow: 0 0.04em 0.04em rgba(0, 0, 0, 0.35);\n }\n\n .primary {\n background: var(--color-label-primary);\n color: var(--color-label-primary-text);\n }\n\n .secondary {\n background: var(--color-label-secondary);\n color: var(--color-label-secondary-text);\n text-shadow: none;\n }\n\n .light {\n background: var(--color-overlay-light);\n color: var(--color-overlay-light-text);\n text-shadow: none;\n }\n\n .dark {\n background: var(--color-overlay-dark);\n color: var(--color-overlay-dark-text);\n text-shadow: none;\n }\n\n .clickable {\n cursor: pointer;\n }\n `;\n }\n\n @property({ type: Boolean })\n clickable: boolean;\n\n @property({ type: Boolean })\n primary: boolean;\n\n @property({ type: Boolean })\n secondary: boolean;\n\n @property({ type: Boolean })\n light: boolean;\n\n @property({ type: Boolean })\n dark: boolean;\n\n @property()\n backgroundColor: string;\n\n @property()\n textColor: string;\n\n public render(): TemplateResult {\n const labelStyle =\n this.backgroundColor && this.textColor\n ? {\n background: `${this.backgroundColor}`,\n color: `${this.textColor}`,\n }\n : {};\n\n return html`\n <div\n class=\"label ${getClasses({\n clickable: this.clickable,\n primary: this.primary,\n secondary: this.secondary,\n light: this.light,\n dark: this.dark,\n })}\"\n style=${styleMap(labelStyle)}\n >\n <div class=\"mask\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { geoJSON, map as createMap, } from 'leaflet';
3
- import { css, html, LitElement, property } from 'lit-element';
3
+ import { css, html, LitElement } from 'lit';
4
+ import { property } from 'lit/decorators';
4
5
  import { getUrl } from '../utils';
5
6
  import { highlightedFeature, normalFeature, visibleStyle } from './helpers';
6
7
  export class LeafletMap extends LitElement {
@@ -1 +1 @@
1
- {"version":3,"file":"LeafletMap.js","sourceRoot":"","sources":["../../../src/leafletmap/LeafletMap.ts"],"names":[],"mappings":";AAEA,OAAO,EAEL,OAAO,EAIP,GAAG,IAAI,SAAS,GAEjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,MAAM,EAAe,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE5E,MAAM,OAAO,UAAW,SAAQ,UAAU;IA6DxC;QACE,KAAK,EAAE,CAAC;QAlBV,UAAK,GAAG,EAAE,CAAC;QAGX,aAAQ,GAAG,EAAE,CAAC;QAMd,YAAO,GAAsB,IAAI,CAAC;QAGlC,SAAI,GAAwB,EAAE,CAAC;QAE/B,gBAAW,GAAgB,IAAI,CAAC;QAChC,WAAM,GAAiB,IAAI,CAAC;QAc5B,UAAK,GAA8B,EAAE,CAAC;QACtC,gBAAW,GAAS,IAAI,CAAC;IAXzB,CAAC;IA9DD,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmCT,CAAC;IACJ,CAAC;IA2BO,aAAa;QACnB,OAAO,IAAI,CAAC,UAA8B,CAAC;IAC7C,CAAC;IAEO,WAAW;QACjB,OAAO,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACnE,CAAC;IAKO,UAAU;QAChB,MAAM,aAAa,GAAG,CAAC,OAA+B,EAAE,IAAU,EAAE,E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AE;2CACuB;AAGlC;IADC,QAAQ,EAAE;wCACoB","sourcesContent":["/* eslint-disable @typescript-eslint/camelcase */\nimport { Feature, Geometry } from 'geojson';\nimport {\n GeoJSON,\n geoJSON,\n LeafletEvent,\n LeafletMouseEvent,\n Map as RenderedMap,\n map as createMap,\n Path,\n} from 'leaflet';\nimport { css, html, LitElement, property } from 'lit-element';\n\nimport { FeatureProperties } from '../interfaces';\nimport { getUrl, WebResponse } from '../utils';\nimport { highlightedFeature, normalFeature, visibleStyle } from './helpers';\n\nexport class LeafletMap extends LitElement {\n static get styles() {\n return css`\n :host {\n display: block;\n padding: 0px;\n }\n\n #alias-map {\n top: 0px;\n height: 100%;\n }\n\n .leaflet-container {\n background: transparent;\n }\n\n .path {\n position: absolute;\n color: #666;\n }\n\n .path > .step {\n display: inline-block;\n font-size: 12px;\n margin-left: 5px;\n }\n\n .path > .step.hovered {\n color: #999;\n }\n\n .path > .step.linked {\n text-decoration: underline;\n color: var(--color-link-primary);\n cursor: pointer;\n }\n `;\n }\n\n @property()\n feature: FeatureProperties;\n\n @property()\n osmId = '';\n\n @property()\n endpoint = '';\n\n @property()\n onFeatureClicked: (feature: FeatureProperties) => void;\n\n @property()\n hovered: FeatureProperties = null;\n\n @property()\n path: FeatureProperties[] = [];\n\n renderedMap: RenderedMap = null;\n states: GeoJSON<any> = null;\n\n constructor() {\n super();\n }\n\n private getRenderRoot(): DocumentFragment {\n return this.renderRoot as DocumentFragment;\n }\n\n private getEndpoint(): string {\n return this.endpoint + (!this.endpoint.endsWith('/') ? '/' : '');\n }\n\n paths: { [osmId: string]: Path } = {};\n lastHovered: Path = null;\n\n private refreshMap(): void {\n const onEachFeature = (feature: Feature<Geometry, any>, path: Path) => {\n this.paths[feature.properties.osm_id] = path;\n\n path.on({\n click: (event: LeafletMouseEvent) => {\n const feature: FeatureProperties = event.target.feature.properties;\n if (feature.osm_id !== this.path[this.path.length - 1].osm_id) {\n const orig = event.originalEvent;\n\n orig.stopPropagation();\n orig.preventDefault();\n\n if (this.onFeatureClicked) {\n this.onFeatureClicked(feature);\n }\n\n this.hovered = null;\n this.path.push(feature);\n this.osmId = feature.osm_id;\n this.refreshMap();\n }\n },\n mouseover: (event: LeafletEvent) => {\n const feature: FeatureProperties = event.target.feature.properties;\n if (feature.osm_id !== this.path[this.path.length - 1].osm_id) {\n event.target.setStyle(highlightedFeature);\n this.hovered = feature;\n }\n },\n mouseout: (event: LeafletEvent) => {\n event.target.setStyle(normalFeature);\n this.hovered = null;\n },\n });\n };\n\n getUrl(this.getEndpoint() + 'geometry/' + this.osmId + '/').then(\n (response: WebResponse) => {\n if (this.states) {\n this.renderedMap.removeLayer(this.states);\n }\n\n const data = response.json;\n if (this.path.length === 0) {\n this.path = [\n {\n name: data.name,\n osm_id: this.osmId,\n level: 0,\n },\n ];\n }\n\n this.states = geoJSON(data.geometry, {\n style: visibleStyle,\n onEachFeature,\n });\n this.renderedMap.fitBounds(this.states.getBounds(), {});\n this.states.addTo(this.renderedMap);\n }\n );\n }\n\n public updated(changedProperties: Map<string, any>) {\n if (changedProperties.has('hovered')) {\n if (this.lastHovered) {\n this.lastHovered.setStyle(normalFeature);\n }\n\n if (this.hovered) {\n const layer = this.paths[this.hovered.osm_id];\n this.lastHovered = layer;\n if (layer) {\n layer.setStyle(highlightedFeature);\n }\n }\n }\n\n if (changedProperties.has('feature') && this.feature) {\n this.hovered = null;\n if (\n this.path.length === 0 ||\n this.path[this.path.length - 1].osm_id !== this.feature.osm_id\n ) {\n this.path.push(this.feature);\n }\n }\n\n if (changedProperties.has('osmId')) {\n const path: FeatureProperties[] = [];\n for (const feature of this.path) {\n path.push(feature);\n if (feature.osm_id === this.osmId) {\n if (this.onFeatureClicked) {\n this.onFeatureClicked(feature);\n }\n break;\n }\n }\n\n this.path = path;\n\n this.refreshMap();\n }\n }\n\n public firstUpdated(changedProperties: any) {\n const mapElement = this.getRenderRoot().getElementById('alias-map');\n this.renderedMap = createMap(mapElement, {\n attributionControl: false,\n scrollWheelZoom: false,\n zoomControl: false,\n }).setView([0, 1], 4);\n this.renderedMap.dragging.disable();\n this.renderedMap.doubleClickZoom.disable();\n\n this.refreshMap();\n super.firstUpdated(changedProperties);\n }\n\n private handleClickedBreadcrumb(e: MouseEvent): void {\n this.osmId = (e.currentTarget as HTMLElement).getAttribute('data-osmid');\n const path: FeatureProperties[] = [];\n for (const feature of this.path) {\n path.push(feature);\n if (feature.osm_id === this.osmId) {\n if (this.onFeatureClicked) {\n this.onFeatureClicked(feature);\n }\n break;\n }\n }\n\n this.path = path;\n this.refreshMap();\n }\n\n render() {\n if (!this.osmId) {\n return html`<div>No osm map id</div>`;\n }\n\n return html`\n <link\n rel=\"stylesheet\"\n href=\"https://unpkg.com/leaflet@1.5.1/dist/leaflet.css\"\n />\n <div id=\"alias-map\"></div>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"LeafletMap.js","sourceRoot":"","sources":["../../../src/leafletmap/LeafletMap.ts"],"names":[],"mappings":";AACA,OAAO,EAEL,OAAO,EAIP,GAAG,IAAI,SAAS,GAEjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAe,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE5E,MAAM,OAAO,UAAW,SAAQ,UAAU;IA6DxC;QACE,KAAK,EAAE,CAAC;QAlBV,UAAK,GAAG,EAAE,CAAC;QAGX,aAAQ,GAAG,EAAE,CAAC;QAMd,YAAO,GAAsB,IAAI,CAAC;QAGlC,SAAI,GAAwB,EAAE,CAAC;QAE/B,gBAAW,GAAgB,IAAI,CAAC;QAChC,WAAM,GAAiB,IAAI,CAAC;QAc5B,UAAK,GAA8B,EAAE,CAAC;QACtC,gBAAW,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AI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;iBAChC;gBACD,MAAM;aACP;SACF;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,OAAO,IAAI,CAAA,0BAA0B,CAAC;SACvC;QAED,OAAO,IAAI,CAAA;;;;;;KAMV,CAAC;IACJ,CAAC;CACF;AA1LC;IADC,QAAQ,EAAE;2CACgB;AAG3B;IADC,QAAQ,EAAE;yCACA;AAGX;IADC,QAAQ,EAAE;4CACG;AAGd;IADC,QAAQ,EAAE;oDAC4C;AAGvD;IADC,QAAQ,EAAE;2CACuB;AAGlC;IADC,QAAQ,EAAE;wCACoB","sourcesContent":["import { Feature, Geometry } from 'geojson';\nimport {\n GeoJSON,\n geoJSON,\n LeafletEvent,\n LeafletMouseEvent,\n Map as RenderedMap,\n map as createMap,\n Path,\n} from 'leaflet';\nimport { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators';\n\nimport { FeatureProperties } from '../interfaces';\nimport { getUrl, WebResponse } from '../utils';\nimport { highlightedFeature, normalFeature, visibleStyle } from './helpers';\n\nexport class LeafletMap extends LitElement {\n static get styles() {\n return css`\n :host {\n display: block;\n padding: 0px;\n }\n\n #alias-map {\n top: 0px;\n height: 100%;\n }\n\n .leaflet-container {\n background: transparent;\n }\n\n .path {\n position: absolute;\n color: #666;\n }\n\n .path > .step {\n display: inline-block;\n font-size: 12px;\n margin-left: 5px;\n }\n\n .path > .step.hovered {\n color: #999;\n }\n\n .path > .step.linked {\n text-decoration: underline;\n color: var(--color-link-primary);\n cursor: pointer;\n }\n `;\n }\n\n @property()\n feature: FeatureProperties;\n\n @property()\n osmId = '';\n\n @property()\n endpoint = '';\n\n @property()\n onFeatureClicked: (feature: FeatureProperties) => void;\n\n @property()\n hovered: FeatureProperties = null;\n\n @property()\n path: FeatureProperties[] = [];\n\n renderedMap: RenderedMap = null;\n states: GeoJSON<any> = null;\n\n constructor() {\n super();\n }\n\n private getRenderRoot(): DocumentFragment {\n return this.renderRoot as DocumentFragment;\n }\n\n private getEndpoint(): string {\n return this.endpoint + (!this.endpoint.endsWith('/') ? '/' : '');\n }\n\n paths: { [osmId: string]: Path } = {};\n lastHovered: Path = null;\n\n private refreshMap(): void {\n const onEachFeature = (feature: Feature<Geometry, any>, path: Path) => {\n this.paths[feature.properties.osm_id] = path;\n\n path.on({\n click: (event: LeafletMouseEvent) => {\n const feature: FeatureProperties = event.target.feature.properties;\n if (feature.osm_id !== this.path[this.path.length - 1].osm_id) {\n const orig = event.originalEvent;\n\n orig.stopPropagation();\n orig.preventDefault();\n\n if (this.onFeatureClicked) {\n this.onFeatureClicked(feature);\n }\n\n this.hovered = null;\n this.path.push(feature);\n this.osmId = feature.osm_id;\n this.refreshMap();\n }\n },\n mouseover: (event: LeafletEvent) => {\n const feature: FeatureProperties = event.target.feature.properties;\n if (feature.osm_id !== this.path[this.path.length - 1].osm_id) {\n event.target.setStyle(highlightedFeature);\n this.hovered = feature;\n }\n },\n mouseout: (event: LeafletEvent) => {\n event.target.setStyle(normalFeature);\n this.hovered = null;\n },\n });\n };\n\n getUrl(this.getEndpoint() + 'geometry/' + this.osmId + '/').then(\n (response: WebResponse) => {\n if (this.states) {\n this.renderedMap.removeLayer(this.states);\n }\n\n const data = response.json;\n if (this.path.length === 0) {\n this.path = [\n {\n name: data.name,\n osm_id: this.osmId,\n level: 0,\n },\n ];\n }\n\n this.states = geoJSON(data.geometry, {\n style: visibleStyle,\n onEachFeature,\n });\n this.renderedMap.fitBounds(this.states.getBounds(), {});\n this.states.addTo(this.renderedMap);\n }\n );\n }\n\n public updated(changedProperties: Map<string, any>) {\n if (changedProperties.has('hovered')) {\n if (this.lastHovered) {\n this.lastHovered.setStyle(normalFeature);\n }\n\n if (this.hovered) {\n const layer = this.paths[this.hovered.osm_id];\n this.lastHovered = layer;\n if (layer) {\n layer.setStyle(highlightedFeature);\n }\n }\n }\n\n if (changedProperties.has('feature') && this.feature) {\n this.hovered = null;\n if (\n this.path.length === 0 ||\n this.path[this.path.length - 1].osm_id !== this.feature.osm_id\n ) {\n this.path.push(this.feature);\n }\n }\n\n if (changedProperties.has('osmId')) {\n const path: FeatureProperties[] = [];\n for (const feature of this.path) {\n path.push(feature);\n if (feature.osm_id === this.osmId) {\n if (this.onFeatureClicked) {\n this.onFeatureClicked(feature);\n }\n break;\n }\n }\n\n this.path = path;\n\n this.refreshMap();\n }\n }\n\n public firstUpdated(changedProperties: any) {\n const mapElement = this.getRenderRoot().getElementById('alias-map');\n this.renderedMap = createMap(mapElement, {\n attributionControl: false,\n scrollWheelZoom: false,\n zoomControl: false,\n }).setView([0, 1], 4);\n this.renderedMap.dragging.disable();\n this.renderedMap.doubleClickZoom.disable();\n\n this.refreshMap();\n super.firstUpdated(changedProperties);\n }\n\n private handleClickedBreadcrumb(e: MouseEvent): void {\n this.osmId = (e.currentTarget as HTMLElement).getAttribute('data-osmid');\n const path: FeatureProperties[] = [];\n for (const feature of this.path) {\n path.push(feature);\n if (feature.osm_id === this.osmId) {\n if (this.onFeatureClicked) {\n this.onFeatureClicked(feature);\n }\n break;\n }\n }\n\n this.path = path;\n this.refreshMap();\n }\n\n render() {\n if (!this.osmId) {\n return html`<div>No osm map id</div>`;\n }\n\n return html`\n <link\n rel=\"stylesheet\"\n href=\"https://unpkg.com/leaflet@1.5.1/dist/leaflet.css\"\n />\n <div id=\"alias-map\"></div>\n `;\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
- import { css, html, property } from 'lit-element';
2
+ import { css, html } from 'lit';
3
+ import { property } from 'lit/decorators';
3
4
  import { reset } from 'sinon';
4
5
  import { CustomEventType } from '../interfaces';
5
6
  import { RapidElement } from '../RapidElement';
@@ -173,10 +174,11 @@ export class TembaList extends RapidElement {
173
174
  this.cursorIndex = newIndex;
174
175
  // make sure our focused item is visible
175
176
  window.setTimeout(() => {
176
- const option = this.shadowRoot
177
- .querySelector('temba-options')
178
- .shadowRoot.querySelector('.option.focused');
179
- option.scrollIntoView({ block: 'end', inline: 'nearest' });
177
+ const options = this.shadowRoot.querySelector('temba-options');
178
+ if (options) {
179
+ const option = options.shadowRoot.querySelector('.option.focused');
180
+ option.scrollIntoView({ block: 'end', inline: 'nearest' });
181
+ }
180
182
  }, 0);
181
183
  }
182
184
  }