@quandis/qbo4.ui 4.0.1-CI-20240429-225952 → 4.0.1-CI-20240430-215338

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.
@@ -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
@@ -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() {