@crowdstrike/glide-core 0.32.3 → 0.34.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.js +3 -2
- package/dist/button-group.button.js +3 -2
- package/dist/button-group.js +3 -2
- package/dist/button.js +5 -10
- package/dist/button.styles.js +0 -12
- package/dist/checkbox-group.js +8 -7
- package/dist/checkbox.js +11 -9
- package/dist/checkbox.styles.js +1 -1
- package/dist/drawer.js +3 -2
- package/dist/dropdown.js +51 -45
- package/dist/dropdown.option.d.ts +2 -0
- package/dist/dropdown.option.js +26 -25
- package/dist/dropdown.styles.js +11 -2
- package/dist/form-controls-layout.js +3 -2
- package/dist/icon-button.js +2 -2
- package/dist/inline-alert.d.ts +4 -0
- package/dist/inline-alert.js +25 -6
- package/dist/input.js +7 -7
- package/dist/input.styles.js +3 -2
- package/dist/label.js +3 -2
- package/dist/library/assert-slot.js +2 -2
- package/dist/library/assert-slot.test.js +92 -0
- package/dist/library/localize.d.ts +1 -0
- package/dist/link.js +2 -2
- package/dist/menu.js +61 -30
- package/dist/menu.styles.js +1 -0
- package/dist/modal.icon-button.js +3 -2
- package/dist/modal.js +3 -2
- package/dist/option.d.ts +5 -0
- package/dist/option.js +28 -5
- package/dist/options.d.ts +2 -0
- package/dist/options.group.js +3 -2
- package/dist/options.js +7 -8
- package/dist/options.styles.js +0 -6
- package/dist/popover.js +3 -2
- package/dist/radio-group.js +4 -3
- package/dist/radio-group.radio.js +3 -2
- package/dist/select.d.ts +90 -0
- package/dist/select.js +532 -0
- package/dist/slider.js +3 -3
- package/dist/slider.styles.js +1 -3
- package/dist/spinner.js +2 -2
- package/dist/split-button.js +3 -2
- package/dist/split-button.primary-button.js +2 -2
- package/dist/split-button.primary-link.js +2 -2
- package/dist/split-button.secondary-button.js +2 -2
- package/dist/styles/opacity-and-scale-animation.js +2 -1
- package/dist/styles/variables.css +12 -8
- package/dist/tab.group.js +3 -2
- package/dist/tab.js +3 -2
- package/dist/tab.panel.js +3 -2
- package/dist/tag.d.ts +1 -0
- package/dist/tag.js +8 -2
- package/dist/tag.styles.js +9 -1
- package/dist/textarea.js +8 -7
- package/dist/textarea.styles.js +3 -2
- package/dist/toast.js +2 -2
- package/dist/toast.toasts.js +3 -2
- package/dist/toggle.js +3 -2
- package/dist/tooltip.container.js +3 -2
- package/dist/tooltip.js +6 -9
- package/dist/translations/en.js +1 -0
- package/dist/translations/fr.d.ts +1 -1
- package/dist/translations/fr.js +1 -0
- package/dist/translations/ja.d.ts +1 -1
- package/dist/translations/ja.js +1 -0
- package/package.json +4 -4
- package/dist/library/shadow-root-mode.d.ts +0 -2
- package/dist/library/shadow-root-mode.js +0 -4
package/dist/dropdown.styles.js
CHANGED
@@ -93,9 +93,10 @@ export default [
|
|
93
93
|
}
|
94
94
|
|
95
95
|
&.readonly {
|
96
|
-
background-color:
|
96
|
+
background-color: var(
|
97
|
+
--glide-core-color-interactive-surface-container--disabled
|
98
|
+
);
|
97
99
|
border-color: transparent;
|
98
|
-
padding-inline-start: 0;
|
99
100
|
}
|
100
101
|
|
101
102
|
&.quiet {
|
@@ -249,6 +250,14 @@ export default [
|
|
249
250
|
align-content: center;
|
250
251
|
color: var(--glide-core-color-interactive-text-link);
|
251
252
|
white-space: nowrap;
|
253
|
+
|
254
|
+
&.disabled {
|
255
|
+
color: var(--glide-core-color-interactive-text-link--disabled);
|
256
|
+
}
|
257
|
+
|
258
|
+
&.readonly {
|
259
|
+
color: var(--glide-core-color-interactive-text-default);
|
260
|
+
}
|
252
261
|
}
|
253
262
|
|
254
263
|
.single-select-icon-slot {
|
@@ -17,7 +17,6 @@ import Slider from './slider.js';
|
|
17
17
|
import TextArea from './textarea.js';
|
18
18
|
import styles from './form-controls-layout.styles.js';
|
19
19
|
import assertSlot from './library/assert-slot.js';
|
20
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
21
20
|
import final from './library/final.js';
|
22
21
|
/**
|
23
22
|
* @attr {'left'|'middle'|'right'} [split='left']
|
@@ -34,10 +33,12 @@ let FormControlsLayout = class FormControlsLayout extends LitElement {
|
|
34
33
|
this.#slotElementRef = createRef();
|
35
34
|
this.#split = 'left';
|
36
35
|
}
|
36
|
+
/* c8 ignore start */
|
37
37
|
static { this.shadowRootOptions = {
|
38
38
|
...LitElement.shadowRootOptions,
|
39
|
-
mode:
|
39
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
40
40
|
}; }
|
41
|
+
/* c8 ignore end */
|
41
42
|
static { this.styles = styles; }
|
42
43
|
/**
|
43
44
|
* @default 'left'
|
package/dist/icon-button.js
CHANGED
@@ -12,7 +12,6 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
12
12
|
import packageJson from '../package.json' with { type: 'json' };
|
13
13
|
import styles from './icon-button.styles.js';
|
14
14
|
import assertSlot from './library/assert-slot.js';
|
15
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
16
15
|
import final from './library/final.js';
|
17
16
|
import required from './library/required.js';
|
18
17
|
/**
|
@@ -42,10 +41,11 @@ let IconButton = class IconButton extends LitElement {
|
|
42
41
|
this.#buttonElementRef = createRef();
|
43
42
|
this.#defaultSlotElementRef = createRef();
|
44
43
|
}
|
44
|
+
/* c8 ignore start */
|
45
45
|
static { this.shadowRootOptions = {
|
46
46
|
...LitElement.shadowRootOptions,
|
47
47
|
delegatesFocus: true,
|
48
|
-
mode:
|
48
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
49
49
|
}; }
|
50
50
|
static { this.styles = styles; }
|
51
51
|
// A getter and setter because Lit Analzyer doesn't recognize "aria-description"
|
package/dist/inline-alert.d.ts
CHANGED
@@ -11,6 +11,9 @@ declare global {
|
|
11
11
|
* @attr {string} [version]
|
12
12
|
*
|
13
13
|
* @slot {Element | string} - The content of the alert
|
14
|
+
*
|
15
|
+
* @readonly
|
16
|
+
* @prop {string} ariaLabel
|
14
17
|
*/
|
15
18
|
export default class InlineAlert extends LitElement {
|
16
19
|
#private;
|
@@ -18,6 +21,7 @@ export default class InlineAlert extends LitElement {
|
|
18
21
|
static styles: import("lit").CSSResult[];
|
19
22
|
variant: 'informational' | 'medium' | 'high' | 'critical';
|
20
23
|
readonly version: string;
|
24
|
+
get ariaLabel(): string;
|
21
25
|
firstUpdated(): void;
|
22
26
|
render(): import("lit").TemplateResult<1>;
|
23
27
|
}
|
package/dist/inline-alert.js
CHANGED
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
7
7
|
import { html, LitElement } from 'lit';
|
8
8
|
import { classMap } from 'lit/directives/class-map.js';
|
9
9
|
import { createRef, ref } from 'lit/directives/ref.js';
|
10
|
-
import { customElement, property } from 'lit/decorators.js';
|
10
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
11
11
|
import { styleMap } from 'lit/directives/style-map.js';
|
12
12
|
import packageJson from '../package.json' with { type: 'json' };
|
13
13
|
import styles from './inline-alert.styles.js';
|
@@ -15,8 +15,8 @@ import severityInformationalIcon from './icons/severity-informational.js';
|
|
15
15
|
import severityMediumIcon from './icons/severity-medium.js';
|
16
16
|
import severityCriticalIcon from './icons/severity-critical.js';
|
17
17
|
import assertSlot from './library/assert-slot.js';
|
18
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
19
18
|
import final from './library/final.js';
|
19
|
+
import { LocalizeController } from './library/localize.js';
|
20
20
|
/**
|
21
21
|
* @attr {'informational'|'medium'|'high'|'critical'} [variant='informational']
|
22
22
|
*
|
@@ -24,6 +24,9 @@ import final from './library/final.js';
|
|
24
24
|
* @attr {string} [version]
|
25
25
|
*
|
26
26
|
* @slot {Element | string} - The content of the alert
|
27
|
+
*
|
28
|
+
* @readonly
|
29
|
+
* @prop {string} ariaLabel
|
27
30
|
*/
|
28
31
|
let InlineAlert = class InlineAlert extends LitElement {
|
29
32
|
constructor() {
|
@@ -32,12 +35,24 @@ let InlineAlert = class InlineAlert extends LitElement {
|
|
32
35
|
this.version = packageJson.version;
|
33
36
|
this.#animationDuration = 100;
|
34
37
|
this.#componentElementRef = createRef();
|
38
|
+
this.#localize = new LocalizeController(this);
|
35
39
|
}
|
40
|
+
/* c8 ignore start */
|
36
41
|
static { this.shadowRootOptions = {
|
37
42
|
...LitElement.shadowRootOptions,
|
38
|
-
mode:
|
43
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
39
44
|
}; }
|
45
|
+
/* c8 ignore end */
|
40
46
|
static { this.styles = styles; }
|
47
|
+
get ariaLabel() {
|
48
|
+
return this.#localize.term(this.variant === 'informational'
|
49
|
+
? 'severityInformational'
|
50
|
+
: this.variant === 'medium'
|
51
|
+
? 'severityMedium'
|
52
|
+
: this.variant === 'high'
|
53
|
+
? 'severityHigh'
|
54
|
+
: 'severityCritical');
|
55
|
+
}
|
41
56
|
firstUpdated() {
|
42
57
|
this.#componentElementRef.value?.addEventListener('animationend', () => {
|
43
58
|
this.#componentElementRef.value?.classList.remove('added');
|
@@ -46,14 +61,14 @@ let InlineAlert = class InlineAlert extends LitElement {
|
|
46
61
|
render() {
|
47
62
|
return html `
|
48
63
|
<div
|
64
|
+
aria-label=${this.ariaLabel}
|
49
65
|
class=${classMap({
|
50
66
|
component: true,
|
51
67
|
added: true,
|
52
68
|
[this.variant]: true,
|
53
69
|
})}
|
54
|
-
role="alert"
|
55
|
-
aria-labelledby="label"
|
56
70
|
data-test="component"
|
71
|
+
role="alert"
|
57
72
|
style="--private-animation-duration: ${this.#animationDuration}ms"
|
58
73
|
${ref(this.#componentElementRef)}
|
59
74
|
>
|
@@ -67,7 +82,7 @@ let InlineAlert = class InlineAlert extends LitElement {
|
|
67
82
|
${icons[this.variant]}
|
68
83
|
</div>
|
69
84
|
|
70
|
-
<div
|
85
|
+
<div class="content">
|
71
86
|
<slot ${assertSlot()}>
|
72
87
|
<!--
|
73
88
|
The content of the alert
|
@@ -81,6 +96,7 @@ let InlineAlert = class InlineAlert extends LitElement {
|
|
81
96
|
}
|
82
97
|
#animationDuration;
|
83
98
|
#componentElementRef;
|
99
|
+
#localize;
|
84
100
|
};
|
85
101
|
__decorate([
|
86
102
|
property({ reflect: true, useDefault: true })
|
@@ -88,6 +104,9 @@ __decorate([
|
|
88
104
|
__decorate([
|
89
105
|
property({ reflect: true })
|
90
106
|
], InlineAlert.prototype, "version", void 0);
|
107
|
+
__decorate([
|
108
|
+
state()
|
109
|
+
], InlineAlert.prototype, "ariaLabel", null);
|
91
110
|
InlineAlert = __decorate([
|
92
111
|
customElement('glide-core-inline-alert'),
|
93
112
|
final
|
package/dist/input.js
CHANGED
@@ -19,7 +19,6 @@ import { LocalizeController } from './library/localize.js';
|
|
19
19
|
import magnifyingGlassIcon from './icons/magnifying-glass.js';
|
20
20
|
import styles from './input.styles.js';
|
21
21
|
import xIcon from './icons/x.js';
|
22
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
23
22
|
import final from './library/final.js';
|
24
23
|
import required from './library/required.js';
|
25
24
|
/**
|
@@ -82,9 +81,10 @@ import required from './library/required.js';
|
|
82
81
|
*/
|
83
82
|
let Input = class Input extends LitElement {
|
84
83
|
static { this.formAssociated = true; }
|
84
|
+
/* c8 ignore start */
|
85
85
|
static { this.shadowRootOptions = {
|
86
86
|
...LitElement.shadowRootOptions,
|
87
|
-
mode:
|
87
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
88
88
|
delegatesFocus: true,
|
89
89
|
}; }
|
90
90
|
static { this.styles = styles; }
|
@@ -318,7 +318,7 @@ let Input = class Input extends LitElement {
|
|
318
318
|
reportValidity() {
|
319
319
|
this.isReportValidityOrSubmit = true;
|
320
320
|
const isValid = this.#internals.reportValidity();
|
321
|
-
// Ensures
|
321
|
+
// Ensures getters referencing `this.validity.valid` re-run.
|
322
322
|
this.requestUpdate();
|
323
323
|
return isValid;
|
324
324
|
}
|
@@ -397,12 +397,12 @@ let Input = class Input extends LitElement {
|
|
397
397
|
this.isReportValidityOrSubmit = true;
|
398
398
|
const isFirstInvalidFormElement = this.form?.querySelector(':invalid') === this;
|
399
399
|
if (isFirstInvalidFormElement) {
|
400
|
-
// - `
|
401
|
-
//
|
402
|
-
//
|
400
|
+
// - `delegatesFocus` is preferred because it's declarative. But it's limited to
|
401
|
+
// focusing the first focusable element. That doesn't work for us because the first
|
402
|
+
// focusable element is the Tooltip when it's present.
|
403
403
|
//
|
404
404
|
// - Canceling this event means the input won't get focus, even if we were to use
|
405
|
-
// `
|
405
|
+
// `delegatesFocus`.
|
406
406
|
//
|
407
407
|
// - The browser will ignore this if Input isn't the first invalid form control.
|
408
408
|
//
|
package/dist/input.styles.js
CHANGED
@@ -86,9 +86,10 @@ export default [
|
|
86
86
|
with ":read-only": https://bugs.chromium.org/p/chromium/issues/detail?id=1519649
|
87
87
|
*/
|
88
88
|
&.readonly {
|
89
|
-
background-color:
|
89
|
+
background-color: var(
|
90
|
+
--glide-core-color-interactive-surface-container--disabled
|
91
|
+
);
|
90
92
|
border: 1px solid transparent;
|
91
|
-
padding-inline-start: 0;
|
92
93
|
}
|
93
94
|
|
94
95
|
&.disabled {
|
package/dist/label.js
CHANGED
@@ -16,7 +16,6 @@ import styles from './label.styles.js';
|
|
16
16
|
import { LocalizeController } from './library/localize.js';
|
17
17
|
import assertSlot from './library/assert-slot.js';
|
18
18
|
import onResize from './library/on-resize.js';
|
19
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
20
19
|
import final from './library/final.js';
|
21
20
|
/**
|
22
21
|
* @attr {boolean} [disabled=false]
|
@@ -50,10 +49,12 @@ let Label = class Label extends LitElement {
|
|
50
49
|
this.#localize = new LocalizeController(this);
|
51
50
|
this.#summarySlotElementRef = createRef();
|
52
51
|
}
|
52
|
+
/* c8 ignore start */
|
53
53
|
static { this.shadowRootOptions = {
|
54
54
|
...LitElement.shadowRootOptions,
|
55
|
-
mode:
|
55
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
56
56
|
}; }
|
57
|
+
/* c8 ignore end */
|
57
58
|
static { this.styles = styles; }
|
58
59
|
render() {
|
59
60
|
// `aria-hidden` is used on the tooltip so the contents of the label aren't
|
@@ -48,11 +48,11 @@ class AssertSlot extends Directive {
|
|
48
48
|
part.element?.addEventListener('slotchange', () => {
|
49
49
|
if (isOptional &&
|
50
50
|
part.element instanceof HTMLSlotElement &&
|
51
|
-
part.element.assignedNodes().length === 0) {
|
51
|
+
part.element.assignedNodes({ flatten: true }).length === 0) {
|
52
52
|
return;
|
53
53
|
}
|
54
54
|
if (part.element instanceof HTMLSlotElement &&
|
55
|
-
part.element.assignedNodes().length === 0) {
|
55
|
+
part.element.assignedNodes({ flatten: true }).length === 0) {
|
56
56
|
if (slotted && slotted.length > 0) {
|
57
57
|
const message = part.element.name
|
58
58
|
? `Expected the "${part.element.name}" slot of ${host.constructor.name} to have a slotted element that extends ${slotted
|
@@ -51,6 +51,34 @@ let WhenNotUsedInsideATag = class WhenNotUsedInsideATag extends LitElement {
|
|
51
51
|
WhenNotUsedInsideATag = __decorate([
|
52
52
|
customElement('glide-core-when-not-used-inside-tag')
|
53
53
|
], WhenNotUsedInsideATag);
|
54
|
+
let Reslotted = class Reslotted extends LitElement {
|
55
|
+
constructor() {
|
56
|
+
super(...arguments);
|
57
|
+
this.optional = false;
|
58
|
+
this.slotted = [];
|
59
|
+
}
|
60
|
+
render() {
|
61
|
+
return html `<glide-core-with-slot
|
62
|
+
name=${ifDefined(this.name)}
|
63
|
+
.slotted=${this.slotted}
|
64
|
+
?optional=${this.optional}
|
65
|
+
>
|
66
|
+
<slot name=${ifDefined(this.name)}></slot>
|
67
|
+
</glide-core-with-slot>`;
|
68
|
+
}
|
69
|
+
};
|
70
|
+
__decorate([
|
71
|
+
property()
|
72
|
+
], Reslotted.prototype, "name", void 0);
|
73
|
+
__decorate([
|
74
|
+
property({ type: Boolean })
|
75
|
+
], Reslotted.prototype, "optional", void 0);
|
76
|
+
__decorate([
|
77
|
+
property({ type: Array })
|
78
|
+
], Reslotted.prototype, "slotted", void 0);
|
79
|
+
Reslotted = __decorate([
|
80
|
+
customElement('glide-core-reslotted')
|
81
|
+
], Reslotted);
|
54
82
|
it('throws when a required default slot is empty', async () => {
|
55
83
|
const stub = sinon.stub(console, 'error');
|
56
84
|
const spy = sinon.spy();
|
@@ -283,3 +311,67 @@ it('throws when not used inside an opening tag', async () => {
|
|
283
311
|
}
|
284
312
|
expect(spy.args.at(0)?.at(0).message).to.equal("Directive must be inside the element's opening tag.");
|
285
313
|
});
|
314
|
+
it('throws when a reslotted and required default slot is empty', async () => {
|
315
|
+
const stub = sinon.stub(console, 'error');
|
316
|
+
const spy = sinon.spy();
|
317
|
+
const onerror = window.onerror;
|
318
|
+
// eslint-disable-next-line unicorn/prefer-add-event-listener
|
319
|
+
window.onerror = spy;
|
320
|
+
await fixture(html `<glide-core-reslotted
|
321
|
+
.slotted=${[HTMLDivElement]}
|
322
|
+
></glide-core-reslotted>`);
|
323
|
+
expect(spy.callCount).to.equal(1);
|
324
|
+
expect(spy.args.at(0)?.at(0)).to.equal('Uncaught TypeError: Expected WithSlot to have a slotted element that extends HTMLDivElement.');
|
325
|
+
// eslint-disable-next-line unicorn/prefer-add-event-listener
|
326
|
+
window.onerror = onerror;
|
327
|
+
stub.restore();
|
328
|
+
});
|
329
|
+
it('throws when a reslotted default slot has the wrong element', async () => {
|
330
|
+
const stub = sinon.stub(console, 'error');
|
331
|
+
const spy = sinon.spy();
|
332
|
+
const onerror = window.onerror;
|
333
|
+
// eslint-disable-next-line unicorn/prefer-add-event-listener
|
334
|
+
window.onerror = spy;
|
335
|
+
await fixture(html `<glide-core-reslotted .slotted=${[HTMLDivElement]}>
|
336
|
+
<a href="/">Link</a>
|
337
|
+
</glide-core-reslotted>`);
|
338
|
+
expect(spy.callCount).to.equal(1);
|
339
|
+
expect(spy.args.at(0)?.at(0)).to.equal('Uncaught TypeError: Expected WithSlot to have a slotted element that extends HTMLDivElement. Extends HTMLAnchorElement instead.');
|
340
|
+
// eslint-disable-next-line unicorn/prefer-add-event-listener
|
341
|
+
window.onerror = onerror;
|
342
|
+
stub.restore();
|
343
|
+
});
|
344
|
+
it('does not throw when a reslotted default slot has the correct element', async () => {
|
345
|
+
const spy = sinon.spy();
|
346
|
+
window.addEventListener('error', spy);
|
347
|
+
await fixture(html `<glide-core-reslotted .slotted=${[HTMLDivElement]}>
|
348
|
+
<div>Content</div>
|
349
|
+
</glide-core-reslotted>`);
|
350
|
+
expect(spy.callCount).to.equal(0);
|
351
|
+
});
|
352
|
+
it('throws when a reslotted and required named slot is empty', async () => {
|
353
|
+
const stub = sinon.stub(console, 'error');
|
354
|
+
const spy = sinon.spy();
|
355
|
+
window.addEventListener('unhandledrejection', spy, { once: true });
|
356
|
+
await fixture(html `<glide-core-reslotted
|
357
|
+
name="test"
|
358
|
+
.slotted=${[HTMLDivElement]}
|
359
|
+
></glide-core-reslotted>`);
|
360
|
+
await waitUntil(() => spy.callCount);
|
361
|
+
expect(spy.callCount).to.equal(1);
|
362
|
+
expect(spy.args.at(0)?.at(0) instanceof PromiseRejectionEvent).to.be.true;
|
363
|
+
expect(spy.args.at(0)?.at(0).reason.message).to.equal('Expected the "test" slot of WithSlot to have a slotted element that extends HTMLDivElement.');
|
364
|
+
stub.restore();
|
365
|
+
});
|
366
|
+
it('does not throw when a reslotted optional named slot is empty', async () => {
|
367
|
+
const spy = sinon.spy();
|
368
|
+
window.addEventListener('unhandledrejection', spy, { once: true });
|
369
|
+
await fixture(html `<glide-core-reslotted name="test" optional></glide-core-reslotted>`);
|
370
|
+
expect(spy.callCount).to.equal(0);
|
371
|
+
});
|
372
|
+
it('does not throw when a reslotted optional slot is empty', async () => {
|
373
|
+
const spy = sinon.spy();
|
374
|
+
window.addEventListener('unhandledrejection', spy, { once: true });
|
375
|
+
await fixture(html `<glide-core-reslotted optional></glide-core-reslotted>`);
|
376
|
+
expect(spy.callCount).to.equal(0);
|
377
|
+
});
|
package/dist/link.js
CHANGED
@@ -11,7 +11,6 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
11
|
import { createRef, ref } from 'lit/directives/ref.js';
|
12
12
|
import packageJson from '../package.json' with { type: 'json' };
|
13
13
|
import styles from './link.styles.js';
|
14
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
15
14
|
import final from './library/final.js';
|
16
15
|
import required from './library/required.js';
|
17
16
|
/**
|
@@ -32,10 +31,11 @@ let Link = class Link extends LitElement {
|
|
32
31
|
this.version = packageJson.version;
|
33
32
|
this.#componentElementRef = createRef();
|
34
33
|
}
|
34
|
+
/* c8 ignore start */
|
35
35
|
static { this.shadowRootOptions = {
|
36
36
|
...LitElement.shadowRootOptions,
|
37
37
|
delegatesFocus: true,
|
38
|
-
mode:
|
38
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
39
39
|
}; }
|
40
40
|
static { this.styles = styles; }
|
41
41
|
click() {
|
package/dist/menu.js
CHANGED
@@ -18,7 +18,6 @@ import Option from './option.js';
|
|
18
18
|
import Input from './input.js';
|
19
19
|
import assertSlot from './library/assert-slot.js';
|
20
20
|
import styles from './menu.styles.js';
|
21
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
22
21
|
import final from './library/final.js';
|
23
22
|
import uniqueId from './library/unique-id.js';
|
24
23
|
/**
|
@@ -107,10 +106,12 @@ let Menu = class Menu extends LitElement {
|
|
107
106
|
};
|
108
107
|
}
|
109
108
|
static { Menu_1 = this; }
|
109
|
+
/* c8 ignore start */
|
110
110
|
static { this.shadowRootOptions = {
|
111
111
|
...LitElement.shadowRootOptions,
|
112
|
-
mode:
|
112
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
113
113
|
}; }
|
114
|
+
/* c8 ignore end */
|
114
115
|
static { this.styles = styles; }
|
115
116
|
/**
|
116
117
|
* @default false
|
@@ -184,9 +185,9 @@ let Menu = class Menu extends LitElement {
|
|
184
185
|
firstUpdated() {
|
185
186
|
if (this.#optionsElement && this.#targetElement) {
|
186
187
|
this.#optionsElement.privateLoading = this.loading;
|
187
|
-
|
188
|
-
|
189
|
-
|
188
|
+
if (this.loading) {
|
189
|
+
this.#targetElement.ariaDescription = this.#localize.term('loading');
|
190
|
+
}
|
190
191
|
}
|
191
192
|
if (this.open && !this.isTargetDisabled) {
|
192
193
|
const openedSubMenus = this.#subMenus.filter(({ open }) => open);
|
@@ -298,8 +299,8 @@ let Menu = class Menu extends LitElement {
|
|
298
299
|
@keydown=${this.#onTargetAndDefaultSlotKeyDown}
|
299
300
|
@mousedown=${this.#onDefaultSlotMouseDown}
|
300
301
|
@mouseover=${this.#onDefaultSlotMouseOver}
|
301
|
-
@
|
302
|
-
@
|
302
|
+
@disabled=${this.#onDefaultSlotDisabled}
|
303
|
+
@slotchange=${this.#onDefaultSlotSlotChange}
|
303
304
|
@toggle=${this.#onDefaultSlotToggle}
|
304
305
|
${assertSlot([Element])}
|
305
306
|
${ref(this.#defaultSlotElementRef)}
|
@@ -457,7 +458,9 @@ let Menu = class Menu extends LitElement {
|
|
457
458
|
this.#targetElement?.focus(options);
|
458
459
|
}
|
459
460
|
}
|
460
|
-
#hide() {
|
461
|
+
async #hide() {
|
462
|
+
// There's a comment in `#show()` explaining why.
|
463
|
+
await this.#activeOption?.updateComplete;
|
461
464
|
this.#cleanUpFloatingUi?.();
|
462
465
|
this.#defaultSlotElementRef.value?.hidePopover();
|
463
466
|
if (this.#optionsElement) {
|
@@ -545,7 +548,7 @@ let Menu = class Menu extends LitElement {
|
|
545
548
|
}
|
546
549
|
});
|
547
550
|
}
|
548
|
-
#
|
551
|
+
#onDefaultSlotDisabled(event) {
|
549
552
|
if (this.#activeOption === event.target &&
|
550
553
|
event.target instanceof Option &&
|
551
554
|
event.target.disabled &&
|
@@ -1051,6 +1054,13 @@ let Menu = class Menu extends LitElement {
|
|
1051
1054
|
this.#hide();
|
1052
1055
|
}
|
1053
1056
|
});
|
1057
|
+
/* c8 ignore start */
|
1058
|
+
if (this.#targetElement?.ariaDescription !== null &&
|
1059
|
+
this.#targetElement?.ariaDescription !== this.#localize.term('loading')) {
|
1060
|
+
// eslint-disable-next-line no-console
|
1061
|
+
console.warn("Menu will overwrite the `aria-description` on your target when Menu's `loading` attribute it set.");
|
1062
|
+
}
|
1063
|
+
/* c8 ignore end */
|
1054
1064
|
if (this.#targetElement && this.#optionsElement) {
|
1055
1065
|
observer.observe(this.#targetElement, {
|
1056
1066
|
attributeFilter: ['aria-disabled', 'disabled'],
|
@@ -1153,7 +1163,44 @@ let Menu = class Menu extends LitElement {
|
|
1153
1163
|
#onTargetSlotInput() {
|
1154
1164
|
this.open = true;
|
1155
1165
|
}
|
1156
|
-
#show() {
|
1166
|
+
async #show() {
|
1167
|
+
if (this.#previouslyActiveOption &&
|
1168
|
+
!this.#previouslyActiveOption.disabled &&
|
1169
|
+
this.#optionsElement) {
|
1170
|
+
this.#previouslyActiveOption.privateActive = true;
|
1171
|
+
}
|
1172
|
+
else if (this.#firstEnabledOption && this.#optionsElement) {
|
1173
|
+
this.#firstEnabledOption.privateActive = true;
|
1174
|
+
this.#previouslyActiveOption = this.#firstEnabledOption;
|
1175
|
+
}
|
1176
|
+
if (this.#optionsElement && this.#activeOption?.id) {
|
1177
|
+
this.#optionsElement.ariaActivedescendant = this.#activeOption.id;
|
1178
|
+
this.#activeOption.privateTooltipOpen = this.privateOpenedViaKeyboard;
|
1179
|
+
}
|
1180
|
+
else if (this.#optionsElement) {
|
1181
|
+
this.#optionsElement.ariaActivedescendant = '';
|
1182
|
+
}
|
1183
|
+
// If we don't wait for the Option to update, it'll briefly appear as inactive when
|
1184
|
+
// Menu opens because `showPopover()` is synchronous and component updates are not.
|
1185
|
+
//
|
1186
|
+
// A side effect of waiting, however, is that calling `#show()` then immediately
|
1187
|
+
// calling `#hide()` won't work as expected: Menu will never close because the
|
1188
|
+
// `showPopover()` call below will be slightly delayed. So `hidePopover()`, via
|
1189
|
+
// `#hide()`, will be called just before `showPopover()`.
|
1190
|
+
//
|
1191
|
+
// That's why we also wait for the Option to update in `#hide()`. `#hide()` being
|
1192
|
+
// called immediately after `#show()` may seem unlikely. But Menu itself does it
|
1193
|
+
// when multiple sub-Menus are initially open.
|
1194
|
+
//
|
1195
|
+
// When, for example, Menu and two of its sub-Menus are initially open, each
|
1196
|
+
// sub-Menu's `open` setter will get called, and each `open` setter will call
|
1197
|
+
// `#show()`.
|
1198
|
+
//
|
1199
|
+
// But two open sub-Menus doesn't make sense. So Menu, shortly after the sub-Menus'
|
1200
|
+
// `open` setters are initially called, will set the `open` property of the other
|
1201
|
+
// sub-Menu to `false` in `firstUpdated()`. Thus a `#hide()` call immediately after
|
1202
|
+
// `#show()`.
|
1203
|
+
await this.#activeOption?.updateComplete;
|
1157
1204
|
this.#cleanUpFloatingUi?.();
|
1158
1205
|
// Ideally, we wouldn't show the popover until after Floating UI has calculated its
|
1159
1206
|
// position. But calling `showPopover()` changes the nature of how `top` and `left`
|
@@ -1206,27 +1253,11 @@ let Menu = class Menu extends LitElement {
|
|
1206
1253
|
else if (!this.#isSubMenu && this.#targetElement) {
|
1207
1254
|
this.#targetElement.ariaExpanded = 'true';
|
1208
1255
|
}
|
1209
|
-
if (this.#
|
1210
|
-
this.#
|
1211
|
-
}
|
1212
|
-
if (this.#previouslyActiveOption &&
|
1213
|
-
!this.#previouslyActiveOption.disabled &&
|
1214
|
-
this.#optionsElement) {
|
1215
|
-
this.#previouslyActiveOption.privateActive = true;
|
1216
|
-
this.#previouslyActiveOption.privateTooltipOpen =
|
1217
|
-
this.privateOpenedViaKeyboard;
|
1218
|
-
this.#optionsElement.ariaActivedescendant =
|
1219
|
-
this.#previouslyActiveOption.id;
|
1220
|
-
}
|
1221
|
-
else if (this.#firstEnabledOption && this.#optionsElement) {
|
1222
|
-
this.#firstEnabledOption.privateActive = true;
|
1223
|
-
this.#firstEnabledOption.privateTooltipOpen =
|
1224
|
-
this.privateOpenedViaKeyboard;
|
1225
|
-
this.#previouslyActiveOption = this.#firstEnabledOption;
|
1226
|
-
this.#optionsElement.ariaActivedescendant = this.#firstEnabledOption.id;
|
1256
|
+
if (this.#isSubMenu && this.#parentOption) {
|
1257
|
+
this.#parentOption.ariaExpanded = 'true';
|
1227
1258
|
}
|
1228
|
-
else if (this.#
|
1229
|
-
this.#
|
1259
|
+
else if (!this.#isSubMenu && this.#targetElement) {
|
1260
|
+
this.#targetElement.ariaExpanded = 'true';
|
1230
1261
|
}
|
1231
1262
|
if (this.#targetElement && this.#defaultSlotElementRef.value) {
|
1232
1263
|
this.#cleanUpFloatingUi = autoUpdate(this.#targetElement, this.#defaultSlotElementRef.value, () => {
|
package/dist/menu.styles.js
CHANGED
@@ -35,6 +35,7 @@ export default [
|
|
35
35
|
padding-block-end: 0;
|
36
36
|
padding-block-start: var(--glide-core-spacing-base-xxxs);
|
37
37
|
padding-inline: var(--glide-core-spacing-base-xxxs);
|
38
|
+
position: absolute;
|
38
39
|
|
39
40
|
/*
|
40
41
|
This little hack replaces "padding-block-end", which the last option overlaps
|
@@ -11,7 +11,6 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
11
|
import packageJson from '../package.json' with { type: 'json' };
|
12
12
|
import styles from './modal.icon-button.styles.js';
|
13
13
|
import assertSlot from './library/assert-slot.js';
|
14
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
15
14
|
import final from './library/final.js';
|
16
15
|
import required from './library/required.js';
|
17
16
|
/**
|
@@ -27,10 +26,12 @@ let ModalIconButton = class ModalIconButton extends LitElement {
|
|
27
26
|
super(...arguments);
|
28
27
|
this.version = packageJson.version;
|
29
28
|
}
|
29
|
+
/* c8 ignore start */
|
30
30
|
static { this.shadowRootOptions = {
|
31
31
|
...LitElement.shadowRootOptions,
|
32
|
-
mode:
|
32
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
33
33
|
}; }
|
34
|
+
/* c8 ignore end */
|
34
35
|
static { this.styles = styles; }
|
35
36
|
render() {
|
36
37
|
return html `
|
package/dist/modal.js
CHANGED
@@ -18,7 +18,6 @@ import Tooltip from './tooltip.js';
|
|
18
18
|
import styles from './modal.styles.js';
|
19
19
|
import xIcon from './icons/x.js';
|
20
20
|
import assertSlot from './library/assert-slot.js';
|
21
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
22
21
|
import severityInformationalIcon from './icons/severity-informational.js';
|
23
22
|
import severityMediumIcon from './icons/severity-medium.js';
|
24
23
|
import severityCriticalIcon from './icons/severity-critical.js';
|
@@ -107,10 +106,12 @@ let Modal = class Modal extends LitElement {
|
|
107
106
|
});
|
108
107
|
};
|
109
108
|
}
|
109
|
+
/* c8 ignore start */
|
110
110
|
static { this.shadowRootOptions = {
|
111
111
|
...LitElement.shadowRootOptions,
|
112
|
-
mode:
|
112
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
113
113
|
}; }
|
114
|
+
/* c8 ignore end */
|
114
115
|
static { this.styles = styles; }
|
115
116
|
/**
|
116
117
|
* @default false
|
package/dist/option.d.ts
CHANGED
@@ -28,6 +28,11 @@ declare global {
|
|
28
28
|
* @slot {Element | Text} [content] - This is the unhappy path. It's the escape hatch where you can render arbitrary content and lay it out however you need to. If you go this route, `slot="icon"` and `slot="submenu"` will become unavailable. And the `label` and `description` attributes won't be rendered. The `label` attribute is still required. We'll show it in a tooltip when your content overflows. If you need a second line of text in the tooltip, provide you can provide it via the `description` attribute.
|
29
29
|
* @slot {Element} [icon]
|
30
30
|
* @slot {Menu} [submenu]
|
31
|
+
*
|
32
|
+
* @fires {Event} deselected
|
33
|
+
* @fires {Event} disabled
|
34
|
+
* @fires {Event} enabled
|
35
|
+
* @fires {Event} selected
|
31
36
|
*/
|
32
37
|
export default class Option extends LitElement {
|
33
38
|
#private;
|