@crowdstrike/glide-core 0.8.0 → 0.9.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/button-group.button.d.ts +14 -15
- package/dist/button-group.button.js +1 -1
- package/dist/button-group.button.styles.js +75 -52
- package/dist/button-group.button.test.basics.d.ts +1 -1
- package/dist/button-group.button.test.basics.js +83 -147
- package/dist/button-group.button.test.events.js +8 -67
- package/dist/button-group.button.test.focus.js +13 -0
- package/dist/button-group.button.test.interactions.d.ts +1 -0
- package/dist/button-group.button.test.interactions.js +42 -0
- package/dist/button-group.d.ts +7 -10
- package/dist/button-group.js +1 -1
- package/dist/button-group.stories.d.ts +1 -5
- package/dist/button-group.styles.js +18 -6
- package/dist/button-group.test.basics.js +113 -234
- package/dist/button-group.test.events.js +210 -263
- package/dist/button-group.test.focus.d.ts +1 -0
- package/dist/button-group.test.focus.js +39 -0
- package/dist/button-group.test.interactions.d.ts +1 -0
- package/dist/button-group.test.interactions.js +91 -0
- package/dist/button.test.basics.js +1 -1
- package/dist/checkbox-group.js +1 -1
- package/dist/checkbox-group.styles.js +1 -1
- package/dist/checkbox-group.test.basics.js +1 -1
- package/dist/checkbox-group.test.events.js +4 -4
- package/dist/checkbox-group.test.focus.js +4 -3
- package/dist/checkbox.d.ts +7 -1
- package/dist/checkbox.js +1 -1
- package/dist/checkbox.styles.js +10 -0
- package/dist/checkbox.test.events.js +4 -4
- package/dist/checkbox.test.focus.js +2 -2
- package/dist/{checkbox.test.states.js → checkbox.test.interactions.js} +24 -1
- package/dist/drawer.js +1 -1
- package/dist/dropdown.d.ts +6 -4
- package/dist/dropdown.js +1 -1
- package/dist/dropdown.option.d.ts +6 -2
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.option.styles.js +13 -0
- package/dist/dropdown.option.test.basics.js +6 -3
- package/dist/dropdown.option.test.events.js +1 -1
- package/dist/dropdown.option.test.focus.js +1 -1
- package/dist/dropdown.option.test.interactions.multiple.js +1 -54
- package/dist/dropdown.option.test.interactions.single.js +51 -9
- package/dist/dropdown.styles.js +20 -19
- package/dist/dropdown.test.basics.js +143 -2
- package/dist/dropdown.test.basics.multiple.js +5 -2
- package/dist/dropdown.test.events.filterable.js +74 -0
- package/dist/dropdown.test.events.js +49 -160
- package/dist/dropdown.test.events.multiple.js +265 -8
- package/dist/dropdown.test.events.single.js +199 -2
- package/dist/dropdown.test.focus.filterable.js +9 -5
- package/dist/dropdown.test.focus.js +1 -1
- package/dist/dropdown.test.focus.multiple.js +1 -1
- package/dist/dropdown.test.focus.single.js +1 -1
- package/dist/dropdown.test.interactions.filterable.js +68 -11
- package/dist/dropdown.test.interactions.js +94 -5
- package/dist/dropdown.test.interactions.multiple.js +202 -5
- package/dist/dropdown.test.interactions.single.js +68 -6
- package/dist/form-controls-layout.test.basics.js +1 -1
- package/dist/icon-button.test.basics.js +1 -1
- package/dist/icons/checked.d.ts +1 -1
- package/dist/icons/checked.js +1 -1
- package/dist/icons/magnifying-glass.js +1 -1
- package/dist/input.d.ts +0 -6
- package/dist/input.js +1 -1
- package/dist/input.styles.js +7 -2
- package/dist/input.test.basics.js +19 -5
- package/dist/input.test.events.js +4 -4
- package/dist/input.test.focus.js +4 -4
- package/dist/input.test.translations.d.ts +1 -0
- package/dist/input.test.translations.js +38 -0
- package/dist/input.test.validity.js +133 -4
- package/dist/label.d.ts +1 -1
- package/dist/label.js +1 -1
- package/dist/label.styles.js +22 -13
- package/dist/label.test.basics.js +26 -24
- package/dist/library/expect-argument-error.js +1 -1
- package/dist/library/localize.d.ts +3 -1
- package/dist/menu.d.ts +3 -5
- package/dist/menu.js +1 -1
- package/dist/menu.options.test.basics.js +2 -2
- package/dist/menu.styles.js +1 -15
- package/dist/menu.test.basics.d.ts +1 -2
- package/dist/menu.test.basics.js +22 -6
- package/dist/menu.test.focus.d.ts +1 -0
- package/dist/menu.test.focus.js +13 -6
- package/dist/menu.test.interactions.js +212 -56
- package/dist/modal.icon-button.test.basics.js +1 -1
- package/dist/modal.js +1 -1
- package/dist/modal.styles.js +18 -13
- package/dist/modal.tertiary-icon.d.ts +0 -1
- package/dist/modal.tertiary-icon.js +1 -1
- package/dist/modal.tertiary-icon.test.basics.js +1 -1
- package/dist/modal.test.basics.js +1 -1
- package/dist/modal.test.events.js +10 -10
- package/dist/radio-group.js +1 -1
- package/dist/radio-group.styles.js +1 -1
- package/dist/radio-group.test.focus.js +3 -3
- package/dist/radio.d.ts +1 -0
- package/dist/radio.js +1 -1
- package/dist/radio.styles.js +33 -0
- package/dist/split-container.test.basics.js +4 -0
- package/dist/split-link.test.interactions.js +1 -1
- package/dist/styles/variables.css +1 -1
- package/dist/tab.d.ts +1 -1
- package/dist/tab.group.js +1 -1
- package/dist/tab.group.test.basics.js +1 -1
- package/dist/tab.group.test.interactions.js +198 -2
- package/dist/tab.js +1 -1
- package/dist/tab.panel.d.ts +1 -0
- package/dist/tab.panel.js +1 -1
- package/dist/tab.panel.styles.js +11 -1
- package/dist/tag.test.basics.js +2 -2
- package/dist/textarea.d.ts +0 -1
- package/dist/textarea.js +2 -2
- package/dist/textarea.stories.d.ts +3 -4
- package/dist/textarea.styles.js +14 -3
- package/dist/textarea.test.basics.js +80 -44
- package/dist/textarea.test.events.js +56 -41
- package/dist/textarea.test.translations.d.ts +1 -0
- package/dist/textarea.test.translations.js +34 -0
- package/dist/textarea.test.validity.js +104 -20
- package/dist/toasts.js +1 -1
- package/dist/toasts.styles.js +8 -1
- package/dist/toasts.test.basics.js +20 -0
- package/dist/toggle.js +1 -1
- package/dist/toggle.test.focus.js +1 -1
- package/dist/toggle.test.interactions.d.ts +1 -0
- package/dist/tooltip.d.ts +7 -5
- package/dist/tooltip.js +1 -1
- package/dist/tooltip.styles.js +90 -25
- package/dist/tooltip.test.basics.js +38 -3
- package/dist/tooltip.test.interactions.js +136 -34
- package/dist/translations/en.js +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/ja.js +1 -1
- package/dist/tree.d.ts +0 -1
- package/dist/tree.item.d.ts +1 -2
- package/dist/tree.item.js +1 -1
- package/dist/tree.item.menu.d.ts +0 -1
- package/dist/tree.item.menu.js +1 -1
- package/dist/tree.js +1 -1
- package/dist/tree.test.basics.js +1 -1
- package/package.json +2 -4
- package/dist/drawer.test.floating-components.d.ts +0 -1
- package/dist/drawer.test.floating-components.js +0 -52
- package/dist/library/set-containing-block.d.ts +0 -15
- package/dist/library/set-containing-block.js +0 -1
- package/dist/modal.test.floating-components.js +0 -63
- /package/dist/{checkbox.test.states.d.ts → button-group.button.test.focus.d.ts} +0 -0
- /package/dist/{modal.test.floating-components.d.ts → checkbox.test.interactions.d.ts} +0 -0
- /package/dist/{toggle.test.states.d.ts → dropdown.test.events.filterable.d.ts} +0 -0
- /package/dist/{toggle.test.states.js → toggle.test.interactions.js} +0 -0
@@ -1,15 +1,17 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
2
|
import './input.js';
|
3
|
-
import { expect, fixture, html } from '@open-wc/testing';
|
3
|
+
import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
|
4
4
|
import { sendKeys } from '@web/test-runner-commands';
|
5
|
-
import
|
6
|
-
|
5
|
+
import GlideCoreInput from './input.js';
|
6
|
+
GlideCoreInput.shadowRootOptions.mode = 'open';
|
7
7
|
it('is valid if empty but not required', async () => {
|
8
8
|
const input = await fixture(html `<glide-core-input></glide-core-input>`);
|
9
9
|
expect(input.validity?.valid).to.be.true;
|
10
10
|
expect(input.validity?.valueMissing).to.be.false;
|
11
11
|
expect(input.checkValidity()).to.be.true;
|
12
12
|
expect(input.reportValidity()).to.be.true;
|
13
|
+
await elementUpdated(input);
|
14
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'false');
|
13
15
|
});
|
14
16
|
it('is valid after being filled in when empty and required', async () => {
|
15
17
|
const input = await fixture(html `<glide-core-input required></glide-core-input>`);
|
@@ -19,6 +21,8 @@ it('is valid after being filled in when empty and required', async () => {
|
|
19
21
|
expect(input.validity?.valueMissing).to.be.false;
|
20
22
|
expect(input.checkValidity()).to.be.true;
|
21
23
|
expect(input.reportValidity()).to.be.true;
|
24
|
+
await elementUpdated(input);
|
25
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'false');
|
22
26
|
});
|
23
27
|
it('is invalid if no value and required', async () => {
|
24
28
|
const input = await fixture(html `<glide-core-input required></glide-core-input>`);
|
@@ -27,6 +31,8 @@ it('is invalid if no value and required', async () => {
|
|
27
31
|
expect(input.willValidate).to.be.true;
|
28
32
|
expect(input.checkValidity()).to.be.false;
|
29
33
|
expect(input.reportValidity()).to.be.false;
|
34
|
+
await elementUpdated(input);
|
35
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'true');
|
30
36
|
});
|
31
37
|
it('is invalid after value is cleared when required', async () => {
|
32
38
|
const input = await fixture(html `<glide-core-input
|
@@ -34,13 +40,76 @@ it('is invalid after value is cleared when required', async () => {
|
|
34
40
|
value="value"
|
35
41
|
required
|
36
42
|
></glide-core-input>`);
|
37
|
-
const clearButton = input.shadowRoot?.querySelector('
|
43
|
+
const clearButton = input.shadowRoot?.querySelector('[data-test="clear-button"]');
|
38
44
|
clearButton?.click();
|
39
45
|
await input.updateComplete;
|
40
46
|
expect(input.validity?.valid).to.be.false;
|
41
47
|
expect(input.validity?.valueMissing).to.be.true;
|
42
48
|
expect(input.checkValidity()).to.be.false;
|
43
49
|
expect(input.reportValidity()).to.be.false;
|
50
|
+
await elementUpdated(input);
|
51
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'true');
|
52
|
+
});
|
53
|
+
it('is valid when empty and does not exceed `maxlength`', async () => {
|
54
|
+
const input = await fixture(html `<glide-core-input maxlength="3"></glide-core-input>`);
|
55
|
+
expect(input.validity?.valid).to.be.true;
|
56
|
+
expect(input.validity?.valueMissing).to.be.false;
|
57
|
+
expect(input.validity?.tooLong).to.be.false;
|
58
|
+
expect(input.checkValidity()).to.be.true;
|
59
|
+
expect(input.reportValidity()).to.be.true;
|
60
|
+
await elementUpdated(input);
|
61
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'false');
|
62
|
+
});
|
63
|
+
it('is valid when filled in and does not exceed `maxlength`', async () => {
|
64
|
+
const input = await fixture(html `<glide-core-input maxlength="3"></glide-core-input>`);
|
65
|
+
input.focus();
|
66
|
+
await sendKeys({ type: 'val' });
|
67
|
+
expect(input.validity?.valid).to.be.true;
|
68
|
+
expect(input.validity?.valueMissing).to.be.false;
|
69
|
+
expect(input.validity?.tooLong).to.be.false;
|
70
|
+
expect(input.checkValidity()).to.be.true;
|
71
|
+
expect(input.reportValidity()).to.be.true;
|
72
|
+
await elementUpdated(input);
|
73
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'false');
|
74
|
+
});
|
75
|
+
it('is valid when filled in, disabled, and value exceeds `maxlength`', async () => {
|
76
|
+
const input = await fixture(html `<glide-core-input
|
77
|
+
value="value"
|
78
|
+
maxlength="3"
|
79
|
+
disabled
|
80
|
+
></glide-core-input>`);
|
81
|
+
expect(input.validity?.valid).to.be.true;
|
82
|
+
expect(input.validity?.valueMissing).to.be.false;
|
83
|
+
expect(input.validity?.tooLong).to.be.false;
|
84
|
+
expect(input.checkValidity()).to.be.true;
|
85
|
+
expect(input.reportValidity()).to.be.true;
|
86
|
+
await elementUpdated(input);
|
87
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'false');
|
88
|
+
});
|
89
|
+
it('is valid when filled in, readonly, and value exceeds `maxlength`', async () => {
|
90
|
+
const input = await fixture(html `<glide-core-input
|
91
|
+
value="value"
|
92
|
+
maxlength="3"
|
93
|
+
readonly
|
94
|
+
></glide-core-input>`);
|
95
|
+
expect(input.validity?.valid).to.be.true;
|
96
|
+
expect(input.validity?.valueMissing).to.be.false;
|
97
|
+
expect(input.validity?.tooLong).to.be.false;
|
98
|
+
expect(input.checkValidity()).to.be.true;
|
99
|
+
expect(input.reportValidity()).to.be.true;
|
100
|
+
await elementUpdated(input);
|
101
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'false');
|
102
|
+
});
|
103
|
+
it('is invalid when filled in and exceeds `maxlength`', async () => {
|
104
|
+
const input = await fixture(html `<glide-core-input maxlength="3"></glide-core-input>`);
|
105
|
+
input.focus();
|
106
|
+
await sendKeys({ type: 'value' });
|
107
|
+
expect(input.validity?.valid).to.be.false;
|
108
|
+
expect(input.validity?.tooLong).to.be.true;
|
109
|
+
expect(input.checkValidity()).to.be.false;
|
110
|
+
expect(input.reportValidity()).to.be.false;
|
111
|
+
await elementUpdated(input);
|
112
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'true');
|
44
113
|
});
|
45
114
|
it('is valid if no value and required but disabled', async () => {
|
46
115
|
const input = await fixture(html `<glide-core-input disabled required></glide-core-input>`);
|
@@ -48,4 +117,64 @@ it('is valid if no value and required but disabled', async () => {
|
|
48
117
|
expect(input.validity?.valueMissing).to.be.false;
|
49
118
|
expect(input.checkValidity()).to.be.true;
|
50
119
|
expect(input.reportValidity()).to.be.true;
|
120
|
+
await elementUpdated(input);
|
121
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'false');
|
122
|
+
});
|
123
|
+
it('updates validity when `required` and `value` is changed programmatically', async () => {
|
124
|
+
const input = await fixture(html `<glide-core-input label="Label" required></glide-core-input>`);
|
125
|
+
expect(input.validity?.valid).to.be.false;
|
126
|
+
expect(input.validity?.valueMissing).to.be.true;
|
127
|
+
expect(input.checkValidity()).to.be.false;
|
128
|
+
expect(input.reportValidity()).to.be.false;
|
129
|
+
await elementUpdated(input);
|
130
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'true');
|
131
|
+
input.value = 'text';
|
132
|
+
await elementUpdated(input);
|
133
|
+
expect(input.validity?.valid).to.be.true;
|
134
|
+
expect(input.validity?.valueMissing).to.be.false;
|
135
|
+
expect(input.checkValidity()).to.be.true;
|
136
|
+
expect(input.reportValidity()).to.be.true;
|
137
|
+
await elementUpdated(input);
|
138
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'false');
|
139
|
+
// Resetting the value to empty to ensure it goes
|
140
|
+
// back to an invalid state
|
141
|
+
input.value = '';
|
142
|
+
await elementUpdated(input);
|
143
|
+
expect(input.validity?.valid).to.be.false;
|
144
|
+
expect(input.validity?.valueMissing).to.be.true;
|
145
|
+
expect(input.checkValidity()).to.be.false;
|
146
|
+
expect(input.reportValidity()).to.be.false;
|
147
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'true');
|
148
|
+
});
|
149
|
+
it('is invalid when `value` is empty and `required` is set to `true` programmatically', async () => {
|
150
|
+
const input = await fixture(html `<glide-core-input label="Label"></glide-core-input>`);
|
151
|
+
expect(input.validity?.valid).to.be.true;
|
152
|
+
expect(input.validity?.valueMissing).to.be.false;
|
153
|
+
expect(input.checkValidity()).to.be.true;
|
154
|
+
expect(input.reportValidity()).to.be.true;
|
155
|
+
await elementUpdated(input);
|
156
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'false');
|
157
|
+
input.required = true;
|
158
|
+
await elementUpdated(input);
|
159
|
+
expect(input.validity?.valid).to.be.false;
|
160
|
+
expect(input.validity?.valueMissing).to.be.true;
|
161
|
+
expect(input.checkValidity()).to.be.false;
|
162
|
+
expect(input.reportValidity()).to.be.false;
|
163
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'true');
|
164
|
+
});
|
165
|
+
it('is valid when `value` is empty and `required` is set to `false` programmatically', async () => {
|
166
|
+
const input = await fixture(html `<glide-core-input label="Label" required></glide-core-input>`);
|
167
|
+
expect(input.validity?.valid).to.be.false;
|
168
|
+
expect(input.validity?.valueMissing).to.be.true;
|
169
|
+
expect(input.checkValidity()).to.be.false;
|
170
|
+
expect(input.reportValidity()).to.be.false;
|
171
|
+
await elementUpdated(input);
|
172
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'true');
|
173
|
+
input.required = false;
|
174
|
+
await elementUpdated(input);
|
175
|
+
expect(input.validity?.valid).to.be.true;
|
176
|
+
expect(input.validity?.valueMissing).to.be.false;
|
177
|
+
expect(input.checkValidity()).to.be.true;
|
178
|
+
expect(input.reportValidity()).to.be.true;
|
179
|
+
expect(input.shadowRoot?.querySelector('input')).to.have.attribute('aria-invalid', 'false');
|
51
180
|
});
|
package/dist/label.d.ts
CHANGED
package/dist/label.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,o,l){var i,s=arguments.length,r=s<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,l);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(r=(s<3?i(r):s>3?i(t,o,r):i(t,o))||r);return s>3&&r&&Object.defineProperty(t,o,r),r};import"./tooltip.js";import{LitElement,html}from"lit";import{LocalizeController}from"./library/localize.js";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import ow,{owSlot}from"./library/ow.js";import styles from"./label.styles.js";
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,l){var i,s=arguments.length,r=s<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,l);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(r=(s<3?i(r):s>3?i(t,o,r):i(t,o))||r);return s>3&&r&&Object.defineProperty(t,o,r),r};import"./tooltip.js";import{LitElement,html,svg}from"lit";import{LocalizeController}from"./library/localize.js";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import ow,{owSlot}from"./library/ow.js";import styles from"./label.styles.js";const infoCircleIcon=svg`<circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"><path d="M12 16L12 12" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="8" r="1" fill="currentColor">`;let GlideCoreLabel=class GlideCoreLabel extends LitElement{constructor(){super(...arguments),this.disabled=!1,this.error=!1,this.hide=!1,this.orientation="horizontal",this.required=!1,this.hasDescriptionSlot=!1,this.hasSummarySlot=!1,this.hasTooltipSlot=!1,this.isLabelTooltip=!1,this.label="",this.#e=createRef(),this.#t=createRef(),this.#o=createRef(),this.#l=createRef(),this.#i=new LocalizeController(this),this.#s=createRef(),this.#r=createRef()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}firstUpdated(){owSlot(this.#t.value),owSlot(this.#e.value)}render(){return html`<div class="${classMap({component:!0,horizontal:"horizontal"===this.orientation,vertical:"vertical"===this.orientation,left:"left"===this.split,middle:"middle"===this.split,"hidden-label":this.hide})}"><div class="${classMap({"tooltips-and-label":!0,hidden:this.hide,left:"left"===this.split,middle:"middle"===this.split})}" part="tooltips-and-label"><glide-core-tooltip class="${classMap({"optional-tooltip":!0,vertical:"vertical"===this.orientation,visible:this.hasTooltipSlot})}" placement="${"vertical"===this.orientation?"right":"bottom"}"><span class="optional-tooltip-target" slot="target" tabindex="0"><svg aria-label="${this.#i.term("moreInformation")}" width="16" height="16" viewBox="0 0 24 24" fill="none">${infoCircleIcon}</svg></span><slot name="tooltip" @slotchange="${this.#a}" ${ref(this.#r)}></slot></glide-core-tooltip><glide-core-tooltip class="label-tooltip" placement="right" ?disabled="${!this.isLabelTooltip}"><div class="${classMap({label:!0,disabled:this.disabled})}" data-test="label" slot="target" ${ref(this.#l)}><slot @slotchange="${this.#n}" ${ref(this.#t)}></slot>${this.required?html`<span aria-hidden="true" class="required-symbol">*</span>`:""}</div><div aria-hidden="true">${this.label}</div></glide-core-tooltip></div><div class="control-and-summary"><slot class="${classMap({control:!0,error:this.error,disabled:this.disabled,vertical:"vertical"===this.orientation,summaryless:!this.hasSummarySlot,"hidden-label":this.hide})}" name="control" @slotchange="${this.#d}" ${ref(this.#e)}></slot><slot class="${classMap({summary:!0,error:this.error})}" name="summary" @slotchange="${this.#c}" ${ref(this.#s)}></slot></div><slot class="${classMap({description:!0,visible:this.hasDescriptionSlot,error:this.error,tooltip:this.hasTooltipSlot})}" id="description" name="description" @slotchange="${this.#h}" ${ref(this.#o)}></slot></div>`}#e;#t;#o;#l;#i;#s;#r;#d(){owSlot(this.#e.value)}#n(){owSlot(this.#t.value);const e=this.#t.value?.assignedElements().at(0),t=this.#l.value;ow(e,ow.object.instanceOf(Element)),ow(t,ow.object.instanceOf(HTMLElement)),e.textContent&&(this.label=e.textContent);new ResizeObserver((()=>{this.isLabelTooltip=e.getBoundingClientRect().width>t.getBoundingClientRect().width})).observe(t)}#h(){const e=this.#o.value?.assignedNodes({flatten:!0});this.hasDescriptionSlot=Boolean(e&&e.length>0)}#c(){const e=this.#s.value?.assignedNodes({flatten:!0});this.hasSummarySlot=Boolean(e&&e.length>0)}#a(){const e=this.#r.value?.assignedNodes({flatten:!0});this.hasTooltipSlot=Boolean(e&&e.length>0)}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"disabled",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"error",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"hide",void 0),__decorate([property({reflect:!0})],GlideCoreLabel.prototype,"orientation",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"required",void 0),__decorate([property()],GlideCoreLabel.prototype,"split",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasDescriptionSlot",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasSummarySlot",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasTooltipSlot",void 0),__decorate([state()],GlideCoreLabel.prototype,"isLabelTooltip",void 0),__decorate([state()],GlideCoreLabel.prototype,"label",void 0),GlideCoreLabel=__decorate([customElement("glide-core-private-label")],GlideCoreLabel);export default GlideCoreLabel;
|
package/dist/label.styles.js
CHANGED
@@ -3,13 +3,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
3
3
|
&.horizontal {
|
4
4
|
column-gap: var(--glide-core-spacing-sm);
|
5
5
|
display: grid;
|
6
|
-
|
7
|
-
/*
|
8
|
-
Since 1fr is actually minmax(auto, 1fr), this explicit minmax will make it so
|
9
|
-
the first column is sized to its content, and the second column fills the rest
|
10
|
-
of the space.
|
11
|
-
*/
|
12
|
-
grid-template-columns: auto minmax(0, 1fr);
|
6
|
+
grid-template-columns: auto minmax(min-content, 1fr);
|
13
7
|
}
|
14
8
|
|
15
9
|
&.vertical {
|
@@ -22,7 +16,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
22
16
|
}
|
23
17
|
|
24
18
|
&.middle {
|
25
|
-
grid-template-columns:
|
19
|
+
grid-template-columns: 50% 50%;
|
26
20
|
}
|
27
21
|
|
28
22
|
&.hidden-label {
|
@@ -35,10 +29,21 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
35
29
|
align-items: center;
|
36
30
|
column-gap: var(--glide-core-spacing-xs);
|
37
31
|
display: flex;
|
38
|
-
justify-content: flex-end;
|
39
32
|
|
40
|
-
/*
|
41
|
-
|
33
|
+
/*
|
34
|
+
Prevents it from growing larger than its column percentage when a child of Form Controls
|
35
|
+
Layout. Also allows for an ellipsis on the label. See the linked comment for why it's "3ch"
|
36
|
+
instead of "0".
|
37
|
+
|
38
|
+
- https://css-tricks.com/flexbox-truncated-text/#aa-the-solution-is-min-width-0-on-the-flex-child
|
39
|
+
- https://github.com/CrowdStrike/glide-core/pull/317#issuecomment-2297025365
|
40
|
+
*/
|
41
|
+
min-inline-size: 3ch;
|
42
|
+
|
43
|
+
&.middle,
|
44
|
+
&.left {
|
45
|
+
justify-content: flex-end;
|
46
|
+
}
|
42
47
|
|
43
48
|
&.hidden {
|
44
49
|
${visuallyHidden};
|
@@ -110,8 +115,12 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
110
115
|
}
|
111
116
|
}
|
112
117
|
|
113
|
-
.label-
|
114
|
-
|
118
|
+
.label-tooltip {
|
119
|
+
display: flex;
|
120
|
+
max-inline-size: 100%;
|
121
|
+
|
122
|
+
/* https://css-tricks.com/flexbox-truncated-text/#aa-the-solution-is-min-width-0-on-the-flex-child */
|
123
|
+
min-inline-size: 0;
|
115
124
|
}
|
116
125
|
|
117
126
|
.required-symbol {
|
@@ -5,13 +5,13 @@ import GlideCoreLabel from './label.js';
|
|
5
5
|
import sinon from 'sinon';
|
6
6
|
GlideCoreLabel.shadowRootOptions.mode = 'open';
|
7
7
|
it('registers', async () => {
|
8
|
-
expect(window.customElements.get('glide-core-label')).to.equal(GlideCoreLabel);
|
8
|
+
expect(window.customElements.get('glide-core-private-label')).to.equal(GlideCoreLabel);
|
9
9
|
});
|
10
10
|
it('has defaults', async () => {
|
11
|
-
const component = await fixture(html `<glide-core-label>
|
11
|
+
const component = await fixture(html `<glide-core-private-label>
|
12
12
|
<label for="input">Label</label>
|
13
13
|
<input id="input" slot="control" />
|
14
|
-
</glide-core-label>`);
|
14
|
+
</glide-core-private-label>`);
|
15
15
|
expect(component.getAttribute('error')).to.equal(null);
|
16
16
|
expect(component.error).to.equal(false);
|
17
17
|
expect(component.getAttribute('hide')).to.equal(null);
|
@@ -22,80 +22,80 @@ it('has defaults', async () => {
|
|
22
22
|
expect(component.required).to.be.false;
|
23
23
|
});
|
24
24
|
it('is accessible', async () => {
|
25
|
-
const component = await fixture(html `<glide-core-label>
|
25
|
+
const component = await fixture(html `<glide-core-private-label>
|
26
26
|
<label for="input">Label</label>
|
27
27
|
<input id="input" slot="control" />
|
28
28
|
<div slot="tooltip">Tooltip</div>
|
29
29
|
<div slot="description">Description</div>
|
30
|
-
</glide-core-label>`);
|
30
|
+
</glide-core-private-label>`);
|
31
31
|
await expect(component).to.be.accessible();
|
32
32
|
});
|
33
33
|
it('can have a label', async () => {
|
34
|
-
const component = await fixture(html `<glide-core-label>
|
34
|
+
const component = await fixture(html `<glide-core-private-label>
|
35
35
|
<label for="input">Label</label>
|
36
36
|
<input id="input" slot="control" />
|
37
|
-
</glide-core-label>`);
|
37
|
+
</glide-core-private-label>`);
|
38
38
|
const assignedElements = component.shadowRoot
|
39
39
|
?.querySelector('slot:not([name])')
|
40
40
|
?.assignedElements();
|
41
41
|
expect(assignedElements?.at(0)?.textContent).to.equal('Label');
|
42
42
|
});
|
43
43
|
it('can have a description', async () => {
|
44
|
-
const component = await fixture(html `<glide-core-label>
|
44
|
+
const component = await fixture(html `<glide-core-private-label>
|
45
45
|
<label for="input">Label</label>
|
46
46
|
<input id="input" slot="control" />
|
47
47
|
<div slot="description">Description</div>
|
48
|
-
</glide-core-label>`);
|
48
|
+
</glide-core-private-label>`);
|
49
49
|
const assignedElements = component.shadowRoot
|
50
50
|
?.querySelector('slot[name="description"]')
|
51
51
|
?.assignedElements();
|
52
52
|
expect(assignedElements?.at(0)?.textContent).to.equal('Description');
|
53
53
|
});
|
54
54
|
it('can have a tooltip', async () => {
|
55
|
-
const component = await fixture(html `<glide-core-label>
|
55
|
+
const component = await fixture(html `<glide-core-private-label>
|
56
56
|
<label for="input">Label</label>
|
57
57
|
<input id="input" slot="control" />
|
58
58
|
<div slot="tooltip">Tooltip</div>
|
59
|
-
</glide-core-label>`);
|
59
|
+
</glide-core-private-label>`);
|
60
60
|
const assignedElements = component.shadowRoot
|
61
61
|
?.querySelector('slot[name="tooltip"]')
|
62
62
|
?.assignedElements();
|
63
63
|
expect(assignedElements?.at(0)?.textContent).to.equal('Tooltip');
|
64
64
|
});
|
65
65
|
it('can be required', async () => {
|
66
|
-
const component = await fixture(html `<glide-core-label required>
|
66
|
+
const component = await fixture(html `<glide-core-private-label required>
|
67
67
|
<label for="input">Label</label>
|
68
68
|
<input id="input" slot="control" />
|
69
|
-
</glide-core-label>`);
|
69
|
+
</glide-core-private-label>`);
|
70
70
|
expect(component.hasAttribute('required')).to.be.true;
|
71
71
|
expect(component.required).to.equal(true);
|
72
72
|
const label = component.shadowRoot?.querySelector('[data-test="label"]');
|
73
73
|
expect(label?.textContent?.includes('*')).to.be.true;
|
74
74
|
});
|
75
75
|
it('can have an `error`', async () => {
|
76
|
-
const component = await fixture(html `<glide-core-label ?error=${true}>
|
76
|
+
const component = await fixture(html `<glide-core-private-label ?error=${true}>
|
77
77
|
<label for="input">Label</label>
|
78
78
|
<input id="input" slot="control" />
|
79
|
-
</glide-core-label>`);
|
79
|
+
</glide-core-private-label>`);
|
80
80
|
expect(component.hasAttribute('error')).to.be.true;
|
81
81
|
expect(component.error).to.equal(true);
|
82
82
|
});
|
83
83
|
it('places the tooltip on the bottom when horizontal', async () => {
|
84
|
-
const component = await fixture(html `<glide-core-label>
|
84
|
+
const component = await fixture(html `<glide-core-private-label>
|
85
85
|
<label for="input">Label</label>
|
86
86
|
<input id="input" slot="control" />
|
87
87
|
<div slot="tooltip">Tooltip</div>
|
88
|
-
</glide-core-label>`);
|
88
|
+
</glide-core-private-label>`);
|
89
89
|
expect(component.shadowRoot
|
90
90
|
?.querySelector('glide-core-tooltip')
|
91
91
|
?.getAttribute('placement')).to.equal('bottom');
|
92
92
|
});
|
93
93
|
it('places the tooltip on the right when vertical', async () => {
|
94
|
-
const component = await fixture(html `<glide-core-label orientation="vertical">
|
94
|
+
const component = await fixture(html `<glide-core-private-label orientation="vertical">
|
95
95
|
<label for="input">Label</label>
|
96
96
|
<input id="input" slot="control" />
|
97
97
|
<div slot="tooltip">Tooltip</div>
|
98
|
-
</glide-core-label>`);
|
98
|
+
</glide-core-private-label>`);
|
99
99
|
expect(component.shadowRoot
|
100
100
|
?.querySelector('glide-core-tooltip')
|
101
101
|
?.getAttribute('placement')).to.equal('right');
|
@@ -103,29 +103,31 @@ it('places the tooltip on the right when vertical', async () => {
|
|
103
103
|
it('throws if it does not have a default slot', async () => {
|
104
104
|
const spy = sinon.spy();
|
105
105
|
try {
|
106
|
-
await fixture(html `<glide-core-
|
106
|
+
await fixture(html `<glide-core-private-label
|
107
|
+
><input slot="control"
|
108
|
+
/></glide-core-private-label>`);
|
107
109
|
}
|
108
110
|
catch (error) {
|
109
111
|
if (error instanceof ArgumentError) {
|
110
112
|
spy();
|
111
113
|
}
|
112
114
|
}
|
113
|
-
expect(spy.
|
115
|
+
expect(spy.callCount).to.equal(1);
|
114
116
|
});
|
115
117
|
it('throws if it does not have a "control" slot', async () => {
|
116
118
|
const spy = sinon.spy();
|
117
119
|
const stub = sinon.stub(console, 'error');
|
118
120
|
try {
|
119
|
-
await fixture(html `<glide-core-label>
|
121
|
+
await fixture(html `<glide-core-private-label>
|
120
122
|
<label>Label</label>
|
121
|
-
</glide-core-label>`);
|
123
|
+
</glide-core-private-label>`);
|
122
124
|
}
|
123
125
|
catch (error) {
|
124
126
|
if (error instanceof ArgumentError) {
|
125
127
|
spy();
|
126
128
|
}
|
127
129
|
}
|
128
|
-
expect(spy.
|
130
|
+
expect(spy.callCount).to.equal(1);
|
129
131
|
// It's not clear to me why the error logged by Ow shows up in the console
|
130
132
|
// here and not in the above test or elsewhere. A bug in Web Test Runner?
|
131
133
|
// Something I don't understand about Lit's lifecycle?
|
@@ -1 +1 @@
|
|
1
|
-
import{ArgumentError}from"ow";import{expect}from"@open-wc/testing";import sinon from"sinon";export default async function(o){const
|
1
|
+
import{ArgumentError}from"ow";import{expect}from"@open-wc/testing";import sinon from"sinon";export default async function(o){const n=window.onerror;window.onerror=null;const r=sinon.spy();try{await o.call(context)}catch(o){o instanceof ArgumentError&&r()}expect(r.callCount).to.equal(1),window.onerror=n}
|
@@ -10,10 +10,12 @@ export interface Translation extends DefaultTranslation {
|
|
10
10
|
dismiss: string;
|
11
11
|
open: string;
|
12
12
|
selectAll: string;
|
13
|
-
clearEntry: string;
|
14
13
|
moreInformation: string;
|
15
14
|
notifications: string;
|
16
15
|
nextTab: string;
|
17
16
|
previousTab: string;
|
17
|
+
announcedCharacterCount: (current: number, maximum: number) => string;
|
18
|
+
displayedCharacterCount: (current: number, maximum: number) => string;
|
19
|
+
clearEntry: (label: string) => string;
|
18
20
|
removeTag: (name: string) => string;
|
19
21
|
}
|
package/dist/menu.d.ts
CHANGED
@@ -8,7 +8,7 @@ declare global {
|
|
8
8
|
/**
|
9
9
|
* @description A basic menu.
|
10
10
|
*
|
11
|
-
* @slot -
|
11
|
+
* @slot - `<glide-core-menu-options>`.
|
12
12
|
* @slot target - A focusable element against which Menu will be positioned. Opens and closes Menu when interacted with.
|
13
13
|
*/
|
14
14
|
export default class GlideCoreMenu extends LitElement {
|
@@ -18,15 +18,13 @@ export default class GlideCoreMenu extends LitElement {
|
|
18
18
|
get open(): boolean;
|
19
19
|
set open(isOpen: boolean);
|
20
20
|
placement: Placement;
|
21
|
-
containingBlock?: Element;
|
22
21
|
get size(): 'small' | 'large';
|
23
22
|
set size(size: 'small' | 'large');
|
24
23
|
connectedCallback(): void;
|
25
24
|
createRenderRoot(): ShadowRoot;
|
26
25
|
disconnectedCallback(): void;
|
27
26
|
firstUpdated(): void;
|
28
|
-
focus(): void;
|
27
|
+
focus(options?: FocusOptions): void;
|
28
|
+
private get isTargetDisabled();
|
29
29
|
render(): import("lit").TemplateResult<1>;
|
30
|
-
setContainingBlock(containingBlock: Element): void;
|
31
|
-
private isTargetDisabled;
|
32
30
|
}
|
package/dist/menu.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,i,o){var n,s=arguments.length,
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,o){var n,s=arguments.length,l=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(l=(s<3?n(l):s>3?n(t,i,l):n(t,i))||l);return s>3&&l&&Object.defineProperty(t,i,l),l};import{LitElement,html}from"lit";import{autoUpdate,computePosition,flip,offset}from"@floating-ui/dom";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property}from"lit/decorators.js";import{nanoid}from"nanoid";import GlideCoreMenuButton from"./menu.button.js";import GlideCoreMenuLink from"./menu.link.js";import GlideCoreMenuOptions from"./menu.options.js";import ow,{owSlot,owSlotType}from"./library/ow.js";import styles from"./menu.styles.js";let GlideCoreMenu=class GlideCoreMenu extends LitElement{constructor(){super(...arguments),this.placement="bottom-start",this.#e=createRef(),this.#t=createRef(),this.#i=!1,this.#o=!1,this.#n="large",this.#s=createRef(),this.#l=e=>{e.target&&e.target instanceof Node&&this.contains(e.target)||(this.open=!1,this.#a&&(this.#a.ariaActivedescendant=""))}}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get open(){return this.#o}set open(e){this.#o=e,e&&!this.isTargetDisabled?this.#r():this.#c()}get size(){return this.#n}set size(e){this.#n=e,this.#a&&(this.#a.privateSize=e)}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.#l,{capture:!0})}createRenderRoot(){return this.#d=super.createRenderRoot(),this.#d}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.#l,{capture:!0})}firstUpdated(){ow(this.#a,ow.object.instanceOf(GlideCoreMenuOptions)),owSlot(this.#t.value),owSlot(this.#s.value),owSlotType(this.#t.value,[GlideCoreMenuOptions]),this.#t.value.popover="manual";const e=this.#h?.at(0);this.open&&e&&!this.isTargetDisabled&&(e.privateActive=!0,this.#r())}focus(e){this.#p&&"focus"in this.#p&&this.#p?.focus(e)}get isTargetDisabled(){const e=this.#p&&"disabled"in this.#p&&this.#p.disabled,t=this.#p&&"true"===this.#p.ariaDisabled;return Boolean(e)||Boolean(t)}render(){return html`<div class="component" @focusout="${this.#m}" ${ref(this.#e)}><slot class="target-slot" name="target" @click="${this.#u}" @keydown="${this.#f}" @slotchange="${this.#E}" ${ref(this.#s)}></slot><slot class="default-slot" @click="${this.#v}" @focusin="${this.#g}" @keydown="${this.#f}" @mouseover="${this.#w}" @slotchange="${this.#S}" ${ref(this.#t)}></slot></div>`}#C;#e;#t;#i;#o;#d;#n;#s;get#y(){return this.#h?.find((({privateActive:e})=>e))}#l;#c(){this.#C?.(),this.#a&&(this.#a.ariaActivedescendant=""),this.#p&&(this.#p.ariaExpanded="false"),this.#t.value?.hidePopover()}get#a(){const e=this.#t.value?.assignedElements().at(0);return e instanceof GlideCoreMenuOptions?e:null}#S(){ow(this.#a,ow.object.instanceOf(GlideCoreMenuOptions)),owSlot(this.#t.value),owSlotType(this.#t.value,[GlideCoreMenuOptions]);const e=this.#h?.at(0);e&&(e.privateActive=!0),this.#a.privateSize=this.size}#v(){this.open=!1}#g(e){(e.target instanceof GlideCoreMenuButton||e.target instanceof GlideCoreMenuLink)&&this.#y&&this.#a&&(e.target.privateActive=!0,this.#y.privateActive=!1,this.#a.ariaActivedescendant=e.target.id)}#w(e){if(e.target instanceof GlideCoreMenuLink||e.target instanceof GlideCoreMenuButton){if(this.#h)for(const t of this.#h)t.privateActive=t===e.target;this.#a&&(this.#a.ariaActivedescendant=e.target.id)}}#m(e){const t=e.relatedTarget instanceof HTMLElement&&this.#d?.contains(e.relatedTarget),i=e.relatedTarget instanceof GlideCoreMenuOptions,o=e.relatedTarget instanceof GlideCoreMenuButton||e.relatedTarget instanceof GlideCoreMenuLink;t||i||o||(this.open=!1)}#f(e){if(ow(this.#a,ow.object.instanceOf(GlideCoreMenuOptions)),[" ","Enter","Escape"].includes(e.key)&&this.open)return this.open=!1,this.focus(),void(this.#i=!0);if([" ","ArrowUp","ArrowDown"].includes(e.key)&&!this.open&&this.#y)return e.preventDefault(),this.open=!0,void(this.#a.ariaActivedescendant=this.#y.id);if(this.open){ow(this.#h,ow.array),ow(this.#a,ow.object.instanceOf(GlideCoreMenuOptions)),ow(this.#y,ow.object.is((e=>e instanceof GlideCoreMenuButton||e instanceof GlideCoreMenuLink)));const t=this.#h.indexOf(this.#y);if("ArrowUp"===e.key&&!e.metaKey){e.preventDefault();const i=this.#h.at(t-1);return void(i&&0!==t&&(this.#y.privateActive=!1,this.#a.ariaActivedescendant=i.id,i.privateActive=!0))}if("ArrowDown"===e.key&&!e.metaKey){e.preventDefault();const i=this.#h.at(t+1);return void(i&&(this.#y.privateActive=!1,this.#a.ariaActivedescendant=i.id,i.privateActive=!0))}if("ArrowUp"===e.key&&e.metaKey||"Home"===e.key||"PageUp"===e.key){e.preventDefault();const t=this.#h.at(0);return void(t&&(this.#y.privateActive=!1,this.#a.ariaActivedescendant=t.id,t.privateActive=!0))}if("ArrowDown"===e.key&&e.metaKey||"End"===e.key||"PageDown"===e.key){e.preventDefault();const t=this.#h.at(-1);return void(t&&(this.#y.privateActive=!1,this.#a.ariaActivedescendant=t.id,t.privateActive=!0))}}}#E(){owSlot(this.#s.value),ow(this.#p,ow.object.instanceOf(Element)),ow(this.#a,ow.object.instanceOf(GlideCoreMenuOptions));new MutationObserver((e=>{e.some((e=>"disabled"===e.attributeName||"aria-disabled"===e.attributeName))&&(this.open&&!this.isTargetDisabled?this.#r():this.#c())})).observe(this.#p,{attributes:!0}),this.#p.ariaHasPopup="true",this.#p.id=nanoid(),this.#p.setAttribute("aria-controls",this.#a.id),this.#a.ariaLabelledby=this.#p.id,this.open&&!this.isTargetDisabled?this.#r():this.#c()}#u(){this.isTargetDisabled?this.#c():this.#i?this.#i=!1:(this.#h&&this.#h.length>0&&(this.open=!this.open),!this.open&&this.#a&&this.focus())}get#h(){let e=this.#t.value?.assignedElements()?.at(0)?.children;const t=e?.[0];if(t instanceof HTMLSlotElement&&(e=t.assignedElements()),e)return[...e].filter((e=>e instanceof GlideCoreMenuLink||e instanceof GlideCoreMenuButton))}#r(){this.#C?.(),this.#p&&this.#t.value&&(this.#C=autoUpdate(this.#p,this.#t.value,(()=>{(async()=>{if(this.#p&&this.#t.value){const{x:e,y:t,placement:i}=await computePosition(this.#p,this.#t.value,{placement:this.placement,middleware:[offset({mainAxis:Number.parseFloat(window.getComputedStyle(document.body).getPropertyValue("--glide-core-spacing-xxs"))*Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)}),flip()]});this.#t.value.dataset.placement=i,Object.assign(this.#t.value.style,{left:`${e}px`,top:`${t}px`})}this.#t.value?.showPopover(),this.#a&&this.#y?.id&&(this.#a.ariaActivedescendant=this.#y.id),this.#p&&(this.#p.ariaExpanded="true")})()})))}get#p(){return this.#s.value?.assignedElements().at(0)}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreMenu.prototype,"open",null),__decorate([property({reflect:!0})],GlideCoreMenu.prototype,"placement",void 0),__decorate([property({reflect:!0})],GlideCoreMenu.prototype,"size",null),GlideCoreMenu=__decorate([customElement("glide-core-menu")],GlideCoreMenu);export default GlideCoreMenu;
|
@@ -19,7 +19,7 @@ it('throws if it does not have a default slot', async () => {
|
|
19
19
|
spy();
|
20
20
|
}
|
21
21
|
}
|
22
|
-
expect(spy.
|
22
|
+
expect(spy.callCount).to.equal(1);
|
23
23
|
});
|
24
24
|
it('throws if the default slot is the incorrect type', async () => {
|
25
25
|
await expectArgumentError(() => {
|
@@ -40,5 +40,5 @@ it('does not throw if the default slot only contains whitespace', async () => {
|
|
40
40
|
spy();
|
41
41
|
}
|
42
42
|
}
|
43
|
-
expect(spy.
|
43
|
+
expect(spy.callCount).to.equal(0);
|
44
44
|
});
|
package/dist/menu.styles.js
CHANGED
@@ -20,25 +20,11 @@ import{css}from"lit";export default[css`
|
|
20
20
|
border-radius: var(--glide-core-spacing-xs);
|
21
21
|
box-shadow: var(--glide-core-shadow-lg);
|
22
22
|
box-sizing: border-box;
|
23
|
-
display: flex;
|
24
23
|
inline-size: max-content;
|
25
|
-
inset
|
26
|
-
inset-inline-start: 0;
|
24
|
+
inset: unset;
|
27
25
|
margin-block: 0;
|
28
26
|
min-inline-size: 9.375rem;
|
29
27
|
padding: var(--glide-core-spacing-xxxs);
|
30
28
|
position: absolute;
|
31
|
-
visibility: hidden;
|
32
|
-
|
33
|
-
/*
|
34
|
-
".container" is relative and many Menus may be stacked in a column.
|
35
|
-
This ensures the ".menu" of Menus earlier in the column aren't obscured
|
36
|
-
by the ".target-container" that come later.
|
37
|
-
*/
|
38
|
-
z-index: 1;
|
39
|
-
|
40
|
-
&.visible {
|
41
|
-
visibility: visible;
|
42
|
-
}
|
43
29
|
}
|
44
30
|
`];
|
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
import './menu.link.js';
|
1
|
+
export {};
|