@crowdstrike/glide-core 0.32.2 → 0.33.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 +7 -11
- package/dist/button.styles.js +10 -8
- package/dist/checkbox-group.js +8 -7
- package/dist/checkbox.d.ts +1 -0
- package/dist/checkbox.js +26 -17
- package/dist/checkbox.styles.js +1 -1
- package/dist/drawer.js +3 -2
- package/dist/dropdown.js +19 -18
- package/dist/dropdown.option.d.ts +2 -0
- package/dist/dropdown.option.js +26 -25
- package/dist/form-controls-layout.js +3 -2
- package/dist/icon-button.js +2 -2
- package/dist/inline-alert.js +3 -2
- package/dist/input.js +9 -9
- 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/link.js +2 -2
- package/dist/menu.js +83 -44
- 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 +7 -7
- 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 +7 -4
- package/dist/tab.group.js +3 -2
- package/dist/tab.js +3 -2
- package/dist/tab.panel.js +3 -2
- package/dist/tag.js +2 -2
- package/dist/textarea.d.ts +1 -0
- package/dist/textarea.js +19 -10
- package/dist/toast.js +2 -2
- package/dist/toast.toasts.js +3 -2
- package/dist/toggle.d.ts +1 -0
- package/dist/toggle.js +13 -4
- package/dist/tooltip.container.js +3 -2
- package/dist/tooltip.js +4 -7
- 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/accordion.js
CHANGED
@@ -13,7 +13,6 @@ import packageJson from '../package.json' with { type: 'json' };
|
|
13
13
|
import chevronIcon from './icons/chevron.js';
|
14
14
|
import styles from './accordion.styles.js';
|
15
15
|
import assertSlot from './library/assert-slot.js';
|
16
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
17
16
|
import final from './library/final.js';
|
18
17
|
import required from './library/required.js';
|
19
18
|
/**
|
@@ -43,11 +42,13 @@ let Accordion = class Accordion extends LitElement {
|
|
43
42
|
this.#suffixIconsSlotElementRef = createRef();
|
44
43
|
this.#summaryElementRef = createRef();
|
45
44
|
}
|
45
|
+
/* c8 ignore start */
|
46
46
|
static { this.shadowRootOptions = {
|
47
47
|
...LitElement.shadowRootOptions,
|
48
48
|
delegatesFocus: true,
|
49
|
-
mode:
|
49
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
50
50
|
}; }
|
51
|
+
/* c8 ignore end */
|
51
52
|
static { this.styles = styles; }
|
52
53
|
/**
|
53
54
|
* @default false
|
@@ -11,7 +11,6 @@ import { classMap } from 'lit/directives/class-map.js';
|
|
11
11
|
import packageJson from '../package.json' with { type: 'json' };
|
12
12
|
import styles from './button-group.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
|
/**
|
@@ -42,10 +41,12 @@ let ButtonGroupButton = class ButtonGroupButton extends LitElement {
|
|
42
41
|
this.#iconSlotElementRef = createRef();
|
43
42
|
this.#isSelected = false;
|
44
43
|
}
|
44
|
+
/* c8 ignore start */
|
45
45
|
static { this.shadowRootOptions = {
|
46
46
|
...LitElement.shadowRootOptions,
|
47
|
-
mode:
|
47
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
48
48
|
}; }
|
49
|
+
/* c8 ignore end */
|
49
50
|
static { this.styles = styles; }
|
50
51
|
/**
|
51
52
|
* @default false
|
package/dist/button-group.js
CHANGED
@@ -12,7 +12,6 @@ import packageJson from '../package.json' with { type: 'json' };
|
|
12
12
|
import ButtonGroupButton from './button-group.button.js';
|
13
13
|
import styles from './button-group.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
|
/**
|
@@ -32,10 +31,12 @@ let ButtonGroup = class ButtonGroup extends LitElement {
|
|
32
31
|
this.#defaultSlotElementRef = createRef();
|
33
32
|
this.#orientation = 'horizontal';
|
34
33
|
}
|
34
|
+
/* c8 ignore start */
|
35
35
|
static { this.shadowRootOptions = {
|
36
36
|
...LitElement.shadowRootOptions,
|
37
|
-
mode:
|
37
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
38
38
|
}; }
|
39
|
+
/* c8 ignore end */
|
39
40
|
static { this.styles = styles; }
|
40
41
|
/**
|
41
42
|
* @default undefined
|
package/dist/button.js
CHANGED
@@ -11,7 +11,6 @@ import { createRef, ref } from 'lit/directives/ref.js';
|
|
11
11
|
import { customElement, property, state } from 'lit/decorators.js';
|
12
12
|
import packageJson from '../package.json' with { type: 'json' };
|
13
13
|
import styles from './button.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
|
/**
|
@@ -36,11 +35,13 @@ import required from './library/required.js';
|
|
36
35
|
*/
|
37
36
|
let Button = class Button extends LitElement {
|
38
37
|
static { this.formAssociated = true; }
|
38
|
+
/* c8 ignore start */
|
39
39
|
static { this.shadowRootOptions = {
|
40
40
|
...LitElement.shadowRootOptions,
|
41
41
|
delegatesFocus: true,
|
42
|
-
mode:
|
42
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
43
43
|
}; }
|
44
|
+
/* c8 ignore end */
|
44
45
|
static { this.styles = styles; }
|
45
46
|
// A getter and setter because Lit Analzyer doesn't recognize "aria-description"
|
46
47
|
// as a valid attribute on the `<button>` and doesn't provide a way to selectively
|
@@ -70,6 +71,7 @@ let Button = class Button extends LitElement {
|
|
70
71
|
}
|
71
72
|
render() {
|
72
73
|
return html `<glide-core-tooltip
|
74
|
+
class="tooltip"
|
73
75
|
label=${this.tooltip ?? ''}
|
74
76
|
?disabled=${!this.disabled || !this.tooltip}
|
75
77
|
>
|
@@ -92,11 +94,8 @@ let Button = class Button extends LitElement {
|
|
92
94
|
${ref(this.#buttonElementRef)}
|
93
95
|
>
|
94
96
|
<slot
|
95
|
-
class=${classMap({
|
96
|
-
'prefix-icon-slot': true,
|
97
|
-
hidden: this.variant === 'link',
|
98
|
-
})}
|
99
97
|
name="prefix-icon"
|
98
|
+
?hidden=${this.variant === 'link'}
|
100
99
|
@slotchange=${this.#onPrefixIconSlotChange}
|
101
100
|
${ref(this.#prefixIconSlotElementRef)}
|
102
101
|
>
|
@@ -106,14 +105,11 @@ let Button = class Button extends LitElement {
|
|
106
105
|
-->
|
107
106
|
</slot>
|
108
107
|
|
109
|
-
|
108
|
+
<span class="label">${this.label}</span>
|
110
109
|
|
111
110
|
<slot
|
112
|
-
class=${classMap({
|
113
|
-
'suffix-icon-slot': true,
|
114
|
-
hidden: this.variant === 'link',
|
115
|
-
})}
|
116
111
|
name="suffix-icon"
|
112
|
+
?hidden=${this.variant === 'link'}
|
117
113
|
@slotchange=${this.#onSuffixIconSlotChange}
|
118
114
|
${ref(this.#suffixIconSlotElementRef)}
|
119
115
|
>
|
package/dist/button.styles.js
CHANGED
@@ -22,6 +22,7 @@ export default [
|
|
22
22
|
font-weight: var(--glide-core-typography-weight-bold);
|
23
23
|
gap: var(--glide-core-spacing-base-xs);
|
24
24
|
justify-content: center;
|
25
|
+
max-inline-size: 100%;
|
25
26
|
padding-block: var(--glide-core-spacing-base-xs);
|
26
27
|
padding-inline: var(--glide-core-spacing-base-md);
|
27
28
|
transition-duration: var(--glide-core-duration-moderate-02);
|
@@ -143,6 +144,7 @@ export default [
|
|
143
144
|
font-size: var(--glide-core-typography-size-body-default);
|
144
145
|
font-weight: var(--glide-core-typography-weight-regular);
|
145
146
|
padding: 0;
|
147
|
+
text-align: start;
|
146
148
|
|
147
149
|
&.disabled {
|
148
150
|
color: var(--glide-core-color-interactive-text-link--disabled);
|
@@ -167,16 +169,16 @@ export default [
|
|
167
169
|
}
|
168
170
|
}
|
169
171
|
|
170
|
-
.
|
171
|
-
|
172
|
-
|
173
|
-
}
|
172
|
+
.tooltip {
|
173
|
+
max-inline-size: 100%;
|
174
|
+
white-space: inherit;
|
174
175
|
}
|
175
176
|
|
176
|
-
.
|
177
|
-
|
178
|
-
|
179
|
-
|
177
|
+
.label {
|
178
|
+
min-inline-size: 3ch;
|
179
|
+
overflow: hidden;
|
180
|
+
text-overflow: ellipsis;
|
181
|
+
white-space: inherit;
|
180
182
|
}
|
181
183
|
`,
|
182
184
|
];
|
package/dist/checkbox-group.js
CHANGED
@@ -16,7 +16,6 @@ import packageJson from '../package.json' with { type: 'json' };
|
|
16
16
|
import Checkbox from './checkbox.js';
|
17
17
|
import styles from './checkbox-group.styles.js';
|
18
18
|
import assertSlot from './library/assert-slot.js';
|
19
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
20
19
|
import final from './library/final.js';
|
21
20
|
import required from './library/required.js';
|
22
21
|
/**
|
@@ -64,10 +63,12 @@ import required from './library/required.js';
|
|
64
63
|
*/
|
65
64
|
let CheckboxGroup = class CheckboxGroup extends LitElement {
|
66
65
|
static { this.formAssociated = true; }
|
66
|
+
/* c8 ignore start */
|
67
67
|
static { this.shadowRootOptions = {
|
68
68
|
...LitElement.shadowRootOptions,
|
69
|
-
mode:
|
69
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
70
70
|
}; }
|
71
|
+
/* c8 ignore end */
|
71
72
|
static { this.styles = styles; }
|
72
73
|
/**
|
73
74
|
* @default false
|
@@ -298,7 +299,7 @@ let CheckboxGroup = class CheckboxGroup extends LitElement {
|
|
298
299
|
reportValidity() {
|
299
300
|
this.isReportValidityOrSubmit = true;
|
300
301
|
const isValid = this.#internals.reportValidity();
|
301
|
-
// Ensures
|
302
|
+
// Ensures getters referencing `this.validity.valid` re-run.
|
302
303
|
this.requestUpdate();
|
303
304
|
return isValid;
|
304
305
|
}
|
@@ -363,12 +364,12 @@ let CheckboxGroup = class CheckboxGroup extends LitElement {
|
|
363
364
|
this.isReportValidityOrSubmit = true;
|
364
365
|
const isFirstInvalidFormElement = this.form?.querySelector(':invalid') === this;
|
365
366
|
if (isFirstInvalidFormElement) {
|
366
|
-
// - `
|
367
|
-
//
|
368
|
-
//
|
367
|
+
// - `delegatesFocus` is preferred because it's declarative. But it's limited to
|
368
|
+
// focusing the first focusable element. That doesn't work for us because the first
|
369
|
+
// focusable element is the Tooltip when it's present.
|
369
370
|
//
|
370
371
|
// - Canceling this event means the input won't get focus, even if we were to use
|
371
|
-
// `
|
372
|
+
// `delegatesFocus`.
|
372
373
|
//
|
373
374
|
// - The browser will ignore this if Checkbox isn't the first invalid form control.
|
374
375
|
//
|
package/dist/checkbox.d.ts
CHANGED
package/dist/checkbox.js
CHANGED
@@ -17,7 +17,6 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
17
17
|
import packageJson from '../package.json' with { type: 'json' };
|
18
18
|
import checkedIcon from './icons/checked.js';
|
19
19
|
import styles from './checkbox.styles.js';
|
20
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
21
20
|
import final from './library/final.js';
|
22
21
|
import required from './library/required.js';
|
23
22
|
/**
|
@@ -40,6 +39,7 @@ import required from './library/required.js';
|
|
40
39
|
* @slot {Element} [private-icon]
|
41
40
|
*
|
42
41
|
* @fires {Event} change
|
42
|
+
* @fires {Event} input
|
43
43
|
* @fires {Event} invalid
|
44
44
|
*
|
45
45
|
* @readonly
|
@@ -68,10 +68,12 @@ import required from './library/required.js';
|
|
68
68
|
*/
|
69
69
|
let Checkbox = class Checkbox extends LitElement {
|
70
70
|
static { this.formAssociated = true; }
|
71
|
+
/* c8 ignore start */
|
71
72
|
static { this.shadowRootOptions = {
|
72
73
|
...LitElement.shadowRootOptions,
|
73
|
-
mode:
|
74
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
74
75
|
}; }
|
76
|
+
/* c8 ignore end */
|
75
77
|
static { this.styles = styles; }
|
76
78
|
/**
|
77
79
|
* @default undefined
|
@@ -354,7 +356,7 @@ let Checkbox = class Checkbox extends LitElement {
|
|
354
356
|
reportValidity() {
|
355
357
|
this.privateIsReportValidityOrSubmit = true;
|
356
358
|
const isValid = this.#internals.reportValidity();
|
357
|
-
// Ensures
|
359
|
+
// Ensures getters referencing `this.validity.valid` re-run.
|
358
360
|
this.requestUpdate();
|
359
361
|
return isValid;
|
360
362
|
}
|
@@ -436,12 +438,12 @@ let Checkbox = class Checkbox extends LitElement {
|
|
436
438
|
this.privateIsReportValidityOrSubmit = true;
|
437
439
|
const isFirstInvalidFormElement = this.form?.querySelector(':invalid') === this;
|
438
440
|
if (isFirstInvalidFormElement) {
|
439
|
-
// - `
|
440
|
-
//
|
441
|
-
//
|
441
|
+
// - `delegatesFocus` is preferred because it's declarative. But it's limited to
|
442
|
+
// focusing the first focusable element. That doesn't work for us because the first
|
443
|
+
// focusable element is the Tooltip when it's present.
|
442
444
|
//
|
443
445
|
// - Canceling this event means the input won't get focus, even if we were to use
|
444
|
-
// `
|
446
|
+
// `delegatesFocus`.
|
445
447
|
//
|
446
448
|
// - The browser will ignore this if Checkbox isn't the first invalid form control.
|
447
449
|
//
|
@@ -480,12 +482,12 @@ let Checkbox = class Checkbox extends LitElement {
|
|
480
482
|
this.reportValidity();
|
481
483
|
this.isBlurring = false;
|
482
484
|
}
|
483
|
-
// Only "change" would need to be handled if not for some consumers needing
|
484
|
-
//
|
485
|
+
// Only "change" would need to be handled if not for some consumers needing to
|
486
|
+
// force Checkbox checked or unchecked until the user has completed some action.
|
485
487
|
//
|
486
|
-
// The way
|
487
|
-
// "change" handler and then immediately set `checked` back to its desired
|
488
|
-
//
|
488
|
+
// The way they can force Checkbox to be checked or unchecked is to add an "input"
|
489
|
+
// or "change" handler and then immediately set `checked` back to its desired state
|
490
|
+
// inside that handler.
|
489
491
|
//
|
490
492
|
// To do that, consumers need to await `this.updateComplete` so `checked` isn't
|
491
493
|
// immediately reverted after Checkbox updates, which happens asynchronously and
|
@@ -495,18 +497,25 @@ let Checkbox = class Checkbox extends LitElement {
|
|
495
497
|
// why we're handling "input" as well: so that "input", like "change", results
|
496
498
|
// in an update that can be awaited.
|
497
499
|
//
|
498
|
-
// If "input" events were dispatched after "change" events, only handling
|
499
|
-
//
|
500
|
-
//
|
500
|
+
// If "input" events were dispatched after "change" events, only handling "change"
|
501
|
+
// here would suffice because an update from "change" would already be pending by
|
502
|
+
// the time "input" is dispatched.
|
501
503
|
#onInputChangeOrInput(event) {
|
502
504
|
if (event.target instanceof HTMLInputElement) {
|
503
505
|
this.checked = event.target.checked;
|
504
506
|
}
|
505
507
|
// If the input has been interacted with it's no longer indeterminate.
|
506
508
|
this.indeterminate = false;
|
509
|
+
// Our analyzer plugin (`add-events.ts`) doesn't and can't account for events that
|
510
|
+
// are implicitly dispatched by a native form control in a component. So we stop
|
511
|
+
// the original event and dispatch our own.
|
512
|
+
if (event.type === 'input') {
|
513
|
+
event.stopPropagation();
|
514
|
+
this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
515
|
+
}
|
507
516
|
if (event.type === 'change') {
|
508
|
-
// Unlike "input" events, "change" events aren't composed. So we have to
|
509
|
-
//
|
517
|
+
// Unlike "input" events, "change" events aren't composed. So we have to manually
|
518
|
+
// dispatch them.
|
510
519
|
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
511
520
|
}
|
512
521
|
}
|
package/dist/checkbox.styles.js
CHANGED
@@ -44,7 +44,7 @@ export default [
|
|
44
44
|
border-radius: var(--glide-core-rounding-base-radius-xxs);
|
45
45
|
box-sizing: border-box;
|
46
46
|
color: var(
|
47
|
-
--glide-core-private-color-checkbox-surface-background-selected
|
47
|
+
--glide-core-private-color-checkbox-surface-background-selected
|
48
48
|
);
|
49
49
|
display: flex;
|
50
50
|
flex-shrink: 0; /* Don't shrink when the summary wraps. */
|
package/dist/drawer.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 './drawer.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
|
/**
|
@@ -38,10 +37,12 @@ let Drawer = class Drawer extends LitElement {
|
|
38
37
|
this.#defaultSlotElementRef = createRef();
|
39
38
|
this.#isOpen = false;
|
40
39
|
}
|
40
|
+
/* c8 ignore start */
|
41
41
|
static { this.shadowRootOptions = {
|
42
42
|
...LitElement.shadowRootOptions,
|
43
|
-
mode:
|
43
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
44
44
|
}; }
|
45
|
+
/* c8 ignore end */
|
45
46
|
static { this.styles = styles; }
|
46
47
|
/**
|
47
48
|
* @default false
|
package/dist/dropdown.js
CHANGED
@@ -28,7 +28,6 @@ import magnifyingGlassIcon from './icons/magnifying-glass.js';
|
|
28
28
|
import pencilIcon from './icons/pencil.js';
|
29
29
|
import styles from './dropdown.styles.js';
|
30
30
|
import assertSlot from './library/assert-slot.js';
|
31
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
32
31
|
import final from './library/final.js';
|
33
32
|
import required from './library/required.js';
|
34
33
|
import uniqueId from './library/unique-id.js';
|
@@ -94,10 +93,12 @@ import uniqueId from './library/unique-id.js';
|
|
94
93
|
*/
|
95
94
|
let Dropdown = class Dropdown extends LitElement {
|
96
95
|
static { this.formAssociated = true; }
|
96
|
+
/* c8 ignore start */
|
97
97
|
static { this.shadowRootOptions = {
|
98
98
|
...LitElement.shadowRootOptions,
|
99
|
-
mode:
|
99
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
100
100
|
}; }
|
101
|
+
/* c8 ignore end */
|
101
102
|
static { this.styles = styles; }
|
102
103
|
/**
|
103
104
|
* @default false
|
@@ -918,9 +919,9 @@ let Dropdown = class Dropdown extends LitElement {
|
|
918
919
|
-->
|
919
920
|
</slot>
|
920
921
|
|
921
|
-
${when(this.#isShowValidationFeedback && this.validityMessage, () => html `<span class="validity-message" data-test="validity-message"
|
922
|
-
|
923
|
-
>`)}
|
922
|
+
${when(this.#isShowValidationFeedback && this.validityMessage, () => html `<span class="validity-message" data-test="validity-message">
|
923
|
+
${unsafeHTML(this.validityMessage)}
|
924
|
+
</span>`)}
|
924
925
|
</div>
|
925
926
|
</glide-core-private-label>
|
926
927
|
</div>`;
|
@@ -928,7 +929,7 @@ let Dropdown = class Dropdown extends LitElement {
|
|
928
929
|
reportValidity() {
|
929
930
|
this.isReportValidityOrSubmit = true;
|
930
931
|
const isValid = this.#internals.reportValidity();
|
931
|
-
// Ensures
|
932
|
+
// Ensures getters referencing `this.validity.valid` re-run.
|
932
933
|
this.requestUpdate();
|
933
934
|
return isValid;
|
934
935
|
}
|
@@ -1095,7 +1096,7 @@ let Dropdown = class Dropdown extends LitElement {
|
|
1095
1096
|
// We only want to focus the input if the "invalid" event resulted from either:
|
1096
1097
|
//
|
1097
1098
|
// 1. A form submission.
|
1098
|
-
// 2. A call of `reportValidity()` that did not result from
|
1099
|
+
// 2. A call of `reportValidity()` that did not result from Dropdown's "blur"
|
1099
1100
|
// event.
|
1100
1101
|
if (this.isCheckingValidity || this.isBlurring) {
|
1101
1102
|
return;
|
@@ -1104,7 +1105,7 @@ let Dropdown = class Dropdown extends LitElement {
|
|
1104
1105
|
const isFirstInvalidFormElement = this.form?.querySelector(':invalid') === this;
|
1105
1106
|
if (isFirstInvalidFormElement) {
|
1106
1107
|
// Canceling the event means Dropdown won't get focus, even if we were to use
|
1107
|
-
// `
|
1108
|
+
// `delegatesFocus`. So we have to focus manually.
|
1108
1109
|
this.focus();
|
1109
1110
|
}
|
1110
1111
|
});
|
@@ -1461,8 +1462,7 @@ let Dropdown = class Dropdown extends LitElement {
|
|
1461
1462
|
this.#inputElementRef.value.value = this.activeOption.label;
|
1462
1463
|
this.inputValue = this.activeOption.label;
|
1463
1464
|
// One is subtracted to account for an apparent Chrome bug where `scrollWidth`
|
1464
|
-
// is off by one relative to `clientWidth` when they should be the same.
|
1465
|
-
// happens whenever the input field was overflowing and now isn't.
|
1465
|
+
// is off by one relative to `clientWidth` when they should be the same.
|
1466
1466
|
this.isInputOverflowing =
|
1467
1467
|
this.#inputElementRef.value.scrollWidth - 1 >
|
1468
1468
|
this.#inputElementRef.value.clientWidth;
|
@@ -1874,7 +1874,9 @@ let Dropdown = class Dropdown extends LitElement {
|
|
1874
1874
|
#onInputResize() {
|
1875
1875
|
if (this.#inputElementRef.value) {
|
1876
1876
|
this.isInputOverflowing =
|
1877
|
-
|
1877
|
+
// One is subtracted to account for an apparent Chrome bug where `scrollWidth`
|
1878
|
+
// is off by one relative to `clientWidth` when they should be the same.
|
1879
|
+
this.#inputElementRef.value.scrollWidth - 1 >
|
1878
1880
|
this.#inputElementRef.value.clientWidth;
|
1879
1881
|
}
|
1880
1882
|
}
|
@@ -1949,8 +1951,7 @@ let Dropdown = class Dropdown extends LitElement {
|
|
1949
1951
|
this.#inputElementRef.value.value = option.label;
|
1950
1952
|
this.inputValue = option.label;
|
1951
1953
|
// One is subtracted to account for an apparent Chrome bug where `scrollWidth`
|
1952
|
-
// is off by one relative to `clientWidth` when they should be the same.
|
1953
|
-
// happens whenever the input field was overflowing and now isn't.
|
1954
|
+
// is off by one relative to `clientWidth` when they should be the same.
|
1954
1955
|
this.isInputOverflowing =
|
1955
1956
|
this.#inputElementRef.value.scrollWidth - 1 >
|
1956
1957
|
this.#inputElementRef.value.clientWidth;
|
@@ -2007,8 +2008,7 @@ let Dropdown = class Dropdown extends LitElement {
|
|
2007
2008
|
this.lastSelectedAndEnabledOption?.label ?? '';
|
2008
2009
|
this.inputValue = this.lastSelectedAndEnabledOption?.label ?? '';
|
2009
2010
|
// One is subtracted to account for an apparent Chrome bug where `scrollWidth`
|
2010
|
-
// is off by one relative to `clientWidth` when they should be the same.
|
2011
|
-
// happens whenever the input field was overflowing and now isn't.
|
2011
|
+
// is off by one relative to `clientWidth` when they should be the same.
|
2012
2012
|
this.isInputOverflowing =
|
2013
2013
|
this.#inputElementRef.value.scrollWidth - 1 >
|
2014
2014
|
this.#inputElementRef.value.clientWidth;
|
@@ -2077,8 +2077,7 @@ let Dropdown = class Dropdown extends LitElement {
|
|
2077
2077
|
this.#inputElementRef.value.value = event.target.label;
|
2078
2078
|
this.inputValue = event.target.label;
|
2079
2079
|
// One is subtracted to account for an apparent Chrome bug where `scrollWidth`
|
2080
|
-
// is off by one relative to `clientWidth` when they should be the same.
|
2081
|
-
// happens whenever the input field was overflowing and now isn't.
|
2080
|
+
// is off by one relative to `clientWidth` when they should be the same.
|
2082
2081
|
this.isInputOverflowing =
|
2083
2082
|
this.#inputElementRef.value.scrollWidth - 1 >
|
2084
2083
|
this.#inputElementRef.value.clientWidth;
|
@@ -2116,8 +2115,10 @@ let Dropdown = class Dropdown extends LitElement {
|
|
2116
2115
|
this.#inputElementRef.value.value =
|
2117
2116
|
this.lastSelectedAndEnabledOption.label;
|
2118
2117
|
this.inputValue = this.lastSelectedAndEnabledOption.label;
|
2118
|
+
// One is subtracted to account for an apparent Chrome bug where `scrollWidth`
|
2119
|
+
// is off by one relative to `clientWidth` when they should be the same.
|
2119
2120
|
this.isInputOverflowing =
|
2120
|
-
this.#inputElementRef.value.scrollWidth >
|
2121
|
+
this.#inputElementRef.value.scrollWidth - 1 >
|
2121
2122
|
this.#inputElementRef.value.clientWidth;
|
2122
2123
|
}
|
2123
2124
|
else {
|
@@ -75,8 +75,10 @@ export default class DropdownOption extends LitElement {
|
|
75
75
|
private get lastSelectedAndEnabledOption();
|
76
76
|
click(): void;
|
77
77
|
connectedCallback(): void;
|
78
|
+
private get countSuffix();
|
78
79
|
disconnectedCallback(): void;
|
79
80
|
firstUpdated(): void;
|
81
|
+
private get isCountGreaterThanZero();
|
80
82
|
privateEdit(): void;
|
81
83
|
privateUpdateCheckbox(): Promise<void>;
|
82
84
|
render(): import("lit").TemplateResult<1>;
|
package/dist/dropdown.option.js
CHANGED
@@ -17,7 +17,6 @@ import checkedIcon from './icons/checked.js';
|
|
17
17
|
import pencilIcon from './icons/pencil.js';
|
18
18
|
import { LocalizeController } from './library/localize.js';
|
19
19
|
import styles from './dropdown.option.styles.js';
|
20
|
-
import shadowRootMode from './library/shadow-root-mode.js';
|
21
20
|
import final from './library/final.js';
|
22
21
|
import required from './library/required.js';
|
23
22
|
import uniqueId from './library/unique-id.js';
|
@@ -76,10 +75,12 @@ let DropdownOption = class DropdownOption extends LitElement {
|
|
76
75
|
this.#selected = false;
|
77
76
|
this.#value = '';
|
78
77
|
}
|
78
|
+
/* c8 ignore start */
|
79
79
|
static { this.shadowRootOptions = {
|
80
80
|
...LitElement.shadowRootOptions,
|
81
|
-
mode:
|
81
|
+
mode: window.navigator.webdriver ? 'open' : 'closed',
|
82
82
|
}; }
|
83
|
+
/* c8 ignore end */
|
83
84
|
static { this.styles = styles; }
|
84
85
|
/**
|
85
86
|
* @default undefined
|
@@ -199,6 +200,13 @@ let DropdownOption = class DropdownOption extends LitElement {
|
|
199
200
|
});
|
200
201
|
this.#intersectionObserver.observe(this);
|
201
202
|
}
|
203
|
+
get countSuffix() {
|
204
|
+
return typeof this.count === 'number' && this.count >= 0
|
205
|
+
? this.count >= 1000
|
206
|
+
? '999+'
|
207
|
+
: this.count.toString()
|
208
|
+
: '';
|
209
|
+
}
|
202
210
|
disconnectedCallback() {
|
203
211
|
super.disconnectedCallback();
|
204
212
|
this.#intersectionObserver?.disconnect();
|
@@ -208,6 +216,9 @@ let DropdownOption = class DropdownOption extends LitElement {
|
|
208
216
|
this.#checkboxElementRef.value.checked = this.selected && !this.disabled;
|
209
217
|
}
|
210
218
|
}
|
219
|
+
get isCountGreaterThanZero() {
|
220
|
+
return typeof this.count === 'number' && this.count >= 0;
|
221
|
+
}
|
211
222
|
privateEdit() {
|
212
223
|
this.dispatchEvent(new Event('edit', { bubbles: true, composed: true }));
|
213
224
|
}
|
@@ -274,7 +285,7 @@ let DropdownOption = class DropdownOption extends LitElement {
|
|
274
285
|
class=${classMap({
|
275
286
|
'edit-button': true,
|
276
287
|
active: this.privateIsEditActive,
|
277
|
-
count:
|
288
|
+
count: this.isCountGreaterThanZero,
|
278
289
|
disabled: this.disabled,
|
279
290
|
multiple: Boolean(this.isMultiple),
|
280
291
|
})}
|
@@ -286,7 +297,7 @@ let DropdownOption = class DropdownOption extends LitElement {
|
|
286
297
|
${pencilIcon}
|
287
298
|
</button>`;
|
288
299
|
})}
|
289
|
-
${when(this.
|
300
|
+
${when(this.isCountGreaterThanZero, () => {
|
290
301
|
return html `<div
|
291
302
|
class=${classMap({
|
292
303
|
'count-container': true,
|
@@ -294,15 +305,7 @@ let DropdownOption = class DropdownOption extends LitElement {
|
|
294
305
|
})}
|
295
306
|
data-test="count-container"
|
296
307
|
>
|
297
|
-
${
|
298
|
-
// `this.count` is guaranteed to be defined by the `when()` above.
|
299
|
-
//
|
300
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
301
|
-
this.count >= 1000, () => {
|
302
|
-
return '999+';
|
303
|
-
}, () => {
|
304
|
-
return this.count;
|
305
|
-
})}
|
308
|
+
${this.countSuffix}
|
306
309
|
</div>`;
|
307
310
|
})}
|
308
311
|
`;
|
@@ -311,7 +314,7 @@ let DropdownOption = class DropdownOption extends LitElement {
|
|
311
314
|
<div
|
312
315
|
class=${classMap({
|
313
316
|
option: true,
|
314
|
-
count:
|
317
|
+
count: this.isCountGreaterThanZero,
|
315
318
|
disabled: this.disabled,
|
316
319
|
editable: this.editable,
|
317
320
|
})}
|
@@ -369,7 +372,7 @@ let DropdownOption = class DropdownOption extends LitElement {
|
|
369
372
|
class=${classMap({
|
370
373
|
'edit-button': true,
|
371
374
|
active: this.privateActive && this.privateIsEditActive,
|
372
|
-
count:
|
375
|
+
count: this.isCountGreaterThanZero,
|
373
376
|
disabled: this.disabled,
|
374
377
|
})}
|
375
378
|
data-test="edit-button"
|
@@ -381,7 +384,7 @@ let DropdownOption = class DropdownOption extends LitElement {
|
|
381
384
|
</button>`;
|
382
385
|
})}
|
383
386
|
|
384
|
-
${when(this.
|
387
|
+
${when(this.isCountGreaterThanZero, () => {
|
385
388
|
return html `<div
|
386
389
|
class=${classMap({
|
387
390
|
'count-container': true,
|
@@ -389,15 +392,7 @@ let DropdownOption = class DropdownOption extends LitElement {
|
|
389
392
|
})}
|
390
393
|
data-test="count-container"
|
391
394
|
>
|
392
|
-
${
|
393
|
-
// `this.count` is guaranteed to be defined by the `when()` above.
|
394
|
-
//
|
395
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
396
|
-
this.count >= 1000, () => {
|
397
|
-
return '999+';
|
398
|
-
}, () => {
|
399
|
-
return this.count;
|
400
|
-
})}
|
395
|
+
${this.countSuffix}
|
401
396
|
</div>`;
|
402
397
|
})}
|
403
398
|
</div>
|
@@ -526,6 +521,12 @@ __decorate([
|
|
526
521
|
__decorate([
|
527
522
|
state()
|
528
523
|
], DropdownOption.prototype, "lastSelectedAndEnabledOption", null);
|
524
|
+
__decorate([
|
525
|
+
state()
|
526
|
+
], DropdownOption.prototype, "countSuffix", null);
|
527
|
+
__decorate([
|
528
|
+
state()
|
529
|
+
], DropdownOption.prototype, "isCountGreaterThanZero", null);
|
529
530
|
__decorate([
|
530
531
|
state()
|
531
532
|
], DropdownOption.prototype, "isLabelOverflow", void 0);
|
@@ -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'
|