@crowdstrike/glide-core 0.12.2 → 0.13.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.
- package/dist/accordion.d.ts +1 -1
- package/dist/accordion.styles.js +2 -1
- package/dist/button-group.js +1 -1
- package/dist/button-group.stories.d.ts +0 -1
- package/dist/button-group.test.events.js +2 -0
- package/dist/checkbox-group.styles.js +1 -1
- package/dist/checkbox.styles.js +6 -3
- package/dist/drawer.js +1 -1
- package/dist/dropdown.d.ts +8 -1
- package/dist/dropdown.js +140 -74
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.option.styles.js +39 -7
- package/dist/dropdown.option.test.interactions.multiple.js +2 -2
- package/dist/dropdown.option.test.interactions.single.js +2 -2
- package/dist/dropdown.styles.js +121 -16
- package/dist/dropdown.test.basics.filterable.js +19 -57
- package/dist/dropdown.test.basics.js +24 -244
- package/dist/dropdown.test.basics.multiple.js +13 -60
- package/dist/dropdown.test.basics.single.js +2 -8
- package/dist/dropdown.test.events.filterable.js +12 -66
- package/dist/dropdown.test.events.js +75 -49
- package/dist/dropdown.test.events.multiple.js +17 -87
- package/dist/dropdown.test.events.single.js +12 -60
- package/dist/dropdown.test.focus.filterable.js +11 -58
- package/dist/dropdown.test.focus.js +62 -9
- package/dist/dropdown.test.focus.multiple.js +22 -38
- package/dist/dropdown.test.focus.single.js +5 -16
- package/dist/dropdown.test.interactions.filterable.js +167 -69
- package/dist/dropdown.test.interactions.js +226 -244
- package/dist/dropdown.test.interactions.multiple.js +78 -274
- package/dist/dropdown.test.interactions.single.js +20 -85
- package/dist/dropdown.test.validity.js +12 -49
- package/dist/input.d.ts +1 -1
- package/dist/input.js +2 -1
- package/dist/input.styles.js +44 -30
- package/dist/label.js +1 -1
- package/dist/label.styles.js +7 -3
- package/dist/library/localize.d.ts +2 -0
- package/dist/menu.js +1 -1
- package/dist/menu.stories.d.ts +1 -0
- package/dist/menu.styles.js +1 -1
- package/dist/menu.test.interactions.js +1 -1
- package/dist/modal.d.ts +1 -1
- package/dist/modal.js +1 -1
- package/dist/radio-group.stories.d.ts +0 -1
- package/dist/radio-group.styles.js +1 -1
- package/dist/styles/variables.css +1 -1
- package/dist/tab.group.d.ts +0 -1
- package/dist/tab.group.js +1 -1
- package/dist/tab.group.styles.js +5 -13
- package/dist/tab.panel.styles.js +0 -3
- package/dist/tabs.stories.d.ts +0 -1
- package/dist/tag.js +1 -1
- package/dist/tag.styles.js +5 -3
- package/dist/tag.test.interactions.js +8 -8
- package/dist/textarea.styles.js +1 -1
- package/dist/translations/en.js +1 -1
- package/dist/translations/fr.d.ts +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/ja.d.ts +1 -1
- package/dist/translations/ja.js +1 -1
- package/dist/tree.stories.d.ts +0 -1
- package/package.json +18 -18
@@ -7,60 +7,17 @@ import GlideCoreDropdownOption from './dropdown.option.js';
|
|
7
7
|
GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
8
8
|
GlideCoreDropdownOption.shadowRootOptions.mode = 'open';
|
9
9
|
const defaultSlot = html `
|
10
|
-
<glide-core-dropdown-option
|
11
|
-
|
12
|
-
|
13
|
-
></glide-core-dropdown-option>
|
14
|
-
|
15
|
-
<glide-core-dropdown-option
|
16
|
-
|
17
|
-
|
18
|
-
></glide-core-dropdown-option>
|
19
|
-
|
20
|
-
<glide-core-dropdown-option
|
21
|
-
label="Three"
|
22
|
-
value="three"
|
23
|
-
></glide-core-dropdown-option>
|
24
|
-
|
25
|
-
<glide-core-dropdown-option
|
26
|
-
label="Four"
|
27
|
-
value="four"
|
28
|
-
></glide-core-dropdown-option>
|
29
|
-
|
30
|
-
<glide-core-dropdown-option
|
31
|
-
label="Five"
|
32
|
-
value="five"
|
33
|
-
></glide-core-dropdown-option>
|
34
|
-
|
35
|
-
<glide-core-dropdown-option
|
36
|
-
label="Six"
|
37
|
-
value="six"
|
38
|
-
></glide-core-dropdown-option>
|
39
|
-
|
40
|
-
<glide-core-dropdown-option
|
41
|
-
label="Seven"
|
42
|
-
value="seven"
|
43
|
-
></glide-core-dropdown-option>
|
44
|
-
|
45
|
-
<glide-core-dropdown-option
|
46
|
-
label="Eight"
|
47
|
-
value="eight"
|
48
|
-
></glide-core-dropdown-option>
|
49
|
-
|
50
|
-
<glide-core-dropdown-option
|
51
|
-
label="Nine"
|
52
|
-
value="nine"
|
53
|
-
></glide-core-dropdown-option>
|
54
|
-
|
55
|
-
<glide-core-dropdown-option
|
56
|
-
label="Ten"
|
57
|
-
value="ten"
|
58
|
-
></glide-core-dropdown-option>
|
59
|
-
|
60
|
-
<glide-core-dropdown-option
|
61
|
-
label="Eleven"
|
62
|
-
value="eleven"
|
63
|
-
></glide-core-dropdown-option>
|
10
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
11
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
12
|
+
<glide-core-dropdown-option label="Three"></glide-core-dropdown-option>
|
13
|
+
<glide-core-dropdown-option label="Four"></glide-core-dropdown-option>
|
14
|
+
<glide-core-dropdown-option label="Five"></glide-core-dropdown-option>
|
15
|
+
<glide-core-dropdown-option label="Six"></glide-core-dropdown-option>
|
16
|
+
<glide-core-dropdown-option label="Seven"></glide-core-dropdown-option>
|
17
|
+
<glide-core-dropdown-option label="Eight"></glide-core-dropdown-option>
|
18
|
+
<glide-core-dropdown-option label="Nine"></glide-core-dropdown-option>
|
19
|
+
<glide-core-dropdown-option label="Ten"></glide-core-dropdown-option>
|
20
|
+
<glide-core-dropdown-option label="Eleven"></glide-core-dropdown-option>
|
64
21
|
`;
|
65
22
|
it('focuses the input when `focus()` is called', async () => {
|
66
23
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
@@ -130,10 +87,6 @@ it('focuses the input on submit when required and no option is selected', async
|
|
130
87
|
const form = document.createElement('form');
|
131
88
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" required>
|
132
89
|
${defaultSlot}
|
133
|
-
<glide-core-dropdown-option
|
134
|
-
label="Label"
|
135
|
-
value="value"
|
136
|
-
></glide-core-dropdown-option>
|
137
90
|
</glide-core-dropdown>`, {
|
138
91
|
parentNode: form,
|
139
92
|
});
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
2
|
import './dropdown.option.js';
|
3
|
-
import { expect, fixture, html } from '@open-wc/testing';
|
3
|
+
import { aTimeout, elementUpdated, expect, fixture, html, } from '@open-wc/testing';
|
4
4
|
import { sendKeys } from '@web/test-runner-commands';
|
5
5
|
import GlideCoreDropdown from './dropdown.js';
|
6
6
|
import GlideCoreDropdownOption from './dropdown.option.js';
|
@@ -14,10 +14,7 @@ it('closes and reports validity when it loses focus', async () => {
|
|
14
14
|
open
|
15
15
|
required
|
16
16
|
>
|
17
|
-
<glide-core-dropdown-option
|
18
|
-
label="Label"
|
19
|
-
value="value"
|
20
|
-
></glide-core-dropdown-option>
|
17
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
21
18
|
</glide-core-dropdown>`, { parentNode: div });
|
22
19
|
const button = document.createElement('button');
|
23
20
|
div.prepend(button);
|
@@ -39,10 +36,7 @@ it('closes and reports validity when it loses focus', async () => {
|
|
39
36
|
});
|
40
37
|
it('is focused when clicked', async () => {
|
41
38
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
42
|
-
<glide-core-dropdown-option
|
43
|
-
label="Label"
|
44
|
-
value="value"
|
45
|
-
></glide-core-dropdown-option>
|
39
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
46
40
|
</glide-core-dropdown>`);
|
47
41
|
// Calling `click()` would be sweet. The problem is it sets `event.detail` to `0`,
|
48
42
|
// which puts us in a guard in the event handler. `Event` has no `detail` property
|
@@ -52,3 +46,62 @@ it('is focused when clicked', async () => {
|
|
52
46
|
button?.dispatchEvent(new CustomEvent('click', { bubbles: true, detail: 1 }));
|
53
47
|
expect(component.shadowRoot?.activeElement).to.equal(button);
|
54
48
|
});
|
49
|
+
it('focuses the Add button on ArrowDown', async () => {
|
50
|
+
const component = await fixture(html `<glide-core-dropdown
|
51
|
+
add-button-label="Add"
|
52
|
+
label="Label"
|
53
|
+
placeholder="Placeholder"
|
54
|
+
open
|
55
|
+
>
|
56
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
57
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
58
|
+
</glide-core-dropdown>`);
|
59
|
+
// Wait for it to open.
|
60
|
+
await aTimeout(0);
|
61
|
+
const options = component.querySelectorAll('glide-core-dropdown-option');
|
62
|
+
component.focus();
|
63
|
+
await sendKeys({ press: 'ArrowDown' }); // Two
|
64
|
+
await sendKeys({ press: 'ArrowDown' }); // Add button
|
65
|
+
const addButton = component.shadowRoot?.querySelector('[data-test="add-button"]');
|
66
|
+
expect(options[0]?.privateActive).to.be.false;
|
67
|
+
expect(options[0]?.privateActive).to.be.false;
|
68
|
+
expect(options[1]?.privateActive).to.be.false;
|
69
|
+
expect(options[1]?.privateIsEditActive).to.be.false;
|
70
|
+
expect(options[1]?.privateIsOpenTooltip).to.be.false;
|
71
|
+
expect(component.shadowRoot?.activeElement).to.equal(addButton);
|
72
|
+
});
|
73
|
+
it('returns focus to itself on Escape when the Add button has focus', async () => {
|
74
|
+
const component = await fixture(html `<glide-core-dropdown
|
75
|
+
add-button-label="Add"
|
76
|
+
label="Label"
|
77
|
+
placeholder="Placeholder"
|
78
|
+
open
|
79
|
+
>
|
80
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
81
|
+
</glide-core-dropdown>`);
|
82
|
+
// Wait for it to open.
|
83
|
+
await aTimeout(0);
|
84
|
+
component.focus();
|
85
|
+
await sendKeys({ press: 'Tab' });
|
86
|
+
await sendKeys({ press: 'Escape' });
|
87
|
+
expect(document.activeElement).to.equal(component);
|
88
|
+
});
|
89
|
+
it('returns focus to itself when an option is activated and the Add button has focus', async () => {
|
90
|
+
const component = await fixture(html `<glide-core-dropdown
|
91
|
+
add-button-label="Add"
|
92
|
+
label="Label"
|
93
|
+
placeholder="Placeholder"
|
94
|
+
open
|
95
|
+
>
|
96
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
97
|
+
</glide-core-dropdown>`);
|
98
|
+
// Wait for it to open.
|
99
|
+
await aTimeout(0);
|
100
|
+
component.focus();
|
101
|
+
await sendKeys({ press: 'Tab' });
|
102
|
+
component
|
103
|
+
.querySelector('glide-core-dropdown-option')
|
104
|
+
?.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
105
|
+
await elementUpdated(component);
|
106
|
+
expect(document.activeElement).to.equal(component);
|
107
|
+
});
|
@@ -6,15 +6,8 @@ GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
|
6
6
|
GlideCoreDropdownOption.shadowRootOptions.mode = 'open';
|
7
7
|
it('focuses the primary button when `focus()` is called', async () => {
|
8
8
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" multiple>
|
9
|
-
<glide-core-dropdown-option
|
10
|
-
|
11
|
-
value="one"
|
12
|
-
></glide-core-dropdown-option>
|
13
|
-
|
14
|
-
<glide-core-dropdown-option
|
15
|
-
label="Two"
|
16
|
-
value="two"
|
17
|
-
></glide-core-dropdown-option>
|
9
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
10
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
18
11
|
</glide-core-dropdown>`);
|
19
12
|
component.focus();
|
20
13
|
expect(component.shadowRoot?.activeElement).to.equal(component.shadowRoot?.querySelector('[data-test="primary-button"]'));
|
@@ -27,15 +20,9 @@ it('focuses the primary button on submit when required and no options are select
|
|
27
20
|
multiple
|
28
21
|
required
|
29
22
|
>
|
30
|
-
<glide-core-dropdown-option
|
31
|
-
label="One"
|
32
|
-
value="one"
|
33
|
-
></glide-core-dropdown-option>
|
23
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
34
24
|
|
35
|
-
<glide-core-dropdown-option
|
36
|
-
label="Two"
|
37
|
-
value="two"
|
38
|
-
></glide-core-dropdown-option>
|
25
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
39
26
|
</glide-core-dropdown>`, {
|
40
27
|
parentNode: form,
|
41
28
|
});
|
@@ -51,15 +38,8 @@ it('focuses the primary button when `reportValidity` is called when required and
|
|
51
38
|
multiple
|
52
39
|
required
|
53
40
|
>
|
54
|
-
<glide-core-dropdown-option
|
55
|
-
|
56
|
-
value="one"
|
57
|
-
></glide-core-dropdown-option>
|
58
|
-
|
59
|
-
<glide-core-dropdown-option
|
60
|
-
label="Two"
|
61
|
-
value="two"
|
62
|
-
></glide-core-dropdown-option>
|
41
|
+
<glide-core-dropdown-option label="One"></glide-core-dropdown-option>
|
42
|
+
<glide-core-dropdown-option label="Two"></glide-core-dropdown-option>
|
63
43
|
</glide-core-dropdown>`, { parentNode: form });
|
64
44
|
component.reportValidity();
|
65
45
|
const button = component.shadowRoot?.querySelector('[data-test="primary-button"]');
|
@@ -75,13 +55,11 @@ it('does not focus the primary button when `checkValidity` is called', async ()
|
|
75
55
|
>
|
76
56
|
<glide-core-dropdown-option
|
77
57
|
label="One"
|
78
|
-
value="one"
|
79
58
|
selected
|
80
59
|
></glide-core-dropdown-option>
|
81
60
|
|
82
61
|
<glide-core-dropdown-option
|
83
62
|
label="Two"
|
84
|
-
value="two"
|
85
63
|
selected
|
86
64
|
></glide-core-dropdown-option>
|
87
65
|
</glide-core-dropdown>`, { parentNode: form });
|
@@ -97,19 +75,16 @@ it('focuses the second tag when the first one is removed', async () => {
|
|
97
75
|
>
|
98
76
|
<glide-core-dropdown-option
|
99
77
|
label="One"
|
100
|
-
value="one"
|
101
78
|
selected
|
102
79
|
></glide-core-dropdown-option>
|
103
80
|
|
104
81
|
<glide-core-dropdown-option
|
105
82
|
label="Two"
|
106
|
-
value="two"
|
107
83
|
selected
|
108
84
|
></glide-core-dropdown-option>
|
109
85
|
|
110
86
|
<glide-core-dropdown-option
|
111
87
|
label="Three"
|
112
|
-
value="three"
|
113
88
|
selected
|
114
89
|
></glide-core-dropdown-option>
|
115
90
|
</glide-core-dropdown>`);
|
@@ -129,19 +104,16 @@ it('focuses the third tag when the second one is removed', async () => {
|
|
129
104
|
>
|
130
105
|
<glide-core-dropdown-option
|
131
106
|
label="One"
|
132
|
-
value="one"
|
133
107
|
selected
|
134
108
|
></glide-core-dropdown-option>
|
135
109
|
|
136
110
|
<glide-core-dropdown-option
|
137
111
|
label="Two"
|
138
|
-
value="two"
|
139
112
|
selected
|
140
113
|
></glide-core-dropdown-option>
|
141
114
|
|
142
115
|
<glide-core-dropdown-option
|
143
116
|
label="Three"
|
144
|
-
value="three"
|
145
117
|
selected
|
146
118
|
></glide-core-dropdown-option>
|
147
119
|
</glide-core-dropdown>`);
|
@@ -152,7 +124,7 @@ it('focuses the third tag when the second one is removed', async () => {
|
|
152
124
|
await aTimeout(0);
|
153
125
|
expect(component.shadowRoot?.activeElement).to.equal(tags?.[2]);
|
154
126
|
});
|
155
|
-
it('focuses the second tag when the
|
127
|
+
it('focuses the second tag when the third tag removed', async () => {
|
156
128
|
const component = await fixture(html `<glide-core-dropdown
|
157
129
|
label="Label"
|
158
130
|
placeholder="Placeholder"
|
@@ -161,19 +133,16 @@ it('focuses the second tag when the last one removed', async () => {
|
|
161
133
|
>
|
162
134
|
<glide-core-dropdown-option
|
163
135
|
label="One"
|
164
|
-
value="one"
|
165
136
|
selected
|
166
137
|
></glide-core-dropdown-option>
|
167
138
|
|
168
139
|
<glide-core-dropdown-option
|
169
140
|
label="Two"
|
170
|
-
value="two"
|
171
141
|
selected
|
172
142
|
></glide-core-dropdown-option>
|
173
143
|
|
174
144
|
<glide-core-dropdown-option
|
175
145
|
label="Three"
|
176
|
-
value="three"
|
177
146
|
selected
|
178
147
|
></glide-core-dropdown-option>
|
179
148
|
</glide-core-dropdown>`);
|
@@ -184,3 +153,18 @@ it('focuses the second tag when the last one removed', async () => {
|
|
184
153
|
await aTimeout(0);
|
185
154
|
expect(component.shadowRoot?.activeElement).to.equal(tags?.[1]);
|
186
155
|
});
|
156
|
+
it('focuses itself when the last tag is removed', async () => {
|
157
|
+
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" multiple>
|
158
|
+
<glide-core-dropdown-option
|
159
|
+
label="One"
|
160
|
+
selected
|
161
|
+
></glide-core-dropdown-option>
|
162
|
+
</glide-core-dropdown>`);
|
163
|
+
component.shadowRoot
|
164
|
+
?.querySelector('[data-test="tag"]')
|
165
|
+
?.click();
|
166
|
+
await elementUpdated(component);
|
167
|
+
// Wait for the timeout in `#onTagRemove`.
|
168
|
+
await aTimeout(0);
|
169
|
+
expect(document.activeElement).to.equal(component);
|
170
|
+
});
|
@@ -1,3 +1,4 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
1
2
|
import './dropdown.option.js';
|
2
3
|
import { expect, fixture, html } from '@open-wc/testing';
|
3
4
|
import GlideCoreDropdown from './dropdown.js';
|
@@ -6,10 +7,7 @@ GlideCoreDropdown.shadowRootOptions.mode = 'open';
|
|
6
7
|
GlideCoreDropdownOption.shadowRootOptions.mode = 'open';
|
7
8
|
it('focuses the primary button when `focus()` is called', async () => {
|
8
9
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder">
|
9
|
-
<glide-core-dropdown-option
|
10
|
-
label="Label"
|
11
|
-
value="value"
|
12
|
-
></glide-core-dropdown-option>
|
10
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
13
11
|
</glide-core-dropdown>`);
|
14
12
|
component.focus();
|
15
13
|
expect(component.shadowRoot?.activeElement).to.equal(component.shadowRoot?.querySelector('[data-test="primary-button"]'));
|
@@ -17,10 +15,7 @@ it('focuses the primary button when `focus()` is called', async () => {
|
|
17
15
|
it('focuses the button on submit', async () => {
|
18
16
|
const form = document.createElement('form');
|
19
17
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" required>
|
20
|
-
<glide-core-dropdown-option
|
21
|
-
label="Label"
|
22
|
-
value="value"
|
23
|
-
></glide-core-dropdown-option>
|
18
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
24
19
|
</glide-core-dropdown>`, {
|
25
20
|
parentNode: form,
|
26
21
|
});
|
@@ -31,10 +26,7 @@ it('focuses the button on submit', async () => {
|
|
31
26
|
it('focuses the primary button when `reportValidity` is called when required and no option is selected', async () => {
|
32
27
|
const form = document.createElement('form');
|
33
28
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" required>
|
34
|
-
<glide-core-dropdown-option
|
35
|
-
label="Label"
|
36
|
-
value="value"
|
37
|
-
></glide-core-dropdown-option>
|
29
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
38
30
|
</glide-core-dropdown>`, { parentNode: form });
|
39
31
|
component.reportValidity();
|
40
32
|
const button = component.shadowRoot?.querySelector('[data-test="primary-button"]');
|
@@ -43,10 +35,7 @@ it('focuses the primary button when `reportValidity` is called when required and
|
|
43
35
|
it('does not focus the primary button when `checkValidity` is called', async () => {
|
44
36
|
const form = document.createElement('form');
|
45
37
|
const component = await fixture(html `<glide-core-dropdown label="Label" placeholder="Placeholder" required>
|
46
|
-
<glide-core-dropdown-option
|
47
|
-
label="Label"
|
48
|
-
value="value"
|
49
|
-
></glide-core-dropdown-option>
|
38
|
+
<glide-core-dropdown-option label="Label"></glide-core-dropdown-option>
|
50
39
|
</glide-core-dropdown>`, { parentNode: form });
|
51
40
|
component.checkValidity();
|
52
41
|
expect(component.shadowRoot?.activeElement).to.equal(null);
|