@nyaruka/temba-components 0.75.0 → 0.75.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/demo/index.html +1 -1
  3. package/dist/{47acce75.js → 42372647.js} +51 -32
  4. package/dist/index.js +51 -32
  5. package/dist/static/svg/index.svg +1 -1
  6. package/dist/sw.js +1 -1
  7. package/dist/sw.js.map +1 -1
  8. package/dist/templates/components-body.html +1 -1
  9. package/dist/templates/components-head.html +1 -1
  10. package/out-tsc/src/compose/Compose.js +0 -1
  11. package/out-tsc/src/compose/Compose.js.map +1 -1
  12. package/out-tsc/src/contacts/ContactFieldEditor.js +0 -1
  13. package/out-tsc/src/contacts/ContactFieldEditor.js.map +1 -1
  14. package/out-tsc/src/dialog/Dialog.js +20 -2
  15. package/out-tsc/src/dialog/Dialog.js.map +1 -1
  16. package/out-tsc/src/dropdown/Dropdown.js +46 -42
  17. package/out-tsc/src/dropdown/Dropdown.js.map +1 -1
  18. package/out-tsc/src/lightbox/Lightbox.js +2 -3
  19. package/out-tsc/src/lightbox/Lightbox.js.map +1 -1
  20. package/out-tsc/src/list/TembaList.js +8 -1
  21. package/out-tsc/src/list/TembaList.js.map +1 -1
  22. package/out-tsc/src/list/TembaMenu.js +5 -2
  23. package/out-tsc/src/list/TembaMenu.js.map +1 -1
  24. package/out-tsc/src/vectoricon/index.js +2 -2
  25. package/out-tsc/src/vectoricon/index.js.map +1 -1
  26. package/package.json +1 -1
  27. package/src/compose/Compose.ts +0 -1
  28. package/src/contacts/ContactFieldEditor.ts +0 -1
  29. package/src/dialog/Dialog.ts +20 -6
  30. package/src/dropdown/Dropdown.ts +41 -30
  31. package/src/lightbox/Lightbox.ts +2 -3
  32. package/src/list/TembaList.ts +7 -1
  33. package/src/list/TembaMenu.ts +5 -2
  34. package/src/vectoricon/index.ts +2 -2
  35. package/static/svg/index.svg +1 -1
  36. package/static/svg/work/traced/volume-min.svg +1 -0
  37. package/static/svg/work/used/volume-min.svg +3 -0
@@ -4,19 +4,6 @@ import { property } from 'lit/decorators.js';
4
4
  import { RapidElement } from '../RapidElement';
5
5
  import { getClasses } from '../utils';
6
6
  export class Dropdown extends RapidElement {
7
- constructor() {
8
- super(...arguments);
9
- this.open = false;
10
- this.top = false;
11
- this.bottom = false;
12
- this.left = false;
13
- this.right = false;
14
- this.arrowSize = 6;
15
- this.arrowOffset = this.arrowSize * 2;
16
- this.offsetX = 0;
17
- this.offsetY = 0;
18
- this.mask = false;
19
- }
20
7
  static get styles() {
21
8
  return css `
22
9
  .wrapper {
@@ -93,6 +80,20 @@ export class Dropdown extends RapidElement {
93
80
  }
94
81
  `;
95
82
  }
83
+ constructor() {
84
+ super();
85
+ this.open = false;
86
+ this.top = false;
87
+ this.bottom = false;
88
+ this.left = false;
89
+ this.right = false;
90
+ this.arrowSize = 6;
91
+ this.arrowOffset = this.arrowSize * 2;
92
+ this.offsetX = 0;
93
+ this.offsetY = 0;
94
+ this.mask = false;
95
+ this.ensureOnScreen = this.ensureOnScreen.bind(this);
96
+ }
96
97
  firstUpdated(props) {
97
98
  super.firstUpdated(props);
98
99
  const arrow = this.shadowRoot.querySelector('.arrow');
@@ -135,43 +136,46 @@ export class Dropdown extends RapidElement {
135
136
  }
136
137
  }
137
138
  if (changedProperties.has('open')) {
138
- this.ensureOnScreen();
139
+ // check right away if we are on the screen, and then again moments after render
140
+ window.setTimeout(this.ensureOnScreen, 0);
141
+ window.setTimeout(this.ensureOnScreen, 100);
139
142
  }
140
143
  }
