@dile/ui 2.13.0 → 2.14.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.
@@ -0,0 +1,3 @@
1
+ import { DileConfirmText } from './src/DileConfirmText.js';
2
+
3
+ window.customElements.define('dile-confirm-text', DileConfirmText);
@@ -0,0 +1 @@
1
+ export { DileConfirmText } from './src/DileConfirmText.js';
@@ -0,0 +1,107 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { DileConfirm } from '../../confirm/src/DileConfirm.js';
3
+ import '../../modal/modal.js';
4
+ import '../../input/input.js';
5
+ import '../../inline-feedback/inline-feedback.js';
6
+
7
+ export class DileConfirmText extends DileConfirm {
8
+
9
+ static get styles() {
10
+ return [super.styles, css`
11
+ :host {
12
+ display: block;
13
+ --dile-modal-background-color: rgba(90, 0, 0, 0.8);
14
+ --dile-modal-content-shadow-color: rgba(20, 0, 0, 0.5);
15
+ --dile-confirm-cancel-button-color: #007bff;
16
+ --dile-confirm-accept-button-color: #dc3545;
17
+ --dile-input-message-color: #991010;
18
+ }
19
+ .content {
20
+ padding: 1rem;
21
+ text-align: left;
22
+ }
23
+ .title {
24
+ padding: 0 1rem;
25
+ padding-top: 1rem;
26
+ font-size: 1.2em;
27
+ font-weight: bold;
28
+ margin-bottom: 0.5rem;
29
+ }
30
+ `];
31
+ }
32
+
33
+ static get properties() {
34
+ return {
35
+ ...super.properties,
36
+ title: { type: String },
37
+ confirmationText: { type: String },
38
+ inputLabel: { type: String },
39
+ inputMessage: { type: String },
40
+ wrongTextMessage: { type: String },
41
+ emptyTextMessage: { type: String },
42
+ };
43
+ }
44
+
45
+ constructor() {
46
+ super();
47
+ this.confirmationText = 'CONFIRM';
48
+ this.inputLabel = 'Type ' + this.confirmationText + ' in the text field to confirm your action.';
49
+ this.inputMessage = 'Your data will be deleted and cannot be recovered.';
50
+ this.wrongTextMessage = `You must type "${this.confirmationText}" in uppercase letters`;
51
+ this.emptyTextMessage = 'You have not typed anything in the text field';
52
+ }
53
+
54
+ render() {
55
+ return html`
56
+ <dile-modal
57
+ ?blocking="${this.blocking}"
58
+ ?opened="${this.opened}"
59
+ id="modal"
60
+ @dile-modal-background-closed="${this.cancel}">
61
+ ${this.title ? html`<div class="title">${this.title}</div>` : ''}
62
+ <div class="content">
63
+ <slot></slot>
64
+ <dile-input
65
+ id="eltext"
66
+ @focus="${this.cleanInline}"
67
+ label="${this.inputLabel}"
68
+ message="${this.inputMessage}"></dile-input>
69
+ <dile-inline-feedback id="feedback"></dile-inline-feedback>
70
+ <div class="actions">
71
+ <a href="#" class="button cancel" @click="${this._cancelHandler}">${this.cancelLabel}</a>
72
+ <a href="#" class="button accept" @click="${this._acceptHandler}">${this.acceptLabel}</a>
73
+ </div>
74
+ </div>
75
+ </dile-modal>
76
+ `;
77
+ }
78
+
79
+ _acceptHandler(e) {
80
+ e.preventDefault();
81
+ this.feedback.clear();
82
+ let text = this.shadowRoot.getElementById('eltext').value;
83
+ if(text === '') {
84
+ this.feedback.negativeFeedback(this.emptyTextMessage);
85
+ return;
86
+ }
87
+ if(text !== this.confirmationText) {
88
+ this.feedback.negativeFeedback(this.wrongTextMessage);
89
+ return;
90
+ }
91
+ this.accept();
92
+ }
93
+
94
+ firstUpdated() {
95
+ super.firstUpdated();
96
+ this.feedback = this.shadowRoot.getElementById('feedback');
97
+ }
98
+
99
+ cleanInline() {
100
+ this.feedback.clear();
101
+ }
102
+
103
+ cancel() {
104
+ super.cancel();
105
+ this.cleanInline();
106
+ }
107
+ }
@@ -25,6 +25,7 @@ export const DileSelectable = (SuperClass) =>
25
25
  this.hashSelection = false;
26
26
  this.itemSelectedChangedHandler = this._itemSelectedChanged.bind(this);
27
27
  this.onHashChangeHandler = this._onHashChange.bind(this);
28
+ this.someItemChangedHandler = this.someItemChanged.bind(this);
28
29
  }
29
30
 
30
31
  _onHashChange() {
@@ -64,12 +65,14 @@ export const DileSelectable = (SuperClass) =>
64
65
  super.connectedCallback();
65
66
  this.addEventListener('dile-item-selected', this.itemSelectedChangedHandler);
66
67
  window.addEventListener("hashchange", this.onHashChangeHandler);
68
+ window.addEventListener("dile-selected-changed", this.someItemChangedHandler);
67
69
  }
68
70
 
69
71
  disconnectedCallback() {
70
72
  super.disconnectedCallback();
71
73
  this.removeEventListener('dile-item-selected', this.itemSelectedChangedHandler);
72
74
  window.removeEventListener("hashchange", this.onHashChangeHandler);
75
+ window.removeEventListener("dile-selected-changed", this.someItemChangedHandler);
73
76
  }
74
77
 
75
78
  firstUpdated() {
@@ -151,4 +154,12 @@ export const DileSelectable = (SuperClass) =>
151
154
  getItems() {
152
155
  return this.shadowRoot.querySelector('slot').assignedElements({flatten: true});
153
156
  }
157
+
158
+ someItemChanged(e) {
159
+ if(this.selectorId && e.detail.selectorId === this.selectorId) {
160
+ if(this.selected != e.detail.selected) {
161
+ this.selected = e.detail.selected;
162
+ }
163
+ }
164
+ }
154
165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/ui",
3
- "version": "2.13.0",
3
+ "version": "2.14.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": "fe694c1012976386590ba407e057b6851fdfa0df"
29
+ "gitHead": "f7a66b88507409901e09b5ca7852358237a7559c"
30
30
  }