@material/web 0.1.0-alpha.1 → 0.1.0-alpha.2

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.
Files changed (34) hide show
  1. package/button/lib/_shared.scss +2 -2
  2. package/checkbox/lib/_checkbox.scss +1 -1
  3. package/checkbox/lib/checkbox-styles.css.js +1 -1
  4. package/checkbox/lib/checkbox-styles.css.js.map +1 -1
  5. package/chips/chip/lib/_chip-theme.scss +10 -10
  6. package/chips/chip/lib/_chip.scss +2 -2
  7. package/fab/lib/_shared.scss +2 -2
  8. package/iconbutton/lib/_filled-icon-button.scss +4 -4
  9. package/iconbutton/lib/_filled-tonal-icon-button.scss +4 -4
  10. package/iconbutton/lib/_outlined-icon-button.scss +3 -3
  11. package/iconbutton/lib/_standard-icon-button.scss +3 -3
  12. package/navigationtab/lib/_navigation-tab.scss +3 -3
  13. package/package.json +1 -1
  14. package/radio/lib/_radio-theme.scss +3 -3
  15. package/radio/lib/radio.d.ts +32 -33
  16. package/radio/lib/radio.js +83 -112
  17. package/radio/lib/radio.js.map +1 -1
  18. package/ripple/lib/_ripple.scss +21 -4
  19. package/ripple/lib/ripple-styles.css.js +1 -1
  20. package/ripple/lib/ripple-styles.css.js.map +1 -1
  21. package/ripple/lib/ripple.js +4 -1
  22. package/ripple/lib/ripple.js.map +1 -1
  23. package/segmentedbutton/lib/_shared.scss +3 -3
  24. package/switch/lib/_handle.scss +4 -3
  25. package/switch/lib/switch-styles.css.js +1 -1
  26. package/switch/lib/switch-styles.css.js.map +1 -1
  27. package/switch/lib/switch.d.ts +17 -21
  28. package/switch/lib/switch.js +54 -57
  29. package/switch/lib/switch.js.map +1 -1
  30. package/textfield/filled-text-field.d.ts +1 -0
  31. package/textfield/filled-text-field.js.map +1 -1
  32. package/textfield/outlined-text-field.d.ts +1 -0
  33. package/textfield/outlined-text-field.js.map +1 -1
  34. package/ripple/_ripple-theme.scss +0 -17
@@ -8,27 +8,32 @@ import { __decorate, __metadata } from "tslib";
8
8
  // tslint:disable:strip-private-property-underscore
9
9
  import '../../focus/focus-ring.js';
10
10
  import '../../ripple/ripple.js';
11
- import { html } from 'lit';
12
- import { property, query, state } from 'lit/decorators.js';
11
+ import { html, LitElement, nothing } from 'lit';
12
+ import { property, query, queryAsync, state } from 'lit/decorators.js';
13
13
  import { classMap } from 'lit/directives/class-map.js';
14
- import { ifDefined } from 'lit/directives/if-defined.js';
15
- import { ActionElement } from '../../actionelement/action-element.js';
14
+ import { when } from 'lit/directives/when.js';
15
+ import { dispatchActivationClick, isActivationClick } from '../../controller/events.js';
16
+ import { FormController, getFormValue } from '../../controller/form-controller.js';
16
17
  import { ariaProperty } from '../../decorators/aria-property.js';
17
18
  import { pointerPress, shouldShowStrongFocus } from '../../focus/strong-focus.js';
18
- import { MdRipple } from '../../ripple/ripple.js';
19
+ import { ripple } from '../../ripple/directive.js';
19
20
  import { SingleSelectionController } from './single-selection-controller.js';
20
21
  /**
21
22
  * @fires checked
22
23
  * @soyCompatible
23
24
  */
