@dile/ui 2.13.1 → 2.14.1

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
+ }
@@ -86,7 +86,7 @@ export const DileSelectable = (SuperClass) =>
86
86
  this._onHashChange();
87
87
  this.setSelectedItem();
88
88
  if(this.selected !== undefined) {
89
- setTimeout( () => this.dispatchSelectedChanged(), 500);
89
+ setTimeout( () => this.dispatchSelectedChanged(true), 500);
90
90
  }
91
91
  }
92
92
 
@@ -136,13 +136,14 @@ export const DileSelectable = (SuperClass) =>
136
136
  this.dispatchSelectedChanged();
137
137
  }
138
138
 
139
- dispatchSelectedChanged() {
139
+ dispatchSelectedChanged(initializationEvent = false) {
140
140
  this.dispatchEvent(new CustomEvent('dile-selected-changed', {
141
141
  bubbles: true,
142
142
  composed: true,
143
143
  detail: {
144
144
  selected: this.selected,
145
145
  selectorId: this.selectorId,
146
+ initializationEvent,
146
147
  }
147
148
  }));
148
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/ui",
3
- "version": "2.13.1",
3
+ "version": "2.14.1",
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": "2cce4548dfe05e5ef9f72228ff1cb7d3eeb5e285"
29
+ "gitHead": "29c107ef8ff78170087a57c5c47904ce7c72996b"
30
30
  }