@quandis/qbo4.ui 4.0.1-CI-20240429-225952 → 4.0.1-CI-20240501-230003

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.
@@ -72,6 +72,8 @@ let QboFormElement = class QboFormElement extends LitElement {
72
72
  }
73
73
  establishFormData() {
74
74
  const elements = this.shadowRoot?.querySelectorAll('input, select, textarea');
75
+ if (!elements || elements?.length === 0)
76
+ return;
75
77
  const inputs = Array.from(elements).filter(e => !e.assignedSlot
76
78
  && (e instanceof HTMLInputElement
77
79
  || e instanceof HTMLSelectElement
@@ -60,6 +60,7 @@ export class QboFormElement extends LitElement {
60
60
 
61
61
  establishFormData() {
62
62
  const elements = this.shadowRoot?.querySelectorAll('input, select, textarea');
63
+ if (!elements || elements?.length === 0) return;
63
64
  const inputs = Array.from(elements!).filter(e => !e.assignedSlot
64
65
  && (e instanceof HTMLInputElement
65
66
  || e instanceof HTMLSelectElement
@@ -182,20 +182,20 @@ let QboMainMenu = class QboMainMenu extends QboFetch {
182
182
  </li>`;
183
183
  }
184
184
  render() {
185
- if (this.jsonData.MainMenu) {
185
+ if (this.jsonData && this.jsonData.Root && this.jsonData.Root.MainMenu) {
186
186
  return html `
187
187
  <nav class="${this.navClass}">
188
188
  <div>
189
189
  <a href="#">
190
- ${this.renderImage(this.jsonData.MainMenu.Image)}
191
- ${this.jsonData.MainMenu.Label}
190
+ ${this.renderImage(this.jsonData.Root.MainMenu.Image)}
191
+ ${this.jsonData.Root.MainMenu.Label}
192
192
  </a>
193
193
  <button type="${this.buttonType}" data-bs-toggle="${this.collapseToggle}" data-bs-target="#${this.dropdownId}" aria-expanded="${this.ariaExpanded}" aria-label="${this.ariaLabel}">
194
194
  <span/>
195
195
  </button>
196
196
  <div id="${this.dropdownId}">
197
197
  <ul>
198
- ${this.renderMenu(this.jsonData.MainMenu, false, false)}
198
+ ${this.renderMenu(this.jsonData.Root.MainMenu, false, false)}
199
199
  </ul>
200
200
  </div>
201
201
  </div>
@@ -238,20 +238,20 @@ export class QboMainMenu extends QboFetch {
238
238
  }
239
239
 
240
240
  render() {
241
- if (this.jsonData.MainMenu) {
241
+ if (this.jsonData && this.jsonData.Root && this.jsonData.Root.MainMenu) {
242
242
  return html`
243
243
  <nav class="${this.navClass}">
244
244
  <div>
245
245
  <a href="#">
246
- ${this.renderImage(this.jsonData.MainMenu.Image)}
247
- ${this.jsonData.MainMenu.Label}
246
+ ${this.renderImage(this.jsonData.Root.MainMenu.Image)}
247
+ ${this.jsonData.Root.MainMenu.Label}
248
248
  </a>
249
249
  <button type="${this.buttonType}" data-bs-toggle="${this.collapseToggle}" data-bs-target="#${this.dropdownId}" aria-expanded="${this.ariaExpanded}" aria-label="${this.ariaLabel}">
250
250
  <span/>
251
251
  </button>
252
252
  <div id="${this.dropdownId}">
253
253
  <ul>
254
- ${this.renderMenu(this.jsonData.MainMenu, false, false)}
254
+ ${this.renderMenu(this.jsonData.Root.MainMenu, false, false)}
255
255
  </ul>
256
256
  </div>
257
257
  </div>
@@ -1,11 +1,12 @@
1
- import { QboFetch } from './qbo-fetch.js';
1
+ import { QboFormElement } from './Program.js';
2
2
  /**
3
3
  * Renders a <select> element with options populated from a JSON array.
4
4
  *
5
5
  * @remarks
6
6
  * This element is a thin wrapper around {@link QboFetch} that renders a <select> element with options populated from a JSON array.
7
7
  */
8
- export declare class QboSelect extends QboFetch {
8
+ export declare class QboSelect extends QboFormElement {
9
+ apiEndpoint: string;
9
10
  loading: boolean;
10
11
  optionText: string | null;
11
12
  optionValue: string | null;
@@ -15,6 +16,7 @@ export declare class QboSelect extends QboFetch {
15
16
  options: Array<{
16
17
  [key: string]: string;
17
18
  }> | null;
19
+ jsonData: any | null;
18
20
  renderInHost: boolean;
19
21
  static styles: import("lit").CSSResult[];
20
22
  connectedCallback(): Promise<void>;
@@ -10,16 +10,17 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  import { html, css } from 'lit';
11
11
  import { customElement, property } from 'lit/decorators.js';
12
12
  import { getArray } from './qbo-json.js';
13
- import { QboFetch } from './qbo-fetch.js';
13
+ import { QboFormElement, getApiService } from './Program.js';
14
14
  /**
15
15
  * Renders a <select> element with options populated from a JSON array.
16
16
  *
17
17
  * @remarks
18
18
  * This element is a thin wrapper around {@link QboFetch} that renders a <select> element with options populated from a JSON array.
19
19
  */
20
- let QboSelect = class QboSelect extends QboFetch {
20
+ let QboSelect = class QboSelect extends QboFormElement {
21
21
  constructor() {
22
22
  super(...arguments);
23
+ this.apiEndpoint = 'qbo';
23
24
  this.loading = false;
24
25
  this.optionText = null;
25
26
  this.optionValue = null;
@@ -27,6 +28,7 @@ let QboSelect = class QboSelect extends QboFetch {
27
28
  this.emptyOptionText = '--';
28
29
  this.emptyOptionValue = '';
29
30
  this.options = [];
31
+ this.jsonData = {};
30
32
  this.renderInHost = true;
31
33
  }
32
34
  static { this.styles = [
@@ -38,6 +40,8 @@ let QboSelect = class QboSelect extends QboFetch {
38
40
  async connectedCallback() {
39
41
  this.optionText ??= this.optionValue;
40
42
  super.connectedCallback();
43
+ const service = getApiService(this.apiEndpoint);
44
+ this.jsonData = await service.fetch(null, {});
41
45
  }
42
46
  createRenderRoot() {
43
47
  return this.renderInHost ? this : super.createRenderRoot();
@@ -54,6 +58,10 @@ let QboSelect = class QboSelect extends QboFetch {
54
58
  </select>`;
55
59
  }
56
60
  };
61
+ __decorate([
62
+ property({ type: String }),
63
+ __metadata("design:type", Object)
64
+ ], QboSelect.prototype, "apiEndpoint", void 0);
57
65
  __decorate([
58
66
  property({ type: Boolean }),
59
67
  __metadata("design:type", Object)
@@ -82,6 +90,10 @@ __decorate([
82
90
  property({ type: Array }),
83
91
  __metadata("design:type", Object)
84
92
  ], QboSelect.prototype, "options", void 0);
93
+ __decorate([
94
+ property({ type: Object }),
95
+ __metadata("design:type", Object)
96
+ ], QboSelect.prototype, "jsonData", void 0);
85
97
  __decorate([
86
98
  property({ type: Boolean }),
87
99
  __metadata("design:type", Object)
@@ -2,6 +2,7 @@
2
2
  import { customElement, property } from 'lit/decorators.js';
3
3
  import { getArray } from './qbo-json.js';
4
4
  import { QboFetch } from './qbo-fetch.js';
5
+ import { IApiService, QboFormElement, getApiService } from './Program.js';
5
6
 
6
7
  /**
7
8
  * Renders a <select> element with options populated from a JSON array.
@@ -10,8 +11,11 @@ import { QboFetch } from './qbo-fetch.js';
10
11
  * This element is a thin wrapper around {@link QboFetch} that renders a <select> element with options populated from a JSON array.
11
12
  */
12
13
  @customElement('qbo-select')
13
- export class QboSelect extends QboFetch
14
+ export class QboSelect extends QboFormElement
14
15
  {
16
+ @property({ type: String })
17
+ apiEndpoint = 'qbo';
18
+
15
19
  @property({ type: Boolean })
16
20
  loading = false;
17
21
 
@@ -33,6 +37,9 @@ export class QboSelect extends QboFetch
33
37
  @property({ type: Array })
34
38
  options: Array<{ [key: string]: string }> | null = [];
35
39
 
40
+ @property({ type: Object })
41
+ jsonData: any | null = {};
42
+
36
43
  @property({ type: Boolean })
37
44
  renderInHost = true;
38
45
 
@@ -46,6 +53,9 @@ export class QboSelect extends QboFetch
46
53
  async connectedCallback() {
47
54
  this.optionText ??= this.optionValue;
48
55
  super.connectedCallback();
56
+
57
+ const service: IApiService = getApiService(this.apiEndpoint);
58
+ this.jsonData = await service.fetch(null, { });
49
59
  }
50
60
 
51
61
  createRenderRoot() {