@dile/ui 3.6.4 → 3.6.6
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.
|
@@ -29,4 +29,29 @@ describe('dile-confirm', () => {
|
|
|
29
29
|
|
|
30
30
|
expect(accepted).toBe(true);
|
|
31
31
|
});
|
|
32
|
+
|
|
33
|
+
it('handles dontCloseOnAccept and can be reset with resetProcessing()', async () => {
|
|
34
|
+
const el = await renderConfirm('<dile-confirm dontCloseOnAccept>Are you sure?</dile-confirm>');
|
|
35
|
+
let acceptCount = 0;
|
|
36
|
+
el.addEventListener('dile-confirm-accepted', () => { acceptCount++; });
|
|
37
|
+
|
|
38
|
+
el.shadowRoot.querySelector('.accept').click();
|
|
39
|
+
await el.updateComplete;
|
|
40
|
+
expect(acceptCount).toBe(1);
|
|
41
|
+
expect(el._isProcessing).toBe(true);
|
|
42
|
+
expect(el.shadowRoot.querySelector('.accept').classList.contains('disabled')).toBe(true);
|
|
43
|
+
|
|
44
|
+
// Clicking again while processing should not trigger accept
|
|
45
|
+
el.shadowRoot.querySelector('.accept').click();
|
|
46
|
+
expect(acceptCount).toBe(1);
|
|
47
|
+
|
|
48
|
+
// Calling resetProcessing should unlock the buttons
|
|
49
|
+
el.resetProcessing();
|
|
50
|
+
await el.updateComplete;
|
|
51
|
+
expect(el._isProcessing).toBe(false);
|
|
52
|
+
expect(el.shadowRoot.querySelector('.accept').classList.contains('disabled')).toBe(false);
|
|
53
|
+
|
|
54
|
+
el.shadowRoot.querySelector('.accept').click();
|
|
55
|
+
expect(acceptCount).toBe(2);
|
|
56
|
+
});
|
|
32
57
|
});
|
|
@@ -52,6 +52,7 @@ export class DileConfirm extends LitElement {
|
|
|
52
52
|
cancelLabel: { type: String },
|
|
53
53
|
blocking: { type: Boolean },
|
|
54
54
|
dontCloseOnAccept: { type: Boolean },
|
|
55
|
+
_isProcessing: { state: true },
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -61,6 +62,7 @@ export class DileConfirm extends LitElement {
|
|
|
61
62
|
this.cancelLabel = "Cancell";
|
|
62
63
|
this.opened = false;
|
|
63
64
|
this.blocking = false;
|
|
65
|
+
this.dontCloseOnAccept = false;
|
|
64
66
|
this._isProcessing = false;
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -100,6 +102,7 @@ export class DileConfirm extends LitElement {
|
|
|
100
102
|
|
|
101
103
|
open() {
|
|
102
104
|
this.modal.open();
|
|
105
|
+
this._isProcessing = false;
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
close() {
|
|
@@ -107,6 +110,10 @@ export class DileConfirm extends LitElement {
|
|
|
107
110
|
this._isProcessing = false;
|
|
108
111
|
}
|
|
109
112
|
|
|
113
|
+
resetProcessing() {
|
|
114
|
+
this._isProcessing = false;
|
|
115
|
+
}
|
|
116
|
+
|
|
110
117
|
firstUpdated() {
|
|
111
118
|
this.modal = this.shadowRoot.getElementById("modal");
|
|
112
119
|
}
|
|
@@ -28,7 +28,9 @@ export class DileInputIcon extends DileInput {
|
|
|
28
28
|
...super.styles,
|
|
29
29
|
css`
|
|
30
30
|
.input-icon-btn {
|
|
31
|
+
box-sizing: border-box;
|
|
31
32
|
background: none;
|
|
33
|
+
background-color: var(--dile-input-icon-background-color, var(--dile-input-icon-bg, transparent));
|
|
32
34
|
border: none;
|
|
33
35
|
cursor: pointer;
|
|
34
36
|
padding: var(--dile-input-icon-padding, var(--dile-input-padding, 5px));
|
|
@@ -37,16 +39,18 @@ export class DileInputIcon extends DileInput {
|
|
|
37
39
|
display: flex;
|
|
38
40
|
align-items: center;
|
|
39
41
|
justify-content: center;
|
|
40
|
-
width: var(--dile-input-icon-width,
|
|
41
|
-
height: var(--dile-input-icon-height,
|
|
42
|
+
width: var(--dile-input-icon-width, auto);
|
|
43
|
+
height: var(--dile-input-icon-height, auto);
|
|
44
|
+
min-width: var(--dile-input-icon-width, 32px);
|
|
45
|
+
min-height: var(--dile-input-icon-height, 32px);
|
|
42
46
|
border-radius: var(--dile-input-icon-border-radius, var(--dile-input-border-radius, 5px));
|
|
43
47
|
transition: var(--dile-input-icon-transition, background-color 0.2s);
|
|
44
48
|
}
|
|
45
49
|
.input-icon-btn:hover {
|
|
46
|
-
background-color: var(--dile-input-icon-hover-bg, rgba(0, 0, 0, 0.05));
|
|
50
|
+
background-color: var(--dile-input-icon-hover-background-color, var(--dile-input-icon-hover-bg, rgba(0, 0, 0, 0.05)));
|
|
47
51
|
}
|
|
48
52
|
.input-icon-btn:active {
|
|
49
|
-
background-color: var(--dile-input-icon-active-bg, rgba(0, 0, 0, 0.1));
|
|
53
|
+
background-color: var(--dile-input-icon-active-background-color, var(--dile-input-icon-active-bg, rgba(0, 0, 0, 0.1)));
|
|
50
54
|
}
|
|
51
55
|
.input-icon-btn:disabled {
|
|
52
56
|
cursor: not-allowed;
|
|
@@ -71,44 +75,62 @@ export class DileInputIcon extends DileInput {
|
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
render() {
|
|
74
|
-
const inputType = this.type || 'text';
|
|
75
|
-
|
|
76
78
|
return html`
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
: ''
|
|
107
|
-
|
|
108
|
-
|
|
79
|
+
<main>
|
|
80
|
+
${this.labelTemplate}
|
|
81
|
+
<section class="for-input">
|
|
82
|
+
${this.inputTemplate}
|
|
83
|
+
${this.icon ? this.renderIconButton() : ''}
|
|
84
|
+
${this.labelRight ? html`<span class="labelright">${this.labelRight}</span>` : ''}
|
|
85
|
+
</section>
|
|
86
|
+
${this.messageTemplate}
|
|
87
|
+
</main>
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
get labelTemplate() {
|
|
92
|
+
return this.label
|
|
93
|
+
? html`<label for="textField">${this.label}</label>`
|
|
94
|
+
: '';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
get inputTemplate() {
|
|
98
|
+
return html`
|
|
99
|
+
<input
|
|
100
|
+
type="${this.availableType(this.type)}"
|
|
101
|
+
id="textField"
|
|
102
|
+
name="${this.name}"
|
|
103
|
+
placeholder="${this.placeholder}"
|
|
104
|
+
?disabled="${this.disabled}"
|
|
105
|
+
?readonly="${this.readonly}"
|
|
106
|
+
autocomplete="${this.disableAutocomplete ? 'off' : 'on'}"
|
|
107
|
+
.value="${this.computeValue(this.value)}"
|
|
108
|
+
class="${this.errored ? 'errored' : ''}"
|
|
109
|
+
@keypress="${this._lookForEnter}"
|
|
110
|
+
@input="${this._input}"
|
|
111
|
+
@blur="${this.doBlur}"
|
|
112
|
+
@focus="${this.doFocus}"
|
|
113
|
+
?selectonfocus="${this.selectOnFocus}"
|
|
114
|
+
>
|
|
109
115
|
`;
|
|
110
116
|
}
|
|
111
117
|
|
|
118
|
+
get iconTemplate() {
|
|
119
|
+
return this.renderIconlibIcon(this.icon);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
get buttonTemplate() {
|
|
123
|
+
return html`<button
|
|
124
|
+
class="input-icon-btn"
|
|
125
|
+
type="button"
|
|
126
|
+
@click="${this._handleIconClick}"
|
|
127
|
+
?disabled="${this.disabled}"
|
|
128
|
+
aria-label="Icon action button"
|
|
129
|
+
>
|
|
130
|
+
${this.iconTemplate}
|
|
131
|
+
</button>`;
|
|
132
|
+
}
|
|
133
|
+
|
|
112
134
|
/**
|
|
113
135
|
* Renders an icon using dile-iconlib
|
|
114
136
|
* Supports format "family.name" (e.g., "lucide.eye", "material.home")
|
|
@@ -137,15 +159,7 @@ export class DileInputIcon extends DileInput {
|
|
|
137
159
|
* @returns {TemplateResult}
|
|
138
160
|
*/
|
|
139
161
|
renderIconButton() {
|
|
140
|
-
const button =
|
|
141
|
-
class="input-icon-btn"
|
|
142
|
-
type="button"
|
|
143
|
-
@click="${this._handleIconClick}"
|
|
144
|
-
?disabled="${this.disabled}"
|
|
145
|
-
aria-label="Icon action button"
|
|
146
|
-
>
|
|
147
|
-
${this.renderIconlibIcon(this.icon)}
|
|
148
|
-
</button>`;
|
|
162
|
+
const button = this.buttonTemplate;
|
|
149
163
|
|
|
150
164
|
// If tooltip is defined, wrap button with dile-tooltip
|
|
151
165
|
if (this.tooltip) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/ui",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.6",
|
|
4
4
|
"description": "UI Core components from dile-components.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "3bc0a2459a5ced3e7105ce061f93f07a9c798759"
|
|
32
32
|
}
|