@dile/ui 2.23.12 → 2.24.0

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,2 +1,3 @@
1
1
  export { DileSelect } from './src/DileSelect.js';
2
- export { DileSelectAjax } from './src/DileSelectAjax.js';
2
+ export { DileSelectAjax } from './src/DileSelectAjax.js';
3
+ export { DileSelectBoolean } from './src/DileSelectBoolean.js';
@@ -0,0 +1,3 @@
1
+ import { DileSelectBoolean } from "./src/DileSelectBoolean.js";
2
+
3
+ window.customElements.define("dile-select-boolean", DileSelectBoolean);
@@ -0,0 +1,112 @@
1
+ import { html, css, LitElement } from "lit";
2
+ import { DileEmmitChange } from '../../../mixins/form/index.js';
3
+ import '../select.js';
4
+
5
+ export class DileSelectBoolean extends DileEmmitChange(LitElement) {
6
+ static get formAssociated() {
7
+ return true;
8
+ }
9
+
10
+ static get styles() {
11
+ return css`
12
+ :host {
13
+ display: block;
14
+ }
15
+ `;
16
+ }
17
+
18
+ static get properties() {
19
+ return {
20
+ label: { type: String },
21
+ value: {},
22
+ name: { type: String },
23
+ disabled: { type: Boolean },
24
+ errored: { type: Boolean },
25
+ message: { type: String },
26
+ hideErrorOnInput: { type: Boolean },
27
+ quietOnStart: { type: Boolean },
28
+ trueOption: { type: String },
29
+ falseOption: { type: String },
30
+ };
31
+ }
32
+
33
+ constructor() {
34
+ super();
35
+ this.trueOption = 'Yes';
36
+ this.falseOption = 'No';
37
+ this.errored = false;
38
+ this.hideErrorOnInput = false;
39
+ this.quiet = false;
40
+ this.internals = this.attachInternals();
41
+ }
42
+
43
+ render() {
44
+ return html`
45
+ <dile-select
46
+ label="${this.label || ''}"
47
+ ?errored="${this.errored}"
48
+ message="${this.message || ''}"
49
+ ?disabled="${this.disabled}"
50
+ quietOnStart
51
+ @element-changed="${this._onInnerChange}"
52
+ >
53
+ <select slot="select">
54
+ <option value="true">${this.trueOption}</option>
55
+ <option value="false">${this.falseOption}</option>
56
+ </select>
57
+ </dile-select>
58
+ `;
59
+ }
60
+
61
+ get _innerSelect() {
62
+ return this.shadowRoot.querySelector('dile-select');
63
+ }
64
+
65
+ firstUpdated() {
66
+ this.quiet = this.quietOnStart;
67
+ const inner = this._innerSelect;
68
+ if (this.value !== undefined && this.value !== null) {
69
+ inner.quietChange(this.value ? 'true' : 'false');
70
+ }
71
+ }
72
+
73
+ updated(changedProperties) {
74
+ if (changedProperties.has('value')) {
75
+ const inner = this._innerSelect;
76
+ if (inner) {
77
+ if (this.value !== undefined && this.value !== null) {
78
+ inner.quietChange(this.value ? 'true' : 'false');
79
+ } else {
80
+ inner.clear();
81
+ }
82
+ }
83
+ this.internals.setFormValue(this.value ? 'on' : null);
84
+ if (this.quiet) {
85
+ this.quiet = false;
86
+ } else {
87
+ this.emmitChange();
88
+ }
89
+ }
90
+ }
91
+
92
+ _onInnerChange(e) {
93
+ e.stopPropagation();
94
+ const boolValue = e.detail.value === 'true';
95
+ if (boolValue !== this.value) {
96
+ this.value = boolValue;
97
+ if (this.hideErrorOnInput && this.errored) {
98
+ this.errored = false;
99
+ this.message = '';
100
+ }
101
+ }
102
+ }
103
+
104
+ clear() {
105
+ this.value = undefined;
106
+ }
107
+
108
+ clearError() {
109
+ this.errored = false;
110
+ this.message = '';
111
+ }
112
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/ui",
3
- "version": "2.23.12",
3
+ "version": "2.24.0",
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": "8ed3ed0cd454dddf99c948baa272aac242e90030"
29
+ "gitHead": "23b29920983b8ac81493028af821136571ab87b8"
30
30
  }