@dile/ui 3.12.1 → 3.12.2
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.
|
@@ -28,4 +28,30 @@ describe('dile-order-switch', () => {
|
|
|
28
28
|
|
|
29
29
|
expect(el.value).toBe('desc');
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
it('clicking the label re-announces the current value without toggling when not selected', async () => {
|
|
33
|
+
const el = await renderOrderSwitch('<dile-order-switch name="name" label="Name" value="asc"></dile-order-switch>');
|
|
34
|
+
|
|
35
|
+
let receivedDetail = null;
|
|
36
|
+
el.addEventListener('element-changed', (e) => { receivedDetail = e.detail; });
|
|
37
|
+
|
|
38
|
+
el.shadowRoot.querySelector('span').click();
|
|
39
|
+
await el.updateComplete;
|
|
40
|
+
|
|
41
|
+
expect(el.value).toBe('asc'); // unchanged
|
|
42
|
+
expect(receivedDetail).toEqual({ name: 'name', value: 'asc' });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('clicking the label toggles the order when selected', async () => {
|
|
46
|
+
const el = await renderOrderSwitch('<dile-order-switch name="name" label="Name" value="asc" selected></dile-order-switch>');
|
|
47
|
+
|
|
48
|
+
let receivedDetail = null;
|
|
49
|
+
el.addEventListener('element-changed', (e) => { receivedDetail = e.detail; });
|
|
50
|
+
|
|
51
|
+
el.shadowRoot.querySelector('span').click();
|
|
52
|
+
await el.updateComplete;
|
|
53
|
+
|
|
54
|
+
expect(el.value).toBe('desc'); // toggled
|
|
55
|
+
expect(receivedDetail).toEqual({ name: 'name', value: 'desc' });
|
|
56
|
+
});
|
|
31
57
|
});
|
|
@@ -10,12 +10,18 @@ export class DileOrderSwitch extends DileEmmitChange(LitElement) {
|
|
|
10
10
|
value: { type: String },
|
|
11
11
|
name: { type: String },
|
|
12
12
|
label: { type: String },
|
|
13
|
+
/** Marks this switch as the one currently in effect, e.g. inside a group of
|
|
14
|
+
* order options where only one applies at a time. When true, clicking the
|
|
15
|
+
* label toggles the order (same as clicking the icon) instead of just
|
|
16
|
+
* re-announcing the current value. */
|
|
17
|
+
selected: { type: Boolean },
|
|
13
18
|
};
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
constructor() {
|
|
17
22
|
super();
|
|
18
23
|
this.value = "asc";
|
|
24
|
+
this.selected = false;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
static get styles() {
|
|
@@ -69,8 +75,11 @@ export class DileOrderSwitch extends DileEmmitChange(LitElement) {
|
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
onlyChange() {
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
if (this.selected) {
|
|
79
|
+
this.toggle();
|
|
80
|
+
} else {
|
|
81
|
+
this.emmitChange();
|
|
82
|
+
}
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
toggle() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/ui",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.2",
|
|
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": "27dbd2411bd5856021209c49da6aed285c3fae28"
|
|
32
32
|
}
|