@quandis/qbo4.ui 4.0.1-CI-20240403-131518

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 (94) hide show
  1. package/package.json +52 -0
  2. package/readme.md +456 -0
  3. package/src/qbo/Program.d.ts +18 -0
  4. package/src/qbo/Program.js +18 -0
  5. package/src/qbo/Program.ts +19 -0
  6. package/src/qbo/qbo-api.d.ts +27 -0
  7. package/src/qbo/qbo-api.js +96 -0
  8. package/src/qbo/qbo-api.ts +106 -0
  9. package/src/qbo/qbo-badge.d.ts +32 -0
  10. package/src/qbo/qbo-badge.js +93 -0
  11. package/src/qbo/qbo-badge.js.map +1 -0
  12. package/src/qbo/qbo-badge.ts +80 -0
  13. package/src/qbo/qbo-breadcrumb.d.ts +23 -0
  14. package/src/qbo/qbo-breadcrumb.js +132 -0
  15. package/src/qbo/qbo-breadcrumb.ts +96 -0
  16. package/src/qbo/qbo-datalist.d.ts +22 -0
  17. package/src/qbo/qbo-datalist.js +126 -0
  18. package/src/qbo/qbo-datalist.ts +104 -0
  19. package/src/qbo/qbo-docviewer.d.ts +15 -0
  20. package/src/qbo/qbo-docviewer.js +55 -0
  21. package/src/qbo/qbo-docviewer.ts +39 -0
  22. package/src/qbo/qbo-fetch.d.ts +29 -0
  23. package/src/qbo/qbo-fetch.js +134 -0
  24. package/src/qbo/qbo-fetch.ts +127 -0
  25. package/src/qbo/qbo-json.d.ts +8 -0
  26. package/src/qbo/qbo-json.js +85 -0
  27. package/src/qbo/qbo-json.ts +92 -0
  28. package/src/qbo/qbo-link.d.ts +15 -0
  29. package/src/qbo/qbo-link.js +48 -0
  30. package/src/qbo/qbo-link.js.map +1 -0
  31. package/src/qbo/qbo-link.ts +34 -0
  32. package/src/qbo/qbo-logging.d.ts +13 -0
  33. package/src/qbo/qbo-logging.js +92 -0
  34. package/src/qbo/qbo-logging.ts +72 -0
  35. package/src/qbo/qbo-mainmenu.d.ts +41 -0
  36. package/src/qbo/qbo-mainmenu.js +307 -0
  37. package/src/qbo/qbo-mainmenu.ts +263 -0
  38. package/src/qbo/qbo-markdown.d.ts +9 -0
  39. package/src/qbo/qbo-markdown.js +33 -0
  40. package/src/qbo/qbo-markdown.js.map +1 -0
  41. package/src/qbo/qbo-markdown.ts +22 -0
  42. package/src/qbo/qbo-microphone.d.ts +31 -0
  43. package/src/qbo/qbo-microphone.js +149 -0
  44. package/src/qbo/qbo-microphone.js.map +1 -0
  45. package/src/qbo/qbo-microphone.ts +137 -0
  46. package/src/qbo/qbo-popover.d.ts +8 -0
  47. package/src/qbo/qbo-popover.js +41 -0
  48. package/src/qbo/qbo-popover.ts +26 -0
  49. package/src/qbo/qbo-popup-listener.d.ts +25 -0
  50. package/src/qbo/qbo-popup-listener.js +145 -0
  51. package/src/qbo/qbo-popup-listener.ts +129 -0
  52. package/src/qbo/qbo-popup.d.ts +19 -0
  53. package/src/qbo/qbo-popup.js +95 -0
  54. package/src/qbo/qbo-popup.ts +84 -0
  55. package/src/qbo/qbo-select.d.ts +22 -0
  56. package/src/qbo/qbo-select.js +87 -0
  57. package/src/qbo/qbo-select.ts +65 -0
  58. package/src/qbo/qbo-sidebar.d.ts +10 -0
  59. package/src/qbo/qbo-sidebar.js +65 -0
  60. package/src/qbo/qbo-sidebar.ts +41 -0
  61. package/src/qbo/qbo-table.d.ts +23 -0
  62. package/src/qbo/qbo-table.js +94 -0
  63. package/src/qbo/qbo-table.js.map +1 -0
  64. package/src/qbo/qbo-table.ts +80 -0
  65. package/src/qbo/qbo-validate.d.ts +20 -0
  66. package/src/qbo/qbo-validate.js +92 -0
  67. package/src/qbo/qbo-validate.js.map +1 -0
  68. package/src/qbo/qbo-validate.ts +77 -0
  69. package/src/qbo/qbo-validators.d.ts +37 -0
  70. package/src/qbo/qbo-validators.js +72 -0
  71. package/src/qbo/qbo-validators.ts +66 -0
  72. package/src/qbo/styles.d.ts +3 -0
  73. package/src/qbo/styles.js +27 -0
  74. package/src/qbo/styles.ts +30 -0
  75. package/src/qbo-code/qbo-code.d.ts +12 -0
  76. package/src/qbo-code/qbo-code.js +54 -0
  77. package/src/qbo-code/qbo-code.ts +40 -0
  78. package/src/qbo-flowchart/qbo-flowchart.d.ts +45 -0
  79. package/src/qbo-flowchart/qbo-flowchart.js +309 -0
  80. package/src/qbo-flowchart/qbo-flowchart.js.map +1 -0
  81. package/src/qbo-flowchart/qbo-flowchart.ts +320 -0
  82. package/src/qbo-flowchart/readme.md +2 -0
  83. package/wwwroot/js/qbo4.ui-code.js +37965 -0
  84. package/wwwroot/js/qbo4.ui-code.min.js +3 -0
  85. package/wwwroot/js/qbo4.ui-code.min.js.LICENSE.txt +32 -0
  86. package/wwwroot/js/qbo4.ui-code.min.js.map +1 -0
  87. package/wwwroot/js/qbo4.ui-flowchart.js +44909 -0
  88. package/wwwroot/js/qbo4.ui-flowchart.min.js +9 -0
  89. package/wwwroot/js/qbo4.ui-flowchart.min.js.LICENSE.txt +43 -0
  90. package/wwwroot/js/qbo4.ui-flowchart.min.js.map +1 -0
  91. package/wwwroot/js/qbo4.ui.js +18840 -0
  92. package/wwwroot/js/qbo4.ui.min.js +108 -0
  93. package/wwwroot/js/qbo4.ui.min.js.LICENSE.txt +53 -0
  94. package/wwwroot/js/qbo4.ui.min.js.map +1 -0