24
- export class Radio extends ActionElement {
25
+ export class Radio extends LitElement {
25
26
  constructor() {
26
- super(...arguments);
27
- this._checked = false;
28
- this.showFocusRing = false;
29
- this.global = false;
27
+ super();
28
+ this._checked = false; // tslint:disable-line:enforce-name-casing
30
29
  this.disabled = false;
30
+ /**
31
+ * The element value to use in form submission when checked.
32
+ */
31
33
  this.value = 'on';
34
+ /**
35
+ * The HTML name to use in form submission.
36
+ */
32
37
  this.name = '';
33
38
  /**
34
39
  * Touch target extends beyond visual boundary of a component by default.
@@ -42,12 +47,25 @@ export class Radio extends ActionElement {
42
47
  */
43
48
  this.formElementTabIndex = 0;
44
49
  this.focused = false;
45
- this.rippleElement = null;
50
+ this.showFocusRing = false;
51
+ this.showRipple = false;
52
+ this.getRipple = () => {
53
+ this.showRipple = true;
54
+ return this.ripple;
55
+ };
56
+ this.renderRipple = () => {
57
+ return html `<md-ripple unbounded ?disabled=${this.disabled}></md-ripple>`;
58
+ };
59
+ this.addController(new FormController(this));
60
+ this.addEventListener('click', (event) => {
61
+ if (!isActivationClick(event)) {
62
+ return;
63
+ }
64
+ this.focus();
65
+ dispatchActivationClick(this.input);
66
+ });
46
67
  }
47
68
  get checked() {
48
- return this.getChecked();
49
- }
50
- getChecked() {
51
69
  return this._checked;
52
70
  }
53
71
  /**
@@ -70,9 +88,6 @@ export class Radio extends ActionElement {
70
88
  * and we couldn't tell that radio1 was the most recently checked.
71
89
  */
72
90
  set checked(isChecked) {
73
- this.setChecked(isChecked);
74
- }
75
- setChecked(isChecked) {
76
91
  const oldValue = this._checked;
77
92
  if (isChecked === oldValue) {
78
93
  return;
@@ -84,17 +99,17 @@ export class Radio extends ActionElement {
84
99
  // TODO(b/168543810): Remove triggering event on programmatic API call.
85
100
  this.dispatchEvent(new Event('checked', { bubbles: true, composed: true }));
86
101
  }
87
- /** @soyTemplate */
88
- renderRipple() {
89
- return html `<md-ripple unbounded
90
- ?disabled="${this.disabled}"></md-ripple>`;
102
+ /**
103
+ * The associated form element with which this element's value will submit.
104
+ */
105
+ get form() {
106
+ return this.closest('form');
91
107
  }
92
- /** @soyTemplate */
93
- renderFocusRing() {
94
- return html `<md-focus-ring .visible="${this.showFocusRing}"></md-focus-ring>`;
108
+ [getFormValue]() {
109
+ return this.checked ? this.value : null;
95
110
  }
96
- get isRippleActive() {
97
- return false;
111
+ focus() {
112
+ this.input?.focus();
98
113
  }
99
114
  connectedCallback() {
100
115
  super.connectedCallback();
@@ -126,46 +141,15 @@ export class Radio extends ActionElement {
126
141
  this.selectionController = undefined;
127
142
  }
128
143
  updated(changedProperties) {
129
- if (changedProperties.has('checked') && this.formElement) {
130
- this.formElement.checked = this.checked;
144
+ if (changedProperties.has('checked') && this.input) {
145
+ this.input.checked = this.checked;
131
146
  if (!this.checked) {
132
147
  // Remove focus ring when unchecked on other radio programmatically.
133
148
  // Blur on input since this determines the focus style.
134
- this.formElement?.blur();
149
+ this.input.blur();
135
150
  }
136
151
  }
137
152
  }
138
- createAdapter() { }
139
- beginPress({ positionEvent }) {
140
- this.ripple.beginPress(positionEvent);
141
- }
142
- endPress({ cancelled }) {
143
- this.ripple.endPress();
144
- if (cancelled) {
145
- return;
146
- }
147
- super.endPress({
148
- cancelled,
149
- actionData: { checked: this.formElement.checked, value: this.formElement.value }
150
- });
151
- }
152
- click() {
153
- this.formElement.focus();
154
- this.formElement.click();
155
- }
156
- handleFocus() {
157
- this.focused = true;
158
- this.showFocusRing = shouldShowStrongFocus();
159
- }
160
- handleBlur() {
161
- this.focused = false;
162
- this.showFocusRing = false;
163
- }
164
- setFormData(formData) {
165
- if (this.name && this.checked) {
166
- formData.append(this.name, this.value);
167
- }
168
- }
169
153
  /**
170
154
  * @soyTemplate
171
155
  * @soyAttributes radioAttributes: input
@@ -186,44 +170,34 @@ export class Radio extends ActionElement {
186
170
  class="md3-radio__native-control"
187
171
  type="radio"
188
172
  name="${this.name}"
189
- aria-label="${ifDefined(this.ariaLabel)}"
190
- aria-labelledby="${ifDefined(this.ariaLabelledBy)}"
191
- aria-describedby="${ifDefined(this.ariaDescribedBy)}"
192
- ?checked="${this.checked}"
173
+ aria-label="${this.ariaLabel || nothing}"
174
+ .checked="${this.checked}"
193
175
  .value="${this.value}"
194
176
  ?disabled="${this.disabled}"
195
- @change="${this.changeHandler}"
177
+ @change="${this.handleChange}"
196
178
  @focus="${this.handleFocus}"
197
- @click="${this.handleClick}"
198
179
  @blur="${this.handleBlur}"
199
- @pointerenter=${this.handlePointerEnter}
200
180
  @pointerdown=${this.handlePointerDown}
201
- @pointerup=${this.handlePointerUp}
202
- @pointercancel=${this.handlePointerCancel}
203
- @pointerleave=${this.handlePointerLeave}
181
+ ${ripple(this.getRipple)}
204
182
  >
205
183
  <div class="md3-radio__background">
206
184
  <div class="md3-radio__outer-circle"></div>
207
185
  <div class="md3-radio__inner-circle"></div>
208
186
  </div>
209
187
  <div class="md3-radio__ripple">
210
- ${this.renderRipple()}
188
+ ${when(this.showRipple, this.renderRipple)}
211
189
  </div>
212
190
  </div>`;
213
191
  }
214
- handlePointerEnter() {
215
- this.ripple.beginHover();
192
+ handleBlur() {
193
+ this.focused = false;
194
+ this.showFocusRing = false;
216
195
  }
217
- handlePointerDown(event) {
218
- super.handlePointerDown(event);
219
- pointerPress();
196
+ handleFocus() {
197
+ this.focused = true;
220
198
  this.showFocusRing = shouldShowStrongFocus();
221
199
  }
222
- handlePointerLeave(e) {
223
- super.handlePointerLeave(e);
224
- this.ripple.endHover();
225
- }
226
- changeHandler() {
200
+ handleChange() {
227
201
  if (this.disabled) {
228
202
  return;
229
203
  }
@@ -234,23 +208,16 @@ export class Radio extends ActionElement {
234
208
  composed: true,
235
209
  }));
236
210
  }
211
+ handlePointerDown(event) {
212
+ pointerPress();
213
+ this.showFocusRing = shouldShowStrongFocus();
214
+ }
215
+ renderFocusRing() {
216
+ return html `<md-focus-ring .visible=${this.showFocusRing}></md-focus-ring>`;
217
+ }
237
218
  }
238
- __decorate([
239
- query('input'),
240
- __metadata("design:type", HTMLInputElement)
241
- ], Radio.prototype, "formElement", void 0);
242
- __decorate([
243
- query('md-ripple'),
244
- __metadata("design:type", MdRipple)
245
- ], Radio.prototype, "ripple", void 0);
246
- __decorate([
247
- state(),
248
- __metadata("design:type", Object)
249
- ], Radio.prototype, "showFocusRing", void 0);
250
- __decorate([
251
- property({ type: Boolean }),
252
- __metadata("design:type", Object)
253
- ], Radio.prototype, "global", void 0);
219
+ Radio.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
220
+ Radio.formAssociated = true;
254
221
  __decorate([
255
222
  property({ type: Boolean, reflect: true }),
256
223
  __metadata("design:type", Boolean),
@@ -265,7 +232,7 @@ __decorate([
265
232
  __metadata("design:type", Object)
266
233
  ], Radio.prototype, "value", void 0);
267
234
  __decorate([
268
- property({ type: String }),
235
+ property({ type: String, reflect: true }),
269
236
  __metadata("design:type", Object)
270
237
  ], Radio.prototype, "name", void 0);
271
238
  __decorate([
@@ -276,10 +243,6 @@ __decorate([
276
243
  property({ type: Number }),
277
244
  __metadata("design:type", Object)
278
245
  ], Radio.prototype, "formElementTabIndex", void 0);
279
- __decorate([
280
- state(),
281
- __metadata("design:type", Object)
282
- ], Radio.prototype, "focused", void 0);
283
246
  __decorate([
284
247
  ariaProperty // tslint:disable-line:no-new-decorators
285
248
  ,
@@ -287,15 +250,23 @@ __decorate([
287
250
  __metadata("design:type", String)
288
251
  ], Radio.prototype, "ariaLabel", void 0);
289
252
  __decorate([
290
- ariaProperty // tslint:disable-line:no-new-decorators
291
- ,
292
- property({ attribute: 'data-aria-labelledby', noAccessor: true }),
293
- __metadata("design:type", String)
294
- ], Radio.prototype, "ariaLabelledBy", void 0);
253
+ state(),
254
+ __metadata("design:type", Object)
255
+ ], Radio.prototype, "focused", void 0);
295
256
  __decorate([
296
- ariaProperty // tslint:disable-line:no-new-decorators
297
- ,
298
- property({ type: String, attribute: 'data-aria-describedby', noAccessor: true }),
299
- __metadata("design:type", String)
300
- ], Radio.prototype, "ariaDescribedBy", void 0);
257
+ query('input'),
258
+ __metadata("design:type", HTMLInputElement)
259
+ ], Radio.prototype, "input", void 0);
260
+ __decorate([
261
+ queryAsync('md-ripple'),
262
+ __metadata("design:type", Promise)
263
+ ], Radio.prototype, "ripple", void 0);
264
+ __decorate([
265
+ state(),
266
+ __metadata("design:type", Object)
267
+ ], Radio.prototype, "showFocusRing", void 0);
268
+ __decorate([
269
+ state(),
270
+ __metadata("design:type", Object)
271
+ ], Radio.prototype, "showRipple", void 0);
301
272
  //# sourceMappingURL=radio.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"radio.js","sourceRoot":"","sources":["radio.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,4CAA4C;AAC5C,mDAAmD;AAEnD,OAAO,2BAA2B,CAAC;AACnC,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAC,IAAI,EAAiC,MAAM,KAAK,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,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YAAY,CAAE,wCAAwC;;IACtD,QAAQ,CAAC,EAAC,SAAS,EAAE,sBAAsB,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;;6CACxC;AAKxB;IAHC,YAAY,CAAE,wCAAwC;;IACtD,QAAQ,CACL,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;;8CACtC","sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// Style preference for leading underscores.\n// tslint:disable:strip-private-property-underscore\n\nimport '../../focus/focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, PropertyValues, TemplateResult} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport {ifDefined} from 'lit/directives/if-defined.js';\n\nimport {ActionElement, BeginPressConfig, EndPressConfig} from '../../actionelement/action-element.js';\nimport {ariaProperty} from '../../decorators/aria-property.js';\nimport {pointerPress, shouldShowStrongFocus} from '../../focus/strong-focus.js';\nimport {MdRipple} from '../../ripple/ripple.js';\n\nimport {SingleSelectionController} from './single-selection-controller.js';\n\n/**\n * @fires checked\n * @soyCompatible\n */\nexport class Radio extends ActionElement {\n @query('input') protected formElement!: HTMLInputElement;\n\n @query('md-ripple') ripple!: MdRipple;\n\n protected _checked = false;\n\n @state() protected showFocusRing = false;\n\n @property({type: Boolean}) global = false;\n\n @property({type: Boolean, reflect: true})\n get checked(): boolean {\n return this.getChecked();\n }\n\n protected getChecked(): boolean {\n return this._checked;\n }\n\n /**\n * We define our own getter/setter for `checked` because we need to track\n * changes to it synchronously.\n *\n * The order in which the `checked` property is set across radio buttons\n * within the same group is very important. However, we can't rely on\n * UpdatingElement's `updated` callback to observe these changes (which is\n * also what the `@observer` decorator uses), because it batches changes to\n * all properties.\n *\n * Consider:\n *\n * radio1.disabled = true;\n * radio2.checked = true;\n * radio1.checked = true;\n *\n * In this case we'd first see all changes for radio1, and then for radio2,\n * and we couldn't tell that radio1 was the most recently checked.\n */\n set checked(isChecked: boolean) {\n this.setChecked(isChecked);\n }\n\n protected setChecked(isChecked: boolean) {\n const oldValue = this._checked;\n if (isChecked === oldValue) {\n return;\n }\n this._checked = isChecked;\n this.selectionController?.update(this);\n\n this.requestUpdate('checked', oldValue);\n\n // useful when unchecks self and wrapping element needs to synchronize\n // TODO(b/168543810): Remove triggering event on programmatic API call.\n this.dispatchEvent(new Event('checked', {bubbles: true, composed: true}));\n }\n\n @property({type: Boolean}) override disabled = false;\n\n @property({type: String}) value = 'on';\n\n @property({type: String}) name = '';\n\n /**\n * Touch target extends beyond visual boundary of a component by default.\n * Set to `true` to remove touch target added to the component.\n * @see https://material.io/design/usability/accessibility.html\n */\n @property({type: Boolean}) reducedTouchTarget = false;\n\n protected selectionController?: SingleSelectionController;\n\n /**\n * input's tabindex is updated based on checked status.\n * Tab navigation will be removed from unchecked radios.\n */\n @property({type: Number}) formElementTabIndex = 0;\n\n @state() protected focused = false;\n\n @ariaProperty // tslint:disable-line:no-new-decorators\n @property({attribute: 'data-aria-label', noAccessor: true})\n override ariaLabel!: string;\n\n @ariaProperty // tslint:disable-line:no-new-decorators\n @property({attribute: 'data-aria-labelledby', noAccessor: true})\n ariaLabelledBy!: string;\n\n @ariaProperty // tslint:disable-line:no-new-decorators\n @property(\n {type: String, attribute: 'data-aria-describedby', noAccessor: true})\n ariaDescribedBy!: undefined|string;\n\n protected rippleElement: MdRipple|null = null;\n\n /** @soyTemplate */\n protected renderRipple(): TemplateResult|string {\n return html`<md-ripple unbounded\n ?disabled=\"${this.disabled}\"></md-ripple>`;\n }\n\n /** @soyTemplate */\n protected renderFocusRing(): TemplateResult {\n return html`<md-focus-ring .visible=\"${\n this.showFocusRing}\"></md-focus-ring>`;\n }\n\n get isRippleActive() {\n return false;\n }\n\n override connectedCallback() {\n super.connectedCallback();\n // Note that we must defer creating the selection controller until the\n // element has connected, because selection controllers are keyed by the\n // radio's shadow root. For example, if we're stamping in a lit map\n // or repeat, then we'll be constructed before we're added to a root node.\n //\n // Also note if we aren't using native shadow DOM, we still need a\n // SelectionController, because we should update checked status of other\n // radios in the group when selection changes. It also simplifies\n // implementation and testing to use one in all cases.\n //\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n this.selectionController = SingleSelectionController.getController(this);\n this.selectionController.register(this);\n\n // Radios maybe checked before connected, update selection as soon it is\n // connected to DOM. Last checked radio button in the DOM will be selected.\n //\n // NOTE: If we update selection only after firstUpdate() we might mistakenly\n // update checked status before other radios are rendered.\n this.selectionController.update(this);\n }\n\n override disconnectedCallback() {\n // The controller is initialized in connectedCallback, so if we are in\n // disconnectedCallback then it must be initialized.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.selectionController!.unregister(this);\n this.selectionController = undefined;\n }\n\n override updated(changedProperties: PropertyValues) {\n if (changedProperties.has('checked') && this.formElement) {\n this.formElement.checked = this.checked;\n if (!this.checked) {\n // Remove focus ring when unchecked on other radio programmatically.\n // Blur on input since this determines the focus style.\n this.formElement?.blur();\n }\n }\n }\n\n protected createAdapter() {}\n\n override beginPress({positionEvent}: BeginPressConfig) {\n this.ripple.beginPress(positionEvent);\n }\n\n override endPress({cancelled}: EndPressConfig) {\n this.ripple.endPress();\n\n if (cancelled) {\n return;\n }\n\n super.endPress({\n cancelled,\n actionData:\n {checked: this.formElement.checked, value: this.formElement.value}\n });\n }\n\n override click() {\n this.formElement.focus();\n this.formElement.click();\n }\n\n protected handleFocus() {\n this.focused = true;\n this.showFocusRing = shouldShowStrongFocus();\n }\n\n protected handleBlur() {\n this.focused = false;\n this.showFocusRing = false;\n }\n\n protected setFormData(formData: FormData) {\n if (this.name && this.checked) {\n formData.append(this.name, this.value);\n }\n }\n\n /**\n * @soyTemplate\n * @soyAttributes radioAttributes: input\n * @soyClasses radioClasses: .md3-radio\n */\n protected override render(): TemplateResult {\n /** @classMap */\n const classes = {\n 'md3-radio--touch': !this.reducedTouchTarget,\n 'md3-ripple-upgraded--background-focused': this.focused,\n 'md3-radio--disabled': this.disabled,\n };\n\n return html`\n <div class=\"md3-radio ${classMap(classes)}\">\n ${this.renderFocusRing()}\n <input\n tabindex=\"${this.formElementTabIndex}\"\n class=\"md3-radio__native-control\"\n type=\"radio\"\n name=\"${this.name}\"\n aria-label=\"${ifDefined(this.ariaLabel)}\"\n aria-labelledby=\"${ifDefined(this.ariaLabelledBy)}\"\n aria-describedby=\"${ifDefined(this.ariaDescribedBy)}\"\n ?checked=\"${this.checked}\"\n .value=\"${this.value}\"\n ?disabled=\"${this.disabled}\"\n @change=\"${this.changeHandler}\"\n @focus=\"${this.handleFocus}\"\n @click=\"${this.handleClick}\"\n @blur=\"${this.handleBlur}\"\n @pointerenter=${this.handlePointerEnter}\n @pointerdown=${this.handlePointerDown}\n @pointerup=${this.handlePointerUp}\n @pointercancel=${this.handlePointerCancel}\n @pointerleave=${this.handlePointerLeave}\n >\n <div class=\"md3-radio__background\">\n <div class=\"md3-radio__outer-circle\"></div>\n <div class=\"md3-radio__inner-circle\"></div>\n </div>\n <div class=\"md3-radio__ripple\">\n ${this.renderRipple()}\n </div>\n </div>`;\n }\n\n protected handlePointerEnter() {\n this.ripple.beginHover();\n }\n\n override handlePointerDown(event: PointerEvent) {\n super.handlePointerDown(event);\n\n pointerPress();\n this.showFocusRing = shouldShowStrongFocus();\n }\n\n override handlePointerLeave(e: PointerEvent) {\n super.handlePointerLeave(e);\n this.ripple.endHover();\n }\n\n protected changeHandler() {\n if (this.disabled) {\n return;\n }\n\n // Per spec, the change event on a radio input always represents checked.\n this.checked = true;\n this.dispatchEvent(new Event('change', {\n bubbles: true,\n composed: true,\n }));\n }\n}\n"]}
1
+ {"version":3,"file":"radio.js","sourceRoot":"","sources":["radio.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,4CAA4C;AAC5C,mDAAmD;AAEnD,OAAO,2BAA2B,CAAC;AACnC,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAA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,GAAG,UAAU,CAAC,iBAAiB,EAAE,cAAc,EAAE,IAAI,EAAC,CAAC;AAEtE,oBAAc,GAAG,IAAI,CAAC;AAG7B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;;oCAGxC;AAsC0B;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;;uCAAkB;AAKlB;IAAzB,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;;oCAAc;AAKE;IAAxC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;mCAAW;AAOxB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;;iDAA4B;AAM5B;IAAzB,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;;kDAAyB;AAIlD;IAFC,YAAY,CAAE,wCAAwC;;IACtD,QAAQ,CAAC,EAAC,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;;wCAC/B;AASnB;IAAR,KAAK,EAAE;;sCAAyB;AACjB;IAAf,KAAK,CAAC,OAAO,CAAC;8BAA0B,gBAAgB;oCAAM;AACtC;IAAxB,UAAU,CAAC,WAAW,CAAC;;qCAAkD;AAEjE;IAAR,KAAK,EAAE;;4CAA+B;AAC9B;IAAR,KAAK,EAAE;;yCAA4B","sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// Style preference for leading underscores.\n// tslint:disable:strip-private-property-underscore\n\nimport '../../focus/focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, LitElement, nothing, PropertyValues, TemplateResult} from 'lit';\nimport {property, query, queryAsync, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport {when} from 'lit/directives/when.js';\n\nimport {dispatchActivationClick, isActivationClick} from '../../controller/events.js';\nimport {FormController, getFormValue} from '../../controller/form-controller.js';\nimport {ariaProperty} from '../../decorators/aria-property.js';\nimport {pointerPress, shouldShowStrongFocus} from '../../focus/strong-focus.js';\nimport {ripple} from '../../ripple/directive.js';\nimport {MdRipple} from '../../ripple/ripple.js';\n\nimport {SingleSelectionController} from './single-selection-controller.js';\n\n/**\n * @fires checked\n * @soyCompatible\n */\nexport class Radio extends LitElement {\n static override shadowRootOptions:\n ShadowRootInit = {...LitElement.shadowRootOptions, delegatesFocus: true};\n\n static formAssociated = true;\n\n @property({type: Boolean, reflect: true})\n get checked(): boolean {\n return this._checked;\n }\n\n /**\n * We define our own getter/setter for `checked` because we need to track\n * changes to it synchronously.\n *\n * The order in which the `checked` property is set across radio buttons\n * within the same group is very important. However, we can't rely on\n * UpdatingElement's `updated` callback to observe these changes (which is\n * also what the `@observer` decorator uses), because it batches changes to\n * all properties.\n *\n * Consider:\n *\n * radio1.disabled = true;\n * radio2.checked = true;\n * radio1.checked = true;\n *\n * In this case we'd first see all changes for radio1, and then for radio2,\n * and we couldn't tell that radio1 was the most recently checked.\n */\n set checked(isChecked: boolean) {\n const oldValue = this._checked;\n if (isChecked === oldValue) {\n return;\n }\n this._checked = isChecked;\n this.selectionController?.update(this);\n\n this.requestUpdate('checked', oldValue);\n\n // useful when unchecks self and wrapping element needs to synchronize\n // TODO(b/168543810): Remove triggering event on programmatic API call.\n this.dispatchEvent(new Event('checked', {bubbles: true, composed: true}));\n }\n\n private _checked = false; // tslint:disable-line:enforce-name-casing\n\n @property({type: Boolean}) disabled = false;\n\n /**\n * The element value to use in form submission when checked.\n */\n @property({type: String}) value = 'on';\n\n /**\n * The HTML name to use in form submission.\n */\n @property({type: String, reflect: true}) name = '';\n\n /**\n * Touch target extends beyond visual boundary of a component by default.\n * Set to `true` to remove touch target added to the component.\n * @see https://material.io/design/usability/accessibility.html\n */\n @property({type: Boolean}) reducedTouchTarget = false;\n\n /**\n * input's tabindex is updated based on checked status.\n * Tab navigation will be removed from unchecked radios.\n */\n @property({type: Number}) formElementTabIndex = 0;\n\n @ariaProperty // tslint:disable-line:no-new-decorators\n @property({attribute: 'data-aria-label', noAccessor: true})\n override ariaLabel!: string;\n\n /**\n * The associated form element with which this element's value will submit.\n */\n get form() {\n return this.closest('form');\n }\n\n @state() private focused = false;\n @query('input') private readonly input!: HTMLInputElement|null;\n @queryAsync('md-ripple') private readonly ripple!: Promise<MdRipple|null>;\n private selectionController?: SingleSelectionController;\n @state() private showFocusRing = false;\n @state() private showRipple = false;\n\n constructor() {\n super();\n this.addController(new FormController(this));\n this.addEventListener('click', (event: Event) => {\n if (!isActivationClick(event)) {\n return;\n }\n this.focus();\n dispatchActivationClick(this.input!);\n });\n }\n\n [getFormValue]() {\n return this.checked ? this.value : null;\n }\n\n override focus() {\n this.input?.focus();\n }\n\n override connectedCallback() {\n super.connectedCallback();\n // Note that we must defer creating the selection controller until the\n // element has connected, because selection controllers are keyed by the\n // radio's shadow root. For example, if we're stamping in a lit map\n // or repeat, then we'll be constructed before we're added to a root node.\n //\n // Also note if we aren't using native shadow DOM, we still need a\n // SelectionController, because we should update checked status of other\n // radios in the group when selection changes. It also simplifies\n // implementation and testing to use one in all cases.\n //\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n this.selectionController = SingleSelectionController.getController(this);\n this.selectionController.register(this);\n\n // Radios maybe checked before connected, update selection as soon it is\n // connected to DOM. Last checked radio button in the DOM will be selected.\n //\n // NOTE: If we update selection only after firstUpdate() we might mistakenly\n // update checked status before other radios are rendered.\n this.selectionController.update(this);\n }\n\n override disconnectedCallback() {\n // The controller is initialized in connectedCallback, so if we are in\n // disconnectedCallback then it must be initialized.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.selectionController!.unregister(this);\n this.selectionController = undefined;\n }\n\n override updated(changedProperties: PropertyValues) {\n if (changedProperties.has('checked') && this.input) {\n this.input.checked = this.checked;\n if (!this.checked) {\n // Remove focus ring when unchecked on other radio programmatically.\n // Blur on input since this determines the focus style.\n this.input.blur();\n }\n }\n }\n\n /**\n * @soyTemplate\n * @soyAttributes radioAttributes: input\n * @soyClasses radioClasses: .md3-radio\n */\n protected override render(): TemplateResult {\n /** @classMap */\n const classes = {\n 'md3-radio--touch': !this.reducedTouchTarget,\n 'md3-ripple-upgraded--background-focused': this.focused,\n 'md3-radio--disabled': this.disabled,\n };\n\n return html`\n <div class=\"md3-radio ${classMap(classes)}\">\n ${this.renderFocusRing()}\n <input\n tabindex=\"${this.formElementTabIndex}\"\n class=\"md3-radio__native-control\"\n type=\"radio\"\n name=\"${this.name}\"\n aria-label=\"${this.ariaLabel || nothing}\"\n .checked=\"${this.checked}\"\n .value=\"${this.value}\"\n ?disabled=\"${this.disabled}\"\n @change=\"${this.handleChange}\"\n @focus=\"${this.handleFocus}\"\n @blur=\"${this.handleBlur}\"\n @pointerdown=${this.handlePointerDown}\n ${ripple(this.getRipple)}\n >\n <div class=\"md3-radio__background\">\n <div class=\"md3-radio__outer-circle\"></div>\n <div class=\"md3-radio__inner-circle\"></div>\n </div>\n <div class=\"md3-radio__ripple\">\n ${when(this.showRipple, this.renderRipple)}\n </div>\n </div>`;\n }\n\n private handleBlur() {\n this.focused = false;\n this.showFocusRing = false;\n }\n\n private handleFocus() {\n this.focused = true;\n this.showFocusRing = shouldShowStrongFocus();\n }\n\n private handleChange() {\n if (this.disabled) {\n return;\n }\n\n // Per spec, the change event on a radio input always represents checked.\n this.checked = true;\n this.dispatchEvent(new Event('change', {\n bubbles: true,\n composed: true,\n }));\n }\n\n private handlePointerDown(event: PointerEvent) {\n pointerPress();\n this.showFocusRing = shouldShowStrongFocus();\n }\n\n private readonly getRipple = () => {\n this.showRipple = true;\n return this.ripple;\n };\n\n private readonly renderRipple = () => {\n return html`<md-ripple unbounded ?disabled=${this.disabled}></md-ripple>`;\n };\n\n private renderFocusRing(): TemplateResult {\n return html`<md-focus-ring .visible=${this.showFocusRing}></md-focus-ring>`;\n }\n}\n"]}
@@ -42,9 +42,6 @@
42
42
  inset: 0;
43
43
  pointer-events: none;
44
44
  overflow: hidden;
45
- // TODO(https://bugs.webkit.org/show_bug.cgi?id=247546)
46
- // Remove Safari workaround for incorrect ripple overflow when addressed.
47
- transform: scale(1);
48
45
  }
49
46
 
50
47
  .md3-ripple-surface {
@@ -95,7 +92,13 @@
95
92
  transition-duration: 105ms;
96
93
  }
97
94
 
98
- .md3-ripple--unbounded {
95
+ // TODO(https://bugs.webkit.org/show_bug.cgi?id=247546)
96
+ // Remove Safari workaround for incorrect ripple overflow:
97
+ // setting shape token to `:host([unbounded])` so border-radius can be set
98
+ // only in this state.
99
+ // This addresses `hover` and `pressed` state oveflow.
100
+ .md3-ripple--unbounded,
101
+ :host([unbounded]) {
99
102
  $unbounded: (
100
103
  state-layer-shape: map.get(tokens.md-sys-shape-values(), 'corner-full'),
101
104
  );
@@ -104,6 +107,20 @@
104
107
  --_state-layer-shape: #{map.get($unbounded, 'state-layer-shape')};
105
108
  }
106
109
 
110
+ // TODO(https://bugs.webkit.org/show_bug.cgi?id=247546)
111
+ // Remove Safari workaround for incorrect ripple overflow when addressed.
112
+ // This addresses `hover` and `pressed` state oveflow.
113
+ :host([unbounded]) {
114
+ border-radius: var(--_state-layer-shape);
115
+ }
116
+
117
+ // TODO(https://bugs.webkit.org/show_bug.cgi?id=247546)
118
+ // Remove Safari workaround for incorrect ripple overflow when addressed.
119
+ // This addresses `during animation` state oveflow.
120
+ .md3-ripple--unbounded {
121
+ transform: scale(1);
122
+ }
123
+
107
124
  // TODO(b/230630968): create a forced-colors-mode mixin
108
125
  @media screen and (forced-colors: active) {
109
126
  :host {
@@ -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{--_dragged-state-layer-opacity: var(--md-ripple-dragged-state-layer-opacity, 0.16);--_focus-state-layer-opacity: var(--md-ripple-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-ripple-hover-state-layer-opacity, 0.08);--_pressed-state-layer-opacity: var(--md-ripple-pressed-state-layer-opacity, 0.12);--_state-layer-shape: var(--md-ripple-state-layer-shape, 0px);--_focus-state-layer-color: var(--md-ripple-focus-state-layer-color, black);--_hover-state-layer-color: var(--md-ripple-hover-state-layer-color, black);--_pressed-state-layer-color: var(--md-ripple-pressed-state-layer-color, black);--_dragged-state-layer-color: var(--md-ripple-dragged-state-layer-color, black)}:host{display:flex}:host([disabled]){opacity:0}:host,.md3-ripple-surface{position:absolute;inset:0;pointer-events:none;overflow:hidden;transform:scale(1)}.md3-ripple-surface{border-radius:var(--_state-layer-shape);outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.md3-ripple-surface::before,.md3-ripple-surface::after{position:absolute;opacity:0;pointer-events:none;content:""}.md3-ripple-surface::before{background-color:var(--_hover-state-layer-color);transition:opacity 15ms linear,background-color 15ms linear;inset:0}.md3-ripple-surface::after{background:radial-gradient(closest-side, var(--_pressed-state-layer-color) max(100% - 70px, 65%), transparent 100%);transition:opacity 375ms linear;transform-origin:center center}.md3-ripple--hovered::before{background-color:var(--_hover-state-layer-color);opacity:var(--_hover-state-layer-opacity)}.md3-ripple--focused::before{background-color:var(--_focus-state-layer-color);opacity:var(--_focus-state-layer-opacity);transition-duration:75ms}.md3-ripple--pressed::after{opacity:var(--_pressed-state-layer-opacity);transition-duration:105ms}.md3-ripple--unbounded{--_state-layer-shape: var(--md-ripple-state-layer-shape, 9999px)}@media screen and (forced-colors: active){:host{display:none}}/*# sourceMappingURL=ripple-styles.css.map */
7
+ export const styles = css `:host{--_dragged-state-layer-opacity: var(--md-ripple-dragged-state-layer-opacity, 0.16);--_focus-state-layer-opacity: var(--md-ripple-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-ripple-hover-state-layer-opacity, 0.08);--_pressed-state-layer-opacity: var(--md-ripple-pressed-state-layer-opacity, 0.12);--_state-layer-shape: var(--md-ripple-state-layer-shape, 0px);--_focus-state-layer-color: var(--md-ripple-focus-state-layer-color, black);--_hover-state-layer-color: var(--md-ripple-hover-state-layer-color, black);--_pressed-state-layer-color: var(--md-ripple-pressed-state-layer-color, black);--_dragged-state-layer-color: var(--md-ripple-dragged-state-layer-color, black)}:host{display:flex}:host([disabled]){opacity:0}:host,.md3-ripple-surface{position:absolute;inset:0;pointer-events:none;overflow:hidden}.md3-ripple-surface{border-radius:var(--_state-layer-shape);outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.md3-ripple-surface::before,.md3-ripple-surface::after{position:absolute;opacity:0;pointer-events:none;content:""}.md3-ripple-surface::before{background-color:var(--_hover-state-layer-color);transition:opacity 15ms linear,background-color 15ms linear;inset:0}.md3-ripple-surface::after{background:radial-gradient(closest-side, var(--_pressed-state-layer-color) max(100% - 70px, 65%), transparent 100%);transition:opacity 375ms linear;transform-origin:center center}.md3-ripple--hovered::before{background-color:var(--_hover-state-layer-color);opacity:var(--_hover-state-layer-opacity)}.md3-ripple--focused::before{background-color:var(--_focus-state-layer-color);opacity:var(--_focus-state-layer-opacity);transition-duration:75ms}.md3-ripple--pressed::after{opacity:var(--_pressed-state-layer-opacity);transition-duration:105ms}.md3-ripple--unbounded,:host([unbounded]){--_state-layer-shape: var(--md-ripple-state-layer-shape, 9999px)}:host([unbounded]){border-radius:var(--_state-layer-shape)}.md3-ripple--unbounded{transform:scale(1)}@media screen and (forced-colors: active){:host{display:none}}/*# sourceMappingURL=ripple-styles.css.map */
8
8
  `;
9
9
  //# sourceMappingURL=ripple-styles.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ripple-styles.css.js","sourceRoot":"","sources":["ripple-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{--_dragged-state-layer-opacity: var(--md-ripple-dragged-state-layer-opacity, 0.16);--_focus-state-layer-opacity: var(--md-ripple-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-ripple-hover-state-layer-opacity, 0.08);--_pressed-state-layer-opacity: var(--md-ripple-pressed-state-layer-opacity, 0.12);--_state-layer-shape: var(--md-ripple-state-layer-shape, 0px);--_focus-state-layer-color: var(--md-ripple-focus-state-layer-color, black);--_hover-state-layer-color: var(--md-ripple-hover-state-layer-color, black);--_pressed-state-layer-color: var(--md-ripple-pressed-state-layer-color, black);--_dragged-state-layer-color: var(--md-ripple-dragged-state-layer-color, black)}:host{display:flex}:host([disabled]){opacity:0}:host,.md3-ripple-surface{position:absolute;inset:0;pointer-events:none;overflow:hidden;transform:scale(1)}.md3-ripple-surface{border-radius:var(--_state-layer-shape);outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.md3-ripple-surface::before,.md3-ripple-surface::after{position:absolute;opacity:0;pointer-events:none;content:\"\"}.md3-ripple-surface::before{background-color:var(--_hover-state-layer-color);transition:opacity 15ms linear,background-color 15ms linear;inset:0}.md3-ripple-surface::after{background:radial-gradient(closest-side, var(--_pressed-state-layer-color) max(100% - 70px, 65%), transparent 100%);transition:opacity 375ms linear;transform-origin:center center}.md3-ripple--hovered::before{background-color:var(--_hover-state-layer-color);opacity:var(--_hover-state-layer-opacity)}.md3-ripple--focused::before{background-color:var(--_focus-state-layer-color);opacity:var(--_focus-state-layer-opacity);transition-duration:75ms}.md3-ripple--pressed::after{opacity:var(--_pressed-state-layer-opacity);transition-duration:105ms}.md3-ripple--unbounded{--_state-layer-shape: var(--md-ripple-state-layer-shape, 9999px)}@media screen and (forced-colors: active){:host{display:none}}/*# sourceMappingURL=ripple-styles.css.map */\n`;\n "]}
1
+ {"version":3,"file":"ripple-styles.css.js","sourceRoot":"","sources":["ripple-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{--_dragged-state-layer-opacity: var(--md-ripple-dragged-state-layer-opacity, 0.16);--_focus-state-layer-opacity: var(--md-ripple-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-ripple-hover-state-layer-opacity, 0.08);--_pressed-state-layer-opacity: var(--md-ripple-pressed-state-layer-opacity, 0.12);--_state-layer-shape: var(--md-ripple-state-layer-shape, 0px);--_focus-state-layer-color: var(--md-ripple-focus-state-layer-color, black);--_hover-state-layer-color: var(--md-ripple-hover-state-layer-color, black);--_pressed-state-layer-color: var(--md-ripple-pressed-state-layer-color, black);--_dragged-state-layer-color: var(--md-ripple-dragged-state-layer-color, black)}:host{display:flex}:host([disabled]){opacity:0}:host,.md3-ripple-surface{position:absolute;inset:0;pointer-events:none;overflow:hidden}.md3-ripple-surface{border-radius:var(--_state-layer-shape);outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.md3-ripple-surface::before,.md3-ripple-surface::after{position:absolute;opacity:0;pointer-events:none;content:\"\"}.md3-ripple-surface::before{background-color:var(--_hover-state-layer-color);transition:opacity 15ms linear,background-color 15ms linear;inset:0}.md3-ripple-surface::after{background:radial-gradient(closest-side, var(--_pressed-state-layer-color) max(100% - 70px, 65%), transparent 100%);transition:opacity 375ms linear;transform-origin:center center}.md3-ripple--hovered::before{background-color:var(--_hover-state-layer-color);opacity:var(--_hover-state-layer-opacity)}.md3-ripple--focused::before{background-color:var(--_focus-state-layer-color);opacity:var(--_focus-state-layer-opacity);transition-duration:75ms}.md3-ripple--pressed::after{opacity:var(--_pressed-state-layer-opacity);transition-duration:105ms}.md3-ripple--unbounded,:host([unbounded]){--_state-layer-shape: var(--md-ripple-state-layer-shape, 9999px)}:host([unbounded]){border-radius:var(--_state-layer-shape)}.md3-ripple--unbounded{transform:scale(1)}@media screen and (forced-colors: active){:host{display:none}}/*# sourceMappingURL=ripple-styles.css.map */\n`;\n "]}
@@ -20,6 +20,9 @@ const ANIMATION_FILL = 'forwards';
20
20
  export class Ripple extends LitElement {
21
21
  constructor() {
22
22
  super(...arguments);
23
+ // TODO(https://bugs.webkit.org/show_bug.cgi?id=247546)
24
+ // Remove Safari workaround that requires reflecting `unbounded` so
25
+ // it can be styled against.
23
26
  this.unbounded = false;
24
27
  this.disabled = false;
25
28
  this.hovered = false;
@@ -193,7 +196,7 @@ __decorate([
193
196
  __metadata("design:type", HTMLElement)
194
197
  ], Ripple.prototype, "mdRoot", void 0);
195
198
  __decorate([
196
- property({ type: Boolean }),
199
+ property({ type: Boolean, reflect: true }),
197
200
  __metadata("design:type", Object)
198
201
  ], Ripple.prototype, "unbounded", void 0);
199
202
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"ripple.js","sourceRoot":"","sources":["ripple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,UAAU,EAAiC,MAAM,KAAK,CAAC;AACrE,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAY,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAC,qBAAqB,EAAE,MAAM,EAAC,MAAM,2BAA2B,CAAC;AAExE,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AACvC,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC,qBAA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A2B;AAC1B;IAAR,KAAK,EAAE;;uCAA2B","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, LitElement, PropertyValues, TemplateResult} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\n\nimport {createAnimationSignal, Easing} from '../../motion/animation.js';\n\nconst PRESS_GROW_MS = 450;\nconst MINIMUM_PRESS_MS = 225;\nconst INITIAL_ORIGIN_SCALE = 0.2;\nconst PADDING = 10;\nconst SOFT_EDGE_MINIMUM_SIZE = 75;\nconst SOFT_EDGE_CONTAINER_RATIO = 0.35;\nconst PRESS_PSEUDO = '::after';\nconst ANIMATION_FILL = 'forwards';\n\n/** @soyCompatible */\nexport class Ripple extends LitElement {\n @query('.md3-ripple-surface') mdRoot!: HTMLElement;\n\n @property({type: Boolean}) unbounded = false;\n @property({type: Boolean, reflect: true}) disabled = false;\n\n @state() protected hovered = false;\n @state() protected focused = false;\n @state() protected pressed = false;\n\n protected rippleSize = '';\n protected rippleScale = '';\n protected initialSize = 0;\n protected pressAnimationSignal = createAnimationSignal();\n protected growAnimation: Animation|null = null;\n protected delayedEndPressHandle: number|null = null;\n\n /** @soyTemplate */\n protected override render(): TemplateResult {\n return html`<div class=\"md3-ripple-surface ${\n classMap(this.getRenderRippleClasses())}\"></div>`;\n }\n\n /** @soyTemplate */\n protected getRenderRippleClasses(): ClassInfo {\n return {\n 'md3-ripple--hovered': this.hovered,\n 'md3-ripple--focused': this.focused,\n 'md3-ripple--pressed': this.pressed,\n 'md3-ripple--unbounded': this.unbounded,\n };\n }\n\n protected override update(changedProps: PropertyValues<this>) {\n if (changedProps.has('disabled') && this.disabled) {\n this.endHover();\n this.endFocus();\n this.endPress();\n }\n super.update(changedProps);\n }\n\n protected getDimensions() {\n return (this.parentElement ?? this).getBoundingClientRect();\n }\n\n protected determineRippleSize() {\n const {height, width} = this.getDimensions();\n const maxDim = Math.max(height, width);\n const softEdgeSize =\n Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDim, SOFT_EDGE_MINIMUM_SIZE);\n\n\n let maxRadius = maxDim;\n let initialSize = Math.floor(maxDim * INITIAL_ORIGIN_SCALE);\n\n const hypotenuse = Math.sqrt(width ** 2 + height ** 2);\n maxRadius = hypotenuse + PADDING;\n\n // ensure `initialSize` is even for unbounded\n if (this.unbounded) {\n initialSize = initialSize - (initialSize % 2);\n }\n\n this.initialSize = initialSize;\n this.rippleScale = `${(maxRadius + softEdgeSize) / initialSize}`;\n this.rippleSize = `${this.initialSize}px`;\n }\n\n protected getNormalizedPointerEventCoords(pointerEvent: PointerEvent):\n {x: number, y: number} {\n const {scrollX, scrollY} = window;\n const {left, top} = this.getDimensions();\n const documentX = scrollX + left;\n const documentY = scrollY + top;\n const {pageX, pageY} = pointerEvent;\n return {x: pageX - documentX, y: pageY - documentY};\n }\n\n protected getTranslationCoordinates(positionEvent?: Event|null) {\n const {height, width} = this.getDimensions();\n // end in the center\n const endPoint = {\n x: (width - this.initialSize) / 2,\n y: (height - this.initialSize) / 2,\n };\n\n let startPoint;\n if (positionEvent instanceof PointerEvent) {\n startPoint = this.getNormalizedPointerEventCoords(positionEvent);\n } else {\n startPoint = {\n x: width / 2,\n y: height / 2,\n };\n }\n\n // center around start point\n startPoint = {\n x: startPoint.x - (this.initialSize / 2),\n y: startPoint.y - (this.initialSize / 2),\n };\n\n return {startPoint, endPoint};\n }\n\n protected startPressAnimation(positionEvent?: Event|null) {\n this.determineRippleSize();\n const {startPoint, endPoint} =\n this.getTranslationCoordinates(positionEvent);\n const translateStart = `${startPoint.x}px, ${startPoint.y}px`;\n const translateEnd = `${endPoint.x}px, ${endPoint.y}px`;\n\n const signal = this.pressAnimationSignal.start();\n\n const growAnimation = this.mdRoot.animate(\n {\n top: [0, 0],\n left: [0, 0],\n height: [this.rippleSize, this.rippleSize],\n width: [this.rippleSize, this.rippleSize],\n transform: [\n `translate(${translateStart}) scale(1)`,\n `translate(${translateEnd}) scale(${this.rippleScale})`\n ],\n },\n {\n pseudoElement: PRESS_PSEUDO,\n duration: PRESS_GROW_MS,\n easing: Easing.STANDARD,\n fill: ANIMATION_FILL\n });\n\n growAnimation.addEventListener('finish', () => {\n this.pressAnimationSignal.finish();\n this.growAnimation = null;\n });\n\n signal.addEventListener('abort', () => {\n growAnimation.cancel();\n this.growAnimation = null;\n });\n\n this.growAnimation = growAnimation;\n }\n\n /**\n * @deprecated Use beginHover\n */\n startHover(hoverEvent?: Event) {\n this.beginHover(hoverEvent);\n }\n\n beginHover(hoverEvent?: Event) {\n if ((hoverEvent as PointerEvent)?.pointerType !== 'touch') {\n this.hovered = true;\n }\n }\n\n endHover() {\n this.hovered = false;\n }\n\n /**\n * @deprecated Use beginFocus\n */\n startFocus() {\n this.beginFocus();\n }\n\n beginFocus() {\n this.focused = true;\n }\n\n endFocus() {\n this.focused = false;\n }\n\n /**\n * @deprecated Use beginPress\n */\n startPress(positionEvent?: Event|null) {\n this.beginPress(positionEvent);\n }\n\n beginPress(positionEvent?: Event|null) {\n this.pressed = true;\n if (this.delayedEndPressHandle !== null) {\n clearTimeout(this.delayedEndPressHandle);\n this.delayedEndPressHandle = null;\n }\n this.startPressAnimation(positionEvent);\n }\n\n endPress() {\n const pressAnimationPlayState = this.growAnimation?.currentTime ?? Infinity;\n if (pressAnimationPlayState >= MINIMUM_PRESS_MS) {\n this.pressed = false;\n } else {\n this.delayedEndPressHandle = setTimeout(() => {\n this.pressed = false;\n this.delayedEndPressHandle = null;\n }, MINIMUM_PRESS_MS - pressAnimationPlayState);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ripple.js","sourceRoot":"","sources":["ripple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,UAAU,EAAiC,MAAM,KAAK,CAAC;AACrE,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACzD,OA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EAAE;gBAC3C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;gBACrB,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;YACpC,CAAC,EAAE,gBAAgB,GAAG,uBAAuB,CAAC,CAAC;SAChD;IACH,CAAC;CACF;AA/M+B;IAA7B,KAAK,CAAC,qBAAqB,CAAC;8BAAU,WAAW;sCAAC;AAKT;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;yCAAmB;AAClB;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;wCAAkB;AAElD;IAAR,KAAK,EAAE;;uCAA2B;AAC1B;IAAR,KAAK,EAAE;;uCAA2B;AAC1B;IAAR,KAAK,EAAE;;uCAA2B","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, LitElement, PropertyValues, TemplateResult} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\n\nimport {createAnimationSignal, Easing} from '../../motion/animation.js';\n\nconst PRESS_GROW_MS = 450;\nconst MINIMUM_PRESS_MS = 225;\nconst INITIAL_ORIGIN_SCALE = 0.2;\nconst PADDING = 10;\nconst SOFT_EDGE_MINIMUM_SIZE = 75;\nconst SOFT_EDGE_CONTAINER_RATIO = 0.35;\nconst PRESS_PSEUDO = '::after';\nconst ANIMATION_FILL = 'forwards';\n\n/** @soyCompatible */\nexport class Ripple extends LitElement {\n @query('.md3-ripple-surface') mdRoot!: HTMLElement;\n\n // TODO(https://bugs.webkit.org/show_bug.cgi?id=247546)\n // Remove Safari workaround that requires reflecting `unbounded` so\n // it can be styled against.\n @property({type: Boolean, reflect: true}) unbounded = false;\n @property({type: Boolean, reflect: true}) disabled = false;\n\n @state() protected hovered = false;\n @state() protected focused = false;\n @state() protected pressed = false;\n\n protected rippleSize = '';\n protected rippleScale = '';\n protected initialSize = 0;\n protected pressAnimationSignal = createAnimationSignal();\n protected growAnimation: Animation|null = null;\n protected delayedEndPressHandle: number|null = null;\n\n /** @soyTemplate */\n protected override render(): TemplateResult {\n return html`<div class=\"md3-ripple-surface ${\n classMap(this.getRenderRippleClasses())}\"></div>`;\n }\n\n /** @soyTemplate */\n protected getRenderRippleClasses(): ClassInfo {\n return {\n 'md3-ripple--hovered': this.hovered,\n 'md3-ripple--focused': this.focused,\n 'md3-ripple--pressed': this.pressed,\n 'md3-ripple--unbounded': this.unbounded,\n };\n }\n\n protected override update(changedProps: PropertyValues<this>) {\n if (changedProps.has('disabled') && this.disabled) {\n this.endHover();\n this.endFocus();\n this.endPress();\n }\n super.update(changedProps);\n }\n\n protected getDimensions() {\n return (this.parentElement ?? this).getBoundingClientRect();\n }\n\n protected determineRippleSize() {\n const {height, width} = this.getDimensions();\n const maxDim = Math.max(height, width);\n const softEdgeSize =\n Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDim, SOFT_EDGE_MINIMUM_SIZE);\n\n\n let maxRadius = maxDim;\n let initialSize = Math.floor(maxDim * INITIAL_ORIGIN_SCALE);\n\n const hypotenuse = Math.sqrt(width ** 2 + height ** 2);\n maxRadius = hypotenuse + PADDING;\n\n // ensure `initialSize` is even for unbounded\n if (this.unbounded) {\n initialSize = initialSize - (initialSize % 2);\n }\n\n this.initialSize = initialSize;\n this.rippleScale = `${(maxRadius + softEdgeSize) / initialSize}`;\n this.rippleSize = `${this.initialSize}px`;\n }\n\n protected getNormalizedPointerEventCoords(pointerEvent: PointerEvent):\n {x: number, y: number} {\n const {scrollX, scrollY} = window;\n const {left, top} = this.getDimensions();\n const documentX = scrollX + left;\n const documentY = scrollY + top;\n const {pageX, pageY} = pointerEvent;\n return {x: pageX - documentX, y: pageY - documentY};\n }\n\n protected getTranslationCoordinates(positionEvent?: Event|null) {\n const {height, width} = this.getDimensions();\n // end in the center\n const endPoint = {\n x: (width - this.initialSize) / 2,\n y: (height - this.initialSize) / 2,\n };\n\n let startPoint;\n if (positionEvent instanceof PointerEvent) {\n startPoint = this.getNormalizedPointerEventCoords(positionEvent);\n } else {\n startPoint = {\n x: width / 2,\n y: height / 2,\n };\n }\n\n // center around start point\n startPoint = {\n x: startPoint.x - (this.initialSize / 2),\n y: startPoint.y - (this.initialSize / 2),\n };\n\n return {startPoint, endPoint};\n }\n\n protected startPressAnimation(positionEvent?: Event|null) {\n this.determineRippleSize();\n const {startPoint, endPoint} =\n this.getTranslationCoordinates(positionEvent);\n const translateStart = `${startPoint.x}px, ${startPoint.y}px`;\n const translateEnd = `${endPoint.x}px, ${endPoint.y}px`;\n\n const signal = this.pressAnimationSignal.start();\n\n const growAnimation = this.mdRoot.animate(\n {\n top: [0, 0],\n left: [0, 0],\n height: [this.rippleSize, this.rippleSize],\n width: [this.rippleSize, this.rippleSize],\n transform: [\n `translate(${translateStart}) scale(1)`,\n `translate(${translateEnd}) scale(${this.rippleScale})`\n ],\n },\n {\n pseudoElement: PRESS_PSEUDO,\n duration: PRESS_GROW_MS,\n easing: Easing.STANDARD,\n fill: ANIMATION_FILL\n });\n\n growAnimation.addEventListener('finish', () => {\n this.pressAnimationSignal.finish();\n this.growAnimation = null;\n });\n\n signal.addEventListener('abort', () => {\n growAnimation.cancel();\n this.growAnimation = null;\n });\n\n this.growAnimation = growAnimation;\n }\n\n /**\n * @deprecated Use beginHover\n */\n startHover(hoverEvent?: Event) {\n this.beginHover(hoverEvent);\n }\n\n beginHover(hoverEvent?: Event) {\n if ((hoverEvent as PointerEvent)?.pointerType !== 'touch') {\n this.hovered = true;\n }\n }\n\n endHover() {\n this.hovered = false;\n }\n\n /**\n * @deprecated Use beginFocus\n */\n startFocus() {\n this.beginFocus();\n }\n\n beginFocus() {\n this.focused = true;\n }\n\n endFocus() {\n this.focused = false;\n }\n\n /**\n * @deprecated Use beginPress\n */\n startPress(positionEvent?: Event|null) {\n this.beginPress(positionEvent);\n }\n\n beginPress(positionEvent?: Event|null) {\n this.pressed = true;\n if (this.delayedEndPressHandle !== null) {\n clearTimeout(this.delayedEndPressHandle);\n this.delayedEndPressHandle = null;\n }\n this.startPressAnimation(positionEvent);\n }\n\n endPress() {\n const pressAnimationPlayState = this.growAnimation?.currentTime ?? Infinity;\n if (pressAnimationPlayState >= MINIMUM_PRESS_MS) {\n this.pressed = false;\n } else {\n this.delayedEndPressHandle = setTimeout(() => {\n this.pressed = false;\n this.delayedEndPressHandle = null;\n }, MINIMUM_PRESS_MS - pressAnimationPlayState);\n }\n }\n}\n"]}
@@ -8,7 +8,7 @@
8
8
 
9
9
  @use 'sass:map';
10
10
  @use '../../motion/animation';
11
- @use '../../ripple/ripple-theme';
11
+ @use '../../ripple/ripple';
12
12
  @use '../../sass/color';
13
13
  @use '../../sass/resolvers';
14
14
  @use '../../sass/touch-target';
@@ -193,7 +193,7 @@
193
193
  }
194
194
  }
195
195
 
196
- @include ripple-theme.theme(
196
+ @include ripple.theme(
197
197
  (
198
198
  hover-state-layer-color: var(--_unselected-hover-state-layer-color),
199
199
  hover-state-layer-opacity: var(--_hover-state-layer-opacity),
@@ -240,7 +240,7 @@
240
240
  }
241
241
  }
242
242
 
243
- @include ripple-theme.theme(
243
+ @include ripple.theme(
244
244
  (
245
245
  hover-state-layer-color: var(--_selected-hover-state-layer-color),
246
246
  hover-state-layer-opacity: var(--_hover-state-layer-opacity),
@@ -8,10 +8,11 @@
8
8
 
9
9
  @use 'sass:map';
10
10
 
11
- @use '../../ripple/ripple-theme';
11
+ @use '../../ripple/ripple';
12
12
 
13
13
  @mixin styles() {
14
14
  .md3-switch__handle-container {
15
+ display: flex;
15
16
  $margin: calc(var(--_track-width) - var(--_track-height));
16
17
 
17
18
  .md3-switch--selected & {
@@ -88,7 +89,7 @@
88
89
  width: var(--_state-layer-size);
89
90
 
90
91
  .md3-switch--selected & {
91
- @include ripple-theme.theme(
92
+ @include ripple.theme(
92
93
  (
93
94
  hover-state-layer-color: var(--_selected-hover-state-layer-color),
94
95
  focus-state-layer-color: var(--_selected-focus-state-layer-color),
@@ -102,7 +103,7 @@
102
103
  }
103
104
 
104
105
  .md3-switch--unselected & {
105
- @include ripple-theme.theme(
106
+ @include ripple.theme(
106
107
  (
107
108
  hover-state-layer-color: var(--_unselected-hover-state-layer-color),
108
109
  focus-state-layer-color: var(--_unselected-focus-state-layer-color),