@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.
- package/package.json +52 -0
- package/readme.md +456 -0
- package/src/qbo/Program.d.ts +18 -0
- package/src/qbo/Program.js +18 -0
- package/src/qbo/Program.ts +19 -0
- package/src/qbo/qbo-api.d.ts +27 -0
- package/src/qbo/qbo-api.js +96 -0
- package/src/qbo/qbo-api.ts +106 -0
- package/src/qbo/qbo-badge.d.ts +32 -0
- package/src/qbo/qbo-badge.js +93 -0
- package/src/qbo/qbo-badge.js.map +1 -0
- package/src/qbo/qbo-badge.ts +80 -0
- package/src/qbo/qbo-breadcrumb.d.ts +23 -0
- package/src/qbo/qbo-breadcrumb.js +132 -0
- package/src/qbo/qbo-breadcrumb.ts +96 -0
- package/src/qbo/qbo-datalist.d.ts +22 -0
- package/src/qbo/qbo-datalist.js +126 -0
- package/src/qbo/qbo-datalist.ts +104 -0
- package/src/qbo/qbo-docviewer.d.ts +15 -0
- package/src/qbo/qbo-docviewer.js +55 -0
- package/src/qbo/qbo-docviewer.ts +39 -0
- package/src/qbo/qbo-fetch.d.ts +29 -0
- package/src/qbo/qbo-fetch.js +134 -0
- package/src/qbo/qbo-fetch.ts +127 -0
- package/src/qbo/qbo-json.d.ts +8 -0
- package/src/qbo/qbo-json.js +85 -0
- package/src/qbo/qbo-json.ts +92 -0
- package/src/qbo/qbo-link.d.ts +15 -0
- package/src/qbo/qbo-link.js +48 -0
- package/src/qbo/qbo-link.js.map +1 -0
- package/src/qbo/qbo-link.ts +34 -0
- package/src/qbo/qbo-logging.d.ts +13 -0
- package/src/qbo/qbo-logging.js +92 -0
- package/src/qbo/qbo-logging.ts +72 -0
- package/src/qbo/qbo-mainmenu.d.ts +41 -0
- package/src/qbo/qbo-mainmenu.js +307 -0
- package/src/qbo/qbo-mainmenu.ts +263 -0
- package/src/qbo/qbo-markdown.d.ts +9 -0
- package/src/qbo/qbo-markdown.js +33 -0
- package/src/qbo/qbo-markdown.js.map +1 -0
- package/src/qbo/qbo-markdown.ts +22 -0
- package/src/qbo/qbo-microphone.d.ts +31 -0
- package/src/qbo/qbo-microphone.js +149 -0
- package/src/qbo/qbo-microphone.js.map +1 -0
- package/src/qbo/qbo-microphone.ts +137 -0
- package/src/qbo/qbo-popover.d.ts +8 -0
- package/src/qbo/qbo-popover.js +41 -0
- package/src/qbo/qbo-popover.ts +26 -0
- package/src/qbo/qbo-popup-listener.d.ts +25 -0
- package/src/qbo/qbo-popup-listener.js +145 -0
- package/src/qbo/qbo-popup-listener.ts +129 -0
- package/src/qbo/qbo-popup.d.ts +19 -0
- package/src/qbo/qbo-popup.js +95 -0
- package/src/qbo/qbo-popup.ts +84 -0
- package/src/qbo/qbo-select.d.ts +22 -0
- package/src/qbo/qbo-select.js +87 -0
- package/src/qbo/qbo-select.ts +65 -0
- package/src/qbo/qbo-sidebar.d.ts +10 -0
- package/src/qbo/qbo-sidebar.js +65 -0
- package/src/qbo/qbo-sidebar.ts +41 -0
- package/src/qbo/qbo-table.d.ts +23 -0
- package/src/qbo/qbo-table.js +94 -0
- package/src/qbo/qbo-table.js.map +1 -0
- package/src/qbo/qbo-table.ts +80 -0
- package/src/qbo/qbo-validate.d.ts +20 -0
- package/src/qbo/qbo-validate.js +92 -0
- package/src/qbo/qbo-validate.js.map +1 -0
- package/src/qbo/qbo-validate.ts +77 -0
- package/src/qbo/qbo-validators.d.ts +37 -0
- package/src/qbo/qbo-validators.js +72 -0
- package/src/qbo/qbo-validators.ts +66 -0
- package/src/qbo/styles.d.ts +3 -0
- package/src/qbo/styles.js +27 -0
- package/src/qbo/styles.ts +30 -0
- package/src/qbo-code/qbo-code.d.ts +12 -0
- package/src/qbo-code/qbo-code.js +54 -0
- package/src/qbo-code/qbo-code.ts +40 -0
- package/src/qbo-flowchart/qbo-flowchart.d.ts +45 -0
- package/src/qbo-flowchart/qbo-flowchart.js +309 -0
- package/src/qbo-flowchart/qbo-flowchart.js.map +1 -0
- package/src/qbo-flowchart/qbo-flowchart.ts +320 -0
- package/src/qbo-flowchart/readme.md +2 -0
- package/wwwroot/js/qbo4.ui-code.js +37965 -0
- package/wwwroot/js/qbo4.ui-code.min.js +3 -0
- package/wwwroot/js/qbo4.ui-code.min.js.LICENSE.txt +32 -0
- package/wwwroot/js/qbo4.ui-code.min.js.map +1 -0
- package/wwwroot/js/qbo4.ui-flowchart.js +44909 -0
- package/wwwroot/js/qbo4.ui-flowchart.min.js +9 -0
- package/wwwroot/js/qbo4.ui-flowchart.min.js.LICENSE.txt +43 -0
- package/wwwroot/js/qbo4.ui-flowchart.min.js.map +1 -0
- package/wwwroot/js/qbo4.ui.js +18840 -0
- package/wwwroot/js/qbo4.ui.min.js +108 -0
- package/wwwroot/js/qbo4.ui.min.js.LICENSE.txt +53 -0
- package/wwwroot/js/qbo4.ui.min.js.map +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { QboFetch } from './qbo-fetch.js';
|
|
2
|
+
export declare class QboDataList extends QboFetch {
|
|
3
|
+
listId: null;
|
|
4
|
+
min: number;
|
|
5
|
+
options: Array<{
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
}> | null;
|
|
8
|
+
renderInHost: boolean;
|
|
9
|
+
text: string | null;
|
|
10
|
+
value: string | null;
|
|
11
|
+
fetchOnLoad: boolean;
|
|
12
|
+
endpoint: String | null | undefined;
|
|
13
|
+
headers: any | null | undefined;
|
|
14
|
+
payload: any | null;
|
|
15
|
+
targets: NodeListOf<Element> | null;
|
|
16
|
+
connectedCallback(): void;
|
|
17
|
+
disconnectedCallback(): void;
|
|
18
|
+
createRenderRoot(): Element | ShadowRoot;
|
|
19
|
+
buildDataList(e: any): Promise<void>;
|
|
20
|
+
setOutputValue(e: any): void;
|
|
21
|
+
render(): import("lit").TemplateResult<1>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
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 } from 'lit';
|
|
11
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
12
|
+
import { getArray } from './qbo-json.js';
|
|
13
|
+
import { QboFetch } from './qbo-fetch.js';
|
|
14
|
+
let QboDataList = class QboDataList extends QboFetch {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.listId = null;
|
|
18
|
+
this.min = 3;
|
|
19
|
+
this.options = [];
|
|
20
|
+
this.renderInHost = true;
|
|
21
|
+
this.text = null;
|
|
22
|
+
this.value = null;
|
|
23
|
+
this.fetchOnLoad = false;
|
|
24
|
+
this.endpoint = null;
|
|
25
|
+
this.headers = null;
|
|
26
|
+
this.payload = {};
|
|
27
|
+
this.targets = null;
|
|
28
|
+
}
|
|
29
|
+
connectedCallback() {
|
|
30
|
+
super.connectedCallback();
|
|
31
|
+
this.targets = document.querySelectorAll(`input[list=${this.listId}]`);
|
|
32
|
+
const el = this;
|
|
33
|
+
this.targets.forEach(function (target) {
|
|
34
|
+
target.addEventListener('keyup', el.buildDataList.bind(el));
|
|
35
|
+
if (target.hasAttribute('data-for'))
|
|
36
|
+
target.addEventListener('change', el.setOutputValue.bind(el));
|
|
37
|
+
});
|
|
38
|
+
this.endpoint = this.apiEndpoint.toString();
|
|
39
|
+
this.headers = this.getHeaders();
|
|
40
|
+
this.payload = this.getPayload(this.headers);
|
|
41
|
+
}
|
|
42
|
+
disconnectedCallback() {
|
|
43
|
+
const el = this;
|
|
44
|
+
this.targets?.forEach(function (target) {
|
|
45
|
+
target.removeEventListener('keyup', el.buildDataList.bind(el));
|
|
46
|
+
if (target.hasAttribute('data-for'))
|
|
47
|
+
target.removeEventListener('change', el.setOutputValue.bind(el));
|
|
48
|
+
});
|
|
49
|
+
super.disconnectedCallback();
|
|
50
|
+
}
|
|
51
|
+
createRenderRoot() {
|
|
52
|
+
return this.renderInHost ? this : super.createRenderRoot();
|
|
53
|
+
}
|
|
54
|
+
async buildDataList(e) {
|
|
55
|
+
const target = e.target;
|
|
56
|
+
if (target instanceof HTMLInputElement) {
|
|
57
|
+
if (target.value.length >= this.min) {
|
|
58
|
+
if (this.endpoint != null)
|
|
59
|
+
this.apiEndpoint = new URL(this.endpoint.replace('{value}', `${target.value}`), this.baseURI);
|
|
60
|
+
await this.fetchData(this.headers, this.payload);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
setOutputValue(e) {
|
|
65
|
+
const target = e.target;
|
|
66
|
+
let targetFor = null;
|
|
67
|
+
if (target.hasAttribute('data-for')) {
|
|
68
|
+
const attribute = target.getAttribute('data-for');
|
|
69
|
+
targetFor = document.getElementById(attribute)
|
|
70
|
+
|| target.querySelector(attribute)
|
|
71
|
+
|| target.parentElement?.querySelector(attribute)
|
|
72
|
+
|| document.getElementsByName(attribute)[0];
|
|
73
|
+
}
|
|
74
|
+
if (target instanceof HTMLInputElement && targetFor instanceof HTMLInputElement) {
|
|
75
|
+
const text = this.text;
|
|
76
|
+
const result = this.options?.filter(function (j) { return j[text] == target.value; });
|
|
77
|
+
target.value = result?.length == 1 ? result[0][`${this.text}`] : '';
|
|
78
|
+
targetFor.value = result?.length == 1 ? result[0][`${this.value}`] : '';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
render() {
|
|
82
|
+
this.options = getArray(this.jsonData);
|
|
83
|
+
if (!this.options || this.options.length === 0)
|
|
84
|
+
return html ``;
|
|
85
|
+
if (this.options != null) {
|
|
86
|
+
this.value ??= Object.keys(this.options[0])[0];
|
|
87
|
+
this.text ??= Object.keys(this.options[0])[1] ?? this.value;
|
|
88
|
+
}
|
|
89
|
+
return html `
|
|
90
|
+
<datalist id=${this.listId}>
|
|
91
|
+
${this.options.map(option => html `<option value="${option[this.text]}" data-value="${option[this.value]}"/>`)}
|
|
92
|
+
</datalist>`;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
__decorate([
|
|
96
|
+
property({ type: String }),
|
|
97
|
+
__metadata("design:type", Object)
|
|
98
|
+
], QboDataList.prototype, "listId", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
property({ type: Number }),
|
|
101
|
+
__metadata("design:type", Object)
|
|
102
|
+
], QboDataList.prototype, "min", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
property({ type: Array }),
|
|
105
|
+
__metadata("design:type", Object)
|
|
106
|
+
], QboDataList.prototype, "options", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
property({ type: Boolean }),
|
|
109
|
+
__metadata("design:type", Object)
|
|
110
|
+
], QboDataList.prototype, "renderInHost", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
property({ type: String }),
|
|
113
|
+
__metadata("design:type", Object)
|
|
114
|
+
], QboDataList.prototype, "text", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: String }),
|
|
117
|
+
__metadata("design:type", Object)
|
|
118
|
+
], QboDataList.prototype, "value", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
property({ type: Boolean }),
|
|
121
|
+
__metadata("design:type", Object)
|
|
122
|
+
], QboDataList.prototype, "fetchOnLoad", void 0);
|
|
123
|
+
QboDataList = __decorate([
|
|
124
|
+
customElement('qbo-datalist')
|
|
125
|
+
], QboDataList);
|
|
126
|
+
export { QboDataList };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { html, PropertyValues } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { getArray } from './qbo-json.js';
|
|
4
|
+
import { QboFetch } from './qbo-fetch.js';
|
|
5
|
+
|
|
6
|
+
@customElement('qbo-datalist')
|
|
7
|
+
export class QboDataList extends QboFetch {
|
|
8
|
+
|
|
9
|
+
@property({ type: String })
|
|
10
|
+
listId = null;
|
|
11
|
+
|
|
12
|
+
@property({ type: Number })
|
|
13
|
+
min = 3;
|
|
14
|
+
|
|
15
|
+
@property({ type: Array })
|
|
16
|
+
options: Array<{ [key: string]: string }> | null = [];
|
|
17
|
+
|
|
18
|
+
@property({ type: Boolean })
|
|
19
|
+
renderInHost = true;
|
|
20
|
+
|
|
21
|
+
@property({ type: String })
|
|
22
|
+
text: string | null = null;
|
|
23
|
+
|
|
24
|
+
@property({ type: String })
|
|
25
|
+
value: string | null = null;
|
|
26
|
+
|
|
27
|
+
@property({ type: Boolean })
|
|
28
|
+
fetchOnLoad = false;
|
|
29
|
+
|
|
30
|
+
endpoint: String | null | undefined = null;
|
|
31
|
+
|
|
32
|
+
headers: any | null | undefined = null;
|
|
33
|
+
|
|
34
|
+
payload: any | null = {};
|
|
35
|
+
|
|
36
|
+
targets: NodeListOf<Element> | null = null
|
|
37
|
+
|
|
38
|
+
connectedCallback() {
|
|
39
|
+
super.connectedCallback();
|
|
40
|
+
this.targets = document.querySelectorAll(`input[list=${this.listId}]`);
|
|
41
|
+
const el = this;
|
|
42
|
+
this.targets.forEach(function (target) {
|
|
43
|
+
target.addEventListener('keyup', el.buildDataList.bind(el));
|
|
44
|
+
if (target.hasAttribute('data-for')) target.addEventListener('change', el.setOutputValue.bind(el));
|
|
45
|
+
});
|
|
46
|
+
this.endpoint = this.apiEndpoint.toString();
|
|
47
|
+
this.headers = this.getHeaders();
|
|
48
|
+
this.payload = this.getPayload(this.headers);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
disconnectedCallback() {
|
|
52
|
+
const el = this;
|
|
53
|
+
this.targets?.forEach(function (target) {
|
|
54
|
+
target.removeEventListener('keyup', el.buildDataList.bind(el));
|
|
55
|
+
if (target.hasAttribute('data-for')) target.removeEventListener('change', el.setOutputValue.bind(el));
|
|
56
|
+
});
|
|
57
|
+
super.disconnectedCallback();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
createRenderRoot() {
|
|
61
|
+
return this.renderInHost ? this : super.createRenderRoot();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async buildDataList(e: any) {
|
|
65
|
+
const target = e.target;
|
|
66
|
+
if (target instanceof HTMLInputElement) {
|
|
67
|
+
if (target.value.length >= this.min) {
|
|
68
|
+
if (this.endpoint != null) this.apiEndpoint = new URL(this.endpoint.replace('{value}', `${target.value}`), this.baseURI);
|
|
69
|
+
await this.fetchData(this.headers, this.payload);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setOutputValue(e: any) {
|
|
75
|
+
const target = e.target;
|
|
76
|
+
let targetFor: HTMLInputElement | null = null;
|
|
77
|
+
if (target.hasAttribute('data-for')) {
|
|
78
|
+
const attribute = target.getAttribute('data-for');
|
|
79
|
+
targetFor = document.getElementById(attribute)
|
|
80
|
+
|| target.querySelector(attribute)
|
|
81
|
+
|| target.parentElement?.querySelector(attribute)
|
|
82
|
+
|| document.getElementsByName(attribute)![0];
|
|
83
|
+
}
|
|
84
|
+
if (target instanceof HTMLInputElement && targetFor instanceof HTMLInputElement) {
|
|
85
|
+
const text = this.text;
|
|
86
|
+
const result = this.options?.filter(function (j) { return j[text!] == target.value; });
|
|
87
|
+
target.value = result?.length == 1 ? result[0][`${this.text}`] : '';
|
|
88
|
+
targetFor.value = result?.length == 1 ? result[0][`${this.value}`] : '';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
render() {
|
|
93
|
+
this.options = getArray(this.jsonData);
|
|
94
|
+
if (!this.options || this.options.length === 0) return html``;
|
|
95
|
+
if (this.options != null) {
|
|
96
|
+
this.value ??= Object.keys(this.options[0])[0];
|
|
97
|
+
this.text ??= Object.keys(this.options[0])[1] ?? this.value;
|
|
98
|
+
}
|
|
99
|
+
return html`
|
|
100
|
+
<datalist id=${this.listId}>
|
|
101
|
+
${this.options.map(option => html`<option value="${option[this.text!]}" data-value="${option[this.value!]}"/>`)}
|
|
102
|
+
</datalist>`;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { QboFetch } from './qbo-fetch.js';
|
|
2
|
+
/**
|
|
3
|
+
* Renders a <select> element with options populated from a JSON array.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This element is a thin wrapper around {@link QboFetch} that renders a <select> element with options populated from a JSON array.
|
|
7
|
+
*/
|
|
8
|
+
export declare class QboDocViewer extends QboFetch {
|
|
9
|
+
open: boolean;
|
|
10
|
+
loading: boolean;
|
|
11
|
+
renderInHost: boolean;
|
|
12
|
+
static styles: import("lit").CSSResult[];
|
|
13
|
+
connectedCallback(): Promise<void>;
|
|
14
|
+
render(): import("lit").TemplateResult<1>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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, css } from 'lit';
|
|
11
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
12
|
+
import { QboFetch } from './qbo-fetch.js';
|
|
13
|
+
/**
|
|
14
|
+
* Renders a <select> element with options populated from a JSON array.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* This element is a thin wrapper around {@link QboFetch} that renders a <select> element with options populated from a JSON array.
|
|
18
|
+
*/
|
|
19
|
+
let QboDocViewer = class QboDocViewer extends QboFetch {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.open = false;
|
|
23
|
+
this.loading = false;
|
|
24
|
+
this.renderInHost = false;
|
|
25
|
+
}
|
|
26
|
+
// container: HTMLElement;
|
|
27
|
+
static { this.styles = [
|
|
28
|
+
css `
|
|
29
|
+
/* Add any custom styles here */
|
|
30
|
+
.foo { color: red; }
|
|
31
|
+
`
|
|
32
|
+
]; }
|
|
33
|
+
async connectedCallback() {
|
|
34
|
+
super.connectedCallback();
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
return html `<iframe src='sample.pdf' width='100%' height='800px' frameborder='0'></iframe>`;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
__decorate([
|
|
41
|
+
property({ type: Boolean }),
|
|
42
|
+
__metadata("design:type", Object)
|
|
43
|
+
], QboDocViewer.prototype, "open", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
property({ type: Boolean }),
|
|
46
|
+
__metadata("design:type", Object)
|
|
47
|
+
], QboDocViewer.prototype, "loading", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
property({ type: Boolean }),
|
|
50
|
+
__metadata("design:type", Object)
|
|
51
|
+
], QboDocViewer.prototype, "renderInHost", void 0);
|
|
52
|
+
QboDocViewer = __decorate([
|
|
53
|
+
customElement('qbo-docviewer')
|
|
54
|
+
], QboDocViewer);
|
|
55
|
+
export { QboDocViewer };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { html, css } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { QboFetch } from './qbo-fetch.js';
|
|
4
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Renders a <select> element with options populated from a JSON array.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This element is a thin wrapper around {@link QboFetch} that renders a <select> element with options populated from a JSON array.
|
|
11
|
+
*/
|
|
12
|
+
@customElement('qbo-docviewer')
|
|
13
|
+
export class QboDocViewer extends QboFetch {
|
|
14
|
+
@property({ type: Boolean })
|
|
15
|
+
open = false;
|
|
16
|
+
|
|
17
|
+
@property({ type: Boolean })
|
|
18
|
+
loading = false;
|
|
19
|
+
|
|
20
|
+
@property({ type: Boolean })
|
|
21
|
+
renderInHost = false;
|
|
22
|
+
|
|
23
|
+
// container: HTMLElement;
|
|
24
|
+
|
|
25
|
+
static styles = [
|
|
26
|
+
css`
|
|
27
|
+
/* Add any custom styles here */
|
|
28
|
+
.foo { color: red; }
|
|
29
|
+
`
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
async connectedCallback() {
|
|
33
|
+
super.connectedCallback();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
render() {
|
|
37
|
+
return html`<iframe src='sample.pdf' width='100%' height='800px' frameborder='0'></iframe>`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class IFetch {
|
|
3
|
+
apiEndpoint: URL;
|
|
4
|
+
method: string;
|
|
5
|
+
error: boolean;
|
|
6
|
+
jsonData: any | null;
|
|
7
|
+
html: string | null;
|
|
8
|
+
protected fetchData(headers: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
}, payload: Object | null): Promise<void>;
|
|
11
|
+
protected getPayload(headers: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
}): any;
|
|
14
|
+
protected getHeaders(): {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
type Constructor<T = {}> = new (...args: any[]) => T;
|
|
19
|
+
export declare const QboFetchMixin: <T extends Constructor<LitElement>>(superClass: T) => Constructor<IFetch> & T;
|
|
20
|
+
/**
|
|
21
|
+
* Fetches Json data from an API endpoint.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* @param apiEndpoint - The API endpoint to fetch data from.
|
|
25
|
+
* @param method - The HTTP method to use when fetching data.
|
|
26
|
+
* @param error - Indicates whether an error occurred while fetching data.
|
|
27
|
+
*/
|
|
28
|
+
export declare const QboFetch: Constructor<IFetch> & typeof LitElement;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
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 } from 'lit';
|
|
11
|
+
import { property } from 'lit/decorators.js';
|
|
12
|
+
export const QboFetchMixin = (superClass) => {
|
|
13
|
+
class QboFetchClass extends superClass {
|
|
14
|
+
constructor(...args) {
|
|
15
|
+
super(...args);
|
|
16
|
+
this.apiEndpoint = null;
|
|
17
|
+
this.method = 'GET';
|
|
18
|
+
this.error = false;
|
|
19
|
+
this.jsonData = {};
|
|
20
|
+
this.accept = "application/json";
|
|
21
|
+
this.headerTag = 'script[name="headers"]';
|
|
22
|
+
this.html = null;
|
|
23
|
+
this.fetchOnLoad = true;
|
|
24
|
+
}
|
|
25
|
+
async connectedCallback() {
|
|
26
|
+
super.connectedCallback();
|
|
27
|
+
if (this.fetchOnLoad) {
|
|
28
|
+
const headers = this.getHeaders();
|
|
29
|
+
const payload = this.getPayload(headers);
|
|
30
|
+
await this.fetchData(headers, payload);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
getHeaders() {
|
|
34
|
+
const headerElement = this.querySelector(this.headerTag);
|
|
35
|
+
let headers = { "Accept": this.accept };
|
|
36
|
+
if (headerElement && headerElement.textContent !== null) {
|
|
37
|
+
try {
|
|
38
|
+
headers = JSON.parse(headerElement.textContent);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error('Error parsing header JSON:', error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return headers;
|
|
45
|
+
}
|
|
46
|
+
getPayload(headers) {
|
|
47
|
+
const payloadTag = this.querySelector('script[name="payload"]');
|
|
48
|
+
let payload = null;
|
|
49
|
+
if (payloadTag && payloadTag.textContent !== null) {
|
|
50
|
+
try {
|
|
51
|
+
payload = JSON.parse(payloadTag.textContent);
|
|
52
|
+
if (payload)
|
|
53
|
+
headers["Content-Type"] = "application/json";
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
console.error('Error parsing payload JSON:', error);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return payload;
|
|
60
|
+
}
|
|
61
|
+
/* @description Fetch data from an api, and set @see {@link html} or @see {@link jsonData} with the result. */
|
|
62
|
+
async fetchData(headers, payload) {
|
|
63
|
+
if (this.apiEndpoint === null)
|
|
64
|
+
return;
|
|
65
|
+
if (payload !== null)
|
|
66
|
+
this.method = 'POST';
|
|
67
|
+
try {
|
|
68
|
+
const response = await fetch(this.apiEndpoint, {
|
|
69
|
+
method: this.method,
|
|
70
|
+
headers: headers,
|
|
71
|
+
body: payload ? JSON.stringify(payload) : null
|
|
72
|
+
});
|
|
73
|
+
switch (this.accept) {
|
|
74
|
+
case "application/json":
|
|
75
|
+
this.jsonData = await response.json();
|
|
76
|
+
this.html = null;
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
this.html = await response.text();
|
|
80
|
+
this.jsonData = null;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
this.dispatchEvent(new CustomEvent('qbo-updated', { bubbles: true, composed: true }));
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
this.error = true;
|
|
87
|
+
dispatchEvent(new CustomEvent('qbo-error', { detail: err }));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
__decorate([
|
|
92
|
+
property({ type: URL }),
|
|
93
|
+
__metadata("design:type", Object)
|
|
94
|
+
], QboFetchClass.prototype, "apiEndpoint", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
property({ type: String }),
|
|
97
|
+
__metadata("design:type", Object)
|
|
98
|
+
], QboFetchClass.prototype, "method", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
property({ type: Boolean }),
|
|
101
|
+
__metadata("design:type", Object)
|
|
102
|
+
], QboFetchClass.prototype, "error", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
property({ type: Object }),
|
|
105
|
+
__metadata("design:type", Object)
|
|
106
|
+
], QboFetchClass.prototype, "jsonData", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
property({ type: String }),
|
|
109
|
+
__metadata("design:type", Object)
|
|
110
|
+
], QboFetchClass.prototype, "accept", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
property({ type: String }),
|
|
113
|
+
__metadata("design:type", Object)
|
|
114
|
+
], QboFetchClass.prototype, "headerTag", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: String }),
|
|
117
|
+
__metadata("design:type", Object)
|
|
118
|
+
], QboFetchClass.prototype, "html", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
property({ type: Boolean }),
|
|
121
|
+
__metadata("design:type", Object)
|
|
122
|
+
], QboFetchClass.prototype, "fetchOnLoad", void 0);
|
|
123
|
+
;
|
|
124
|
+
return QboFetchClass;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Fetches Json data from an API endpoint.
|
|
128
|
+
*
|
|
129
|
+
* @remarks
|
|
130
|
+
* @param apiEndpoint - The API endpoint to fetch data from.
|
|
131
|
+
* @param method - The HTTP method to use when fetching data.
|
|
132
|
+
* @param error - Indicates whether an error occurred while fetching data.
|
|
133
|
+
*/
|
|
134
|
+
export const QboFetch = QboFetchMixin(LitElement);
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
|
|
4
|
+
// Define the interface for the mixin
|
|
5
|
+
export declare class IFetch {
|
|
6
|
+
apiEndpoint: URL;
|
|
7
|
+
method: string;
|
|
8
|
+
error: boolean;
|
|
9
|
+
jsonData: any | null;
|
|
10
|
+
html: string | null;
|
|
11
|
+
protected fetchData(headers: { [key: string]: string; }, payload: Object | null): Promise<void>;
|
|
12
|
+
protected getPayload(headers: { [key: string]: string; });
|
|
13
|
+
protected getHeaders(): { [key: string]: string };
|
|
14
|
+
// protected createRenderRoot(): unknown;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Constructor<T = {}> = new (...args: any[]) => T;
|
|
18
|
+
|
|
19
|
+
export const QboFetchMixin = <T extends Constructor<LitElement>>(superClass: T) => {
|
|
20
|
+
class QboFetchClass extends superClass {
|
|
21
|
+
@property({ type: URL })
|
|
22
|
+
apiEndpoint = null;
|
|
23
|
+
|
|
24
|
+
@property({ type: String })
|
|
25
|
+
method = 'GET';
|
|
26
|
+
|
|
27
|
+
@property({ type: Boolean })
|
|
28
|
+
error = false;
|
|
29
|
+
|
|
30
|
+
@property({ type: Object })
|
|
31
|
+
jsonData: any | null = {};
|
|
32
|
+
|
|
33
|
+
@property({ type: String })
|
|
34
|
+
accept = "application/json";
|
|
35
|
+
|
|
36
|
+
@property({ type: String })
|
|
37
|
+
headerTag = 'script[name="headers"]';
|
|
38
|
+
|
|
39
|
+
@property({ type: String })
|
|
40
|
+
html: String | null = null;
|
|
41
|
+
|
|
42
|
+
@property({ type: Boolean })
|
|
43
|
+
fetchOnLoad = true;
|
|
44
|
+
|
|
45
|
+
constructor(...args: any[]) {
|
|
46
|
+
super(...args);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async connectedCallback() {
|
|
50
|
+
super.connectedCallback();
|
|
51
|
+
|
|
52
|
+
if (this.fetchOnLoad) {
|
|
53
|
+
const headers = this.getHeaders();
|
|
54
|
+
const payload = this.getPayload(headers);
|
|
55
|
+
await this.fetchData(headers, payload);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getHeaders() {
|
|
60
|
+
const headerElement = this.querySelector(this.headerTag);
|
|
61
|
+
let headers: { [key: string]: string } = { "Accept": this.accept };
|
|
62
|
+
if (headerElement && headerElement.textContent !== null) {
|
|
63
|
+
try {
|
|
64
|
+
headers = JSON.parse(headerElement.textContent);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error('Error parsing header JSON:', error);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return headers;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getPayload(headers: { [key: string]: string; }) {
|
|
73
|
+
const payloadTag = this.querySelector('script[name="payload"]');
|
|
74
|
+
let payload: Object | null = null;
|
|
75
|
+
if (payloadTag && payloadTag.textContent !== null) {
|
|
76
|
+
try {
|
|
77
|
+
payload = JSON.parse(payloadTag.textContent);
|
|
78
|
+
if (payload)
|
|
79
|
+
headers["Content-Type"] = "application/json";
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error('Error parsing payload JSON:', error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return payload;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* @description Fetch data from an api, and set @see {@link html} or @see {@link jsonData} with the result. */
|
|
88
|
+
async fetchData(headers: { [key: string]: string; }, payload: Object | null) {
|
|
89
|
+
if (this.apiEndpoint === null) return;
|
|
90
|
+
if (payload !== null)
|
|
91
|
+
this.method = 'POST';
|
|
92
|
+
try {
|
|
93
|
+
const response = await fetch(this.apiEndpoint, {
|
|
94
|
+
method: this.method,
|
|
95
|
+
headers: headers,
|
|
96
|
+
body: payload ? JSON.stringify(payload) : null
|
|
97
|
+
});
|
|
98
|
+
switch (this.accept) {
|
|
99
|
+
case "application/json":
|
|
100
|
+
this.jsonData = await response.json();
|
|
101
|
+
this.html = null;
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
this.html = await response.text();
|
|
105
|
+
this.jsonData = null;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
this.dispatchEvent(new CustomEvent('qbo-updated', { bubbles: true, composed: true }));
|
|
109
|
+
} catch (err) {
|
|
110
|
+
this.error = true;
|
|
111
|
+
dispatchEvent(new CustomEvent('qbo-error', { detail: err }));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return QboFetchClass as unknown as Constructor<IFetch> & T;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Fetches Json data from an API endpoint.
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* @param apiEndpoint - The API endpoint to fetch data from.
|
|
124
|
+
* @param method - The HTTP method to use when fetching data.
|
|
125
|
+
* @param error - Indicates whether an error occurred while fetching data.
|
|
126
|
+
*/
|
|
127
|
+
export const QboFetch = QboFetchMixin(LitElement);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare function getArray(json: any, arrayName?: string): Array<{
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}> | null;
|
|
4
|
+
declare function substitute(inputString: string, ...jsonData: any): string;
|
|
5
|
+
declare function replicate(target: HTMLElement | null, template: HTMLTemplateElement | null, sourceData: Array<{
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
}>, emptyContent?: boolean): void;
|
|
8
|
+
export { getArray, substitute, replicate };
|