@dile/crud 2.2.5 → 2.2.7

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.
@@ -1,5 +1,6 @@
1
1
  import { LitElement, html, css } from 'lit';
2
2
  import '@dile/ui/components/switch/switch.js';
3
+ import '@dile/ui/components/spinner/spinner-icon.js';
3
4
  import '../../ajax/ajax.js';
4
5
  import { RequestApiAdapter } from '../../../lib/RequestApiAdapter.js';
5
6
 
@@ -9,6 +10,14 @@ export class DileAjaxSwitch extends LitElement {
9
10
  :host {
10
11
  display: block;
11
12
  }
13
+ .switch-container {
14
+ display: flex;
15
+ align-items: center;
16
+ gap: 8px;
17
+ }
18
+ dile-spinner-icon {
19
+ flex-shrink: 0;
20
+ }
12
21
  `
13
22
  ];
14
23
 
@@ -18,7 +27,7 @@ export class DileAjaxSwitch extends LitElement {
18
27
  endpoint: { type: String },
19
28
  checkedLabel: { type: String },
20
29
  uncheckedLabel: { type: String },
21
- loading: { type: Boolean },
30
+ loading: { type: Boolean, reflect: true },
22
31
  method: { type: String },
23
32
  requestApiAdapter: { type: Object },
24
33
  };
@@ -28,6 +37,7 @@ export class DileAjaxSwitch extends LitElement {
28
37
  super();
29
38
  this.requestApiAdapter = new RequestApiAdapter();
30
39
  this.method = 'patch';
40
+ this.loading = false;
31
41
  }
32
42
 
33
43
  render() {
@@ -39,14 +49,17 @@ export class DileAjaxSwitch extends LitElement {
39
49
  @ajax-success="${this.doSuccessAjax}"
40
50
  @ajax-error="${this.doErrorAjax}"
41
51
  ></dile-ajax>
42
- <dile-switch
43
- ?disabled=${this.loading}
44
- ?checked=${this.value}
45
- useReactiveLabels
46
- checkedLabel="${this.checkedLabel}"
47
- uncheckedLabel="${this.uncheckedLabel}"
48
- @dile-switch-changed=${this.save}
49
- ></dile-switch>
52
+ <div class="switch-container">
53
+ <dile-switch
54
+ ?disabled=${this.loading}
55
+ ?checked=${this.value}
56
+ useReactiveLabels
57
+ checkedLabel="${this.checkedLabel}"
58
+ uncheckedLabel="${this.uncheckedLabel}"
59
+ @dile-switch-changed=${this.save}
60
+ ></dile-switch>
61
+ <dile-spinner-icon ?active=${this.loading}></dile-spinner-icon>
62
+ </div>
50
63
  `;
51
64
  }
52
65
 
@@ -63,13 +76,23 @@ export class DileAjaxSwitch extends LitElement {
63
76
  }
64
77
  }
65
78
 
66
- doErrorAjax() {
79
+ doErrorAjax(e) {
67
80
  this.loading = false;
68
81
  this.value = !this.value;
82
+ this.dispatchEvent(new CustomEvent('dile-ajax-switch-error', {
83
+ detail: e.detail,
84
+ composed: true,
85
+ bubbles: true,
86
+ }));
69
87
  }
70
88
 
71
- doSuccessAjax() {
89
+ doSuccessAjax(e) {
72
90
  this.loading = false;
91
+ this.dispatchEvent(new CustomEvent('dile-ajax-switch-success', {
92
+ detail: e.detail,
93
+ composed: true,
94
+ bubbles: true,
95
+ }));
73
96
  }
74
97
  }
75
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/crud",
3
- "version": "2.2.5",
3
+ "version": "2.2.7",
4
4
  "description": "Components to create a generic crud system based on Web Components and Lit",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -25,12 +25,12 @@
25
25
  },
26
26
  "homepage": "https://dile-components.com/",
27
27
  "dependencies": {
28
- "@dile/ui": "^3.5.5",
28
+ "@dile/ui": "^3.6.0",
29
29
  "axios": "^1.19.0",
30
30
  "lit": "^2.7.0 || ^3.0.0"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "eaa249f1df1f0e86d83924de110ab86cf05e1c11"
35
+ "gitHead": "38fa60c43d27a6b9d083a0d5be2e3be4b2a67f00"
36
36
  }