@material/web 1.0.2-nightly.6a1fb38.0 → 1.0.2-nightly.739cf33.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/checkbox/internal/checkbox.d.ts +6 -65
- package/checkbox/internal/checkbox.js +17 -116
- package/checkbox/internal/checkbox.js.map +1 -1
- package/chips/internal/_shared.scss +16 -3
- package/chips/internal/_trailing-icon.scss +2 -1
- package/chips/internal/assist-styles.css.js +1 -1
- package/chips/internal/assist-styles.css.js.map +1 -1
- package/chips/internal/chip-set.js +2 -6
- package/chips/internal/chip-set.js.map +1 -1
- package/chips/internal/chip.d.ts +8 -0
- package/chips/internal/chip.js +17 -2
- package/chips/internal/chip.js.map +1 -1
- package/chips/internal/filter-chip.d.ts +8 -0
- package/chips/internal/filter-chip.js +17 -4
- package/chips/internal/filter-chip.js.map +1 -1
- package/chips/internal/filter-styles.css.js +1 -1
- package/chips/internal/filter-styles.css.js.map +1 -1
- package/chips/internal/input-styles.css.js +1 -1
- package/chips/internal/input-styles.css.js.map +1 -1
- package/chips/internal/shared-styles.css.js +1 -1
- package/chips/internal/shared-styles.css.js.map +1 -1
- package/chips/internal/suggestion-styles.css.js +1 -1
- package/chips/internal/suggestion-styles.css.js.map +1 -1
- package/chips/internal/trailing-icon-styles.css.js +1 -1
- package/chips/internal/trailing-icon-styles.css.js.map +1 -1
- package/fab/internal/_shared.scss +1 -0
- package/fab/internal/shared-styles.css.js +1 -1
- package/fab/internal/shared-styles.css.js.map +1 -1
- package/field/internal/_content.scss +3 -1
- package/field/internal/shared-styles.css.js +1 -1
- package/field/internal/shared-styles.css.js.map +1 -1
- package/internal/aria/aria.d.ts +0 -29
- package/internal/aria/aria.js +0 -141
- package/internal/aria/aria.js.map +1 -1
- package/internal/controller/form-submitter.js +2 -2
- package/internal/controller/form-submitter.js.map +1 -1
- package/labs/behaviors/constraint-validation.d.ts +133 -0
- package/labs/behaviors/constraint-validation.js +131 -0
- package/labs/behaviors/constraint-validation.js.map +1 -0
- package/labs/behaviors/element-internals.js +1 -5
- package/labs/behaviors/element-internals.js.map +1 -1
- package/labs/behaviors/focusable.js +20 -7
- package/labs/behaviors/focusable.js.map +1 -1
- package/labs/behaviors/on-report-validity.d.ts +70 -0
- package/labs/behaviors/on-report-validity.js +185 -0
- package/labs/behaviors/on-report-validity.js.map +1 -0
- package/labs/behaviors/validators/checkbox-validator.d.ts +35 -0
- package/labs/behaviors/validators/checkbox-validator.js +32 -0
- package/labs/behaviors/validators/checkbox-validator.js.map +1 -0
- package/labs/behaviors/validators/radio-validator.d.ts +38 -0
- package/labs/behaviors/validators/radio-validator.js +65 -0
- package/labs/behaviors/validators/radio-validator.js.map +1 -0
- package/labs/behaviors/validators/select-validator.d.ts +35 -0
- package/labs/behaviors/validators/select-validator.js +33 -0
- package/labs/behaviors/validators/select-validator.js.map +1 -0
- package/labs/behaviors/validators/text-field-validator.d.ts +110 -0
- package/labs/behaviors/validators/text-field-validator.js +146 -0
- package/labs/behaviors/validators/text-field-validator.js.map +1 -0
- package/labs/behaviors/validators/validator.d.ts +96 -0
- package/labs/behaviors/validators/validator.js +73 -0
- package/labs/behaviors/validators/validator.js.map +1 -0
- package/labs/card/internal/_outlined-card.scss +1 -1
- package/labs/card/internal/_shared.scss +10 -2
- package/labs/card/internal/outlined-styles.css.js +1 -1
- package/labs/card/internal/outlined-styles.css.js.map +1 -1
- package/labs/card/internal/shared-styles.css.js +1 -1
- package/labs/card/internal/shared-styles.css.js.map +1 -1
- package/labs/segmentedbutton/internal/_shared.scss +1 -0
- package/labs/segmentedbutton/internal/shared-styles.css.js +1 -1
- package/labs/segmentedbutton/internal/shared-styles.css.js.map +1 -1
- package/list/internal/list.js +2 -6
- package/list/internal/list.js.map +1 -1
- package/list/internal/listitem/_list-item.scss +2 -0
- package/list/internal/listitem/list-item-styles.css.js +1 -1
- package/list/internal/listitem/list-item-styles.css.js.map +1 -1
- package/menu/internal/controllers/menuItemController.d.ts +13 -1
- package/menu/internal/controllers/menuItemController.js +32 -6
- package/menu/internal/controllers/menuItemController.js.map +1 -1
- package/menu/internal/controllers/surfacePositionController.d.ts +2 -1
- package/menu/internal/controllers/surfacePositionController.js.map +1 -1
- package/menu/internal/menu.js +7 -8
- package/menu/internal/menu.js.map +1 -1
- package/menu/internal/menuitem/menu-item.d.ts +2 -0
- package/menu/internal/menuitem/menu-item.js +13 -1
- package/menu/internal/menuitem/menu-item.js.map +1 -1
- package/package.json +1 -1
- package/radio/internal/radio.d.ts +11 -1
- package/radio/internal/radio.js +28 -2
- package/radio/internal/radio.js.map +1 -1
- package/radio/internal/single-selection-controller.d.ts +5 -5
- package/radio/internal/single-selection-controller.js +16 -14
- package/radio/internal/single-selection-controller.js.map +1 -1
- package/select/internal/_shared.scss +5 -0
- package/select/internal/select.d.ts +21 -72
- package/select/internal/select.js +106 -184
- package/select/internal/select.js.map +1 -1
- package/select/internal/selectoption/select-option.d.ts +2 -0
- package/select/internal/selectoption/select-option.js +13 -1
- package/select/internal/selectoption/select-option.js.map +1 -1
- package/select/internal/selectoption/selectOptionController.d.ts +7 -3
- package/select/internal/selectoption/selectOptionController.js +8 -11
- package/select/internal/selectoption/selectOptionController.js.map +1 -1
- package/select/internal/shared-styles.css.js +1 -1
- package/select/internal/shared-styles.css.js.map +1 -1
- package/switch/internal/_icon.scss +14 -10
- package/switch/internal/switch-styles.css.js +1 -1
- package/switch/internal/switch-styles.css.js.map +1 -1
- package/switch/internal/switch.d.ts +5 -65
- package/switch/internal/switch.js +26 -123
- package/switch/internal/switch.js.map +1 -1
- package/tabs/internal/tab.js +2 -6
- package/tabs/internal/tab.js.map +1 -1
- package/tabs/internal/tabs.js +2 -6
- package/tabs/internal/tabs.js.map +1 -1
- package/textfield/internal/text-field.d.ts +9 -74
- package/textfield/internal/text-field.js +34 -150
- package/textfield/internal/text-field.js.map +1 -1
- package/tokens/_md-comp-assist-chip.scss +11 -0
- package/tokens/_md-comp-filter-chip.scss +14 -0
- package/tokens/_md-comp-input-chip.scss +14 -0
- package/tokens/_md-comp-suggestion-chip.scss +11 -0
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
import '../../focus/md-focus-ring.js';
|
|
7
7
|
import '../../ripple/ripple.js';
|
|
8
8
|
import { LitElement, PropertyValues } from 'lit';
|
|
9
|
+
import { createValidator, getValidityAnchor } from '../../labs/behaviors/constraint-validation.js';
|
|
9
10
|
import { getFormState, getFormValue } from '../../labs/behaviors/form-associated.js';
|
|
10
|
-
|
|
11
|
+
import { CheckboxValidator } from '../../labs/behaviors/validators/checkbox-validator.js';
|
|
12
|
+
declare const checkboxBaseClass: import("../../labs/behaviors/mixin.js").MixinReturn<import("../../labs/behaviors/mixin.js").MixinReturn<(abstract new (...args: any[]) => import("../../labs/behaviors/element-internals.js").WithElementInternals) & typeof LitElement & import("../../labs/behaviors/form-associated.js").FormAssociatedConstructor, import("../../labs/behaviors/form-associated.js").FormAssociated>, import("../../labs/behaviors/constraint-validation.js").ConstraintValidation>;
|
|
11
13
|
/**
|
|
12
14
|
* A checkbox component.
|
|
13
15
|
*
|
|
@@ -49,83 +51,22 @@ export declare class Checkbox extends checkboxBaseClass {
|
|
|
49
51
|
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value
|
|
50
52
|
*/
|
|
51
53
|
value: string;
|
|
52
|
-
/**
|
|
53
|
-
* Returns a ValidityState object that represents the validity states of the
|
|
54
|
-
* checkbox.
|
|
55
|
-
*
|
|
56
|
-
* Note that checkboxes will only set `valueMissing` if `required` and not
|
|
57
|
-
* checked.
|
|
58
|
-
*
|
|
59
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#validation
|
|
60
|
-
*/
|
|
61
|
-
get validity(): ValidityState;
|
|
62
|
-
/**
|
|
63
|
-
* Returns the native validation error message.
|
|
64
|
-
*
|
|
65
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#constraint_validation_process
|
|
66
|
-
*/
|
|
67
|
-
get validationMessage(): string;
|
|
68
|
-
/**
|
|
69
|
-
* Returns whether an element will successfully validate based on forms
|
|
70
|
-
* validation rules and constraints.
|
|
71
|
-
*
|
|
72
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#constraint_validation_process
|
|
73
|
-
*/
|
|
74
|
-
get willValidate(): boolean;
|
|
75
54
|
private prevChecked;
|
|
76
55
|
private prevDisabled;
|
|
77
56
|
private prevIndeterminate;
|
|
78
57
|
private readonly input;
|
|
79
|
-
private hasCustomValidityError;
|
|
80
58
|
constructor();
|
|
81
|
-
/**
|
|
82
|
-
* Checks the checkbox's native validation and returns whether or not the
|
|
83
|
-
* element is valid.
|
|
84
|
-
*
|
|
85
|
-
* If invalid, this method will dispatch the `invalid` event.
|
|
86
|
-
*
|
|
87
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
|
|
88
|
-
*
|
|
89
|
-
* @return true if the checkbox is valid, or false if not.
|
|
90
|
-
*/
|
|
91
|
-
checkValidity(): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Checks the checkbox's native validation and returns whether or not the
|
|
94
|
-
* element is valid.
|
|
95
|
-
*
|
|
96
|
-
* If invalid, this method will dispatch the `invalid` event.
|
|
97
|
-
*
|
|
98
|
-
* The `validationMessage` is reported to the user by the browser. Use
|
|
99
|
-
* `setCustomValidity()` to customize the `validationMessage`.
|
|
100
|
-
*
|
|
101
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity
|
|
102
|
-
*
|
|
103
|
-
* @return true if the checkbox is valid, or false if not.
|
|
104
|
-
*/
|
|
105
|
-
reportValidity(): boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Sets the checkbox's native validation error message. This is used to
|
|
108
|
-
* customize `validationMessage`.
|
|
109
|
-
*
|
|
110
|
-
* When the error is not an empty string, the checkbox is considered invalid
|
|
111
|
-
* and `validity.customError` will be true.
|
|
112
|
-
*
|
|
113
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
|
|
114
|
-
*
|
|
115
|
-
* @param error The error message to display.
|
|
116
|
-
*/
|
|
117
|
-
setCustomValidity(error: string): void;
|
|
118
59
|
protected update(changed: PropertyValues<Checkbox>): void;
|
|
119
60
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
120
|
-
|
|
61
|
+
private handleInput;
|
|
121
62
|
private handleChange;
|
|
122
|
-
private syncValidity;
|
|
123
|
-
private getInput;
|
|
124
63
|
disabled: boolean;
|
|
125
64
|
name: string;
|
|
126
65
|
[getFormValue](): string;
|
|
127
66
|
[getFormState](): string;
|
|
128
67
|
formResetCallback(): void;
|
|
129
68
|
formStateRestoreCallback(state: string): void;
|
|
69
|
+
[createValidator](): CheckboxValidator;
|
|
70
|
+
[getValidityAnchor](): HTMLInputElement;
|
|
130
71
|
}
|
|
131
72
|
export {};
|
|
@@ -11,10 +11,12 @@ import { property, query, state } from 'lit/decorators.js';
|
|
|
11
11
|
import { classMap } from 'lit/directives/class-map.js';
|
|
12
12
|
import { requestUpdateOnAriaChange } from '../../internal/aria/delegate.js';
|
|
13
13
|
import { dispatchActivationClick, isActivationClick, redispatchEvent, } from '../../internal/controller/events.js';
|
|
14
|
-
import {
|
|
14
|
+
import { createValidator, getValidityAnchor, mixinConstraintValidation, } from '../../labs/behaviors/constraint-validation.js';
|
|
15
|
+
import { mixinElementInternals } from '../../labs/behaviors/element-internals.js';
|
|
15
16
|
import { getFormState, getFormValue, mixinFormAssociated, } from '../../labs/behaviors/form-associated.js';
|
|
17
|
+
import { CheckboxValidator } from '../../labs/behaviors/validators/checkbox-validator.js';
|
|
16
18
|
// Separate variable needed for closure.
|
|
17
|
-
const checkboxBaseClass = mixinFormAssociated(mixinElementInternals(LitElement));
|
|
19
|
+
const checkboxBaseClass = mixinConstraintValidation(mixinFormAssociated(mixinElementInternals(LitElement)));
|
|
18
20
|
/**
|
|
19
21
|
* A checkbox component.
|
|
20
22
|
*
|
|
@@ -27,38 +29,6 @@ const checkboxBaseClass = mixinFormAssociated(mixinElementInternals(LitElement))
|
|
|
27
29
|
* --bubbles --composed
|
|
28
30
|
*/
|
|
29
31
|
export class Checkbox extends checkboxBaseClass {
|
|
30
|
-
/**
|
|
31
|
-
* Returns a ValidityState object that represents the validity states of the
|
|
32
|
-
* checkbox.
|
|
33
|
-
*
|
|
34
|
-
* Note that checkboxes will only set `valueMissing` if `required` and not
|
|
35
|
-
* checked.
|
|
36
|
-
*
|
|
37
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#validation
|
|
38
|
-
*/
|
|
39
|
-
get validity() {
|
|
40
|
-
this.syncValidity();
|
|
41
|
-
return this[internals].validity;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Returns the native validation error message.
|
|
45
|
-
*
|
|
46
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#constraint_validation_process
|
|
47
|
-
*/
|
|
48
|
-
get validationMessage() {
|
|
49
|
-
this.syncValidity();
|
|
50
|
-
return this[internals].validationMessage;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Returns whether an element will successfully validate based on forms
|
|
54
|
-
* validation rules and constraints.
|
|
55
|
-
*
|
|
56
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#constraint_validation_process
|
|
57
|
-
*/
|
|
58
|
-
get willValidate() {
|
|
59
|
-
this.syncValidity();
|
|
60
|
-
return this[internals].willValidate;
|
|
61
|
-
}
|
|
62
32
|
constructor() {
|
|
63
33
|
super();
|
|
64
34
|
/**
|
|
@@ -87,12 +57,9 @@ export class Checkbox extends checkboxBaseClass {
|
|
|
87
57
|
this.prevChecked = false;
|
|
88
58
|
this.prevDisabled = false;
|
|
89
59
|
this.prevIndeterminate = false;
|
|
90
|
-
// Needed for Safari, see https://bugs.webkit.org/show_bug.cgi?id=261432
|
|
91
|
-
// Replace with this[internals].validity.customError when resolved.
|
|
92
|
-
this.hasCustomValidityError = false;
|
|
93
60
|
if (!isServer) {
|
|
94
61
|
this.addEventListener('click', (event) => {
|
|
95
|
-
if (!isActivationClick(event)) {
|
|
62
|
+
if (!isActivationClick(event) || !this.input) {
|
|
96
63
|
return;
|
|
97
64
|
}
|
|
98
65
|
this.focus();
|
|
@@ -100,52 +67,6 @@ export class Checkbox extends checkboxBaseClass {
|
|
|
100
67
|
});
|
|
101
68
|
}
|
|
102
69
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Checks the checkbox's native validation and returns whether or not the
|
|
105
|
-
* element is valid.
|
|
106
|
-
*
|
|
107
|
-
* If invalid, this method will dispatch the `invalid` event.
|
|
108
|
-
*
|
|
109
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
|
|
110
|
-
*
|
|
111
|
-
* @return true if the checkbox is valid, or false if not.
|
|
112
|
-
*/
|
|
113
|
-
checkValidity() {
|
|
114
|
-
this.syncValidity();
|
|
115
|
-
return this[internals].checkValidity();
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Checks the checkbox's native validation and returns whether or not the
|
|
119
|
-
* element is valid.
|
|
120
|
-
*
|
|
121
|
-
* If invalid, this method will dispatch the `invalid` event.
|
|
122
|
-
*
|
|
123
|
-
* The `validationMessage` is reported to the user by the browser. Use
|
|
124
|
-
* `setCustomValidity()` to customize the `validationMessage`.
|
|
125
|
-
*
|
|
126
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity
|
|
127
|
-
*
|
|
128
|
-
* @return true if the checkbox is valid, or false if not.
|
|
129
|
-
*/
|
|
130
|
-
reportValidity() {
|
|
131
|
-
this.syncValidity();
|
|
132
|
-
return this[internals].reportValidity();
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Sets the checkbox's native validation error message. This is used to
|
|
136
|
-
* customize `validationMessage`.
|
|
137
|
-
*
|
|
138
|
-
* When the error is not an empty string, the checkbox is considered invalid
|
|
139
|
-
* and `validity.customError` will be true.
|
|
140
|
-
*
|
|
141
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
|
|
142
|
-
*
|
|
143
|
-
* @param error The error message to display.
|
|
144
|
-
*/
|
|
145
|
-
setCustomValidity(error) {
|
|
146
|
-
this.hasCustomValidityError = !!error;
|
|
147
|
-
this[internals].setValidity({ customError: !!error }, error, this.getInput());
|
|
148
|
-
}
|
|
149
70
|
update(changed) {
|
|
150
71
|
if (changed.has('checked') ||
|
|
151
72
|
changed.has('disabled') ||
|
|
@@ -190,6 +111,7 @@ export class Checkbox extends checkboxBaseClass {
|
|
|
190
111
|
?required=${this.required}
|
|
191
112
|
.indeterminate=${this.indeterminate}
|
|
192
113
|
.checked=${this.checked}
|
|
114
|
+
@input=${this.handleInput}
|
|
193
115
|
@change=${this.handleChange} />
|
|
194
116
|
|
|
195
117
|
<div class="outline"></div>
|
|
@@ -203,42 +125,15 @@ export class Checkbox extends checkboxBaseClass {
|
|
|
203
125
|
</div>
|
|
204
126
|
`;
|
|
205
127
|
}
|
|
206
|
-
|
|
207
|
-
// Sync validity when properties change, since validation properties may
|
|
208
|
-
// have changed.
|
|
209
|
-
this.syncValidity();
|
|
210
|
-
}
|
|
211
|
-
handleChange(event) {
|
|
128
|
+
handleInput(event) {
|
|
212
129
|
const target = event.target;
|
|
213
130
|
this.checked = target.checked;
|
|
214
131
|
this.indeterminate = target.indeterminate;
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
syncValidity() {
|
|
218
|
-
// Sync the internal <input>'s validity and the host's ElementInternals
|
|
219
|
-
// validity. We do this to re-use native `<input>` validation messages.
|
|
220
|
-
const input = this.getInput();
|
|
221
|
-
if (this.hasCustomValidityError) {
|
|
222
|
-
input.setCustomValidity(this[internals].validationMessage);
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
input.setCustomValidity('');
|
|
226
|
-
}
|
|
227
|
-
this[internals].setValidity(input.validity, input.validationMessage, this.getInput());
|
|
132
|
+
// <input> 'input' event bubbles and is composed, don't re-dispatch it.
|
|
228
133
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
this.connectedCallback();
|
|
233
|
-
this.performUpdate();
|
|
234
|
-
}
|
|
235
|
-
if (this.isUpdatePending) {
|
|
236
|
-
// If there are pending updates, synchronously perform them. This ensures
|
|
237
|
-
// that constraint validation properties (like `required`) are synced
|
|
238
|
-
// before interacting with input APIs that depend on them.
|
|
239
|
-
this.scheduleUpdate();
|
|
240
|
-
}
|
|
241
|
-
return this.input;
|
|
134
|
+
handleChange(event) {
|
|
135
|
+
// <input> 'change' event is not composed, re-dispatch it.
|
|
136
|
+
redispatchEvent(this, event);
|
|
242
137
|
}
|
|
243
138
|
[getFormValue]() {
|
|
244
139
|
if (!this.checked || this.indeterminate) {
|
|
@@ -257,6 +152,12 @@ export class Checkbox extends checkboxBaseClass {
|
|
|
257
152
|
formStateRestoreCallback(state) {
|
|
258
153
|
this.checked = state === 'true';
|
|
259
154
|
}
|
|
155
|
+
[createValidator]() {
|
|
156
|
+
return new CheckboxValidator(() => this);
|
|
157
|
+
}
|
|
158
|
+
[getValidityAnchor]() {
|
|
159
|
+
return this.input;
|
|
160
|
+
}
|
|
260
161
|
}
|
|
261
162
|
(() => {
|
|
262
163
|
requestUpdateOnAriaChange(Checkbox);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["checkbox.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,KAAK,CAAC;AACxE,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAGrD,OAAO,EAAC,yBAAyB,E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AC;SACb;QAED,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEQ,CAAC,YAAY,CAAC;QACrB,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAEQ,iBAAiB;QACxB,0EAA0E;QAC1E,mDAAmD;QACnD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;IAEQ,wBAAwB,CAAC,KAAa;QAC7C,IAAI,CAAC,OAAO,GAAG,KAAK,KAAK,MAAM,CAAC;IAClC,CAAC;;AAtRD;IACE,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC,GAAA,CAAA;AAED,kBAAkB;AACF,0BAAiB,GAAG;IAClC,GAAG,UAAU,CAAC,iBAAiB;IAC/B,cAAc,EAAE,IAAI;CACrB,AAHgC,CAG/B;AAKyB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;yCAAiB;AAOhB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;+CAAuB;AAQtB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;0CAAkB;AAOhC;IAAX,QAAQ,EAAE;uCAAc;AAqCR;IAAhB,KAAK,EAAE;6CAA6B;AACpB;IAAhB,KAAK,EAAE;8CAA8B;AACrB;IAAhB,KAAK,EAAE;mDAAmC;AACV;IAAhC,KAAK,CAAC,OAAO,CAAC;uCAAkD","sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../focus/md-focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, isServer, LitElement, nothing, PropertyValues} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {ARIAMixinStrict} from '../../internal/aria/aria.js';\nimport {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js';\nimport {\n dispatchActivationClick,\n isActivationClick,\n redispatchEvent,\n} from '../../internal/controller/events.js';\nimport {\n internals,\n mixinElementInternals,\n} from '../../labs/behaviors/element-internals.js';\nimport {\n getFormState,\n getFormValue,\n mixinFormAssociated,\n} from '../../labs/behaviors/form-associated.js';\n\n// Separate variable needed for closure.\nconst checkboxBaseClass = mixinFormAssociated(\n mixinElementInternals(LitElement),\n);\n\n/**\n * A checkbox component.\n *\n *\n * @fires change {Event} The native `change` event on\n * [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event)\n * --bubbles\n * @fires input {InputEvent} The native `input` event on\n * [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event)\n * --bubbles --composed\n */\nexport class Checkbox extends checkboxBaseClass {\n static {\n requestUpdateOnAriaChange(Checkbox);\n }\n\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /**\n * Whether or not the checkbox is selected.\n */\n @property({type: Boolean}) checked = false;\n\n /**\n * Whether or not the checkbox is indeterminate.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes\n */\n @property({type: Boolean}) indeterminate = false;\n\n /**\n * When true, require the checkbox to be selected when participating in\n * form submission.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#validation\n */\n @property({type: Boolean}) required = false;\n\n /**\n * The value of the checkbox that is submitted with a form when selected.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value\n */\n @property() value = 'on';\n\n /**\n * Returns a ValidityState object that represents the validity states of the\n * checkbox.\n *\n * Note that checkboxes will only set `valueMissing` if `required` and not\n * checked.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#validation\n */\n get validity() {\n this.syncValidity();\n return this[internals].validity;\n }\n\n /**\n * Returns the native validation error message.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#constraint_validation_process\n */\n get validationMessage() {\n this.syncValidity();\n return this[internals].validationMessage;\n }\n\n /**\n * Returns whether an element will successfully validate based on forms\n * validation rules and constraints.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#constraint_validation_process\n */\n get willValidate() {\n this.syncValidity();\n return this[internals].willValidate;\n }\n\n @state() private prevChecked = false;\n @state() private prevDisabled = false;\n @state() private prevIndeterminate = false;\n @query('input') private readonly input!: HTMLInputElement | null;\n // Needed for Safari, see https://bugs.webkit.org/show_bug.cgi?id=261432\n // Replace with this[internals].validity.customError when resolved.\n private hasCustomValidityError = false;\n\n constructor() {\n super();\n if (!isServer) {\n this.addEventListener('click', (event: MouseEvent) => {\n if (!isActivationClick(event)) {\n return;\n }\n this.focus();\n dispatchActivationClick(this.input!);\n });\n }\n }\n\n /**\n * Checks the checkbox's native validation and returns whether or not the\n * element is valid.\n *\n * If invalid, this method will dispatch the `invalid` event.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity\n *\n * @return true if the checkbox is valid, or false if not.\n */\n checkValidity() {\n this.syncValidity();\n return this[internals].checkValidity();\n }\n\n /**\n * Checks the checkbox's native validation and returns whether or not the\n * element is valid.\n *\n * If invalid, this method will dispatch the `invalid` event.\n *\n * The `validationMessage` is reported to the user by the browser. Use\n * `setCustomValidity()` to customize the `validationMessage`.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity\n *\n * @return true if the checkbox is valid, or false if not.\n */\n reportValidity() {\n this.syncValidity();\n return this[internals].reportValidity();\n }\n\n /**\n * Sets the checkbox's native validation error message. This is used to\n * customize `validationMessage`.\n *\n * When the error is not an empty string, the checkbox is considered invalid\n * and `validity.customError` will be true.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity\n *\n * @param error The error message to display.\n */\n setCustomValidity(error: string) {\n this.hasCustomValidityError = !!error;\n this[internals].setValidity({customError: !!error}, error, this.getInput());\n }\n\n protected override update(changed: PropertyValues<Checkbox>) {\n if (\n changed.has('checked') ||\n changed.has('disabled') ||\n changed.has('indeterminate')\n ) {\n this.prevChecked = changed.get('checked') ?? this.checked;\n this.prevDisabled = changed.get('disabled') ?? this.disabled;\n this.prevIndeterminate =\n changed.get('indeterminate') ?? this.indeterminate;\n }\n\n super.update(changed);\n }\n\n protected override render() {\n const prevNone = !this.prevChecked && !this.prevIndeterminate;\n const prevChecked = this.prevChecked && !this.prevIndeterminate;\n const prevIndeterminate = this.prevIndeterminate;\n const isChecked = this.checked && !this.indeterminate;\n const isIndeterminate = this.indeterminate;\n\n const containerClasses = classMap({\n 'disabled': this.disabled,\n 'selected': isChecked || isIndeterminate,\n 'unselected': !isChecked && !isIndeterminate,\n 'checked': isChecked,\n 'indeterminate': isIndeterminate,\n 'prev-unselected': prevNone,\n 'prev-checked': prevChecked,\n 'prev-indeterminate': prevIndeterminate,\n 'prev-disabled': this.prevDisabled,\n });\n\n // Needed for closure conformance\n const {ariaLabel, ariaInvalid} = this as ARIAMixinStrict;\n // Note: <input> needs to be rendered before the <svg> for\n // form.reportValidity() to work in Chrome.\n return html`\n <div class=\"container ${containerClasses}\">\n <input\n type=\"checkbox\"\n id=\"input\"\n aria-checked=${isIndeterminate ? 'mixed' : nothing}\n aria-label=${ariaLabel || nothing}\n aria-invalid=${ariaInvalid || nothing}\n ?disabled=${this.disabled}\n ?required=${this.required}\n .indeterminate=${this.indeterminate}\n .checked=${this.checked}\n @change=${this.handleChange} />\n\n <div class=\"outline\"></div>\n <div class=\"background\"></div>\n <md-focus-ring part=\"focus-ring\" for=\"input\"></md-focus-ring>\n <md-ripple for=\"input\" ?disabled=${this.disabled}></md-ripple>\n <svg class=\"icon\" viewBox=\"0 0 18 18\" aria-hidden=\"true\">\n <rect class=\"mark short\" />\n <rect class=\"mark long\" />\n </svg>\n </div>\n `;\n }\n\n protected override updated() {\n // Sync validity when properties change, since validation properties may\n // have changed.\n this.syncValidity();\n }\n\n private handleChange(event: Event) {\n const target = event.target as HTMLInputElement;\n this.checked = target.checked;\n this.indeterminate = target.indeterminate;\n\n redispatchEvent(this, event);\n }\n\n private syncValidity() {\n // Sync the internal <input>'s validity and the host's ElementInternals\n // validity. We do this to re-use native `<input>` validation messages.\n const input = this.getInput();\n if (this.hasCustomValidityError) {\n input.setCustomValidity(this[internals].validationMessage);\n } else {\n input.setCustomValidity('');\n }\n\n this[internals].setValidity(\n input.validity,\n input.validationMessage,\n this.getInput(),\n );\n }\n\n private getInput() {\n if (!this.input) {\n // If the input is not yet defined, synchronously render.\n this.connectedCallback();\n this.performUpdate();\n }\n\n if (this.isUpdatePending) {\n // If there are pending updates, synchronously perform them. This ensures\n // that constraint validation properties (like `required`) are synced\n // before interacting with input APIs that depend on them.\n this.scheduleUpdate();\n }\n\n return this.input!;\n }\n\n // Writable mixin properties for lit-html binding, needed for lit-analyzer\n declare disabled: boolean;\n declare name: string;\n\n override [getFormValue]() {\n if (!this.checked || this.indeterminate) {\n return null;\n }\n\n return this.value;\n }\n\n override [getFormState]() {\n return String(this.checked);\n }\n\n override formResetCallback() {\n // The checked property does not reflect, so the original attribute set by\n // the user is used to determine the default value.\n this.checked = this.hasAttribute('checked');\n }\n\n override formStateRestoreCallback(state: string) {\n this.checked = state === 'true';\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["checkbox.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,KAAK,CAAC;AACxE,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAGrD,OAAO,EAAC,yBAAyB,EAAC,MAAM,i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Ae,CAAC;QACf,OAAO,IAAI,iBAAiB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,CAAC,iBAAiB,CAAC;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;;AApKD;IACE,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC,GAAA,CAAA;AAED,kBAAkB;AACF,0BAAiB,GAAG;IAClC,GAAG,UAAU,CAAC,iBAAiB;IAC/B,cAAc,EAAE,IAAI;CACrB,AAHgC,CAG/B;AAKyB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;yCAAiB;AAOhB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;+CAAuB;AAQtB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;0CAAkB;AAOhC;IAAX,QAAQ,EAAE;uCAAc;AAER;IAAhB,KAAK,EAAE;6CAA6B;AACpB;IAAhB,KAAK,EAAE;8CAA8B;AACrB;IAAhB,KAAK,EAAE;mDAAmC;AACV;IAAhC,KAAK,CAAC,OAAO,CAAC;uCAAkD","sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../focus/md-focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, isServer, LitElement, nothing, PropertyValues} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {ARIAMixinStrict} from '../../internal/aria/aria.js';\nimport {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js';\nimport {\n dispatchActivationClick,\n isActivationClick,\n redispatchEvent,\n} from '../../internal/controller/events.js';\nimport {\n createValidator,\n getValidityAnchor,\n mixinConstraintValidation,\n} from '../../labs/behaviors/constraint-validation.js';\nimport {mixinElementInternals} from '../../labs/behaviors/element-internals.js';\nimport {\n getFormState,\n getFormValue,\n mixinFormAssociated,\n} from '../../labs/behaviors/form-associated.js';\nimport {CheckboxValidator} from '../../labs/behaviors/validators/checkbox-validator.js';\n\n// Separate variable needed for closure.\nconst checkboxBaseClass = mixinConstraintValidation(\n mixinFormAssociated(mixinElementInternals(LitElement)),\n);\n\n/**\n * A checkbox component.\n *\n *\n * @fires change {Event} The native `change` event on\n * [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event)\n * --bubbles\n * @fires input {InputEvent} The native `input` event on\n * [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event)\n * --bubbles --composed\n */\nexport class Checkbox extends checkboxBaseClass {\n static {\n requestUpdateOnAriaChange(Checkbox);\n }\n\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /**\n * Whether or not the checkbox is selected.\n */\n @property({type: Boolean}) checked = false;\n\n /**\n * Whether or not the checkbox is indeterminate.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes\n */\n @property({type: Boolean}) indeterminate = false;\n\n /**\n * When true, require the checkbox to be selected when participating in\n * form submission.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#validation\n */\n @property({type: Boolean}) required = false;\n\n /**\n * The value of the checkbox that is submitted with a form when selected.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value\n */\n @property() value = 'on';\n\n @state() private prevChecked = false;\n @state() private prevDisabled = false;\n @state() private prevIndeterminate = false;\n @query('input') private readonly input!: HTMLInputElement | null;\n\n constructor() {\n super();\n if (!isServer) {\n this.addEventListener('click', (event: MouseEvent) => {\n if (!isActivationClick(event) || !this.input) {\n return;\n }\n this.focus();\n dispatchActivationClick(this.input);\n });\n }\n }\n\n protected override update(changed: PropertyValues<Checkbox>) {\n if (\n changed.has('checked') ||\n changed.has('disabled') ||\n changed.has('indeterminate')\n ) {\n this.prevChecked = changed.get('checked') ?? this.checked;\n this.prevDisabled = changed.get('disabled') ?? this.disabled;\n this.prevIndeterminate =\n changed.get('indeterminate') ?? this.indeterminate;\n }\n\n super.update(changed);\n }\n\n protected override render() {\n const prevNone = !this.prevChecked && !this.prevIndeterminate;\n const prevChecked = this.prevChecked && !this.prevIndeterminate;\n const prevIndeterminate = this.prevIndeterminate;\n const isChecked = this.checked && !this.indeterminate;\n const isIndeterminate = this.indeterminate;\n\n const containerClasses = classMap({\n 'disabled': this.disabled,\n 'selected': isChecked || isIndeterminate,\n 'unselected': !isChecked && !isIndeterminate,\n 'checked': isChecked,\n 'indeterminate': isIndeterminate,\n 'prev-unselected': prevNone,\n 'prev-checked': prevChecked,\n 'prev-indeterminate': prevIndeterminate,\n 'prev-disabled': this.prevDisabled,\n });\n\n // Needed for closure conformance\n const {ariaLabel, ariaInvalid} = this as ARIAMixinStrict;\n // Note: <input> needs to be rendered before the <svg> for\n // form.reportValidity() to work in Chrome.\n return html`\n <div class=\"container ${containerClasses}\">\n <input\n type=\"checkbox\"\n id=\"input\"\n aria-checked=${isIndeterminate ? 'mixed' : nothing}\n aria-label=${ariaLabel || nothing}\n aria-invalid=${ariaInvalid || nothing}\n ?disabled=${this.disabled}\n ?required=${this.required}\n .indeterminate=${this.indeterminate}\n .checked=${this.checked}\n @input=${this.handleInput}\n @change=${this.handleChange} />\n\n <div class=\"outline\"></div>\n <div class=\"background\"></div>\n <md-focus-ring part=\"focus-ring\" for=\"input\"></md-focus-ring>\n <md-ripple for=\"input\" ?disabled=${this.disabled}></md-ripple>\n <svg class=\"icon\" viewBox=\"0 0 18 18\" aria-hidden=\"true\">\n <rect class=\"mark short\" />\n <rect class=\"mark long\" />\n </svg>\n </div>\n `;\n }\n\n private handleInput(event: Event) {\n const target = event.target as HTMLInputElement;\n this.checked = target.checked;\n this.indeterminate = target.indeterminate;\n // <input> 'input' event bubbles and is composed, don't re-dispatch it.\n }\n\n private handleChange(event: Event) {\n // <input> 'change' event is not composed, re-dispatch it.\n redispatchEvent(this, event);\n }\n\n // Writable mixin properties for lit-html binding, needed for lit-analyzer\n declare disabled: boolean;\n declare name: string;\n\n override [getFormValue]() {\n if (!this.checked || this.indeterminate) {\n return null;\n }\n\n return this.value;\n }\n\n override [getFormState]() {\n return String(this.checked);\n }\n\n override formResetCallback() {\n // The checked property does not reflect, so the original attribute set by\n // the user is used to determine the default value.\n this.checked = this.hasAttribute('checked');\n }\n\n override formStateRestoreCallback(state: string) {\n this.checked = state === 'true';\n }\n\n [createValidator]() {\n return new CheckboxValidator(() => this);\n }\n\n [getValidityAnchor]() {\n return this.input;\n }\n}\n"]}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
display: inline-flex;
|
|
22
22
|
height: var(--_container-height);
|
|
23
23
|
cursor: pointer;
|
|
24
|
+
-webkit-tap-highlight-color: transparent;
|
|
24
25
|
|
|
25
26
|
@include ripple.theme(
|
|
26
27
|
(
|
|
@@ -32,6 +33,10 @@
|
|
|
32
33
|
);
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
:host([disabled]) {
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
:host([touch-target='wrapper']) {
|
|
36
41
|
margin: max(0px, (48px - var(--_container-height)) / 2) 0;
|
|
37
42
|
}
|
|
@@ -84,7 +89,6 @@
|
|
|
84
89
|
border: none;
|
|
85
90
|
border-radius: inherit;
|
|
86
91
|
display: flex;
|
|
87
|
-
gap: 8px;
|
|
88
92
|
outline: none;
|
|
89
93
|
padding: 0;
|
|
90
94
|
position: relative;
|
|
@@ -92,8 +96,12 @@
|
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
.primary.action {
|
|
95
|
-
padding-inline-start:
|
|
96
|
-
padding-inline-end:
|
|
99
|
+
padding-inline-start: var(--_leading-space);
|
|
100
|
+
padding-inline-end: var(--_trailing-space);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.has-icon .primary.action {
|
|
104
|
+
padding-inline-start: var(--_with-leading-icon-leading-space);
|
|
97
105
|
}
|
|
98
106
|
|
|
99
107
|
.touch {
|
|
@@ -185,6 +193,11 @@
|
|
|
185
193
|
color: var(--_leading-icon-color);
|
|
186
194
|
}
|
|
187
195
|
|
|
196
|
+
.leading.icon ::slotted(*),
|
|
197
|
+
.leading.icon svg {
|
|
198
|
+
margin-inline-end: var(--_icon-label-space);
|
|
199
|
+
}
|
|
200
|
+
|
|
188
201
|
:where(:hover) .leading.icon {
|
|
189
202
|
color: var(--_hover-leading-icon-color);
|
|
190
203
|
}
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
.trailing.action {
|
|
12
12
|
align-items: center;
|
|
13
13
|
justify-content: center;
|
|
14
|
-
padding:
|
|
14
|
+
padding-inline-start: var(--_icon-label-space);
|
|
15
|
+
padding-inline-end: var(--_with-trailing-icon-trailing-space);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
.trailing.action :is(md-ripple, md-focus-ring) {
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { css } from 'lit';
|
|
7
|
-
export const styles = css `:host{--_container-height: var(--md-assist-chip-container-height, 32px);--_container-shape: var(--md-assist-chip-container-shape, 8px);--_disabled-label-text-color: var(--md-assist-chip-disabled-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-label-text-opacity: var(--md-assist-chip-disabled-label-text-opacity, 0.38);--_elevated-container-color: var(--md-assist-chip-elevated-container-color, var(--md-sys-color-surface-container-low, #f7f2fa));--_elevated-container-elevation: var(--md-assist-chip-elevated-container-elevation, 1);--_elevated-container-shadow-color: var(--md-assist-chip-elevated-container-shadow-color, var(--md-sys-color-shadow, #000));--_elevated-disabled-container-color: var(--md-assist-chip-elevated-disabled-container-color, var(--md-sys-color-on-surface, #1d1b20));--_elevated-disabled-container-elevation: var(--md-assist-chip-elevated-disabled-container-elevation, 0);--_elevated-disabled-container-opacity: var(--md-assist-chip-elevated-disabled-container-opacity, 0.12);--_elevated-focus-container-elevation: var(--md-assist-chip-elevated-focus-container-elevation, 1);--_elevated-hover-container-elevation: var(--md-assist-chip-elevated-hover-container-elevation, 2);--_elevated-pressed-container-elevation: var(--md-assist-chip-elevated-pressed-container-elevation, 1);--_focus-label-text-color: var(--md-assist-chip-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-label-text-color: var(--md-assist-chip-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-color: var(--md-assist-chip-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-opacity: var(--md-assist-chip-hover-state-layer-opacity, 0.08);--_label-text-color: var(--md-assist-chip-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_label-text-font: var(--md-assist-chip-label-text-font, var(--md-sys-typescale-label-large-font, var(--md-ref-typeface-plain, Roboto)));--_label-text-line-height: var(--md-assist-chip-label-text-line-height, var(--md-sys-typescale-label-large-line-height, 1.25rem));--_label-text-size: var(--md-assist-chip-label-text-size, var(--md-sys-typescale-label-large-size, 0.875rem));--_label-text-weight: var(--md-assist-chip-label-text-weight, var(--md-sys-typescale-label-large-weight, var(--md-ref-typeface-weight-medium, 500)));--_pressed-label-text-color: var(--md-assist-chip-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-color: var(--md-assist-chip-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-opacity: var(--md-assist-chip-pressed-state-layer-opacity, 0.12);--_disabled-outline-color: var(--md-assist-chip-disabled-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-outline-opacity: var(--md-assist-chip-disabled-outline-opacity, 0.12);--_focus-outline-color: var(--md-assist-chip-focus-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_outline-color: var(--md-assist-chip-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-assist-chip-outline-width, 1px);--_disabled-leading-icon-color: var(--md-assist-chip-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-leading-icon-opacity: var(--md-assist-chip-disabled-leading-icon-opacity, 0.38);--_focus-leading-icon-color: var(--md-assist-chip-focus-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_hover-leading-icon-color: var(--md-assist-chip-hover-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_leading-icon-color: var(--md-assist-chip-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_icon-size: var(--md-assist-chip-icon-size, 18px);--_pressed-leading-icon-color: var(--md-assist-chip-pressed-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_container-shape-start-start: var( --md-assist-chip-container-shape-start-start, var(--_container-shape) );--_container-shape-start-end: var( --md-assist-chip-container-shape-start-end, var(--_container-shape) );--_container-shape-end-end: var( --md-assist-chip-container-shape-end-end, var(--_container-shape) );--_container-shape-end-start: var( --md-assist-chip-container-shape-end-start, var(--_container-shape) )}@media(forced-colors: active){.link .outline{border-color:ActiveText}}/*# sourceMappingURL=assist-styles.css.map */
|
|
7
|
+
export const styles = css `:host{--_container-height: var(--md-assist-chip-container-height, 32px);--_container-shape: var(--md-assist-chip-container-shape, 8px);--_disabled-label-text-color: var(--md-assist-chip-disabled-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-label-text-opacity: var(--md-assist-chip-disabled-label-text-opacity, 0.38);--_elevated-container-color: var(--md-assist-chip-elevated-container-color, var(--md-sys-color-surface-container-low, #f7f2fa));--_elevated-container-elevation: var(--md-assist-chip-elevated-container-elevation, 1);--_elevated-container-shadow-color: var(--md-assist-chip-elevated-container-shadow-color, var(--md-sys-color-shadow, #000));--_elevated-disabled-container-color: var(--md-assist-chip-elevated-disabled-container-color, var(--md-sys-color-on-surface, #1d1b20));--_elevated-disabled-container-elevation: var(--md-assist-chip-elevated-disabled-container-elevation, 0);--_elevated-disabled-container-opacity: var(--md-assist-chip-elevated-disabled-container-opacity, 0.12);--_elevated-focus-container-elevation: var(--md-assist-chip-elevated-focus-container-elevation, 1);--_elevated-hover-container-elevation: var(--md-assist-chip-elevated-hover-container-elevation, 2);--_elevated-pressed-container-elevation: var(--md-assist-chip-elevated-pressed-container-elevation, 1);--_focus-label-text-color: var(--md-assist-chip-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-label-text-color: var(--md-assist-chip-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-color: var(--md-assist-chip-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-opacity: var(--md-assist-chip-hover-state-layer-opacity, 0.08);--_label-text-color: var(--md-assist-chip-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_label-text-font: var(--md-assist-chip-label-text-font, var(--md-sys-typescale-label-large-font, var(--md-ref-typeface-plain, Roboto)));--_label-text-line-height: var(--md-assist-chip-label-text-line-height, var(--md-sys-typescale-label-large-line-height, 1.25rem));--_label-text-size: var(--md-assist-chip-label-text-size, var(--md-sys-typescale-label-large-size, 0.875rem));--_label-text-weight: var(--md-assist-chip-label-text-weight, var(--md-sys-typescale-label-large-weight, var(--md-ref-typeface-weight-medium, 500)));--_pressed-label-text-color: var(--md-assist-chip-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-color: var(--md-assist-chip-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-opacity: var(--md-assist-chip-pressed-state-layer-opacity, 0.12);--_disabled-outline-color: var(--md-assist-chip-disabled-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-outline-opacity: var(--md-assist-chip-disabled-outline-opacity, 0.12);--_focus-outline-color: var(--md-assist-chip-focus-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_outline-color: var(--md-assist-chip-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-assist-chip-outline-width, 1px);--_disabled-leading-icon-color: var(--md-assist-chip-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-leading-icon-opacity: var(--md-assist-chip-disabled-leading-icon-opacity, 0.38);--_focus-leading-icon-color: var(--md-assist-chip-focus-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_hover-leading-icon-color: var(--md-assist-chip-hover-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_leading-icon-color: var(--md-assist-chip-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_icon-size: var(--md-assist-chip-icon-size, 18px);--_pressed-leading-icon-color: var(--md-assist-chip-pressed-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_leading-space: var(--md-assist-chip-leading-space, 16px);--_trailing-space: var(--md-assist-chip-trailing-space, 16px);--_icon-label-space: var(--md-assist-chip-icon-label-space, 8px);--_with-leading-icon-leading-space: var(--md-assist-chip-with-leading-icon-leading-space, 8px);--_container-shape-start-start: var( --md-assist-chip-container-shape-start-start, var(--_container-shape) );--_container-shape-start-end: var( --md-assist-chip-container-shape-start-end, var(--_container-shape) );--_container-shape-end-end: var( --md-assist-chip-container-shape-end-end, var(--_container-shape) );--_container-shape-end-start: var( --md-assist-chip-container-shape-end-start, var(--_container-shape) )}@media(forced-colors: active){.link .outline{border-color:ActiveText}}/*# sourceMappingURL=assist-styles.css.map */
|
|
8
8
|
`;
|
|
9
9
|
//# sourceMappingURL=assist-styles.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assist-styles.css.js","sourceRoot":"","sources":["assist-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{--_container-height: var(--md-assist-chip-container-height, 32px);--_container-shape: var(--md-assist-chip-container-shape, 8px);--_disabled-label-text-color: var(--md-assist-chip-disabled-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-label-text-opacity: var(--md-assist-chip-disabled-label-text-opacity, 0.38);--_elevated-container-color: var(--md-assist-chip-elevated-container-color, var(--md-sys-color-surface-container-low, #f7f2fa));--_elevated-container-elevation: var(--md-assist-chip-elevated-container-elevation, 1);--_elevated-container-shadow-color: var(--md-assist-chip-elevated-container-shadow-color, var(--md-sys-color-shadow, #000));--_elevated-disabled-container-color: var(--md-assist-chip-elevated-disabled-container-color, var(--md-sys-color-on-surface, #1d1b20));--_elevated-disabled-container-elevation: var(--md-assist-chip-elevated-disabled-container-elevation, 0);--_elevated-disabled-container-opacity: var(--md-assist-chip-elevated-disabled-container-opacity, 0.12);--_elevated-focus-container-elevation: var(--md-assist-chip-elevated-focus-container-elevation, 1);--_elevated-hover-container-elevation: var(--md-assist-chip-elevated-hover-container-elevation, 2);--_elevated-pressed-container-elevation: var(--md-assist-chip-elevated-pressed-container-elevation, 1);--_focus-label-text-color: var(--md-assist-chip-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-label-text-color: var(--md-assist-chip-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-color: var(--md-assist-chip-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-opacity: var(--md-assist-chip-hover-state-layer-opacity, 0.08);--_label-text-color: var(--md-assist-chip-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_label-text-font: var(--md-assist-chip-label-text-font, var(--md-sys-typescale-label-large-font, var(--md-ref-typeface-plain, Roboto)));--_label-text-line-height: var(--md-assist-chip-label-text-line-height, var(--md-sys-typescale-label-large-line-height, 1.25rem));--_label-text-size: var(--md-assist-chip-label-text-size, var(--md-sys-typescale-label-large-size, 0.875rem));--_label-text-weight: var(--md-assist-chip-label-text-weight, var(--md-sys-typescale-label-large-weight, var(--md-ref-typeface-weight-medium, 500)));--_pressed-label-text-color: var(--md-assist-chip-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-color: var(--md-assist-chip-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-opacity: var(--md-assist-chip-pressed-state-layer-opacity, 0.12);--_disabled-outline-color: var(--md-assist-chip-disabled-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-outline-opacity: var(--md-assist-chip-disabled-outline-opacity, 0.12);--_focus-outline-color: var(--md-assist-chip-focus-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_outline-color: var(--md-assist-chip-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-assist-chip-outline-width, 1px);--_disabled-leading-icon-color: var(--md-assist-chip-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-leading-icon-opacity: var(--md-assist-chip-disabled-leading-icon-opacity, 0.38);--_focus-leading-icon-color: var(--md-assist-chip-focus-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_hover-leading-icon-color: var(--md-assist-chip-hover-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_leading-icon-color: var(--md-assist-chip-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_icon-size: var(--md-assist-chip-icon-size, 18px);--_pressed-leading-icon-color: var(--md-assist-chip-pressed-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_container-shape-start-start: var( --md-assist-chip-container-shape-start-start, var(--_container-shape) );--_container-shape-start-end: var( --md-assist-chip-container-shape-start-end, var(--_container-shape) );--_container-shape-end-end: var( --md-assist-chip-container-shape-end-end, var(--_container-shape) );--_container-shape-end-start: var( --md-assist-chip-container-shape-end-start, var(--_container-shape) )}@media(forced-colors: active){.link .outline{border-color:ActiveText}}/*# sourceMappingURL=assist-styles.css.map */\n`;\n "]}
|
|
1
|
+
{"version":3,"file":"assist-styles.css.js","sourceRoot":"","sources":["assist-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{--_container-height: var(--md-assist-chip-container-height, 32px);--_container-shape: var(--md-assist-chip-container-shape, 8px);--_disabled-label-text-color: var(--md-assist-chip-disabled-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-label-text-opacity: var(--md-assist-chip-disabled-label-text-opacity, 0.38);--_elevated-container-color: var(--md-assist-chip-elevated-container-color, var(--md-sys-color-surface-container-low, #f7f2fa));--_elevated-container-elevation: var(--md-assist-chip-elevated-container-elevation, 1);--_elevated-container-shadow-color: var(--md-assist-chip-elevated-container-shadow-color, var(--md-sys-color-shadow, #000));--_elevated-disabled-container-color: var(--md-assist-chip-elevated-disabled-container-color, var(--md-sys-color-on-surface, #1d1b20));--_elevated-disabled-container-elevation: var(--md-assist-chip-elevated-disabled-container-elevation, 0);--_elevated-disabled-container-opacity: var(--md-assist-chip-elevated-disabled-container-opacity, 0.12);--_elevated-focus-container-elevation: var(--md-assist-chip-elevated-focus-container-elevation, 1);--_elevated-hover-container-elevation: var(--md-assist-chip-elevated-hover-container-elevation, 2);--_elevated-pressed-container-elevation: var(--md-assist-chip-elevated-pressed-container-elevation, 1);--_focus-label-text-color: var(--md-assist-chip-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-label-text-color: var(--md-assist-chip-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-color: var(--md-assist-chip-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-opacity: var(--md-assist-chip-hover-state-layer-opacity, 0.08);--_label-text-color: var(--md-assist-chip-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_label-text-font: var(--md-assist-chip-label-text-font, var(--md-sys-typescale-label-large-font, var(--md-ref-typeface-plain, Roboto)));--_label-text-line-height: var(--md-assist-chip-label-text-line-height, var(--md-sys-typescale-label-large-line-height, 1.25rem));--_label-text-size: var(--md-assist-chip-label-text-size, var(--md-sys-typescale-label-large-size, 0.875rem));--_label-text-weight: var(--md-assist-chip-label-text-weight, var(--md-sys-typescale-label-large-weight, var(--md-ref-typeface-weight-medium, 500)));--_pressed-label-text-color: var(--md-assist-chip-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-color: var(--md-assist-chip-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-opacity: var(--md-assist-chip-pressed-state-layer-opacity, 0.12);--_disabled-outline-color: var(--md-assist-chip-disabled-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-outline-opacity: var(--md-assist-chip-disabled-outline-opacity, 0.12);--_focus-outline-color: var(--md-assist-chip-focus-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_outline-color: var(--md-assist-chip-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-assist-chip-outline-width, 1px);--_disabled-leading-icon-color: var(--md-assist-chip-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-leading-icon-opacity: var(--md-assist-chip-disabled-leading-icon-opacity, 0.38);--_focus-leading-icon-color: var(--md-assist-chip-focus-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_hover-leading-icon-color: var(--md-assist-chip-hover-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_leading-icon-color: var(--md-assist-chip-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_icon-size: var(--md-assist-chip-icon-size, 18px);--_pressed-leading-icon-color: var(--md-assist-chip-pressed-leading-icon-color, var(--md-sys-color-primary, #6750a4));--_leading-space: var(--md-assist-chip-leading-space, 16px);--_trailing-space: var(--md-assist-chip-trailing-space, 16px);--_icon-label-space: var(--md-assist-chip-icon-label-space, 8px);--_with-leading-icon-leading-space: var(--md-assist-chip-with-leading-icon-leading-space, 8px);--_container-shape-start-start: var( --md-assist-chip-container-shape-start-start, var(--_container-shape) );--_container-shape-start-end: var( --md-assist-chip-container-shape-start-end, var(--_container-shape) );--_container-shape-end-end: var( --md-assist-chip-container-shape-end-end, var(--_container-shape) );--_container-shape-end-start: var( --md-assist-chip-container-shape-end-start, var(--_container-shape) )}@media(forced-colors: active){.link .outline{border-color:ActiveText}}/*# sourceMappingURL=assist-styles.css.map */\n`;\n "]}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { __decorate } from "tslib";
|
|
7
7
|
import { html, isServer, LitElement } from 'lit';
|
|
8
8
|
import { queryAssignedElements } from 'lit/decorators.js';
|
|
9
|
-
import { polyfillARIAMixin, polyfillElementInternalsAria, } from '../../internal/aria/aria.js';
|
|
10
9
|
import { Chip } from './chip.js';
|
|
11
10
|
/**
|
|
12
11
|
* A chip set component.
|
|
@@ -17,9 +16,9 @@ export class ChipSet extends LitElement {
|
|
|
17
16
|
}
|
|
18
17
|
constructor() {
|
|
19
18
|
super();
|
|
20
|
-
this.internals =
|
|
19
|
+
this.internals =
|
|
21
20
|
// Cast needed for closure
|
|
22
|
-
this.attachInternals()
|
|
21
|
+
this.attachInternals();
|
|
23
22
|
if (!isServer) {
|
|
24
23
|
this.addEventListener('focusin', this.updateTabIndices.bind(this));
|
|
25
24
|
this.addEventListener('update-focus', this.updateTabIndices.bind(this));
|
|
@@ -123,9 +122,6 @@ export class ChipSet extends LitElement {
|
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
|
-
(() => {
|
|
127
|
-
polyfillARIAMixin(ChipSet);
|
|
128
|
-
})();
|
|
129
125
|
__decorate([
|
|
130
126
|
queryAssignedElements()
|
|
131
127
|
], ChipSet.prototype, "childElements", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip-set.js","sourceRoot":"","sources":["chip-set.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,KAAK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I,KAAK,EAAE;YACxB,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC/D,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;YACpD,IAAI,aAAa,IAAI,eAAe,EAAE;gBACpC,oEAAoE;gBACpE,8BAA8B;gBAC9B,WAAW,GAAG,IAAI,CAAC;gBACnB,SAAS;aACV;YAED,IAAI,eAAe,IAAI,CAAC,WAAW,EAAE;gBACnC,WAAW,GAAG,IAAI,CAAC;aACpB;YAED,0EAA0E;YAC1E,+CAA+C;YAC/C,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;SACpB;QAED,IAAI,WAAW,EAAE;YACf,WAAW,CAAC,QAAQ,GAAG,CAAC,CAAC;SAC1B;IACH,CAAC;CACF;AAzH2C;IAAzC,qBAAqB,EAAE;8CAAgD","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, isServer, LitElement} from 'lit';\nimport {queryAssignedElements} from 'lit/decorators.js';\n\nimport {Chip} from './chip.js';\n\n/**\n * A chip set component.\n */\nexport class ChipSet extends LitElement {\n get chips() {\n return this.childElements.filter(\n (child): child is Chip => child instanceof Chip,\n );\n }\n\n @queryAssignedElements() private readonly childElements!: HTMLElement[];\n private readonly internals =\n // Cast needed for closure\n (this as HTMLElement).attachInternals();\n\n constructor() {\n super();\n if (!isServer) {\n this.addEventListener('focusin', this.updateTabIndices.bind(this));\n this.addEventListener('update-focus', this.updateTabIndices.bind(this));\n this.addEventListener('keydown', this.handleKeyDown.bind(this));\n this.internals.role = 'toolbar';\n }\n }\n\n protected override render() {\n return html`<slot @slotchange=${this.updateTabIndices}></slot>`;\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n const isLeft = event.key === 'ArrowLeft';\n const isRight = event.key === 'ArrowRight';\n const isHome = event.key === 'Home';\n const isEnd = event.key === 'End';\n // Ignore non-navigation keys\n if (!isLeft && !isRight && !isHome && !isEnd) {\n return;\n }\n\n const {chips} = this as {chips: MaybeMultiActionChip[]};\n // Don't try to select another chip if there aren't any.\n if (chips.length < 2) {\n return;\n }\n\n // Prevent default interactions, such as scrolling.\n event.preventDefault();\n\n if (isHome || isEnd) {\n const index = isHome ? 0 : chips.length - 1;\n chips[index].focus({trailing: isEnd});\n this.updateTabIndices();\n return;\n }\n\n // Check if moving forwards or backwards\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const forwards = isRtl ? isLeft : isRight;\n const focusedChip = chips.find((chip) => chip.matches(':focus-within'));\n if (!focusedChip) {\n // If there is not already a chip focused, select the first or last chip\n // based on the direction we're traveling.\n const nextChip = forwards ? chips[0] : chips[chips.length - 1];\n nextChip.focus({trailing: !forwards});\n this.updateTabIndices();\n return;\n }\n\n const currentIndex = chips.indexOf(focusedChip);\n let nextIndex = forwards ? currentIndex + 1 : currentIndex - 1;\n // Search for the next sibling that is not disabled to select.\n // If we return to the host index, there is nothing to select.\n while (nextIndex !== currentIndex) {\n if (nextIndex >= chips.length) {\n // Return to start if moving past the last item.\n nextIndex = 0;\n } else if (nextIndex < 0) {\n // Go to end if moving before the first item.\n nextIndex = chips.length - 1;\n }\n\n // Check if the next sibling is disabled. If so,\n // move the index and continue searching.\n //\n // Some toolbar items may be focusable when disabled for increased\n // visibility.\n const nextChip = chips[nextIndex];\n if (nextChip.disabled && !nextChip.alwaysFocusable) {\n if (forwards) {\n nextIndex++;\n } else {\n nextIndex--;\n }\n\n continue;\n }\n\n nextChip.focus({trailing: !forwards});\n this.updateTabIndices();\n break;\n }\n }\n\n private updateTabIndices() {\n // The chip that should be focusable is either the chip that currently has\n // focus or the first chip that can be focused.\n const {chips} = this;\n let chipToFocus: Chip | undefined;\n for (const chip of chips) {\n const isChipFocusable = chip.alwaysFocusable || !chip.disabled;\n const chipIsFocused = chip.matches(':focus-within');\n if (chipIsFocused && isChipFocusable) {\n // Found the first chip that is actively focused. This overrides the\n // first focusable chip found.\n chipToFocus = chip;\n continue;\n }\n\n if (isChipFocusable && !chipToFocus) {\n chipToFocus = chip;\n }\n\n // Disable non-focused chips. If we disable all of them, we'll grant focus\n // to the first focusable child that was found.\n chip.tabIndex = -1;\n }\n\n if (chipToFocus) {\n chipToFocus.tabIndex = 0;\n }\n }\n}\n\ninterface MaybeMultiActionChip extends Chip {\n focus(options?: FocusOptions & {trailing?: boolean}): void;\n}\n"]}
|
package/chips/internal/chip.d.ts
CHANGED
|
@@ -37,6 +37,13 @@ export declare abstract class Chip extends LitElement {
|
|
|
37
37
|
* The label of the chip.
|
|
38
38
|
*/
|
|
39
39
|
label: string;
|
|
40
|
+
/**
|
|
41
|
+
* Only needed for SSR.
|
|
42
|
+
*
|
|
43
|
+
* Add this attribute when a chip has a `slot="icon"` to avoid a Flash Of
|
|
44
|
+
* Unstyled Content.
|
|
45
|
+
*/
|
|
46
|
+
hasIcon: boolean;
|
|
40
47
|
/**
|
|
41
48
|
* The `id` of the action the primary focus ring and ripple are for.
|
|
42
49
|
* TODO(b/310046938): use the same id for both elements
|
|
@@ -56,4 +63,5 @@ export declare abstract class Chip extends LitElement {
|
|
|
56
63
|
protected renderLeadingIcon(): TemplateResult;
|
|
57
64
|
protected abstract renderPrimaryAction(content: unknown): unknown;
|
|
58
65
|
private renderPrimaryContent;
|
|
66
|
+
private handleIconChange;
|
|
59
67
|
}
|
package/chips/internal/chip.js
CHANGED
|
@@ -36,6 +36,13 @@ export class Chip extends LitElement {
|
|
|
36
36
|
* The label of the chip.
|
|
37
37
|
*/
|
|
38
38
|
this.label = '';
|
|
39
|
+
/**
|
|
40
|
+
* Only needed for SSR.
|
|
41
|
+
*
|
|
42
|
+
* Add this attribute when a chip has a `slot="icon"` to avoid a Flash Of
|
|
43
|
+
* Unstyled Content.
|
|
44
|
+
*/
|
|
45
|
+
this.hasIcon = false;
|
|
39
46
|
}
|
|
40
47
|
/**
|
|
41
48
|
* Whether or not the primary ripple is disabled (defaults to `disabled`).
|
|
@@ -65,6 +72,7 @@ export class Chip extends LitElement {
|
|
|
65
72
|
getContainerClasses() {
|
|
66
73
|
return {
|
|
67
74
|
'disabled': this.disabled,
|
|
75
|
+
'has-icon': this.hasIcon,
|
|
68
76
|
};
|
|
69
77
|
}
|
|
70
78
|
renderContainerContent() {
|
|
@@ -81,7 +89,7 @@ export class Chip extends LitElement {
|
|
|
81
89
|
return html `<span class="outline"></span>`;
|
|
82
90
|
}
|
|
83
91
|
renderLeadingIcon() {
|
|
84
|
-
return html `<slot name="icon"></slot>`;
|
|
92
|
+
return html `<slot name="icon" @slotchange=${this.handleIconChange}></slot>`;
|
|
85
93
|
}
|
|
86
94
|
renderPrimaryContent() {
|
|
87
95
|
return html `
|
|
@@ -92,6 +100,10 @@ export class Chip extends LitElement {
|
|
|
92
100
|
<span class="touch"></span>
|
|
93
101
|
`;
|
|
94
102
|
}
|
|
103
|
+
handleIconChange(event) {
|
|
104
|
+
const slot = event.target;
|
|
105
|
+
this.hasIcon = slot.assignedElements({ flatten: true }).length > 0;
|
|
106
|
+
}
|
|
95
107
|
}
|
|
96
108
|
(() => {
|
|
97
109
|
requestUpdateOnAriaChange(Chip);
|
|
@@ -102,7 +114,7 @@ Chip.shadowRootOptions = {
|
|
|
102
114
|
delegatesFocus: true,
|
|
103
115
|
};
|
|
104
116
|
__decorate([
|
|
105
|
-
property({ type: Boolean })
|
|
117
|
+
property({ type: Boolean, reflect: true })
|
|
106
118
|
], Chip.prototype, "disabled", void 0);
|
|
107
119
|
__decorate([
|
|
108
120
|
property({ type: Boolean, attribute: 'always-focusable' })
|
|
@@ -110,4 +122,7 @@ __decorate([
|
|
|
110
122
|
__decorate([
|
|
111
123
|
property()
|
|
112
124
|
], Chip.prototype, "label", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
property({ type: Boolean, reflect: true, attribute: 'has-icon' })
|
|
127
|
+
], Chip.prototype, "hasIcon", void 0);
|
|
113
128
|
//# sourceMappingURL=chip.js.map
|