@@ -0,0 +1,149 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var QboMicrophone_1;
11
+ import { html, LitElement } from 'lit';
12
+ import { customElement, property } from 'lit/decorators.js';
13
+ /**
14
+ * Collect text input from the user.
15
+ */
16
+ let QboMicrophone = class QboMicrophone extends LitElement {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.renderInHost = true;
20
+ this.continuous = false;
21
+ this.interimResults = false;
22
+ this.maxAlternatives = 1;
23
+ this.for = 'input';
24
+ this.class = 'input-group-text bi bi-headset';
25
+ this.activeClass = 'bg-primary-subtle';
26
+ this._recognition = null;
27
+ this.target = null;
28
+ this.listening = false;
29
+ }
30
+ static { QboMicrophone_1 = this; }
31
+ static { this.activeInstance = null; }
32
+ connectedCallback() {
33
+ super.connectedCallback();
34
+ this.addEventListener('click', this.listen);
35
+ const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
36
+ recognition.continuous = this.continuous;
37
+ // recognition.lang = 'en-US';
38
+ recognition.interimResults = this.interimResults;
39
+ recognition.maxAlternatives = this.maxAlternatives;
40
+ recognition.onresult = (e) => { this.onResult(e); };
41
+ recognition.onspeechend = (e) => { this.stop(e); };
42
+ recognition.onerror = (e) => { this.error(e); };
43
+ this._recognition = recognition;
44
+ this.target = document.getElementById(this.for)
45
+ || this.querySelector(this.for)
46
+ || this.parentElement?.querySelector(this.for);
47
+ if (this.target == null)
48
+ console.log(`qbo-microphone: no target found for ${this.for}`);
49
+ }
50
+ disconnectedCallback() {
51
+ this.removeEventListener('click', this.listen);
52
+ super.disconnectedCallback();
53
+ }
54
+ onResult(e) {
55
+ const text = e.results[e.results.length - 1][0].transcript; //e.results[0][0].transcript;
56
+ console.log('Result: ' + text);
57
+ if (this.target == null)
58
+ return;
59
+ const element = this.target;
60
+ if (element instanceof HTMLInputElement) {
61
+ if (element.type === 'radio') {
62
+ if (element.value === text) {
63
+ element.checked = true;
64
+ }
65
+ }
66
+ else {
67
+ if (this.continuous)
68
+ element.value += text;
69
+ else
70
+ element.value = text;
71
+ }
72
+ }
73
+ else if (element instanceof HTMLTextAreaElement) {
74
+ if (this.continuous)
75
+ element.value += text;
76
+ else
77
+ element.value = text;
78
+ }
79
+ else if (element instanceof HTMLSelectElement) {
80
+ for (let i = 0; i < element.options.length; i++) {
81
+ if (element.options[i].value === text || element.options[i].text === text) {
82
+ element.selectedIndex = i;
83
+ break;
84
+ }
85
+ }
86
+ }
87
+ }
88
+ listen(e) {
89
+ if (this.listening)
90
+ this.stop(e);
91
+ else
92
+ this.start();
93
+ }
94
+ start() {
95
+ this.listening = true;
96
+ QboMicrophone_1.activeInstance = this;
97
+ if (this.activeClass)
98
+ this.classList.add(this.activeClass);
99
+ console.log('listening');
100
+ this._recognition.start();
101
+ }
102
+ stop(e) {
103
+ this.listening = false;
104
+ QboMicrophone_1.activeInstance = null;
105
+ if (this.activeClass)
106
+ this.classList.remove(this.activeClass);
107
+ console.log('stopped listening');
108
+ this._recognition.stop();
109
+ this._recognition.abort();
110
+ }
111
+ error(e) {
112
+ console.log('Error during speech recognition:', e);
113
+ }
114
+ render() {
115
+ return html `<slot></slot>`;
116
+ }
117
+ };
118
+ __decorate([
119
+ property({ type: Boolean }),
120
+ __metadata("design:type", Object)
121
+ ], QboMicrophone.prototype, "renderInHost", void 0);
122
+ __decorate([
123
+ property({ type: Boolean }),
124
+ __metadata("design:type", Object)
125
+ ], QboMicrophone.prototype, "continuous", void 0);
126
+ __decorate([
127
+ property({ type: Boolean }),
128
+ __metadata("design:type", Object)
129
+ ], QboMicrophone.prototype, "interimResults", void 0);
130
+ __decorate([
131
+ property({ type: Number }),
132
+ __metadata("design:type", Object)
133
+ ], QboMicrophone.prototype, "maxAlternatives", void 0);
134
+ __decorate([
135
+ property({ type: String }),
136
+ __metadata("design:type", Object)
137
+ ], QboMicrophone.prototype, "for", void 0);
138
+ __decorate([
139
+ property({ type: String }),
140
+ __metadata("design:type", Object)
141
+ ], QboMicrophone.prototype, "class", void 0);
142
+ __decorate([
143
+ property({ type: String }),
144
+ __metadata("design:type", Object)
145
+ ], QboMicrophone.prototype, "activeClass", void 0);
146
+ QboMicrophone = QboMicrophone_1 = __decorate([
147
+ customElement('qbo-microphone')
148
+ ], QboMicrophone);
149
+ export { QboMicrophone };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qbo-select.js","sourceRoot":"","sources":["qbo-select.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;;IAKI;AAEG,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,QAAQ;IAAhC;;QAGH,YAAO,GAAG,KAAK,CAAC;QAGhB,eAAU,GAAkB,IAAI,CAAC;QAGjC,gBAAW,GAAkB,IAAI,CAAC;QAGlC,iBAAY,GAAG,IAAI,CAAC;QAGpB,aAAQ,GAAG,IAAI,CAAC;QAGhB,YAAO,GAA4C,EAAE,CAAC;QAGtD,iBAAY,GAAG,IAAI,CAAC;IA+BxB,CAAC;aA7BU,WAAM,GAAG;QACZ,GAAG,CAAA;;;SAGF;KACJ,AALY,CAKX;IAEF,KAAK,CAAC,iBAAiB;QACnB,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,WAAW,CAAC;QACrC,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAC9B,CAAC;IAED,gBAAgB;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;IAC/D,CAAC;IAED,MAAM;QACF,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;YAC1C,OAAO,IAAI,CAAA,mBAAmB,CAAC;QAEnC,IAAI,CAAC,WAAW,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,IAAI,CAAC,UAAU,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC;QAExE,OAAO,IAAI,CAAA;gCACa,IAAI,CAAC,QAAQ;sBACvB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA,kBAAkB,MAAM,CAAC,IAAI,CAAC,WAAY,CAAC,gBAAgB,MAAM,CAAC,IAAI,CAAC,WAAY,CAAC,KAAK,IAAI,CAAC,YAAY,KAAK,MAAM,CAAC,IAAI,CAAC,UAAW,CAAC,WAAW,CAAC;0BAC9K,CAAC;IACvB,CAAC;;AAhDD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACZ;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACM;AAGjC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACO;AAGlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CACP;AAGpB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;2CACrB;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;0CAC4B;AAGtD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CACR;AArBX,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAoDrB"}
@@ -0,0 +1,137 @@
1
+ import { html, css, LitElement } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+
4
+ declare global {
5
+ interface Window {
6
+ SpeechRecognition:any;
7
+ webkitSpeechRecognition:any;
8
+ }
9
+ }
10
+
11
+ /**
12
+ * Collect text input from the user.
13
+ */
14
+ @customElement('qbo-microphone')
15
+ export class QboMicrophone extends LitElement
16
+ {
17
+ static activeInstance: QboMicrophone | null = null;
18
+
19
+ @property({ type: Boolean })
20
+ renderInHost = true;
21
+
22
+ @property({ type: Boolean })
23
+ continuous = false;
24
+
25
+ @property({ type: Boolean })
26
+ interimResults = false;
27
+
28
+ @property({ type: Number })
29
+ maxAlternatives = 1;
30
+
31
+ @property({ type: String })
32
+ for = 'input';
33
+
34
+ @property({ type: String })
35
+ class = 'input-group-text bi bi-headset';
36
+
37
+ @property({ type: String })
38
+ activeClass = 'bg-primary-subtle';
39
+
40
+ _recognition: any = null;
41
+
42
+ target: Element | null | undefined = null;
43
+
44
+ listening = false;
45
+
46
+ connectedCallback() {
47
+ super.connectedCallback();
48
+ this.addEventListener('click', this.listen);
49
+ const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
50
+ recognition.continuous = this.continuous;
51
+ // recognition.lang = 'en-US';
52
+ recognition.interimResults = this.interimResults;
53
+ recognition.maxAlternatives = this.maxAlternatives;
54
+ recognition.onresult = (e) => { this.onResult(e) };
55
+ recognition.onspeechend = (e) => { this.stop(e) };
56
+ recognition.onerror = (e) => { this.error(e) };
57
+
58
+ this._recognition = recognition;
59
+
60
+ this.target = document.getElementById(this.for)
61
+ || this.querySelector(this.for)
62
+ || this.parentElement?.querySelector(this.for);
63
+ if (this.target == null) console.log(`qbo-microphone: no target found for ${this.for}`);
64
+
65
+ }
66
+
67
+ disconnectedCallback() {
68
+ this.removeEventListener('click', this.listen);
69
+ super.disconnectedCallback();
70
+ }
71
+
72
+ onResult(e: any) {
73
+ const text = e.results[e.results.length-1][0].transcript; //e.results[0][0].transcript;
74
+ console.log('Result: ' + text);
75
+ if (this.target == null)
76
+ return;
77
+ const element = this.target;
78
+ if (element instanceof HTMLInputElement) {
79
+ if (element.type === 'radio') {
80
+ if (element.value === text) {
81
+ element.checked = true;
82
+ }
83
+ } else {
84
+ if (this.continuous)
85
+ element.value += text;
86
+ else
87
+ element.value = text;
88
+ }
89
+ }
90
+ else if (element instanceof HTMLTextAreaElement) {
91
+ if (this.continuous)
92
+ element.value += text;
93
+ else
94
+ element.value = text;
95
+ }
96
+ else if (element instanceof HTMLSelectElement) {
97
+ for (let i = 0; i < element.options.length; i++) {
98
+ if (element.options[i].value === text || element.options[i].text === text) {
99
+ element.selectedIndex = i;
100
+ break;
101
+ }
102
+ }
103
+ }
104
+ }
105
+
106
+ listen(e) {
107
+ if (this.listening) this.stop(e);
108
+ else this.start();
109
+ }
110
+
111
+ start() {
112
+ this.listening = true;
113
+ QboMicrophone.activeInstance = this;
114
+ if (this.activeClass)
115
+ this.classList.add(this.activeClass);
116
+ console.log('listening');
117
+ this._recognition.start();
118
+ }
119
+
120
+ stop(e: any) {
121
+ this.listening = false;
122
+ QboMicrophone.activeInstance = null;
123
+ if (this.activeClass)
124
+ this.classList.remove(this.activeClass);
125
+ console.log('stopped listening');
126
+ this._recognition.stop();
127
+ this._recognition.abort();
128
+ }
129
+
130
+ error(e) {
131
+ console.log('Error during speech recognition:', e);
132
+ }
133
+
134
+ render() {
135
+ return html`<slot></slot>`;
136
+ }
137
+ }
@@ -0,0 +1,8 @@
1
+ import { LitElement, PropertyValues } from 'lit';
2
+ export declare class QboPopover extends LitElement {
3
+ selector: string;
4
+ renderInHost: boolean;
5
+ createRenderRoot(): Element | ShadowRoot;
6
+ updated(changedProperties: PropertyValues): void;
7
+ render(): import("lit").TemplateResult<1>;
8
+ }
@@ -0,0 +1,41 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { html, LitElement } from 'lit';
11
+ import { customElement, property } from 'lit/decorators.js';
12
+ import { Popover } from 'bootstrap';
13
+ let QboPopover = class QboPopover extends LitElement {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.selector = `[data-bs-toggle="popover"]`;
17
+ this.renderInHost = true;
18
+ }
19
+ createRenderRoot() {
20
+ return this.renderInHost ? this : super.createRenderRoot();
21
+ }
22
+ updated(changedProperties) {
23
+ /* Enable Popover */
24
+ this.renderRoot.querySelectorAll(`${this.selector}`).forEach(function (t) {
25
+ new Popover(t);
26
+ });
27
+ }
28
+ render() { return html `<slot></slot>`; }
29
+ };
30
+ __decorate([
31
+ property({ type: String }),
32
+ __metadata("design:type", Object)
33
+ ], QboPopover.prototype, "selector", void 0);
34
+ __decorate([
35
+ property({ type: Boolean }),
36
+ __metadata("design:type", Object)
37
+ ], QboPopover.prototype, "renderInHost", void 0);
38
+ QboPopover = __decorate([
39
+ customElement('qbo-popover')
40
+ ], QboPopover);
41
+ export { QboPopover };
@@ -0,0 +1,26 @@
1
+ import { html, LitElement, PropertyValues } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { Popover } from 'bootstrap';
4
+
5
+ @customElement('qbo-popover')
6
+ export class QboPopover extends LitElement {
7
+
8
+ @property({ type: String })
9
+ selector = `[data-bs-toggle="popover"]`;
10
+
11
+ @property({ type: Boolean })
12
+ renderInHost = true;
13
+
14
+ createRenderRoot() {
15
+ return this.renderInHost ? this : super.createRenderRoot();
16
+ }
17
+
18
+ updated(changedProperties: PropertyValues) {
19
+ /* Enable Popover */
20
+ this.renderRoot.querySelectorAll(`${this.selector}`).forEach(function (t) {
21
+ new Popover(t);
22
+ });
23
+ }
24
+
25
+ render() { return html`<slot></slot>`; }
26
+ }
@@ -0,0 +1,25 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * Listens for a popup event, and renders popup with the content.
4
+ */
5
+ export declare class QboPopupListener extends LitElement {
6
+ open: boolean;
7
+ loading: boolean;
8
+ renderInHost: boolean;
9
+ src: any;
10
+ title: string;
11
+ clickSelector: any;
12
+ eventName: string;
13
+ target: any;
14
+ listen: boolean;
15
+ targetElement: any;
16
+ targetContainer: HTMLIFrameElement | null | undefined;
17
+ connectedCallback(): Promise<void>;
18
+ toggle(): void;
19
+ show(): void;
20
+ hide(event: any): void;
21
+ handleOutsideClick(event: any): void;
22
+ firstUpdated(): void;
23
+ showElement(el: any): void;
24
+ render(): import("lit").TemplateResult<1>;
25
+ }
@@ -0,0 +1,145 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { LitElement, html } from 'lit';
11
+ import { customElement, property } from 'lit/decorators.js';
12
+ /**
13
+ * Listens for a popup event, and renders popup with the content.
14
+ */
15
+ let QboPopupListener = class QboPopupListener extends LitElement {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.open = false;
19
+ this.loading = false;
20
+ this.renderInHost = false;
21
+ this.title = "Popup";
22
+ this.eventName = 'qbo-popup';
23
+ /* If true, call target.addEventListener to listen for any click events. */
24
+ this.listen = true;
25
+ }
26
+ async connectedCallback() {
27
+ super.connectedCallback();
28
+ this.handleOutsideClick = this.handleOutsideClick.bind(this);
29
+ }
30
+ toggle() {
31
+ this.open = !this.open;
32
+ if (this.open)
33
+ document.addEventListener('click', this.handleOutsideClick);
34
+ else
35
+ document.removeEventListener('click', this.handleOutsideClick);
36
+ }
37
+ show() {
38
+ this.open = true;
39
+ document.addEventListener('click', this.handleOutsideClick);
40
+ }
41
+ hide(event) {
42
+ if (event.target.closest('[data-dismiss="modal"]')) {
43
+ this.open = false;
44
+ this.src = null;
45
+ const iframe = this.querySelector('iframe') ?? this.renderRoot.querySelector('iframe');
46
+ if (iframe != null)
47
+ iframe.removeAttribute('src');
48
+ document.removeEventListener('click', this.handleOutsideClick);
49
+ }
50
+ }
51
+ handleOutsideClick(event) {
52
+ // if (this.open && !this.contains(event.target)) {
53
+ // this.open = false;
54
+ // document.removeEventListener('click', this.handleOutsideClick);
55
+ // }
56
+ }
57
+ firstUpdated() {
58
+ const component = this;
59
+ component.targetElement = document.querySelector(component.target) ?? document;
60
+ // component.targetContainer = component.renderRoot.querySelector('iframe');
61
+ component.targetContainer = component.querySelector('iframe') ?? component.renderRoot.querySelector('iframe');
62
+ component.targetElement.addEventListener(component.eventName, (e) => {
63
+ component.showElement(e.target);
64
+ });
65
+ if (component.listen) {
66
+ component.targetElement.addEventListener('click', (e) => {
67
+ const source = e.composedPath().find(el => el instanceof HTMLAnchorElement);
68
+ if (source != null) {
69
+ source.dispatchEvent(new CustomEvent(this.eventName, { bubbles: true, composed: true }));
70
+ e.preventDefault();
71
+ }
72
+ });
73
+ }
74
+ }
75
+ /* @description Sets the popup iframe.src to the el.src. */
76
+ showElement(el) {
77
+ // Handle Youtube watch vs embed
78
+ this.src = el.href.replace('youtube.com/watch', 'youtube.com/embed');
79
+ const iframe = this.querySelector('iframe') ?? this.renderRoot.querySelector('iframe');
80
+ if (iframe != null) {
81
+ iframe.src = this.src;
82
+ this.show();
83
+ }
84
+ }
85
+ render() {
86
+ return html `
87
+ <slot name="button" @click="${this.toggle}"></slot>
88
+ <slot name="content" @click="${this.hide}" style="display:${this.open ? 'flex' : 'none'}">
89
+ <link href="scripts/qbo4.css" rel="stylesheet">
90
+ <div class="modal" tabindex="-1" role="dialog" style="display:block">
91
+ <div class="modal-dialog modal-lg" role="document" style="width:960px; height:600px">
92
+ <div class="modal-content">
93
+ <div class="modal-body" style="height:500px">
94
+ <iframe src="${this.src}" title="${this.title}" frameborder="0" width="100%" height="100%" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
95
+ </div>
96
+ <div class="modal-footer">
97
+ <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
98
+ </div>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </slot>
103
+ `;
104
+ }
105
+ };
106
+ __decorate([
107
+ property({ type: Boolean }),
108
+ __metadata("design:type", Object)
109
+ ], QboPopupListener.prototype, "open", void 0);
110
+ __decorate([
111
+ property({ type: Boolean }),
112
+ __metadata("design:type", Object)
113
+ ], QboPopupListener.prototype, "loading", void 0);
114
+ __decorate([
115
+ property({ type: Boolean }),
116
+ __metadata("design:type", Object)
117
+ ], QboPopupListener.prototype, "renderInHost", void 0);
118
+ __decorate([
119
+ property({ type: String }),
120
+ __metadata("design:type", Object)
121
+ ], QboPopupListener.prototype, "src", void 0);
122
+ __decorate([
123
+ property({ type: String }),
124
+ __metadata("design:type", Object)
125
+ ], QboPopupListener.prototype, "title", void 0);
126
+ __decorate([
127
+ property(),
128
+ __metadata("design:type", Object)
129
+ ], QboPopupListener.prototype, "clickSelector", void 0);
130
+ __decorate([
131
+ property(),
132
+ __metadata("design:type", Object)
133
+ ], QboPopupListener.prototype, "eventName", void 0);
134
+ __decorate([
135
+ property(),
136
+ __metadata("design:type", Object)
137
+ ], QboPopupListener.prototype, "target", void 0);
138
+ __decorate([
139
+ property({ type: Boolean }),
140
+ __metadata("design:type", Object)
141
+ ], QboPopupListener.prototype, "listen", void 0);
142
+ QboPopupListener = __decorate([
143
+ customElement('qbo-popup-listener')
144
+ ], QboPopupListener);
145
+ export { QboPopupListener };
@@ -0,0 +1,129 @@
1
+ import { LitElement, html } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+
4
+ /**
5
+ * Listens for a popup event, and renders popup with the content.
6
+ */
7
+ @customElement('qbo-popup-listener')
8
+ export class QboPopupListener extends LitElement {
9
+ @property({ type: Boolean })
10
+ open = false;
11
+
12
+ @property({ type: Boolean })
13
+ loading = false;
14
+
15
+ @property({ type: Boolean })
16
+ renderInHost = false;
17
+
18
+ @property({ type: String })
19
+ src;
20
+
21
+ @property({ type: String })
22
+ title = "Popup";
23
+
24
+ @property()
25
+ clickSelector;
26
+
27
+ @property()
28
+ eventName = 'qbo-popup';
29
+
30
+ /* @description Css selector for the target element to listen to. */
31
+ @property()
32
+ target;
33
+
34
+ /* If true, call target.addEventListener to listen for any click events. */
35
+ @property({ type: Boolean })
36
+ listen = true;
37
+
38
+ targetElement: any;
39
+ targetContainer: HTMLIFrameElement | null | undefined;
40
+
41
+ async connectedCallback() {
42
+ super.connectedCallback();
43
+ this.handleOutsideClick = this.handleOutsideClick.bind(this);
44
+ }
45
+
46
+ toggle() {
47
+ this.open = !this.open;
48
+ if (this.open)
49
+ document.addEventListener('click', this.handleOutsideClick);
50
+ else
51
+ document.removeEventListener('click', this.handleOutsideClick);
52
+ }
53
+
54
+ show() {
55
+ this.open = true;
56
+ document.addEventListener('click', this.handleOutsideClick);
57
+ }
58
+
59
+ hide(event) {
60
+ if (event.target.closest('[data-dismiss="modal"]')) {
61
+ this.open = false;
62
+ this.src = null;
63
+ const iframe = this.querySelector('iframe') ?? this.renderRoot.querySelector('iframe');
64
+ if (iframe != null)
65
+ iframe.removeAttribute('src');
66
+ document.removeEventListener('click', this.handleOutsideClick);
67
+ }
68
+ }
69
+
70
+ handleOutsideClick(event) {
71
+ // if (this.open && !this.contains(event.target)) {
72
+ // this.open = false;
73
+ // document.removeEventListener('click', this.handleOutsideClick);
74
+ // }
75
+ }
76
+
77
+ firstUpdated() {
78
+ const component = this;
79
+ component.targetElement = document.querySelector(component.target) ?? document;
80
+ // component.targetContainer = component.renderRoot.querySelector('iframe');
81
+ component.targetContainer = component.querySelector('iframe') ?? component.renderRoot.querySelector('iframe');
82
+ component.targetElement.addEventListener(component.eventName, (e) => {
83
+ component.showElement(e.target);
84
+ });
85
+
86
+ if (component.listen) {
87
+ component.targetElement.addEventListener('click', (e) => {
88
+ const source: HTMLAnchorElement | undefined = e.composedPath().find(el => el instanceof HTMLAnchorElement) as HTMLAnchorElement;
89
+ if (source != null) {
90
+ source.dispatchEvent(new CustomEvent(this.eventName, { bubbles: true, composed: true }));
91
+ e.preventDefault();
92
+ }
93
+ });
94
+ }
95
+ }
96
+
97
+ /* @description Sets the popup iframe.src to the el.src. */
98
+ showElement(el) {
99
+ // Handle Youtube watch vs embed
100
+ this.src = el.href.replace('youtube.com/watch', 'youtube.com/embed');
101
+ const iframe = this.querySelector('iframe') ?? this.renderRoot.querySelector('iframe');
102
+ if (iframe != null) {
103
+ iframe.src = this.src;
104
+ this.show();
105
+ }
106
+ }
107
+
108
+
109
+ render() {
110
+ return html`
111
+ <slot name="button" @click="${this.toggle}"></slot>
112
+ <slot name="content" @click="${this.hide}" style="display:${this.open ? 'flex' : 'none'}">
113
+ <link href="scripts/qbo4.css" rel="stylesheet">
114
+ <div class="modal" tabindex="-1" role="dialog" style="display:block">
115
+ <div class="modal-dialog modal-lg" role="document" style="width:960px; height:600px">
116
+ <div class="modal-content">
117
+ <div class="modal-body" style="height:500px">
118
+ <iframe src="${this.src}" title="${this.title}" frameborder="0" width="100%" height="100%" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
119
+ </div>
120
+ <div class="modal-footer">
121
+ <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
122
+ </div>
123
+ </div>
124
+ </div>
125
+ </div>
126
+ </slot>
127
+ `;
128
+ }
129
+ }