@quandis/qbo4.ui 4.0.1-CI-20241107-011209 → 4.0.1-CI-20241108-002603
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/scss/qbo.scss +466 -24
- package/src/qbo/qbo-api.js +5 -7
- package/src/qbo/qbo-api.ts +2 -1
- package/src/qbo/qbo-card.js +5 -7
- package/src/qbo/qbo-card.ts +4 -2
- package/src/qbo/qbo-contextmenu.js +5 -7
- package/src/qbo/qbo-contextmenu.ts +3 -1
- package/src/qbo/qbo-datalist.js +5 -7
- package/src/qbo/qbo-datalist.ts +4 -2
- package/src/qbo/qbo-docviewer.js +5 -7
- package/src/qbo/qbo-docviewer.ts +3 -1
- package/src/qbo/qbo-fetch.js +4 -0
- package/src/qbo/qbo-fetch.ts +3 -0
- package/src/qbo/qbo-form-edit.js +5 -7
- package/src/qbo/qbo-form-edit.ts +3 -1
- package/src/qbo/qbo-form-element.js +7 -12
- package/src/qbo/qbo-form-element.ts +2 -1
- package/src/qbo/qbo-icon.js +7 -11
- package/src/qbo/qbo-icon.ts +3 -1
- package/src/qbo/qbo-menu.d.ts +17 -15
- package/src/qbo/qbo-menu.js +88 -115
- package/src/qbo/qbo-menu.ts +95 -120
- package/src/qbo/qbo-microphone.js +7 -11
- package/src/qbo/qbo-microphone.ts +3 -1
- package/src/qbo/qbo-paginate.js +5 -7
- package/src/qbo/qbo-paginate.ts +3 -1
- package/src/qbo/qbo-popover.d.ts +13 -17
- package/src/qbo/qbo-popover.js +67 -80
- package/src/qbo/qbo-popover.ts +82 -54
- package/src/qbo/qbo-popup-listener.js +5 -7
- package/src/qbo/qbo-popup-listener.ts +3 -1
- package/src/qbo/qbo-popup.js +5 -7
- package/src/qbo/qbo-popup.ts +3 -1
- package/src/qbo/qbo-resize.js +5 -7
- package/src/qbo/qbo-resize.ts +3 -2
- package/src/qbo/qbo-select.js +5 -7
- package/src/qbo/qbo-select.ts +3 -1
- package/src/qbo/qbo-selectable.js +5 -7
- package/src/qbo/qbo-selectable.ts +3 -1
- package/src/qbo/qbo-table.js +5 -7
- package/src/qbo/qbo-table.ts +2 -1
- package/src/qbo/qbo-user-preferences.js +5 -8
- package/src/qbo/qbo-user-preferences.ts +3 -1
- package/src/qbo/qbo-validate.js +5 -8
- package/src/qbo/qbo-validate.ts +3 -1
- package/src/qbo/styles.js +2 -2
- package/src/qbo/styles.ts +2 -2
- package/wwwroot/css/qbo.css +448 -21
- package/wwwroot/css/qbo.css.map +1 -1
- package/wwwroot/css/qbo.min.css +1 -1
- package/wwwroot/css/qboui.css +450 -21
- package/wwwroot/css/qboui.css.map +1 -1
- package/wwwroot/css/qboui.min.css +1 -1
- package/wwwroot/favicon.ico +0 -0
- package/wwwroot/images/qbo-logo-new.svg +25 -0
- package/wwwroot/js/esm/qbo4.ui.js +2672 -7986
- package/wwwroot/js/esm/qbo4.ui.min.js +35 -48
- package/wwwroot/js/esm/qbo4.ui.min.js.LICENSE.txt +0 -6
- package/wwwroot/js/esm/qbo4.ui.min.js.map +1 -1
- package/wwwroot/js/qbo4.ui.js +2679 -8047
- package/wwwroot/js/qbo4.ui.min.js +43 -56
- package/wwwroot/js/qbo4.ui.min.js.LICENSE.txt +0 -6
- package/wwwroot/js/qbo4.ui.min.js.map +1 -1
package/src/qbo/qbo-datalist.js
CHANGED
|
@@ -8,10 +8,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { html } from 'lit';
|
|
11
|
-
import {
|
|
11
|
+
import { property } from 'lit/decorators.js';
|
|
12
12
|
import { getArray } from './qbo-json.js';
|
|
13
13
|
import { QboFetch } from './qbo-fetch.js';
|
|
14
|
-
|
|
14
|
+
export class QboDataList extends QboFetch {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
17
|
this.listId = null;
|
|
@@ -91,7 +91,7 @@ let QboDataList = class QboDataList extends QboFetch {
|
|
|
91
91
|
${this.options.map(option => html `<option value="${option[this.text]}" data-value="${option[this.value]}"/>`)}
|
|
92
92
|
</datalist>`;
|
|
93
93
|
}
|
|
94
|
-
}
|
|
94
|
+
}
|
|
95
95
|
__decorate([
|
|
96
96
|
property({ type: String }),
|
|
97
97
|
__metadata("design:type", Object)
|
|
@@ -120,7 +120,5 @@ __decorate([
|
|
|
120
120
|
property({ type: Boolean }),
|
|
121
121
|
__metadata("design:type", Object)
|
|
122
122
|
], QboDataList.prototype, "fetchOnLoad", void 0);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
], QboDataList);
|
|
126
|
-
export { QboDataList };
|
|
123
|
+
if (!customElements.get('qbo-datalist'))
|
|
124
|
+
customElements.define('qbo-datalist', QboDataList);
|
package/src/qbo/qbo-datalist.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { customElement, property } from 'lit/decorators.js';
|
|
|
3
3
|
import { getArray } from './qbo-json.js';
|
|
4
4
|
import { QboFetch } from './qbo-fetch.js';
|
|
5
5
|
|
|
6
|
-
@customElement('qbo-datalist')
|
|
7
6
|
export class QboDataList extends QboFetch {
|
|
8
7
|
|
|
9
8
|
@property({ type: String })
|
|
@@ -101,4 +100,7 @@ export class QboDataList extends QboFetch {
|
|
|
101
100
|
${this.options.map(option => html`<option value="${option[this.text!]}" data-value="${option[this.value!]}"/>`)}
|
|
102
101
|
</datalist>`;
|
|
103
102
|
}
|
|
104
|
-
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!customElements.get('qbo-datalist'))
|
|
106
|
+
customElements.define('qbo-datalist', QboDataList)
|
package/src/qbo/qbo-docviewer.js
CHANGED
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { html, css } from 'lit';
|
|
11
|
-
import {
|
|
11
|
+
import { property } from 'lit/decorators.js';
|
|
12
12
|
import { QboFetch } from './qbo-fetch.js';
|
|
13
13
|
/**
|
|
14
14
|
* Renders a <select> element with options populated from a JSON array.
|
|
@@ -16,7 +16,7 @@ import { QboFetch } from './qbo-fetch.js';
|
|
|
16
16
|
* @remarks
|
|
17
17
|
* This element is a thin wrapper around {@link QboFetch} that renders a <select> element with options populated from a JSON array.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
export class QboDocViewer extends QboFetch {
|
|
20
20
|
constructor() {
|
|
21
21
|
super(...arguments);
|
|
22
22
|
this.open = false;
|
|
@@ -36,7 +36,7 @@ let QboDocViewer = class QboDocViewer extends QboFetch {
|
|
|
36
36
|
render() {
|
|
37
37
|
return html `<iframe src='sample.pdf' width='100%' height='800px' frameborder='0'></iframe>`;
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
}
|
|
40
40
|
__decorate([
|
|
41
41
|
property({ type: Boolean }),
|
|
42
42
|
__metadata("design:type", Object)
|
|
@@ -49,7 +49,5 @@ __decorate([
|
|
|
49
49
|
property({ type: Boolean }),
|
|
50
50
|
__metadata("design:type", Object)
|
|
51
51
|
], QboDocViewer.prototype, "renderInHost", void 0);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
], QboDocViewer);
|
|
55
|
-
export { QboDocViewer };
|
|
52
|
+
if (!customElements.get('qbo-docviewer'))
|
|
53
|
+
customElements.define('qbo-docviewer', QboDocViewer);
|
package/src/qbo/qbo-docviewer.ts
CHANGED
|
@@ -9,7 +9,6 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
|
9
9
|
* @remarks
|
|
10
10
|
* This element is a thin wrapper around {@link QboFetch} that renders a <select> element with options populated from a JSON array.
|
|
11
11
|
*/
|
|
12
|
-
@customElement('qbo-docviewer')
|
|
13
12
|
export class QboDocViewer extends QboFetch {
|
|
14
13
|
@property({ type: Boolean })
|
|
15
14
|
open = false;
|
|
@@ -37,3 +36,6 @@ export class QboDocViewer extends QboFetch {
|
|
|
37
36
|
return html`<iframe src='sample.pdf' width='100%' height='800px' frameborder='0'></iframe>`;
|
|
38
37
|
}
|
|
39
38
|
}
|
|
39
|
+
|
|
40
|
+
if (!customElements.get('qbo-docviewer'))
|
|
41
|
+
customElements.define('qbo-docviewer', QboDocViewer)
|
package/src/qbo/qbo-fetch.js
CHANGED
|
@@ -59,6 +59,10 @@ export const QboFetchMixin = (superClass) => {
|
|
|
59
59
|
console.error('Error parsing payload JSON:', error);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
else {
|
|
63
|
+
if (Object.keys(this.dataset).length > 0)
|
|
64
|
+
payload = { ...this.dataset };
|
|
65
|
+
}
|
|
62
66
|
return payload;
|
|
63
67
|
}
|
|
64
68
|
/* @description Fetch data from an api, and set @see {@link html} or @see {@link jsonData} with the result. */
|
package/src/qbo/qbo-fetch.ts
CHANGED
|
@@ -88,6 +88,9 @@ export const QboFetchMixin = <T extends Constructor<LitElement>>(superClass: T)
|
|
|
88
88
|
} catch (error) {
|
|
89
89
|
console.error('Error parsing payload JSON:', error);
|
|
90
90
|
}
|
|
91
|
+
} else {
|
|
92
|
+
if (Object.keys(this.dataset).length > 0)
|
|
93
|
+
payload = { ...this.dataset } as Record<string, string>;
|
|
91
94
|
}
|
|
92
95
|
return payload;
|
|
93
96
|
}
|
package/src/qbo/qbo-form-edit.js
CHANGED
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { html, LitElement } from 'lit';
|
|
11
|
-
import {
|
|
11
|
+
import { property } from 'lit/decorators.js';
|
|
12
12
|
import { elementDateTime } from './Program.js';
|
|
13
13
|
const formEditMap = new Map();
|
|
14
14
|
formEditMap.set('defaultLayout', (component) => {
|
|
@@ -44,7 +44,7 @@ formEditMap.set('updatedLayout', (component) => {
|
|
|
44
44
|
<span>${component.UpdatedPerson}</span>
|
|
45
45
|
</div>`;
|
|
46
46
|
});
|
|
47
|
-
|
|
47
|
+
export class QboFormEdit extends LitElement {
|
|
48
48
|
constructor() {
|
|
49
49
|
super(...arguments);
|
|
50
50
|
this.aDropdownClass = 'dropdown-item qbo-pointer';
|
|
@@ -111,7 +111,7 @@ let QboFormEdit = class QboFormEdit extends LitElement {
|
|
|
111
111
|
</div>
|
|
112
112
|
</slot>`;
|
|
113
113
|
}
|
|
114
|
-
}
|
|
114
|
+
}
|
|
115
115
|
__decorate([
|
|
116
116
|
property({ type: String }),
|
|
117
117
|
__metadata("design:type", Object)
|
|
@@ -200,7 +200,5 @@ __decorate([
|
|
|
200
200
|
property({ type: Boolean }),
|
|
201
201
|
__metadata("design:type", Object)
|
|
202
202
|
], QboFormEdit.prototype, "renderInHost", void 0);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
], QboFormEdit);
|
|
206
|
-
export { QboFormEdit };
|
|
203
|
+
if (!customElements.get('qbo-form-edit'))
|
|
204
|
+
customElements.define('qbo-form-edit', QboFormEdit);
|
package/src/qbo/qbo-form-edit.ts
CHANGED
|
@@ -38,7 +38,6 @@ formEditMap.set('updatedLayout', (component: any) => {
|
|
|
38
38
|
</div>`;
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
@customElement('qbo-form-edit')
|
|
42
41
|
export class QboFormEdit extends LitElement {
|
|
43
42
|
|
|
44
43
|
@property({ type: String })
|
|
@@ -150,3 +149,6 @@ export class QboFormEdit extends LitElement {
|
|
|
150
149
|
</slot>`;
|
|
151
150
|
}
|
|
152
151
|
}
|
|
152
|
+
|
|
153
|
+
if (!customElements.get('qbo-form-edit'))
|
|
154
|
+
customElements.define('qbo-form-edit', QboFormEdit)
|
|
@@ -7,12 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
var QboFormElement_1;
|
|
11
10
|
import { html, LitElement } from 'lit';
|
|
12
|
-
import {
|
|
11
|
+
import { property } from 'lit/decorators.js';
|
|
13
12
|
import { substitute } from './qbo-json.js';
|
|
14
|
-
|
|
15
|
-
static { QboFormElement_1 = this; }
|
|
13
|
+
export class QboFormElement extends LitElement {
|
|
16
14
|
static { this.formAssociated = true; }
|
|
17
15
|
constructor() {
|
|
18
16
|
super();
|
|
@@ -76,7 +74,7 @@ let QboFormElement = class QboFormElement extends LitElement {
|
|
|
76
74
|
&& (e instanceof HTMLInputElement
|
|
77
75
|
|| e instanceof HTMLSelectElement
|
|
78
76
|
|| e instanceof HTMLTextAreaElement
|
|
79
|
-
|| e instanceof
|
|
77
|
+
|| e instanceof QboFormElement) && e.name);
|
|
80
78
|
inputs.forEach(element => {
|
|
81
79
|
const input = element;
|
|
82
80
|
if (input instanceof HTMLSelectElement) {
|
|
@@ -85,7 +83,7 @@ let QboFormElement = class QboFormElement extends LitElement {
|
|
|
85
83
|
else if (input instanceof HTMLTextAreaElement) {
|
|
86
84
|
this.value.set(`${this.name}${input.name}`, input.value);
|
|
87
85
|
}
|
|
88
|
-
else if (input instanceof
|
|
86
|
+
else if (input instanceof QboFormElement) {
|
|
89
87
|
for (let [key, value] of input.value.entries()) {
|
|
90
88
|
this.value.set(`${this.name}${key}`, value);
|
|
91
89
|
}
|
|
@@ -104,7 +102,7 @@ let QboFormElement = class QboFormElement extends LitElement {
|
|
|
104
102
|
this.internals.setFormValue(this.value);
|
|
105
103
|
console.trace(`Set ${this.name} values to `, this.value);
|
|
106
104
|
}
|
|
107
|
-
}
|
|
105
|
+
}
|
|
108
106
|
__decorate([
|
|
109
107
|
property({ type: FormData }),
|
|
110
108
|
__metadata("design:type", FormData)
|
|
@@ -121,8 +119,5 @@ __decorate([
|
|
|
121
119
|
property({ type: Object }),
|
|
122
120
|
__metadata("design:type", Object)
|
|
123
121
|
], QboFormElement.prototype, "data", void 0);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
__metadata("design:paramtypes", [])
|
|
127
|
-
], QboFormElement);
|
|
128
|
-
export { QboFormElement };
|
|
122
|
+
if (!customElements.get('qbo-form-element'))
|
|
123
|
+
customElements.define('qbo-form-element', QboFormElement);
|
|
@@ -3,7 +3,6 @@ import { html, css, LitElement, PropertyValues } from 'lit';
|
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
4
|
import { substitute } from './qbo-json.js';
|
|
5
5
|
|
|
6
|
-
@customElement('qbo-form-element')
|
|
7
6
|
export class QboFormElement extends LitElement {
|
|
8
7
|
static formAssociated = true;
|
|
9
8
|
|
|
@@ -118,3 +117,5 @@ export class QboFormElement extends LitElement {
|
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
119
|
|
|
120
|
+
if (!customElements.get('qbo-form-element'))
|
|
121
|
+
customElements.define('qbo-form-element', QboFormElement)
|
package/src/qbo/qbo-icon.js
CHANGED
|
@@ -7,9 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
var QboIcon_1;
|
|
11
10
|
import { LitElement, html } from "lit";
|
|
12
|
-
import {
|
|
11
|
+
import { property } from "lit/decorators.js";
|
|
13
12
|
import { until } from "lit/directives/until.js";
|
|
14
13
|
const iconMap = new Map();
|
|
15
14
|
// qbo modules
|
|
@@ -48,7 +47,7 @@ iconMap.set('video', 'camera-video');
|
|
|
48
47
|
iconMap.set('headset', 'headphones');
|
|
49
48
|
iconMap.set('warning', 'exclamation-triangle');
|
|
50
49
|
// Renders an SVG icon based on the type attribute.
|
|
51
|
-
|
|
50
|
+
export class QboIcon extends LitElement {
|
|
52
51
|
constructor() {
|
|
53
52
|
super(...arguments);
|
|
54
53
|
this.type = 'icon';
|
|
@@ -63,7 +62,6 @@ let QboIcon = class QboIcon extends LitElement {
|
|
|
63
62
|
this.selected = false;
|
|
64
63
|
this.allIcons = undefined;
|
|
65
64
|
}
|
|
66
|
-
static { QboIcon_1 = this; }
|
|
67
65
|
static { this.map = iconMap; }
|
|
68
66
|
// = '/ui/images/icons.svg';
|
|
69
67
|
// Getter to retrieve the `qbo4-basepath` meta tag value
|
|
@@ -101,7 +99,7 @@ let QboIcon = class QboIcon extends LitElement {
|
|
|
101
99
|
return this.allIcons;
|
|
102
100
|
try {
|
|
103
101
|
// Adjust this path to point to the correct location of bootstrap-icons.svg
|
|
104
|
-
const response = await fetch(this.sprite ??
|
|
102
|
+
const response = await fetch(this.sprite ?? QboIcon.spriteUrl);
|
|
105
103
|
const svgText = await response.text();
|
|
106
104
|
// Parse the SVG file
|
|
107
105
|
const parser = new DOMParser();
|
|
@@ -158,7 +156,7 @@ ${Array.from(iconMap.keys()).map(k => html `<div class="col-3">
|
|
|
158
156
|
component.icon = 'warning';
|
|
159
157
|
}
|
|
160
158
|
const id = iconMap.has(component.icon) ? iconMap.get(component.icon) : component.icon;
|
|
161
|
-
return html `<svg width="${component.width}" height="${component.width}" fill="${component.fill}" ?class=${component.getAttribute('class')}><use href="${component.sprite ??
|
|
159
|
+
return html `<svg width="${component.width}" height="${component.width}" fill="${component.fill}" ?class=${component.getAttribute('class')}><use href="${component.sprite ?? QboIcon.spriteUrl}#${id}"></use></svg>`;
|
|
162
160
|
}
|
|
163
161
|
//renderButton(component: any) {
|
|
164
162
|
// return html`<button type="button" ?disabled=${component.disabled}>${component.renderIcon(component)}</button>`;
|
|
@@ -173,7 +171,7 @@ ${Array.from(iconMap.keys()).map(k => html `<div class="col-3">
|
|
|
173
171
|
default: return this.renderIcon(this);
|
|
174
172
|
}
|
|
175
173
|
}
|
|
176
|
-
}
|
|
174
|
+
}
|
|
177
175
|
__decorate([
|
|
178
176
|
property(),
|
|
179
177
|
__metadata("design:type", String)
|
|
@@ -218,7 +216,5 @@ __decorate([
|
|
|
218
216
|
property({ type: Boolean, reflect: true }),
|
|
219
217
|
__metadata("design:type", Boolean)
|
|
220
218
|
], QboIcon.prototype, "selected", void 0);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
], QboIcon);
|
|
224
|
-
export { QboIcon };
|
|
219
|
+
if (!customElements.get('qbo-icon'))
|
|
220
|
+
customElements.define('qbo-icon', QboIcon);
|
package/src/qbo/qbo-icon.ts
CHANGED
|
@@ -44,7 +44,6 @@ iconMap.set('warning', 'exclamation-triangle');
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
// Renders an SVG icon based on the type attribute.
|
|
47
|
-
@customElement('qbo-icon')
|
|
48
47
|
export class QboIcon extends LitElement {
|
|
49
48
|
|
|
50
49
|
static map: Map<string, string> = iconMap;
|
|
@@ -208,3 +207,6 @@ ${Array.from(iconMap.keys()).map(k => html`<div class="col-3">
|
|
|
208
207
|
}
|
|
209
208
|
|
|
210
209
|
}
|
|
210
|
+
|
|
211
|
+
if (!customElements.get('qbo-icon'))
|
|
212
|
+
customElements.define('qbo-icon', QboIcon)
|
package/src/qbo/qbo-menu.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { LitElement } from
|
|
1
|
+
import { LitElement, PropertyValues } from "lit";
|
|
2
|
+
import { Placement } from "@floating-ui/dom";
|
|
2
3
|
export declare class QboMenu extends LitElement {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
private
|
|
4
|
+
placement: Placement;
|
|
5
|
+
private isOpen;
|
|
6
|
+
private slotElement;
|
|
7
|
+
private menuSlotElement;
|
|
8
|
+
private triggerButton;
|
|
9
|
+
private menuContainer;
|
|
10
|
+
private middleware;
|
|
11
|
+
static styles: import("lit").CSSResult;
|
|
7
12
|
connectedCallback(): void;
|
|
8
13
|
disconnectedCallback(): void;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
toggleSideMenu: (event: Event) => void;
|
|
17
|
-
side(): import("lit-html").TemplateResult<1>;
|
|
18
|
-
render(): import("lit-html").TemplateResult<1> | undefined;
|
|
14
|
+
handleMenuOpen: (event: Event) => void;
|
|
15
|
+
handleOutsideClick: (event: Event) => void;
|
|
16
|
+
firstUpdated(changes: PropertyValues): void;
|
|
17
|
+
toggleMenu: (event: Event) => void;
|
|
18
|
+
closeMenu(): void;
|
|
19
|
+
private updateMenuPosition;
|
|
20
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
19
21
|
}
|
package/src/qbo/qbo-menu.js
CHANGED
|
@@ -7,144 +7,117 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { LitElement, html, css } from
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
10
|
+
import { LitElement, html, css } from "lit";
|
|
11
|
+
import { property, query, state } from "lit/decorators.js";
|
|
12
|
+
import { computePosition, shift, flip } from "@floating-ui/dom";
|
|
13
|
+
export class QboMenu extends LitElement {
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...arguments);
|
|
16
|
-
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
16
|
+
// Define the placement property with type `string`
|
|
17
|
+
this.placement = "bottom-start";
|
|
18
|
+
// Internal state to control menu visibility
|
|
19
|
+
this.isOpen = false;
|
|
20
|
+
this.middleware = [flip(), shift()];
|
|
21
|
+
this.handleMenuOpen = (event) => {
|
|
21
22
|
event.preventDefault();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
event.stopPropagation();
|
|
24
|
+
const customEvent = event;
|
|
25
|
+
if (customEvent.detail.menu !== this && this.isOpen) {
|
|
26
|
+
this.closeMenu();
|
|
25
27
|
}
|
|
26
28
|
};
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
this.handleOutsideClick = (event) => {
|
|
30
|
+
const customEvent = event;
|
|
31
|
+
const target = customEvent.target;
|
|
32
|
+
if (target !== this && !this.contains(target)) {
|
|
33
|
+
this.closeMenu();
|
|
30
34
|
}
|
|
31
35
|
};
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
this.toggleMenu = (event) => {
|
|
37
|
+
if (event.target instanceof HTMLElement
|
|
38
|
+
|| event.target instanceof SVGElement
|
|
39
|
+
|| event.target instanceof SVGUseElement) {
|
|
40
|
+
let toggleMenu = true;
|
|
41
|
+
let parent = event.target.parentElement;
|
|
42
|
+
while (toggleMenu && parent) {
|
|
43
|
+
if (parent instanceof HTMLElement && parent.tagName.toLowerCase() == 'aside')
|
|
44
|
+
toggleMenu = false;
|
|
45
|
+
else
|
|
46
|
+
parent = parent.parentElement;
|
|
47
|
+
}
|
|
48
|
+
if (toggleMenu) {
|
|
49
|
+
this.isOpen = !this.isOpen;
|
|
50
|
+
this.menuContainer.classList.toggle("open", this.isOpen);
|
|
51
|
+
if (this.isOpen) {
|
|
52
|
+
this.updateMenuPosition();
|
|
53
|
+
document.dispatchEvent(new CustomEvent("qbo-menu-open", {
|
|
54
|
+
bubbles: true,
|
|
55
|
+
composed: true,
|
|
56
|
+
detail: { menu: this },
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
37
60
|
}
|
|
38
61
|
};
|
|
39
62
|
}
|
|
40
|
-
static { this.styles =
|
|
41
|
-
:host {
|
|
42
|
-
display: block;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.toggle-btn {
|
|
46
|
-
width: 100%;
|
|
47
|
-
background: none;
|
|
48
|
-
border: none;
|
|
49
|
-
font-size: 1.5rem;
|
|
50
|
-
cursor: pointer;
|
|
51
|
-
text-align: left;
|
|
52
|
-
}
|
|
53
|
-
`]; }
|
|
54
|
-
toggleSidebar() {
|
|
55
|
-
this.expanded = !this.expanded;
|
|
56
|
-
}
|
|
63
|
+
static { this.styles = css ``; }
|
|
57
64
|
connectedCallback() {
|
|
58
65
|
super.connectedCallback();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
document.addEventListener('click', this.hideContextMenu);
|
|
62
|
-
this.contextParent?.addEventListener('contextmenu', this.showContextMenu);
|
|
63
|
-
break;
|
|
64
|
-
case 'side':
|
|
65
|
-
this.renderRoot.addEventListener('click', this.toggleSideMenu);
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
66
|
+
// document.addEventListener("click", this.handleOutsideClick.bind);
|
|
67
|
+
document.addEventListener("qbo-menu-open", this.handleMenuOpen.bind(this));
|
|
68
68
|
}
|
|
69
69
|
disconnectedCallback() {
|
|
70
70
|
super.disconnectedCallback();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
document.removeEventListener('click', this.hideContextMenu);
|
|
75
|
-
break;
|
|
76
|
-
case 'side':
|
|
77
|
-
this.renderRoot.removeEventListener('click', this.toggleSideMenu);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
xcreateRenderRoot() {
|
|
82
|
-
return this; // : super.createRenderRoot();
|
|
71
|
+
// document.removeEventListener("click", this.handleOutsideClick);
|
|
72
|
+
document.removeEventListener("qbo-menu-open", this.handleMenuOpen);
|
|
73
|
+
this.triggerButton.removeEventListener("click", this.toggleMenu);
|
|
83
74
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
x = viewportWidth - menuWidth;
|
|
97
|
-
}
|
|
98
|
-
if (y + menuHeight > viewportHeight) {
|
|
99
|
-
y = viewportHeight - menuHeight;
|
|
100
|
-
}
|
|
101
|
-
console.log(`mouse event: ${event.clientX} x ${event.clientY} ; ${x} x ${y}`);
|
|
102
|
-
this.style.left = x + 'px';
|
|
103
|
-
this.style.top = y + 'px';
|
|
75
|
+
firstUpdated(changes) {
|
|
76
|
+
super.firstUpdated(changes);
|
|
77
|
+
this.triggerButton =
|
|
78
|
+
this.querySelector("*[data-trigger]") ||
|
|
79
|
+
this.querySelector("button") ||
|
|
80
|
+
this.parentElement;
|
|
81
|
+
this.menuContainer =
|
|
82
|
+
this.querySelector("*[data-content]") ||
|
|
83
|
+
this.querySelector("aside") ||
|
|
84
|
+
this.querySelector("menu");
|
|
85
|
+
if (this.triggerButton != null)
|
|
86
|
+
this.triggerButton.addEventListener("click", this.toggleMenu);
|
|
104
87
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
(() => {
|
|
109
|
-
const rootNode = this.getRootNode();
|
|
110
|
-
if (rootNode instanceof ShadowRoot || rootNode instanceof Document) {
|
|
111
|
-
return rootNode.querySelector(this.target);
|
|
112
|
-
}
|
|
113
|
-
return null;
|
|
114
|
-
})() ||
|
|
115
|
-
document.querySelector(this.target) ||
|
|
116
|
-
document);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
return this.parentElement;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
context() {
|
|
123
|
-
return html `${this.expanded ? html `<slot></slot>` : ''}`;
|
|
88
|
+
closeMenu() {
|
|
89
|
+
this.isOpen = false;
|
|
90
|
+
this.menuContainer.classList.remove("open");
|
|
124
91
|
}
|
|
125
|
-
|
|
126
|
-
|
|
92
|
+
async updateMenuPosition() {
|
|
93
|
+
const { x, y } = await computePosition(this.triggerButton, this.menuContainer, {
|
|
94
|
+
placement: this.placement,
|
|
95
|
+
middleware: this.middleware,
|
|
96
|
+
});
|
|
97
|
+
Object.assign(this.menuContainer.style, {
|
|
98
|
+
left: `${x}px`,
|
|
99
|
+
top: `${y}px`,
|
|
100
|
+
});
|
|
127
101
|
}
|
|
128
102
|
render() {
|
|
129
|
-
|
|
130
|
-
case 'side': return this.side();
|
|
131
|
-
case 'context': return this.context();
|
|
132
|
-
}
|
|
103
|
+
return html `<slot></slot>`;
|
|
133
104
|
}
|
|
134
|
-
}
|
|
105
|
+
}
|
|
135
106
|
__decorate([
|
|
136
107
|
property({ type: String }),
|
|
137
108
|
__metadata("design:type", String)
|
|
138
|
-
], QboMenu.prototype, "
|
|
139
|
-
__decorate([
|
|
140
|
-
property({ type: Boolean }),
|
|
141
|
-
__metadata("design:type", Boolean)
|
|
142
|
-
], QboMenu.prototype, "expanded", void 0);
|
|
109
|
+
], QboMenu.prototype, "placement", void 0);
|
|
143
110
|
__decorate([
|
|
144
|
-
|
|
111
|
+
state(),
|
|
145
112
|
__metadata("design:type", Object)
|
|
146
|
-
], QboMenu.prototype, "
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
113
|
+
], QboMenu.prototype, "isOpen", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
query("slot"),
|
|
116
|
+
__metadata("design:type", HTMLSlotElement)
|
|
117
|
+
], QboMenu.prototype, "slotElement", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
query('slot[name="menu"]'),
|
|
120
|
+
__metadata("design:type", HTMLSlotElement)
|
|
121
|
+
], QboMenu.prototype, "menuSlotElement", void 0);
|
|
122
|
+
if (!customElements.get("qbo-menu"))
|
|
123
|
+
customElements.define("qbo-menu", QboMenu);
|