141
144
  ensureOnScreen() {
142
- window.setTimeout(() => {
143
- const dropdown = this.shadowRoot.querySelector('.dropdown');
144
- if (dropdown) {
145
- // dropdown will go off the screen, let's push it up
146
- const toggle = this.querySelector('div[slot="toggle"]');
147
- if (dropdown.getBoundingClientRect().bottom > window.innerHeight) {
148
- if (this.bottom) {
149
- dropdown.style.top = toggle.clientHeight + 'px';
150
- }
151
- else {
152
- dropdown.style.top = '';
153
- dropdown.style.bottom = toggle.clientHeight + 'px';
154
- }
145
+ const dropdown = this.shadowRoot.querySelector('.dropdown');
146
+ if (dropdown) {
147
+ // dropdown will go off the screen, let's push it up
148
+ const toggle = this.querySelector('div[slot="toggle"]');
149
+ if (!toggle) {
150
+ return;
151
+ }
152
+ if (dropdown.getBoundingClientRect().bottom > window.innerHeight - 100) {
153
+ if (this.bottom) {
154
+ dropdown.style.top = toggle.clientHeight + 'px';
155
155
  }
156
- else if (dropdown.getBoundingClientRect().top < 0) {
157
- if (this.bottom) {
158
- dropdown.style.top = toggle.clientHeight + 'px';
159
- }
160
- else {
161
- dropdown.style.top = toggle.clientHeight + 'px';
162
- dropdown.style.bottom = '';
163
- }
156
+ else {
157
+ dropdown.style.top = '';
158
+ dropdown.style.bottom = toggle.clientHeight + 'px';
164
159
  }
165
- if (dropdown.getBoundingClientRect().right > window.innerWidth) {
166
- dropdown.style.left = '';
167
- dropdown.style.right = 0 + 'px';
160
+ }
161
+ else if (dropdown.getBoundingClientRect().top < 0) {
162
+ if (this.bottom) {
163
+ dropdown.style.top = toggle.clientHeight + 'px';
168
164
  }
169
- else if (dropdown.getBoundingClientRect().left < 0) {
170
- dropdown.style.left = 0 + 'px';
171
- dropdown.style.right = '';
165
+ else {
166
+ dropdown.style.top = toggle.clientHeight + 'px';
167
+ dropdown.style.bottom = '';
172
168
  }
173
169
  }
174
- }, 100);
170
+ if (dropdown.getBoundingClientRect().right > window.innerWidth) {
171
+ dropdown.style.left = '';
172
+ dropdown.style.right = '0px';
173
+ }
174
+ else if (dropdown.getBoundingClientRect().left < 0) {
175
+ dropdown.style.left = 0 + 'px';
176
+ dropdown.style.right = '';
177
+ }
178
+ }
175
179
  }
176
180
  handleToggleClicked(event) {
177
181
  event.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../../src/dropdown/Dropdown.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,I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AI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;;uBAEW,IAAI,CAAC,uBAAuB;;;;;;;;KAQ9C,CAAC;IACJ,CAAC;CACF;AAzKC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qCAChB;AAGZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCACb;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACd;AAGd;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;yCACf;AAGZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACf;AAGZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACf","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { RapidElement } from '../RapidElement';\nimport { getClasses } from '../utils';\n\nexport class Dropdown extends RapidElement {\n static get styles() {\n return css`\n .wrapper {\n position: relative;\n }\n\n .toggle {\n cursor: pointer;\n }\n\n .dropdown-wrapper {\n position: relative;\n overflow: auto;\n }\n\n .dropdown {\n position: absolute;\n opacity: 0;\n z-index: 2;\n pointer-events: none;\n padding: 0;\n border-radius: var(--curvature);\n background: #fff;\n transform: translateY(1em) scale(0.9);\n transition: all calc(0.8 * var(--transition-speed)) var(--bounce);\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.5em) scale(1);\n }\n\n .mask {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.7);\n opacity: 0;\n transition: opacity var(--transition-speed) ease-in-out;\n pointer-events: none;\n z-index: 1;\n }\n\n .mask.open {\n opacity: 1;\n pointer-events: auto;\n }\n\n .right {\n right: 0;\n }\n `;\n }\n\n @property({ type: Boolean })\n open = false;\n\n @property({ type: Boolean })\n top = false;\n\n @property({ type: Boolean })\n bottom = false;\n\n @property({ type: Boolean })\n left = false;\n\n @property({ type: Boolean })\n right = 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 = 0;\n\n @property({ type: Number })\n offsetY = 0;\n\n @property({ type: Boolean })\n mask = false;\n\n public firstUpdated(props: any) {\n super.firstUpdated(props);\n\n const arrow = this.shadowRoot.querySelector('.arrow') as HTMLDivElement;\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 const dropdown = this.shadowRoot.querySelector(\n '.dropdown'\n ) as HTMLDivElement;\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 // blur our host element too\n (this.shadowRoot.host as HTMLDivElement).blur();\n }, 200);\n });\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n const dropdown = this.shadowRoot.querySelector(\n '.dropdown'\n ) as HTMLDivElement;\n\n if (changedProperties.has('offsetY') || changedProperties.has('offsetX')) {\n dropdown.style.marginTop = this.offsetY + 'px';\n if (dropdown.offsetLeft + dropdown.clientWidth > window.outerWidth) {\n dropdown.style.marginLeft =\n '-' + (dropdown.clientWidth - this.clientWidth - this.offsetX) + 'px';\n } else {\n if (this.right) {\n dropdown.style.marginRight = this.offsetX + 'px';\n } else {\n dropdown.style.marginLeft = this.offsetX + 'px';\n }\n }\n }\n\n if (changedProperties.has('open')) {\n this.ensureOnScreen();\n }\n }\n\n public ensureOnScreen() {\n window.setTimeout(() => {\n const dropdown = this.shadowRoot.querySelector(\n '.dropdown'\n ) as HTMLDivElement;\n\n if (dropdown) {\n // dropdown will go off the screen, let's push it up\n const toggle = this.querySelector('div[slot=\"toggle\"]');\n if (dropdown.getBoundingClientRect().bottom > window.innerHeight) {\n if (this.bottom) {\n dropdown.style.top = toggle.clientHeight + 'px';\n } else {\n dropdown.style.top = '';\n dropdown.style.bottom = toggle.clientHeight + 'px';\n }\n } else if (dropdown.getBoundingClientRect().top < 0) {\n if (this.bottom) {\n dropdown.style.top = toggle.clientHeight + 'px';\n } else {\n dropdown.style.top = toggle.clientHeight + 'px';\n dropdown.style.bottom = '';\n }\n }\n\n if (dropdown.getBoundingClientRect().right > window.innerWidth) {\n dropdown.style.left = '';\n dropdown.style.right = 0 + 'px';\n } else if (dropdown.getBoundingClientRect().left < 0) {\n dropdown.style.left = 0 + 'px';\n dropdown.style.right = '';\n }\n }\n }, 100);\n }\n\n public handleToggleClicked(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\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 private handleDropdownMouseDown(event: MouseEvent): void {\n // block mouse down when clicking inside dropdown so we don't lose focus yet\n event.preventDefault();\n event.stopPropagation();\n }\n\n public render(): TemplateResult {\n return html`\n ${this.mask\n ? html`<div class=\"mask ${this.open ? 'open' : ''}\" />`\n : null}\n\n <div class=\"wrapper ${this.open ? 'open' : ''}\">\n <slot\n name=\"toggle\"\n class=\"toggle\"\n @click=${this.handleToggleClicked}\n ></slot>\n <div\n class=\"${getClasses({\n dropdown: true,\n right: this.right,\n left: this.left,\n top: this.top,\n bottom: this.bottom,\n })}\"\n tabindex=\"0\"\n @mousedown=${this.handleDropdownMouseDown}\n >\n <div class=\"arrow\"></div>\n <div class=\"dropdown-wrapper\">\n <slot name=\"dropdown\" tabindex=\"1\"></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n"]}
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,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,MAAM,OAAO,QAAS,SAAQ,YAAY;IACxC,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyET,CAAC;IACJ,CAAC;IAgCD;QACE,KAAK,EAAE,CAAC;QA9BV,SAAI,GAAG,KAAK,CAAC;QAGb,QAAG,GAAG,KAAK,CAAC;QAGZ,WAAM,GAAG,KAAK,CAAC;QAGf,SAAI,GAAG,KAAK,CAAC;QAGb,UAAK,GAAG,KAAK,CAAC;QAGd,cAAS,GAAG,CAAC,CAAC;QAGd,gBAAW,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QAGjC,YAAO,G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AE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACd;AAGd;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;yCACf;AAGZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACf;AAGZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACf","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { RapidElement } from '../RapidElement';\nimport { getClasses } from '../utils';\nimport { ContactStoreElement } from '../contacts/ContactStoreElement';\n\nexport class Dropdown extends RapidElement {\n static get styles() {\n return css`\n .wrapper {\n position: relative;\n }\n\n .toggle {\n cursor: pointer;\n }\n\n .dropdown-wrapper {\n position: relative;\n overflow: auto;\n }\n\n .dropdown {\n position: absolute;\n opacity: 0;\n z-index: 2;\n pointer-events: none;\n padding: 0;\n border-radius: var(--curvature);\n background: #fff;\n transform: translateY(1em) scale(0.9);\n transition: all calc(0.8 * var(--transition-speed)) var(--bounce);\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.5em) scale(1);\n }\n\n .mask {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.7);\n opacity: 0;\n transition: opacity var(--transition-speed) ease-in-out;\n pointer-events: none;\n z-index: 1;\n }\n\n .mask.open {\n opacity: 1;\n pointer-events: auto;\n }\n\n .right {\n right: 0;\n }\n `;\n }\n\n @property({ type: Boolean })\n open = false;\n\n @property({ type: Boolean })\n top = false;\n\n @property({ type: Boolean })\n bottom = false;\n\n @property({ type: Boolean })\n left = false;\n\n @property({ type: Boolean })\n right = 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 = 0;\n\n @property({ type: Number })\n offsetY = 0;\n\n @property({ type: Boolean })\n mask = false;\n\n constructor() {\n super();\n this.ensureOnScreen = this.ensureOnScreen.bind(this);\n }\n\n public firstUpdated(props: any) {\n super.firstUpdated(props);\n\n const arrow = this.shadowRoot.querySelector('.arrow') as HTMLDivElement;\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 const dropdown = this.shadowRoot.querySelector(\n '.dropdown'\n ) as HTMLDivElement;\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 // blur our host element too\n (this.shadowRoot.host as HTMLDivElement).blur();\n }, 200);\n });\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n const dropdown = this.shadowRoot.querySelector(\n '.dropdown'\n ) as HTMLDivElement;\n\n if (changedProperties.has('offsetY') || changedProperties.has('offsetX')) {\n dropdown.style.marginTop = this.offsetY + 'px';\n if (dropdown.offsetLeft + dropdown.clientWidth > window.outerWidth) {\n dropdown.style.marginLeft =\n '-' + (dropdown.clientWidth - this.clientWidth - this.offsetX) + 'px';\n } else {\n if (this.right) {\n dropdown.style.marginRight = this.offsetX + 'px';\n } else {\n dropdown.style.marginLeft = this.offsetX + 'px';\n }\n }\n }\n\n if (changedProperties.has('open')) {\n // check right away if we are on the screen, and then again moments after render\n window.setTimeout(this.ensureOnScreen, 0);\n window.setTimeout(this.ensureOnScreen, 100);\n }\n }\n\n public ensureOnScreen() {\n const dropdown = this.shadowRoot.querySelector(\n '.dropdown'\n ) as HTMLDivElement;\n\n if (dropdown) {\n // dropdown will go off the screen, let's push it up\n const toggle = this.querySelector('div[slot=\"toggle\"]');\n\n if (!toggle) {\n return;\n }\n\n if (dropdown.getBoundingClientRect().bottom > window.innerHeight - 100) {\n if (this.bottom) {\n dropdown.style.top = toggle.clientHeight + 'px';\n } else {\n dropdown.style.top = '';\n dropdown.style.bottom = toggle.clientHeight + 'px';\n }\n } else if (dropdown.getBoundingClientRect().top < 0) {\n if (this.bottom) {\n dropdown.style.top = toggle.clientHeight + 'px';\n } else {\n dropdown.style.top = toggle.clientHeight + 'px';\n dropdown.style.bottom = '';\n }\n }\n\n if (dropdown.getBoundingClientRect().right > window.innerWidth) {\n dropdown.style.left = '';\n dropdown.style.right = '0px';\n } else if (dropdown.getBoundingClientRect().left < 0) {\n dropdown.style.left = 0 + 'px';\n dropdown.style.right = '';\n }\n }\n }\n\n public handleToggleClicked(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\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 private handleDropdownMouseDown(event: MouseEvent): void {\n // block mouse down when clicking inside dropdown so we don't lose focus yet\n event.preventDefault();\n event.stopPropagation();\n }\n\n public render(): TemplateResult {\n return html`\n ${this.mask\n ? html`<div class=\"mask ${this.open ? 'open' : ''}\" />`\n : null}\n\n <div class=\"wrapper ${this.open ? 'open' : ''}\">\n <slot\n name=\"toggle\"\n class=\"toggle\"\n @click=${this.handleToggleClicked}\n ></slot>\n <div\n class=\"${getClasses({\n dropdown: true,\n right: this.right,\n left: this.left,\n top: this.top,\n bottom: this.bottom,\n })}\"\n tabindex=\"0\"\n @mousedown=${this.handleDropdownMouseDown}\n >\n <div class=\"arrow\"></div>\n <div class=\"dropdown-wrapper\">\n <slot name=\"dropdown\" tabindex=\"1\"></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n"]}
@@ -31,8 +31,8 @@ export class Lightbox extends RapidElement {
31
31
  opacity: 0;
32
32
  background: rgba(0, 0, 0, 0.5);
33
33
  position: absolute;
34
- height: 100vh;
35
- width: 100vw;
34
+ height: 100svh;
35
+ width: 100svw;
36
36
  pointer-events: none;
37
37
  }
38
38
 
@@ -64,7 +64,6 @@ export class Lightbox extends RapidElement {
64
64
  }
65
65
  showElement(ele) {
66
66
  // size our matte according to the ele's boundaries
67
- console.log(ele);
68
67
  const bounds = ele.getBoundingClientRect();
69
68
  this.ele = ele.cloneNode();
70
69
  this.left = bounds.left;
@@ -1 +1 @@
1
- {"version":3,"file":"Lightbox.js","sourceRoot":"","sources":["../../../src/lightbox/Lightbox.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAoB,MAAM,KAAK,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IAA1C;;QAiCE,kBAAa,GAAG,GAAG,CAAC;QAGpB,SAAI,GAAG,KAAK,CAAC;QAGb,SAAI,GAAG,KAAK,CAAC;QAGb,YAAO,GAAG,GAAG,CAAC;QAON,UAAK,GAAG,CAAC,CAAC;QACV,WAAM,GAAG,KAAK,CAAC;QACf,WAAM,GAAG,KAAK,CAAC;IAuGzB,CAAC;IAzJC,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KA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C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACb","sourcesContent":["import { css, html, PropertyValueMap } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { RapidElement } from '../RapidElement';\nimport { getClasses } from '../utils';\nimport { styleMap } from 'lit-html/directives/style-map.js';\n\n/**\n * This component relies on a bit of sleight of hand magic\n * to achieve it's effect. As such, it requires the use of\n * computed animation times and window.setTimeout().\n */\nexport class Lightbox extends RapidElement {\n static get styles() {\n return css`\n :host {\n position: absolute;\n }\n\n .mask {\n display: flex;\n opacity: 0;\n background: rgba(0, 0, 0, 0.5);\n position: absolute;\n height: 100vh;\n width: 100vw;\n pointer-events: none;\n }\n\n .zoom .mask {\n opacity: 1;\n pointer-events: auto;\n }\n\n .matte {\n position: absolute;\n transform: translate(400, 400) scale(3, 3);\n border-radius: 2%;\n overflow: hidden;\n box-shadow: 0 0 12px 3px rgba(0, 0, 0, 0.15);\n }\n `;\n }\n\n @property({ type: Number })\n animationTime = 300;\n\n @property({ type: Boolean })\n show = false;\n\n @property({ type: Boolean })\n zoom = false;\n\n @property({ type: Number })\n zoomPct = 0.9;\n\n private ele: HTMLElement;\n private left: number;\n private top: number;\n private height: number;\n private width: number;\n private scale = 1;\n private xTrans = '0px';\n private yTrans = '0px';\n\n protected updated(\n changed: PropertyValueMap<any> | Map<PropertyKey, unknown>\n ): void {\n if (changed.has('show') && this.show) {\n window.setTimeout(() => {\n this.zoom = true;\n }, 0);\n }\n\n if (changed.has('zoom') && !this.zoom && this.show) {\n window.setTimeout(() => {\n this.show = false;\n }, this.animationTime);\n }\n }\n\n public showElement(ele: HTMLElement) {\n // size our matte according to the ele's boundaries\n console.log(ele);\n const bounds = ele.getBoundingClientRect();\n this.ele = ele.cloneNode() as HTMLElement;\n this.left = bounds.left;\n this.top = bounds.top;\n this.width = bounds.width;\n this.height = bounds.height;\n\n this.xTrans = '0px';\n this.yTrans = '0px';\n this.scale = 1;\n\n let desiredWidth = this.width;\n let desiredHeight = this.height;\n let desiredScale = this.scale;\n\n const maxHeight = window.innerHeight * this.zoomPct;\n const maxWidth = window.innerWidth * this.zoomPct;\n\n // if the width fits, constrain by height\n if (this.width * (maxHeight / this.height) < maxWidth) {\n desiredHeight = window.innerHeight * this.zoomPct;\n desiredScale = desiredHeight / this.height;\n desiredWidth = this.width * desiredScale;\n } else {\n desiredWidth = window.innerWidth * this.zoomPct;\n desiredScale = desiredWidth / this.width;\n desiredHeight = this.height * desiredScale;\n }\n\n const xGrowth = (desiredWidth - this.width) / 2;\n const xDest = (window.innerWidth - desiredWidth) / 2;\n this.xTrans = xDest - this.left + xGrowth + 'px';\n\n const yGrowth = (desiredHeight - this.height) / 2;\n const yDest = (window.innerHeight - desiredHeight) / 2;\n this.yTrans = yDest - this.top + yGrowth + 'px';\n\n this.scale = desiredScale;\n this.show = true;\n }\n\n public handleClick() {\n this.zoom = false;\n }\n\n public render() {\n const styles = {\n transition: `transform ${this.animationTime}ms ease, box-shadow ${this.animationTime}ms ease`,\n };\n\n if (this.show) {\n styles['left'] = this.left + 'px';\n styles['top'] = this.top + 'px';\n styles['width'] = this.width + 'px';\n styles['height'] = this.height + 'px';\n }\n\n if (this.zoom) {\n styles[\n 'transform'\n ] = `translate(${this.xTrans}, ${this.yTrans}) scale(${this.scale}, ${this.scale})`;\n }\n\n return html`\n <div\n class=${getClasses({\n container: true,\n show: this.show,\n zoom: this.zoom,\n })}\n @click=${this.handleClick}\n >\n <div\n class=${getClasses({ mask: true })}\n style=\"transition: all ${this.animationTime}ms; ease\"\n ></div>\n <div class=${getClasses({ matte: true })} style=${styleMap(styles)}>\n ${this.show ? this.ele : null}\n </div>\n </div>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"Lightbox.js","sourceRoot":"","sources":["../../../src/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CAAC,MAAM,WAAW,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC;SACrF;QAED,OAAO,IAAI,CAAA;;gBAEC,UAAU,CAAC;YACjB,SAAS,EAAE,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;iBACO,IAAI,CAAC,WAAW;;;kBAGf,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;mCACT,IAAI,CAAC,aAAa;;qBAEhC,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,UAAU,QAAQ,CAAC,MAAM,CAAC;YAC9D,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI;;;KAGlC,CAAC;IACJ,CAAC;CACF;AAxHC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CACP;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACb","sourcesContent":["import { css, html, PropertyValueMap } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { RapidElement } from '../RapidElement';\nimport { getClasses } from '../utils';\nimport { styleMap } from 'lit-html/directives/style-map.js';\n\n/**\n * This component relies on a bit of sleight of hand magic\n * to achieve it's effect. As such, it requires the use of\n * computed animation times and window.setTimeout().\n */\nexport class Lightbox extends RapidElement {\n static get styles() {\n return css`\n :host {\n position: absolute;\n }\n\n .mask {\n display: flex;\n opacity: 0;\n background: rgba(0, 0, 0, 0.5);\n position: absolute;\n height: 100svh;\n width: 100svw;\n pointer-events: none;\n }\n\n .zoom .mask {\n opacity: 1;\n pointer-events: auto;\n }\n\n .matte {\n position: absolute;\n transform: translate(400, 400) scale(3, 3);\n border-radius: 2%;\n overflow: hidden;\n box-shadow: 0 0 12px 3px rgba(0, 0, 0, 0.15);\n }\n `;\n }\n\n @property({ type: Number })\n animationTime = 300;\n\n @property({ type: Boolean })\n show = false;\n\n @property({ type: Boolean })\n zoom = false;\n\n @property({ type: Number })\n zoomPct = 0.9;\n\n private ele: HTMLElement;\n private left: number;\n private top: number;\n private height: number;\n private width: number;\n private scale = 1;\n private xTrans = '0px';\n private yTrans = '0px';\n\n protected updated(\n changed: PropertyValueMap<any> | Map<PropertyKey, unknown>\n ): void {\n if (changed.has('show') && this.show) {\n window.setTimeout(() => {\n this.zoom = true;\n }, 0);\n }\n\n if (changed.has('zoom') && !this.zoom && this.show) {\n window.setTimeout(() => {\n this.show = false;\n }, this.animationTime);\n }\n }\n\n public showElement(ele: HTMLElement) {\n // size our matte according to the ele's boundaries\n const bounds = ele.getBoundingClientRect();\n this.ele = ele.cloneNode() as HTMLElement;\n this.left = bounds.left;\n this.top = bounds.top;\n this.width = bounds.width;\n this.height = bounds.height;\n\n this.xTrans = '0px';\n this.yTrans = '0px';\n this.scale = 1;\n\n let desiredWidth = this.width;\n let desiredHeight = this.height;\n let desiredScale = this.scale;\n\n const maxHeight = window.innerHeight * this.zoomPct;\n const maxWidth = window.innerWidth * this.zoomPct;\n\n // if the width fits, constrain by height\n if (this.width * (maxHeight / this.height) < maxWidth) {\n desiredHeight = window.innerHeight * this.zoomPct;\n desiredScale = desiredHeight / this.height;\n desiredWidth = this.width * desiredScale;\n } else {\n desiredWidth = window.innerWidth * this.zoomPct;\n desiredScale = desiredWidth / this.width;\n desiredHeight = this.height * desiredScale;\n }\n\n const xGrowth = (desiredWidth - this.width) / 2;\n const xDest = (window.innerWidth - desiredWidth) / 2;\n this.xTrans = xDest - this.left + xGrowth + 'px';\n\n const yGrowth = (desiredHeight - this.height) / 2;\n const yDest = (window.innerHeight - desiredHeight) / 2;\n this.yTrans = yDest - this.top + yGrowth + 'px';\n\n this.scale = desiredScale;\n this.show = true;\n }\n\n public handleClick() {\n this.zoom = false;\n }\n\n public render() {\n const styles = {\n transition: `transform ${this.animationTime}ms ease, box-shadow ${this.animationTime}ms ease`,\n };\n\n if (this.show) {\n styles['left'] = this.left + 'px';\n styles['top'] = this.top + 'px';\n styles['width'] = this.width + 'px';\n styles['height'] = this.height + 'px';\n }\n\n if (this.zoom) {\n styles[\n 'transform'\n ] = `translate(${this.xTrans}, ${this.yTrans}) scale(${this.scale}, ${this.scale})`;\n }\n\n return html`\n <div\n class=${getClasses({\n container: true,\n show: this.show,\n zoom: this.zoom,\n })}\n @click=${this.handleClick}\n >\n <div\n class=${getClasses({ mask: true })}\n style=\"transition: all ${this.animationTime}ms; ease\"\n ></div>\n <div class=${getClasses({ matte: true })} style=${styleMap(styles)}>\n ${this.show ? this.ele : null}\n </div>\n </div>\n `;\n }\n}\n"]}
@@ -276,7 +276,7 @@ export class TembaList extends RapidElement {
276
276
  this.nextSelection = false;
277
277
  }
278
278
  else {
279
- if (this.cursorIndex === -1) {
279
+ if (this.cursorIndex === -1 && !this.isMobile()) {
280
280
  this.cursorIndex = 0;
281
281
  }
282
282
  }
@@ -286,6 +286,13 @@ export class TembaList extends RapidElement {
286
286
  this.setSelection(this.value);
287
287
  this.value = null;
288
288
  }
289
+ else if (this.isMobile() && !this.selected) {
290
+ this.cursorIndex = -1;
291
+ this.value = null;
292
+ this.selected = null;
293
+ const evt = new Event('change', { bubbles: true });
294
+ this.dispatchEvent(evt);
295
+ }
289
296
  return Promise.resolve();
290
297
  }
291
298
  handleScrollThreshold() {
@@ -1 +1 @@
1
- {"version":3,"file":"TembaList.js","sourceRoot":"","sources":["../../../src/list/TembaList.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe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,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACd;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACX;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCACb;AAGd;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACZ;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CACR;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCACb;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDACE;AAG9B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDACW;AAG1C;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDACM;AAGrC;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+CACkC;AAGjE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDACwC;AAGvE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACzB;AAIpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACV","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { CustomEventType } from '../interfaces';\nimport { RapidElement } from '../RapidElement';\nimport { Store } from '../store/Store';\nimport { fetchResultsPage, ResultsPage } from '../utils';\n\nconst DEFAULT_REFRESH = 10000;\n\nexport class TembaList extends RapidElement {\n @property({ type: Array, attribute: false })\n items: any[] = [];\n\n @property({ type: Object, attribute: false })\n selected: any;\n\n @property({ type: Number })\n cursorIndex = -1;\n\n @property({ type: String })\n endpoint: string;\n\n @property({ type: String })\n nextSelection: any;\n\n @property({ type: Number })\n tabIndex = 1;\n\n @property({ type: String })\n valueKey = 'id';\n\n @property({ type: String })\n value: string;\n\n @property({ type: Boolean })\n loading = false;\n\n @property({ type: Boolean })\n collapsed: boolean;\n\n @property({ type: Boolean })\n hideShadow: boolean;\n\n @property({ type: Boolean })\n paused = false;\n\n @property({ type: Boolean })\n internalFocusDisabled = false;\n\n @property({ attribute: false })\n getNextRefresh: (firstOption: any) => any;\n\n @property({ attribute: false })\n sanitizeOption: (option: any) => any;\n\n @property({ attribute: false })\n renderOption: (option: any, selected: boolean) => TemplateResult;\n\n @property({ attribute: false })\n renderOptionDetail: (option: any, selected: boolean) => TemplateResult;\n\n @property({ attribute: false, type: Object })\n mostRecentItem: any;\n\n // changes to the refresh key force a refresh\n @property({ type: String })\n refreshKey = '0';\n\n reverseRefresh = true;\n\n // our next page from our endpoint\n nextPage: string = null;\n\n pages = 0;\n clearRefreshTimeout: any;\n pending: AbortController[] = [];\n\n store: Store;\n\n // used for testing only\n preserve: boolean;\n\n static get styles() {\n return css`\n temba-options {\n display: block;\n width: 100%;\n flex-grow: 1;\n }\n `;\n }\n\n constructor() {\n super();\n this.store = document.querySelector('temba-store') as Store;\n this.handleSelection.bind(this);\n }\n\n private reset(): void {\n this.selected = null;\n this.nextPage = null;\n this.cursorIndex = -1;\n this.mostRecentItem = null;\n this.items = [];\n }\n\n refreshInterval = null;\n\n public connectedCallback() {\n super.connectedCallback();\n this.refreshInterval = setInterval(() => {\n if (!this.paused) {\n this.refreshKey = 'default_' + new Date().getTime();\n }\n }, DEFAULT_REFRESH);\n }\n\n public disconnectedCallback() {\n clearInterval(this.refreshInterval);\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n\n if (changedProperties.has('endpoint') && this.endpoint) {\n this.reset();\n this.loading = true;\n this.fetchItems();\n }\n\n if (changedProperties.has('loading')) {\n if (!this.loading) {\n this.fireCustomEvent(CustomEventType.FetchComplete);\n }\n }\n\n if (\n changedProperties.has('refreshKey') &&\n !changedProperties.has('endpoint')\n ) {\n this.refreshTop();\n }\n\n if (changedProperties.has('mostRecentItem') && this.mostRecentItem) {\n this.fireCustomEvent(CustomEventType.Refreshed);\n }\n\n if (changedProperties.has('cursorIndex')) {\n if (this.cursorIndex > -1) {\n this.selected = this.items[this.cursorIndex];\n this.handleSelected(this.selected);\n }\n }\n\n if (changedProperties.has('items')) {\n //\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public handleSelected(selected: any) {\n const evt = new Event('change', { bubbles: true });\n this.dispatchEvent(evt);\n }\n\n private getValue(obj: any): any {\n if (!obj) {\n return null;\n }\n\n const path = this.valueKey.split('.');\n let current = obj;\n while (path.length > 0) {\n const key = path.shift();\n current = current[key];\n }\n return current;\n }\n\n public setSelection(value: string) {\n const index = this.items.findIndex(item => {\n return this.getValue(item) === value;\n });\n this.cursorIndex = index;\n this.selected = this.items[index];\n const evt = new Event('change', { bubbles: true });\n this.dispatchEvent(evt);\n }\n\n public getItemIndex(value: string) {\n return this.items.findIndex(option => this.getValue(option) === value);\n }\n\n public removeItem(value: string) {\n const index = this.getItemIndex(value);\n this.items.splice(index, 1);\n this.items = [...this.items];\n\n // if we were at the end, move us down\n this.cursorIndex = Math.max(\n 0,\n Math.min(this.items.length - 1, this.cursorIndex - 1)\n );\n\n // request a change even if it is the same, the item is different\n this.requestUpdate('cursorIndex');\n this.requestUpdate('items');\n }\n\n public getSelection(): any {\n return this.selected;\n }\n\n public refresh(): void {\n this.refreshKey = 'requested_' + new Date().getTime();\n }\n\n public setEndpoint(endpoint: string, nextSelection: any = null) {\n this.endpoint = endpoint;\n this.nextSelection = nextSelection;\n }\n\n public getRefreshEndpoint() {\n return this.endpoint;\n }\n\n /**\n * Refreshes the first page, updating any found items in our list\n */\n private async refreshTop(): Promise<void> {\n const refreshEndpoint = this.getRefreshEndpoint();\n if (!refreshEndpoint) {\n return;\n }\n\n // cancel any outstanding requests\n while (this.pending.length > 0) {\n const pending = this.pending.pop();\n pending.abort();\n }\n\n const controller = new AbortController();\n this.pending.push(controller);\n\n const prevItem = this.items[this.cursorIndex];\n\n try {\n const page = await fetchResultsPage(\n this.getRefreshEndpoint(),\n controller\n );\n\n const items = [...this.items];\n // remove any dupes already in our list\n if (page.results) {\n page.results.forEach((newOption: any) => {\n if (this.sanitizeOption) {\n this.sanitizeOption(newOption);\n }\n const newValue = this.getValue(newOption);\n const removeIndex = items.findIndex(\n option => this.getValue(option) === newValue\n );\n\n if (removeIndex > -1) {\n items.splice(removeIndex, 1);\n }\n });\n\n // insert our new items at the front\n let results = page.results;\n if (this.reverseRefresh) {\n results = page.results.reverse();\n }\n const newItems = [...results, ...items];\n\n const topItem = newItems[0];\n if (\n !this.mostRecentItem ||\n JSON.stringify(this.mostRecentItem) !== JSON.stringify(topItem)\n ) {\n this.mostRecentItem = topItem;\n }\n\n if (prevItem) {\n const newItem = newItems[this.cursorIndex];\n const prevValue = this.getValue(prevItem);\n if (prevValue !== this.getValue(newItem)) {\n const newIndex = newItems.findIndex(\n option => this.getValue(option) === prevValue\n );\n this.cursorIndex = newIndex;\n\n // make sure our focused item is visible\n window.setTimeout(() => {\n const options = this.shadowRoot.querySelector('temba-options');\n if (options) {\n const option =\n options.shadowRoot.querySelector('.option.focused');\n option.scrollIntoView({ block: 'end', inline: 'nearest' });\n }\n }, 0);\n }\n }\n\n this.items = newItems;\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n private async fetchItems(): Promise<void> {\n // cancel any outstanding requests\n while (this.pending.length > 0) {\n const pending = this.pending.pop();\n pending.abort();\n }\n\n let endpoint = this.endpoint;\n let pagesToFetch = this.pages || 1;\n let pages = 0;\n let nextPage = null;\n\n let fetchedItems: any[] = [];\n\n while (pagesToFetch > 0 && endpoint) {\n const controller = new AbortController();\n this.pending.push(controller);\n\n try {\n const page = await fetchResultsPage(endpoint, controller);\n\n // sanitize our options if necessary\n if (this.sanitizeOption) {\n page.results.forEach(this.sanitizeOption);\n }\n\n if (page.results) {\n fetchedItems = fetchedItems.concat(page.results);\n }\n\n // save our next pages\n nextPage = page.next;\n endpoint = nextPage;\n pagesToFetch--;\n pages++;\n } catch (error) {\n // aborted\n this.reset();\n console.log(error);\n return;\n }\n\n this.nextPage = nextPage;\n }\n this.pages = pages;\n\n const topItem = fetchedItems[0];\n if (\n !this.mostRecentItem ||\n JSON.stringify(this.mostRecentItem) !== JSON.stringify(topItem)\n ) {\n this.mostRecentItem = topItem;\n }\n\n // see if our cursor needs to move to stay on the same item\n const newItem = fetchedItems[this.cursorIndex];\n\n if (\n !this.nextSelection &&\n this.selected &&\n newItem &&\n this.getValue(newItem) !== this.getValue(this.selected)\n ) {\n const index = fetchedItems.findIndex(item => {\n return this.getValue(item) === this.getValue(this.selected);\n });\n\n // old selection is in the new fetch\n if (index > -1) {\n this.cursorIndex = index;\n }\n // old selection is missing from the new fetch\n else {\n // if our index didn't change, our item still did, fire change\n if (this.cursorIndex === 0) {\n this.requestUpdate('cursorIndex');\n }\n // otherwise select the first item\n else {\n this.cursorIndex = 0;\n }\n }\n }\n\n // save our results\n this.items = fetchedItems;\n this.loading = false;\n this.pending = [];\n\n if (this.nextSelection) {\n this.setSelection(this.nextSelection);\n this.nextSelection = false;\n } else {\n if (this.cursorIndex === -1) {\n this.cursorIndex = 0;\n }\n }\n\n // TODO: Not sure why this is needed\n // this.requestUpdate('cursorIndex');\n\n if (this.value) {\n this.setSelection(this.value);\n this.value = null;\n }\n\n return Promise.resolve();\n }\n\n private handleScrollThreshold() {\n if (this.nextPage && !this.loading) {\n this.loading = true;\n fetchResultsPage(this.nextPage).then((page: ResultsPage) => {\n if (this.sanitizeOption) {\n page.results.forEach(this.sanitizeOption);\n }\n\n this.items = [...this.items, ...page.results];\n this.nextPage = page.next;\n this.pages++;\n this.loading = false;\n });\n }\n }\n\n public renderHeader(): TemplateResult {\n return null;\n }\n\n public renderFooter(): TemplateResult {\n return null;\n }\n\n public getListStyle() {\n return '';\n }\n\n protected handleSelection(event: CustomEvent) {\n const { selected, index } = event.detail;\n\n this.selected = selected;\n this.cursorIndex = index;\n\n event.stopPropagation();\n event.preventDefault();\n }\n\n public render(): TemplateResult {\n return html`\n ${this.renderHeader()}\n <temba-options\n style=\"${this.getListStyle()}\"\n ?visible=${true}\n ?block=${true}\n ?hideShadow=${this.hideShadow}\n ?collapsed=${this.collapsed}\n ?loading=${this.loading}\n ?internalFocusDisabled=${this.internalFocusDisabled}\n .renderOption=${this.renderOption}\n .renderOptionDetail=${this.renderOptionDetail}\n @temba-scroll-threshold=${this.handleScrollThreshold}\n @temba-selection=${this.handleSelection.bind(this)}\n .options=${this.items}\n .cursorIndex=${this.cursorIndex}\n >\n <slot></slot>\n </temba-options>\n ${this.renderFooter()}\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"TembaList.js","sourceRoot":"","sources":["../../../src/list/TembaList.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAe,MAAM,UAAU,CAAC;AAEzD,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B,MAAM,OAAO,SAAU,SAAQ,YAAY;IAyEzC,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;KAMT,CAAC;IACJ,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QAlFV,UAAK,GAAU,EAAE,CAAC;QAMlB,gBAAW,GAAG,CAAC,CAAC,CAAC;QASjB,aAAQ,GAAG,CAAC,CAAC;QAGb,aAAQ,GAAG,IAAI,CAAC;QAMhB,YAAO,GAAG,KAAK,CAAC;QAShB,WAAM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AAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACX;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCACb;AAGd;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACZ;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACT;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CACR;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCACb;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDACE;AAG9B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDACW;AAG1C;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDACM;AAGrC;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+CACkC;AAGjE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDACwC;AAGvE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACzB;AAIpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACV","sourcesContent":["import { css, html, TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { CustomEventType } from '../interfaces';\nimport { RapidElement } from '../RapidElement';\nimport { Store } from '../store/Store';\nimport { fetchResultsPage, ResultsPage } from '../utils';\n\nconst DEFAULT_REFRESH = 10000;\n\nexport class TembaList extends RapidElement {\n @property({ type: Array, attribute: false })\n items: any[] = [];\n\n @property({ type: Object, attribute: false })\n selected: any;\n\n @property({ type: Number })\n cursorIndex = -1;\n\n @property({ type: String })\n endpoint: string;\n\n @property({ type: String })\n nextSelection: any;\n\n @property({ type: Number })\n tabIndex = 1;\n\n @property({ type: String })\n valueKey = 'id';\n\n @property({ type: String })\n value: string;\n\n @property({ type: Boolean })\n loading = false;\n\n @property({ type: Boolean })\n collapsed: boolean;\n\n @property({ type: Boolean })\n hideShadow: boolean;\n\n @property({ type: Boolean })\n paused = false;\n\n @property({ type: Boolean })\n internalFocusDisabled = false;\n\n @property({ attribute: false })\n getNextRefresh: (firstOption: any) => any;\n\n @property({ attribute: false })\n sanitizeOption: (option: any) => any;\n\n @property({ attribute: false })\n renderOption: (option: any, selected: boolean) => TemplateResult;\n\n @property({ attribute: false })\n renderOptionDetail: (option: any, selected: boolean) => TemplateResult;\n\n @property({ attribute: false, type: Object })\n mostRecentItem: any;\n\n // changes to the refresh key force a refresh\n @property({ type: String })\n refreshKey = '0';\n\n reverseRefresh = true;\n\n // our next page from our endpoint\n nextPage: string = null;\n\n pages = 0;\n clearRefreshTimeout: any;\n pending: AbortController[] = [];\n\n store: Store;\n\n // used for testing only\n preserve: boolean;\n\n static get styles() {\n return css`\n temba-options {\n display: block;\n width: 100%;\n flex-grow: 1;\n }\n `;\n }\n\n constructor() {\n super();\n this.store = document.querySelector('temba-store') as Store;\n this.handleSelection.bind(this);\n }\n\n private reset(): void {\n this.selected = null;\n this.nextPage = null;\n this.cursorIndex = -1;\n this.mostRecentItem = null;\n this.items = [];\n }\n\n refreshInterval = null;\n\n public connectedCallback() {\n super.connectedCallback();\n this.refreshInterval = setInterval(() => {\n if (!this.paused) {\n this.refreshKey = 'default_' + new Date().getTime();\n }\n }, DEFAULT_REFRESH);\n }\n\n public disconnectedCallback() {\n clearInterval(this.refreshInterval);\n }\n\n public updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n\n if (changedProperties.has('endpoint') && this.endpoint) {\n this.reset();\n this.loading = true;\n this.fetchItems();\n }\n\n if (changedProperties.has('loading')) {\n if (!this.loading) {\n this.fireCustomEvent(CustomEventType.FetchComplete);\n }\n }\n\n if (\n changedProperties.has('refreshKey') &&\n !changedProperties.has('endpoint')\n ) {\n this.refreshTop();\n }\n\n if (changedProperties.has('mostRecentItem') && this.mostRecentItem) {\n this.fireCustomEvent(CustomEventType.Refreshed);\n }\n\n if (changedProperties.has('cursorIndex')) {\n if (this.cursorIndex > -1) {\n this.selected = this.items[this.cursorIndex];\n this.handleSelected(this.selected);\n }\n }\n\n if (changedProperties.has('items')) {\n //\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public handleSelected(selected: any) {\n const evt = new Event('change', { bubbles: true });\n this.dispatchEvent(evt);\n }\n\n private getValue(obj: any): any {\n if (!obj) {\n return null;\n }\n\n const path = this.valueKey.split('.');\n let current = obj;\n while (path.length > 0) {\n const key = path.shift();\n current = current[key];\n }\n return current;\n }\n\n public setSelection(value: string) {\n const index = this.items.findIndex(item => {\n return this.getValue(item) === value;\n });\n this.cursorIndex = index;\n this.selected = this.items[index];\n const evt = new Event('change', { bubbles: true });\n this.dispatchEvent(evt);\n }\n\n public getItemIndex(value: string) {\n return this.items.findIndex(option => this.getValue(option) === value);\n }\n\n public removeItem(value: string) {\n const index = this.getItemIndex(value);\n this.items.splice(index, 1);\n this.items = [...this.items];\n\n // if we were at the end, move us down\n this.cursorIndex = Math.max(\n 0,\n Math.min(this.items.length - 1, this.cursorIndex - 1)\n );\n\n // request a change even if it is the same, the item is different\n this.requestUpdate('cursorIndex');\n this.requestUpdate('items');\n }\n\n public getSelection(): any {\n return this.selected;\n }\n\n public refresh(): void {\n this.refreshKey = 'requested_' + new Date().getTime();\n }\n\n public setEndpoint(endpoint: string, nextSelection: any = null) {\n this.endpoint = endpoint;\n this.nextSelection = nextSelection;\n }\n\n public getRefreshEndpoint() {\n return this.endpoint;\n }\n\n /**\n * Refreshes the first page, updating any found items in our list\n */\n private async refreshTop(): Promise<void> {\n const refreshEndpoint = this.getRefreshEndpoint();\n if (!refreshEndpoint) {\n return;\n }\n\n // cancel any outstanding requests\n while (this.pending.length > 0) {\n const pending = this.pending.pop();\n pending.abort();\n }\n\n const controller = new AbortController();\n this.pending.push(controller);\n\n const prevItem = this.items[this.cursorIndex];\n\n try {\n const page = await fetchResultsPage(\n this.getRefreshEndpoint(),\n controller\n );\n\n const items = [...this.items];\n // remove any dupes already in our list\n if (page.results) {\n page.results.forEach((newOption: any) => {\n if (this.sanitizeOption) {\n this.sanitizeOption(newOption);\n }\n const newValue = this.getValue(newOption);\n const removeIndex = items.findIndex(\n option => this.getValue(option) === newValue\n );\n\n if (removeIndex > -1) {\n items.splice(removeIndex, 1);\n }\n });\n\n // insert our new items at the front\n let results = page.results;\n if (this.reverseRefresh) {\n results = page.results.reverse();\n }\n const newItems = [...results, ...items];\n\n const topItem = newItems[0];\n if (\n !this.mostRecentItem ||\n JSON.stringify(this.mostRecentItem) !== JSON.stringify(topItem)\n ) {\n this.mostRecentItem = topItem;\n }\n\n if (prevItem) {\n const newItem = newItems[this.cursorIndex];\n const prevValue = this.getValue(prevItem);\n if (prevValue !== this.getValue(newItem)) {\n const newIndex = newItems.findIndex(\n option => this.getValue(option) === prevValue\n );\n this.cursorIndex = newIndex;\n\n // make sure our focused item is visible\n window.setTimeout(() => {\n const options = this.shadowRoot.querySelector('temba-options');\n if (options) {\n const option =\n options.shadowRoot.querySelector('.option.focused');\n option.scrollIntoView({ block: 'end', inline: 'nearest' });\n }\n }, 0);\n }\n }\n\n this.items = newItems;\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n private async fetchItems(): Promise<void> {\n // cancel any outstanding requests\n while (this.pending.length > 0) {\n const pending = this.pending.pop();\n pending.abort();\n }\n\n let endpoint = this.endpoint;\n let pagesToFetch = this.pages || 1;\n let pages = 0;\n let nextPage = null;\n\n let fetchedItems: any[] = [];\n\n while (pagesToFetch > 0 && endpoint) {\n const controller = new AbortController();\n this.pending.push(controller);\n\n try {\n const page = await fetchResultsPage(endpoint, controller);\n\n // sanitize our options if necessary\n if (this.sanitizeOption) {\n page.results.forEach(this.sanitizeOption);\n }\n\n if (page.results) {\n fetchedItems = fetchedItems.concat(page.results);\n }\n\n // save our next pages\n nextPage = page.next;\n endpoint = nextPage;\n pagesToFetch--;\n pages++;\n } catch (error) {\n // aborted\n this.reset();\n console.log(error);\n return;\n }\n\n this.nextPage = nextPage;\n }\n this.pages = pages;\n\n const topItem = fetchedItems[0];\n if (\n !this.mostRecentItem ||\n JSON.stringify(this.mostRecentItem) !== JSON.stringify(topItem)\n ) {\n this.mostRecentItem = topItem;\n }\n\n // see if our cursor needs to move to stay on the same item\n const newItem = fetchedItems[this.cursorIndex];\n\n if (\n !this.nextSelection &&\n this.selected &&\n newItem &&\n this.getValue(newItem) !== this.getValue(this.selected)\n ) {\n const index = fetchedItems.findIndex(item => {\n return this.getValue(item) === this.getValue(this.selected);\n });\n\n // old selection is in the new fetch\n if (index > -1) {\n this.cursorIndex = index;\n }\n // old selection is missing from the new fetch\n else {\n // if our index didn't change, our item still did, fire change\n if (this.cursorIndex === 0) {\n this.requestUpdate('cursorIndex');\n }\n // otherwise select the first item\n else {\n this.cursorIndex = 0;\n }\n }\n }\n\n // save our results\n this.items = fetchedItems;\n this.loading = false;\n this.pending = [];\n\n if (this.nextSelection) {\n this.setSelection(this.nextSelection);\n this.nextSelection = false;\n } else {\n if (this.cursorIndex === -1 && !this.isMobile()) {\n this.cursorIndex = 0;\n }\n }\n\n // TODO: Not sure why this is needed\n // this.requestUpdate('cursorIndex');\n\n if (this.value) {\n this.setSelection(this.value);\n this.value = null;\n } else if (this.isMobile() && !this.selected) {\n this.cursorIndex = -1;\n this.value = null;\n this.selected = null;\n const evt = new Event('change', { bubbles: true });\n this.dispatchEvent(evt);\n }\n\n return Promise.resolve();\n }\n\n private handleScrollThreshold() {\n if (this.nextPage && !this.loading) {\n this.loading = true;\n fetchResultsPage(this.nextPage).then((page: ResultsPage) => {\n if (this.sanitizeOption) {\n page.results.forEach(this.sanitizeOption);\n }\n\n this.items = [...this.items, ...page.results];\n this.nextPage = page.next;\n this.pages++;\n this.loading = false;\n });\n }\n }\n\n public renderHeader(): TemplateResult {\n return null;\n }\n\n public renderFooter(): TemplateResult {\n return null;\n }\n\n public getListStyle() {\n return '';\n }\n\n protected handleSelection(event: CustomEvent) {\n const { selected, index } = event.detail;\n\n this.selected = selected;\n this.cursorIndex = index;\n\n event.stopPropagation();\n event.preventDefault();\n }\n\n public render(): TemplateResult {\n return html`\n ${this.renderHeader()}\n <temba-options\n style=\"${this.getListStyle()}\"\n ?visible=${true}\n ?block=${true}\n ?hideShadow=${this.hideShadow}\n ?collapsed=${this.collapsed}\n ?loading=${this.loading}\n ?internalFocusDisabled=${this.internalFocusDisabled}\n .renderOption=${this.renderOption}\n .renderOptionDetail=${this.renderOptionDetail}\n @temba-scroll-threshold=${this.handleScrollThreshold}\n @temba-selection=${this.handleSelection.bind(this)}\n .options=${this.items}\n .cursorIndex=${this.cursorIndex}\n >\n <slot></slot>\n </temba-options>\n ${this.renderFooter()}\n `;\n }\n}\n"]}
@@ -305,13 +305,17 @@ export class TembaMenu extends ResizeElement {
305
305
  }
306
306
 
307
307
  .mobile.root {
308
- height: 100vh;
308
+ height: 100svh;
309
309
  }
310
310
 
311
311
  .mobile.root.fully-collapsed {
312
312
  height: initial;
313
313
  }
314
314
 
315
+ .root.fully-collapsed.mobile .level.level-0 {
316
+ padding-right: 0.5em;
317
+ }
318
+
315
319
  .root.fully-collapsed.mobile .level.level-0 {
316
320
  flex-direction: row;
317
321
  }
@@ -728,7 +732,6 @@ export class TembaMenu extends ResizeElement {
728
732
  arrowoffset="8"
729
733
  arrowSize="0"
730
734
  drop_align="left"
731
- mask
732
735
  id="dd-${menuItem.id}"
733
736
  >
734
737
  <div slot="toggle">${item}</div>