@dile/ui 2.8.4 → 2.8.5

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,17 +1,23 @@
1
1
  import { html, css, LitElement } from "lit";
2
2
 
3
3
  export class DileButton extends LitElement {
4
+
5
+ static formAssociated = true;
6
+
4
7
  static get properties() {
5
8
  return {
6
9
  disabled: { type: Boolean },
7
10
  name: { type: String },
11
+ type: { type: String },
8
12
  };
9
13
  }
10
14
 
11
15
  constructor() {
12
16
  super();
13
17
  this.disabled = false;
18
+ this._internals = this.attachInternals();
14
19
  }
20
+
15
21
  static get styles() {
16
22
  return css`
17
23
  :host {
@@ -76,7 +82,25 @@ export class DileButton extends LitElement {
76
82
 
77
83
  render() {
78
84
  return html`
79
- <button ?disabled=${this.disabled}><slot></slot></button>
85
+ <button
86
+ @click=${this._onClick}
87
+ ?disabled=${this.disabled}
88
+ type=${this.type}
89
+ ><slot></slot></button>
80
90
  `;
81
91
  }
92
+
93
+ _onClick(e) {
94
+ if (this.disabled) {
95
+ e.preventDefault();
96
+ e.stopPropagation();
97
+ return;
98
+ }
99
+
100
+ if (this.type === "submit") {
101
+ this._internals.form?.requestSubmit();
102
+ } else if (this.type === "reset") {
103
+ this._internals.form?.reset();
104
+ }
105
+ }
82
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/ui",
3
- "version": "2.8.4",
3
+ "version": "2.8.5",
4
4
  "description": "UI Core components from dile-components.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,5 +26,5 @@
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
- "gitHead": "105233f5f9e645c1205f08c95b5115113c38eea5"
29
+ "gitHead": "0750cce05a53c0dae17f2e09397f5cc5b5629724"
30
30
  }