@api-client/ui 0.2.9 → 0.2.11

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 (141) hide show
  1. package/build/src/md/UiElement.d.ts +5 -0
  2. package/build/src/md/UiElement.d.ts.map +1 -1
  3. package/build/src/md/UiElement.js +7 -0
  4. package/build/src/md/UiElement.js.map +1 -1
  5. package/build/src/md/button/ui-elevated-button.d.ts +1 -1
  6. package/build/src/md/button/ui-elevated-button.js +1 -1
  7. package/build/src/md/button/ui-elevated-button.js.map +1 -1
  8. package/build/src/md/button/ui-filled-button.d.ts +1 -1
  9. package/build/src/md/button/ui-filled-button.js +1 -1
  10. package/build/src/md/button/ui-filled-button.js.map +1 -1
  11. package/build/src/md/button/ui-filled-tonal-button.d.ts +3 -3
  12. package/build/src/md/button/ui-filled-tonal-button.d.ts.map +1 -1
  13. package/build/src/md/button/ui-filled-tonal-button.js +6 -6
  14. package/build/src/md/button/ui-filled-tonal-button.js.map +1 -1
  15. package/build/src/md/button/ui-outlined-button.d.ts +1 -1
  16. package/build/src/md/button/ui-outlined-button.js +1 -1
  17. package/build/src/md/button/ui-outlined-button.js.map +1 -1
  18. package/build/src/md/button/ui-text-button.d.ts +1 -1
  19. package/build/src/md/button/ui-text-button.js +1 -1
  20. package/build/src/md/button/ui-text-button.js.map +1 -1
  21. package/build/src/md/checkbox/internals/Checkbox.styles.d.ts.map +1 -1
  22. package/build/src/md/checkbox/internals/Checkbox.styles.js +55 -216
  23. package/build/src/md/checkbox/internals/Checkbox.styles.js.map +1 -1
  24. package/build/src/md/checkbox/internals/CheckboxElement.d.ts +10 -7
  25. package/build/src/md/checkbox/internals/CheckboxElement.d.ts.map +1 -1
  26. package/build/src/md/checkbox/internals/CheckboxElement.js +39 -32
  27. package/build/src/md/checkbox/internals/CheckboxElement.js.map +1 -1
  28. package/build/src/md/checkbox/internals/CheckedElement.d.ts.map +1 -1
  29. package/build/src/md/checkbox/internals/CheckedElement.js +1 -0
  30. package/build/src/md/checkbox/internals/CheckedElement.js.map +1 -1
  31. package/build/src/md/dropdown-list/internals/UiDropdownList.d.ts +13 -2
  32. package/build/src/md/dropdown-list/internals/UiDropdownList.d.ts.map +1 -1
  33. package/build/src/md/dropdown-list/internals/UiDropdownList.js +59 -20
  34. package/build/src/md/dropdown-list/internals/UiDropdownList.js.map +1 -1
  35. package/build/src/md/icon-button/internals/IconButton.d.ts +8 -24
  36. package/build/src/md/icon-button/internals/IconButton.d.ts.map +1 -1
  37. package/build/src/md/icon-button/internals/IconButton.js +35 -63
  38. package/build/src/md/icon-button/internals/IconButton.js.map +1 -1
  39. package/build/src/md/icon-button/internals/{IconButton.styles.d.ts → base.styles.d.ts} +1 -1
  40. package/build/src/md/icon-button/internals/base.styles.d.ts.map +1 -0
  41. package/build/src/md/icon-button/internals/base.styles.js +93 -0
  42. package/build/src/md/icon-button/internals/base.styles.js.map +1 -0
  43. package/build/src/md/icon-button/internals/filled-tonal.styles.d.ts +3 -0
  44. package/build/src/md/icon-button/internals/filled-tonal.styles.d.ts.map +1 -0
  45. package/build/src/md/icon-button/internals/filled-tonal.styles.js +30 -0
  46. package/build/src/md/icon-button/internals/filled-tonal.styles.js.map +1 -0
  47. package/build/src/md/icon-button/internals/filled.styles.d.ts +3 -0
  48. package/build/src/md/icon-button/internals/filled.styles.d.ts.map +1 -0
  49. package/build/src/md/icon-button/internals/filled.styles.js +36 -0
  50. package/build/src/md/icon-button/internals/filled.styles.js.map +1 -0
  51. package/build/src/md/icon-button/internals/outlined.styles.d.ts +3 -0
  52. package/build/src/md/icon-button/internals/outlined.styles.d.ts.map +1 -0
  53. package/build/src/md/icon-button/internals/outlined.styles.js +31 -0
  54. package/build/src/md/icon-button/internals/outlined.styles.js.map +1 -0
  55. package/build/src/md/icon-button/internals/standard.styles.d.ts +3 -0
  56. package/build/src/md/icon-button/internals/standard.styles.d.ts.map +1 -0
  57. package/build/src/md/icon-button/internals/standard.styles.js +18 -0
  58. package/build/src/md/icon-button/internals/standard.styles.js.map +1 -0
  59. package/build/src/md/icon-button/ui-filled-icon-button.d.ts +11 -0
  60. package/build/src/md/icon-button/ui-filled-icon-button.d.ts.map +1 -0
  61. package/build/src/md/icon-button/ui-filled-icon-button.js +28 -0
  62. package/build/src/md/icon-button/ui-filled-icon-button.js.map +1 -0
  63. package/build/src/md/icon-button/ui-filled-tonal-icon-button.d.ts +11 -0
  64. package/build/src/md/icon-button/ui-filled-tonal-icon-button.d.ts.map +1 -0
  65. package/build/src/md/icon-button/ui-filled-tonal-icon-button.js +28 -0
  66. package/build/src/md/icon-button/ui-filled-tonal-icon-button.js.map +1 -0
  67. package/build/src/md/icon-button/ui-icon-button.d.ts.map +1 -1
  68. package/build/src/md/icon-button/ui-icon-button.js +3 -2
  69. package/build/src/md/icon-button/ui-icon-button.js.map +1 -1
  70. package/build/src/md/icon-button/ui-outlined-icon-button.d.ts +11 -0
  71. package/build/src/md/icon-button/ui-outlined-icon-button.d.ts.map +1 -0
  72. package/build/src/md/icon-button/ui-outlined-icon-button.js +28 -0
  73. package/build/src/md/icon-button/ui-outlined-icon-button.js.map +1 -0
  74. package/build/src/md/icons/internals/Icon.d.ts +1 -0
  75. package/build/src/md/icons/internals/Icon.d.ts.map +1 -1
  76. package/build/src/md/icons/internals/Icon.js +13 -0
  77. package/build/src/md/icons/internals/Icon.js.map +1 -1
  78. package/build/src/md/icons/internals/Icon.styles.d.ts.map +1 -1
  79. package/build/src/md/icons/internals/Icon.styles.js +31 -2
  80. package/build/src/md/icons/internals/Icon.styles.js.map +1 -1
  81. package/build/src/md/list/internals/ListItem.d.ts +4 -3
  82. package/build/src/md/list/internals/ListItem.d.ts.map +1 -1
  83. package/build/src/md/list/internals/ListItem.js +55 -15
  84. package/build/src/md/list/internals/ListItem.js.map +1 -1
  85. package/build/src/md/list/internals/ListItem.styles.d.ts.map +1 -1
  86. package/build/src/md/list/internals/ListItem.styles.js +6 -2
  87. package/build/src/md/list/internals/ListItem.styles.js.map +1 -1
  88. package/build/src/md/ripple/internals/ripple.d.ts +2 -1
  89. package/build/src/md/ripple/internals/ripple.d.ts.map +1 -1
  90. package/build/src/md/ripple/internals/ripple.js +42 -12
  91. package/build/src/md/ripple/internals/ripple.js.map +1 -1
  92. package/build/src/md/segmented-button/internals/SegmentedButton.d.ts +1 -1
  93. package/build/src/md/segmented-button/internals/SegmentedButton.d.ts.map +1 -1
  94. package/build/src/md/segmented-button/internals/SegmentedButton.js +1 -1
  95. package/build/src/md/segmented-button/internals/SegmentedButton.js.map +1 -1
  96. package/demo/md/buttons/{button.html → index.html} +1 -1
  97. package/demo/md/{inputs/checkbox.html → checkbox/index.html} +1 -1
  98. package/demo/md/{list/dropdown-list.html → dropdown-list/index.html} +1 -1
  99. package/demo/md/{buttons/icon-button.html → icon-button/index.html} +5 -1
  100. package/demo/md/icon-button/index.ts +236 -0
  101. package/demo/md/index.html +36 -29
  102. package/demo/md/listbox/listbox.html +31 -0
  103. package/demo/md/listbox/listbox.ts +27 -0
  104. package/demo/md/{buttons/segmented-buttons.html → segmented-button/index.html} +1 -1
  105. package/package.json +1 -1
  106. package/src/md/UiElement.ts +8 -0
  107. package/src/md/button/ui-elevated-button.ts +1 -1
  108. package/src/md/button/ui-filled-button.ts +1 -1
  109. package/src/md/button/ui-filled-tonal-button.ts +3 -3
  110. package/src/md/button/ui-outlined-button.ts +1 -1
  111. package/src/md/button/ui-text-button.ts +1 -1
  112. package/src/md/checkbox/internals/Checkbox.styles.ts +55 -216
  113. package/src/md/checkbox/internals/CheckboxElement.ts +39 -26
  114. package/src/md/checkbox/internals/CheckedElement.ts +1 -0
  115. package/src/md/dropdown-list/internals/UiDropdownList.ts +60 -21
  116. package/src/md/icon-button/internals/IconButton.ts +29 -46
  117. package/src/md/icon-button/internals/base.styles.ts +93 -0
  118. package/src/md/icon-button/internals/filled-tonal.styles.ts +30 -0
  119. package/src/md/icon-button/internals/filled.styles.ts +36 -0
  120. package/src/md/icon-button/internals/outlined.styles.ts +31 -0
  121. package/src/md/icon-button/internals/standard.styles.ts +18 -0
  122. package/src/md/icon-button/ui-filled-icon-button.ts +16 -0
  123. package/src/md/icon-button/ui-filled-tonal-icon-button.ts +16 -0
  124. package/src/md/icon-button/ui-icon-button.ts +3 -2
  125. package/src/md/icon-button/ui-outlined-icon-button.ts +16 -0
  126. package/src/md/icons/internals/Icon.styles.ts +31 -2
  127. package/src/md/icons/internals/Icon.ts +14 -0
  128. package/src/md/list/internals/ListItem.styles.ts +6 -2
  129. package/src/md/list/internals/ListItem.ts +51 -18
  130. package/src/md/ripple/internals/ripple.ts +47 -13
  131. package/src/md/segmented-button/internals/SegmentedButton.ts +2 -2
  132. package/test/ui/button/UiIconButton.test.ts +1 -8
  133. package/build/src/md/icon-button/internals/IconButton.styles.d.ts.map +0 -1
  134. package/build/src/md/icon-button/internals/IconButton.styles.js +0 -614
  135. package/build/src/md/icon-button/internals/IconButton.styles.js.map +0 -1
  136. package/demo/md/buttons/icon-button.ts +0 -184
  137. package/src/md/icon-button/internals/IconButton.styles.ts +0 -614
  138. /package/demo/md/buttons/{button.ts → index.ts} +0 -0
  139. /package/demo/md/{inputs/checkbox.ts → checkbox/index.ts} +0 -0
  140. /package/demo/md/{list/dropdown-list.ts → dropdown-list/index.ts} +0 -0
  141. /package/demo/md/{buttons/segmented-buttons.ts → segmented-button/index.ts} +0 -0
@@ -26,7 +26,7 @@ export default class UiRipple extends LitElement {
26
26
  protected rippleSize: string;
27
27
  protected rippleScale: string;
28
28
  protected initialSize: number;
29
- protected pressAnimationSignal: import("../../motion/animation.js").AnimationSignal;
29
+ private rippleStartEvent?;
30
30
  protected growAnimation: Animation | null;
31
31
  protected delayedEndPressHandle: number | null;
32
32
  protected render(): TemplateResult;
@@ -41,6 +41,7 @@ export default class UiRipple extends LitElement {
41
41
  endPoint: IPoint;
42
42
  };
43
43
  protected startPressAnimation(positionEvent?: Event | null): void;
44
+ private endPressAnimation;
44
45
  beginHover(hoverEvent?: Event): void;
45
46
  endHover():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OAAO,CAAC,gBAAgB,CAAC,CAAc;IAIvC,SAAS,CAAC,aAAa,EAAE,SAAS,GAAG,IAAI,CAAO;IAEhD,SAAS,CAAC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAO;cAElC,MAAM,IAAI,cAAc;IAI3C,mBAAmB;IACnB,SAAS,CAAC,sBAAsB,IAAI,SAAS;cAS1B,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IASnE,SAAS,CAAC,aAAa,IAAI,OAAO;IAIlC,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAqBrC,SAAS,CAAC,+BAA+B,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAS7E,SAAS,CAAC,yBAAyB,CAAC,aAAa,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IA2B3G,SAAS,CAAC,mBAAmB,CAAC,aAAa,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;YA2CnD,iBAAiB;IA6B/B,UAAU,CAAC,UAAU,CAAC,EAAE,KAAK,GAAG,IAAI;IAMpC,QAAQ,IAAI,IAAI;IAIhB,UAAU,IAAI,IAAI;IAIlB,QAAQ,IAAI,IAAI;IAIhB,UAAU,CAAC,aAAa,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;IAU9C,QAAQ,IAAI,IAAI;CAYjB"}
@@ -7,9 +7,9 @@ import { __esDecorate, __runInitializers } from "tslib";
7
7
  import { html, LitElement } from 'lit';
8
8
  import { property, query, state } from 'lit/decorators.js';
9
9
  import { classMap } from 'lit/directives/class-map.js';
10
- import { createAnimationSignal, Easing } from '../../motion/animation.js';
10
+ import { Easing } from '../../motion/animation.js';
11
11
  const PRESS_GROW_MS = 450;
12
- const MINIMUM_PRESS_MS = 225;
12
+ const MINIMUM_PRESS_MS = 80;
13
13
  const INITIAL_ORIGIN_SCALE = 0.2;
14
14
  const PADDING = 10;
15
15
  const SOFT_EDGE_MINIMUM_SIZE = 75;
@@ -87,7 +87,8 @@ let UiRipple = (() => {
87
87
  rippleSize = (__runInitializers(this, _pressed_extraInitializers), '');
88
88
  rippleScale = '';
89
89
  initialSize = 0;
90
- pressAnimationSignal = createAnimationSignal();
90
+ rippleStartEvent;
91
+ // protected pressAnimationSignal = createAnimationSignal()
91
92
  growAnimation = null;
92
93
  delayedEndPressHandle = null;
93
94
  render() {
@@ -166,11 +167,13 @@ let UiRipple = (() => {
166
167
  if (!mdRoot) {
167
168
  return;
168
169
  }
170
+ this.pressed = true;
171
+ this.growAnimation?.cancel();
169
172
  this.determineRippleSize();
170
173
  const { startPoint, endPoint } = this.getTranslationCoordinates(positionEvent);
171
174
  const translateStart = `${startPoint.x}px, ${startPoint.y}px`;
172
175
  const translateEnd = `${endPoint.x}px, ${endPoint.y}px`;
173
- const signal = this.pressAnimationSignal.start();
176
+ // const signal = this.pressAnimationSignal.start()
174
177
  const growAnimation = mdRoot.animate({
175
178
  top: [0, 0],
176
179
  left: [0, 0],
@@ -183,16 +186,41 @@ let UiRipple = (() => {
183
186
  easing: Easing.STANDARD,
184
187
  fill: ANIMATION_FILL,
185
188
  });
186
- growAnimation.addEventListener('finish', () => {
187
- this.pressAnimationSignal.finish();
188
- this.growAnimation = null;
189
- });
190
- signal.addEventListener('abort', () => {
191
- growAnimation.cancel();
192
- this.growAnimation = null;
193
- });
189
+ // growAnimation.addEventListener('finish', () => {
190
+ // this.pressAnimationSignal.finish()
191
+ // this.growAnimation = null
192
+ // })
193
+ // signal.addEventListener('abort', () => {
194
+ // growAnimation.cancel()
195
+ // this.growAnimation = null
196
+ // })
194
197
  this.growAnimation = growAnimation;
195
198
  }
199
+ async endPressAnimation() {
200
+ this.rippleStartEvent = undefined;
201
+ // this.state = State.INACTIVE
202
+ const animation = this.growAnimation;
203
+ let pressAnimationPlayState = Infinity;
204
+ if (typeof animation?.currentTime === 'number') {
205
+ pressAnimationPlayState = animation.currentTime;
206
+ }
207
+ else if (animation?.currentTime) {
208
+ pressAnimationPlayState = animation.currentTime.to('ms').value;
209
+ }
210
+ if (pressAnimationPlayState >= MINIMUM_PRESS_MS) {
211
+ this.pressed = false;
212
+ return;
213
+ }
214
+ await new Promise((resolve) => {
215
+ setTimeout(resolve, MINIMUM_PRESS_MS - pressAnimationPlayState);
216
+ });
217
+ if (this.growAnimation !== animation) {
218
+ // A new press animation was started. The old animation was canceled and
219
+ // should not finish the pressed state.
220
+ return;
221
+ }
222
+ this.pressed = false;
223
+ }
196
224
  beginHover(hoverEvent) {
197
225
  if (hoverEvent?.pointerType !== 'touch') {
198
226
  this.hovered = true;
@@ -209,6 +237,7 @@ let UiRipple = (() => {
209
237
  }
210
238
  beginPress(positionEvent) {
211
239
  this.pressed = true;
240
+ this.rippleStartEvent = positionEvent;
212
241
  if (this.delayedEndPressHandle !== null) {
213
242
  clearTimeout(this.delayedEndPressHandle);
214
243
  this.delayedEndPressHandle = null;
@@ -226,6 +255,7 @@ let UiRipple = (() => {
226
255
  this.delayedEndPressHandle = null;
227
256
  }, MINIMUM_PRESS_MS - pressAnimationPlayState);
228
257
  }
258
+ this.endPressAnimation();
229
259
  }
230
260
  };
231
261
  })();
@@ -1 +1 @@
1
- {"version":3,"file":"ripple.js","sourceRoot":"","sources":["../../../../../src/md/ripple/internals/ripple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkC,MAAM,KAAK,CAAA;AACtE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAEzE,MAAM,aAAa,GAAG,GAAG,CAAA;AACzB,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAC5B,MAAM,oBAAoB,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K,CAAA;QACtB,CAAC;QAED,UAAU,CAAC,aAA4B;YACrC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YACnB,IAAI,IAAI,CAAC,qBAAqB,KAAK,IAAI,EAAE,CAAC;gBACxC,YAAY,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;gBACxC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAA;YACnC,CAAC;YACD,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAA;QACzC,CAAC;QAED,QAAQ;YACN,MAAM,uBAAuB,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,IAAI,QAAQ,CAAW,CAAA;YACvF,IAAI,uBAAuB,IAAI,gBAAgB,EAAE,CAAC;gBAChD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;YACtB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,qBAAqB,GAAG,UAAU,CAAC,GAAG,EAAE;oBAC3C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;oBACpB,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAA;gBACnC,CAAC,EAAE,gBAAgB,GAAG,uBAAuB,CAAsB,CAAA;YACrE,CAAC;QACH,CAAC;;;AAtMH,wBAuMC","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'\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\ninterface IPoint {\n x: number\n y: number\n}\n\nexport default class UiRipple extends LitElement {\n @query('.surface') accessor mdRoot!: HTMLElement\n\n /**\n * @attribute\n */\n @property({ type: Boolean }) accessor unbounded = false\n\n /**\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor disabled = false\n\n @state() protected accessor hovered = false\n\n @state() protected accessor focused = false\n\n @state() protected accessor pressed = false\n\n get isPressed(): boolean {\n return this.pressed\n }\n\n protected rippleSize = ''\n\n protected rippleScale = ''\n\n protected initialSize = 0\n\n protected pressAnimationSignal = createAnimationSignal()\n\n protected growAnimation: Animation | null = null\n\n protected delayedEndPressHandle: number | null = null\n\n protected override render(): TemplateResult {\n return html`<div class=\"surface ${classMap(this.getRenderRippleClasses())}\"></div>`\n }\n\n /** @soyTemplate */\n protected getRenderRippleClasses(): ClassInfo {\n return {\n hovered: this.hovered,\n focused: this.focused,\n pressed: this.pressed,\n unbounded: this.unbounded,\n }\n }\n\n protected override update(changedProps: PropertyValues<this>): void {\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(): DOMRect {\n return (this.parentElement ?? this).getBoundingClientRect()\n }\n\n protected determineRippleSize(): void {\n const { height, width } = this.getDimensions()\n const maxDim = Math.max(height, width)\n const softEdgeSize = Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDim, SOFT_EDGE_MINIMUM_SIZE)\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 % 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): IPoint {\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): { startPoint: IPoint; endPoint: IPoint } {\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): void {\n const { mdRoot } = this\n if (!mdRoot) {\n return\n }\n\n this.determineRippleSize()\n const { startPoint, endPoint } = 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 = 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: [`translate(${translateStart}) scale(1)`, `translate(${translateEnd}) scale(${this.rippleScale})`],\n },\n {\n pseudoElement: PRESS_PSEUDO,\n duration: PRESS_GROW_MS,\n easing: Easing.STANDARD,\n fill: ANIMATION_FILL,\n }\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 beginHover(hoverEvent?: Event): void {\n if ((hoverEvent as PointerEvent)?.pointerType !== 'touch') {\n this.hovered = true\n }\n }\n\n endHover(): void {\n this.hovered = false\n }\n\n beginFocus(): void {\n this.focused = true\n }\n\n endFocus(): void {\n this.focused = false\n }\n\n beginPress(positionEvent?: Event | null): void {\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(): void {\n const pressAnimationPlayState = (this.growAnimation?.currentTime ?? Infinity) as number\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) as unknown as number\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ripple.js","sourceRoot":"","sources":["../../../../../src/md/ripple/internals/ripple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkC,MAAM,KAAK,CAAA;AACtE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAElD,MAAM,aAAa,GAAG,GAAG,CAAA;AACzB,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAC3B,MAAM,oBAAoB,GAAG,GAAG,CAAA;AAChC,MAAM,OAAO,GAAG,EAAE,CAAA;AAClB,MAAM,sBAAsB,GAAG,EAAE,CAAA;AACjC,MAAM,yBAAyB,GAAG,IAAI,CAAA;AACtC,MAAM,YAAY,GAAG,SAAS,CAAA;AAC9B,MAAM,cAAc,GAAG,UAAU,CAAA;;sBAOK,UAAU;;;;;;;;;;;;;;;;;;;iBAA3B,QAAS,SAAQ,WAAU;;;kCAC7C,KAAK,CAAC,UAAU,CAAC;qCAKjB,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oCAK3B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAA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AC;gBAC1D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YACrB,CAAC;QACH,CAAC;QAED,QAAQ;YACN,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACtB,CAAC;QAED,UAAU;YACR,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACrB,CAAC;QAED,QAAQ;YACN,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACtB,CAAC;QAED,UAAU,CAAC,aAA4B;YACrC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YACnB,IAAI,CAAC,gBAAgB,GAAG,aAAa,CAAA;YACrC,IAAI,IAAI,CAAC,qBAAqB,KAAK,IAAI,EAAE,CAAC;gBACxC,YAAY,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;gBACxC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAA;YACnC,CAAC;YACD,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAA;QACzC,CAAC;QAED,QAAQ;YACN,MAAM,uBAAuB,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,IAAI,QAAQ,CAAW,CAAA;YACvF,IAAI,uBAAuB,IAAI,gBAAgB,EAAE,CAAC;gBAChD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;YACtB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,qBAAqB,GAAG,UAAU,CAAC,GAAG,EAAE;oBAC3C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;oBACpB,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAA;gBACnC,CAAC,EAAE,gBAAgB,GAAG,uBAAuB,CAAsB,CAAA;YACrE,CAAC;YACD,IAAI,CAAC,iBAAiB,EAAE,CAAA;QAC1B,CAAC;;;AAxOH,wBAyOC","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'\nimport { Easing } from '../../motion/animation.js'\n\nconst PRESS_GROW_MS = 450\nconst MINIMUM_PRESS_MS = 80\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\ninterface IPoint {\n x: number\n y: number\n}\n\nexport default class UiRipple extends LitElement {\n @query('.surface') accessor mdRoot!: HTMLElement\n\n /**\n * @attribute\n */\n @property({ type: Boolean }) accessor unbounded = false\n\n /**\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor disabled = false\n\n @state() protected accessor hovered = false\n\n @state() protected accessor focused = false\n\n @state() protected accessor pressed = false\n\n get isPressed(): boolean {\n return this.pressed\n }\n\n protected rippleSize = ''\n\n protected rippleScale = ''\n\n protected initialSize = 0\n\n private rippleStartEvent?: Event | null\n\n // protected pressAnimationSignal = createAnimationSignal()\n\n protected growAnimation: Animation | null = null\n\n protected delayedEndPressHandle: number | null = null\n\n protected override render(): TemplateResult {\n return html`<div class=\"surface ${classMap(this.getRenderRippleClasses())}\"></div>`\n }\n\n /** @soyTemplate */\n protected getRenderRippleClasses(): ClassInfo {\n return {\n hovered: this.hovered,\n focused: this.focused,\n pressed: this.pressed,\n unbounded: this.unbounded,\n }\n }\n\n protected override update(changedProps: PropertyValues<this>): void {\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(): DOMRect {\n return (this.parentElement ?? this).getBoundingClientRect()\n }\n\n protected determineRippleSize(): void {\n const { height, width } = this.getDimensions()\n const maxDim = Math.max(height, width)\n const softEdgeSize = Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDim, SOFT_EDGE_MINIMUM_SIZE)\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 % 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): IPoint {\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): { startPoint: IPoint; endPoint: IPoint } {\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): void {\n const { mdRoot } = this\n if (!mdRoot) {\n return\n }\n this.pressed = true\n this.growAnimation?.cancel()\n this.determineRippleSize()\n const { startPoint, endPoint } = 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 = 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: [`translate(${translateStart}) scale(1)`, `translate(${translateEnd}) scale(${this.rippleScale})`],\n },\n {\n pseudoElement: PRESS_PSEUDO,\n duration: PRESS_GROW_MS,\n easing: Easing.STANDARD,\n fill: ANIMATION_FILL,\n }\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 private async endPressAnimation() {\n this.rippleStartEvent = undefined\n // this.state = State.INACTIVE\n const animation = this.growAnimation\n let pressAnimationPlayState = Infinity\n if (typeof animation?.currentTime === 'number') {\n pressAnimationPlayState = animation.currentTime\n } else if (animation?.currentTime) {\n pressAnimationPlayState = animation.currentTime.to('ms').value\n }\n\n if (pressAnimationPlayState >= MINIMUM_PRESS_MS) {\n this.pressed = false\n return\n }\n\n await new Promise((resolve) => {\n setTimeout(resolve, MINIMUM_PRESS_MS - pressAnimationPlayState)\n })\n\n if (this.growAnimation !== animation) {\n // A new press animation was started. The old animation was canceled and\n // should not finish the pressed state.\n return\n }\n\n this.pressed = false\n }\n\n beginHover(hoverEvent?: Event): void {\n if ((hoverEvent as PointerEvent)?.pointerType !== 'touch') {\n this.hovered = true\n }\n }\n\n endHover(): void {\n this.hovered = false\n }\n\n beginFocus(): void {\n this.focused = true\n }\n\n endFocus(): void {\n this.focused = false\n }\n\n beginPress(positionEvent?: Event | null): void {\n this.pressed = true\n this.rippleStartEvent = positionEvent\n if (this.delayedEndPressHandle !== null) {\n clearTimeout(this.delayedEndPressHandle)\n this.delayedEndPressHandle = null\n }\n this.startPressAnimation(positionEvent)\n }\n\n endPress(): void {\n const pressAnimationPlayState = (this.growAnimation?.currentTime ?? Infinity) as number\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) as unknown as number\n }\n this.endPressAnimation()\n }\n}\n"]}
@@ -26,7 +26,7 @@ export default class SegmentedButton extends UiElement {
26
26
  connectedCallback(): void;
27
27
  beginPress(options: BeginPressConfig): void;
28
28
  endPress(options: EndPressConfig): void;
29
- protected handlePointerEnter(e: PointerEvent): void;
29
+ handlePointerEnter(e: PointerEvent): void;
30
30
  handlePointerLeave(e: PointerEvent): void;
31
31
  protected handleIconSlotChange(): void;
32
32
  protected render(): TemplateResult;
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedButton.d.ts","sourceRoot":"","sources":["../../../../../src/md/segmented-button/internals/SegmentedButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,cAAc,EAAE,MAAM,KAAK,CAAA;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAA;AAC3F,OAAO,QAAQ,MAAM,kCAAkC,CAAA;AAIvD,OAAO,2BAA2B,CAAA;AAElC;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,SAAS;IAChC,QAAQ,CAAC,MAAM,EAAG,QAAQ,CAAA;IAE9C;;;OAGG;IAC0B,QAAQ,CAAC,QAAQ,UAAQ;IAEE,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAG,WAAW,EAAE,CAAA;IAEvG,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;;OAGG;IACH,IACI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAI1B;;IAgBQ,iBAAiB,IAAI,IAAI;IAUzB,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAK3C,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAShD,SAAS,CAAC,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAI1C,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAKlD,SAAS,CAAC,oBAAoB,IAAI,IAAI;cAInB,MAAM,IAAI,cAAc;IAmB3C,SAAS,CAAC,cAAc,IA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,QAAO,cAAc,CAG1C;CACF"}
@@ -60,7 +60,6 @@ let SegmentedButton = (() => {
60
60
  }
61
61
  constructor() {
62
62
  super();
63
- this.addEventListener('pointerenter', this.handlePointerEnter.bind(this));
64
63
  this.actionController.cancelKeyboardEvents = true;
65
64
  this.addEventListener('keydown', this.handleKeyDown.bind(this));
66
65
  this.addEventListener('keyup', this.handleKeyUp.bind(this));
@@ -68,6 +67,7 @@ let SegmentedButton = (() => {
68
67
  this.addEventListener('pointerdown', this.handlePointerDown.bind(this));
69
68
  this.addEventListener('pointerup', this.handlePointerUp.bind(this));
70
69
  this.addEventListener('pointercancel', this.handlePointerCancel.bind(this));
70
+ this.addEventListener('pointerenter', this.handlePointerEnter.bind(this));
71
71
  this.addEventListener('pointerleave', this.handlePointerLeave.bind(this));
72
72
  this.addEventListener('contextmenu', this.handleContextMenu.bind(this));
73
73
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedButton.js","sourceRoot":"","sources":["../../../../../src/md/segmented-button/internals/SegmentedButton.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,2BAA2B,CAAA;;sBAOW,SAAS;;;;;;;;;;;;iBAAjC,eAAgB,SAAQ,WAAS;;;kCACnD,KAAK,CAAC,WAAW,CAAC;oCAMlB,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAE3B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YACD,OAAO,IAAI,CAAA,gBAAgB,QAAQ,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,iBAAiB,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE,SAAS,CAAA;QAC5G,CAAC;QAES,iBAAiB;YACzB,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;YAC7B,MAAM,OAAO,GAAc;gBACzB,cAAc,EAAE,IAAI;gBACpB,WAAW,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;gBAClC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ;aAC1B,CAAA;YACD,OAAO,IAAI,CAAA;oBACK,QAAQ,CAAC,OAAO,CAAC,oCAAoC,IAAI,CAAC,oBAAoB;KAC7F,CAAA;QACH,CAAC;QAES,aAAa;YACrB,MAAM,WAAW,GAAG,QAAQ,CAAC;gBAC3B,YAAY,EAAE,IAAI;gBAClB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ;aAC3B,CAAC,CAAA;YACF,OAAO,IAAI,CAAA,gBAAgB,WAAW,yBAAyB,KAAK,SAAS,CAAA;QAC/E,CAAC;QAES,YAAY,8DAAG,GAAmB,EAAE;YAC5C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;YACzB,OAAO,IAAI,CAAA,wCAAwC,QAAQ,gBAAgB,CAAA;QAC7E,CAAC,EAAA;;;AArIH;;;;GAIG;AACH,+BAiIC","sourcesContent":["import { html, TemplateResult } from 'lit'\nimport { property, query, queryAssignedElements } from 'lit/decorators.js'\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js'\nimport { UiElement } from '../../UiElement.js'\nimport { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport UiRipple from '../../ripple/internals/ripple.js'\nimport { ripple } from '../../effects/rippleDirective.js'\nimport { check } from '../../icons/Icons.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport '../../ripple/ui-ripple.js'\n\n/**\n * @fires trigger - When a button is triggered.\n * @slot - Default slot for the label\n * @slot icon - A slot to render an icon.\n */\nexport default class SegmentedButton extends UiElement {\n @query('ui-ripple') accessor ripple!: UiRipple\n\n /**\n * Whether the button is selected.\n * @attribute\n */\n @property({ type: Boolean }) accessor selected = false\n\n @queryAssignedElements({ flatten: true, slot: 'icon' }) protected accessor leadingIcons!: HTMLElement[]\n\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this)\n setDisabled(this, value)\n this.requestUpdate('disabled', old)\n }\n\n constructor() {\n super()\n this.addEventListener('pointerenter', this.handlePointerEnter.bind(this))\n this.actionController.cancelKeyboardEvents = true\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\n this.addEventListener('click', this.handleClick.bind(this))\n this.addEventListener('pointerdown', this.handlePointerDown.bind(this))\n this.addEventListener('pointerup', this.handlePointerUp.bind(this))\n this.addEventListener('pointercancel', this.handlePointerCancel.bind(this))\n this.addEventListener('pointerleave', this.handlePointerLeave.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'button')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.ripple.beginPress(options.positionEvent)\n }\n\n override endPress(options: EndPressConfig): void {\n super.endPress(options)\n this.ripple.endPress()\n\n if (!options.cancelled) {\n this.dispatchEvent(new Event('trigger', { bubbles: true, composed: true }))\n }\n }\n\n protected handlePointerEnter(e: PointerEvent): void {\n this.ripple.beginHover(e)\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n this.ripple.endHover()\n }\n\n protected handleIconSlotChange(): void {\n this.requestUpdate()\n }\n\n protected override render(): TemplateResult {\n const { pressed = false, selected = false } = this\n const surfaceClasses = classMap({\n surface: true,\n pressed,\n selected,\n })\n\n return html`\n <div class=\"${surfaceClasses}\" ${ripple(() => this.ripple)}>\n ${this.renderRipple()}\n <div class=\"content\">\n ${this.leadingContent()}\n <slot></slot>\n </div>\n </div>\n `\n }\n\n protected leadingContent(): TemplateResult {\n const { leadingIcons } = this\n const classes: ClassInfo = {\n leading: true,\n visible: !!this.selected || !!leadingIcons.length,\n }\n return html` <div class=\"${classMap(classes)}\">${this.renderLeadingIcon()} ${this.renderChecked()}</div> `\n }\n\n protected renderLeadingIcon(): TemplateResult {\n const { leadingIcons } = this\n const classes: ClassInfo = {\n 'leading-icon': true,\n 'with-icon': !!leadingIcons.length,\n 'hidden': !!this.selected,\n }\n return html`\n <div class=\"${classMap(classes)}\"><slot name=\"icon\" @slotchange=\"${this.handleIconSlotChange}\"></slot></div>\n `\n }\n\n protected renderChecked(): TemplateResult {\n const iconClasses = classMap({\n 'check-mark': true,\n 'checked': !!this.selected,\n })\n return html`<span class=\"${iconClasses}\" role=\"presentation\">${check}</span>`\n }\n\n protected renderRipple = (): TemplateResult => {\n const { disabled } = this\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${disabled}\"></ui-ripple>`\n }\n}\n"]}
1
+ {"version":3,"file":"SegmentedButton.js","sourceRoot":"","sources":["../../../../../src/md/segmented-button/internals/SegmentedButton.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAs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I,CAAC,cAAc,EAAE;;;;KAI5B,CAAA;QACH,CAAC;QAES,cAAc;YACtB,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;YAC7B,MAAM,OAAO,GAAc;gBACzB,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,YAAY,CAAC,MAAM;aAClD,CAAA;YACD,OAAO,IAAI,CAAA,gBAAgB,QAAQ,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,iBAAiB,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE,SAAS,CAAA;QAC5G,CAAC;QAES,iBAAiB;YACzB,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;YAC7B,MAAM,OAAO,GAAc;gBACzB,cAAc,EAAE,IAAI;gBACpB,WAAW,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;gBAClC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ;aAC1B,CAAA;YACD,OAAO,IAAI,CAAA;oBACK,QAAQ,CAAC,OAAO,CAAC,oCAAoC,IAAI,CAAC,oBAAoB;KAC7F,CAAA;QACH,CAAC;QAES,aAAa;YACrB,MAAM,WAAW,GAAG,QAAQ,CAAC;gBAC3B,YAAY,EAAE,IAAI;gBAClB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ;aAC3B,CAAC,CAAA;YACF,OAAO,IAAI,CAAA,gBAAgB,WAAW,yBAAyB,KAAK,SAAS,CAAA;QAC/E,CAAC;QAES,YAAY,8DAAG,GAAmB,EAAE;YAC5C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;YACzB,OAAO,IAAI,CAAA,wCAAwC,QAAQ,gBAAgB,CAAA;QAC7E,CAAC,EAAA;;;AArIH;;;;GAIG;AACH,+BAiIC","sourcesContent":["import { html, TemplateResult } from 'lit'\nimport { property, query, queryAssignedElements } from 'lit/decorators.js'\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js'\nimport { UiElement } from '../../UiElement.js'\nimport { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport UiRipple from '../../ripple/internals/ripple.js'\nimport { ripple } from '../../effects/rippleDirective.js'\nimport { check } from '../../icons/Icons.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport '../../ripple/ui-ripple.js'\n\n/**\n * @fires trigger - When a button is triggered.\n * @slot - Default slot for the label\n * @slot icon - A slot to render an icon.\n */\nexport default class SegmentedButton extends UiElement {\n @query('ui-ripple') accessor ripple!: UiRipple\n\n /**\n * Whether the button is selected.\n * @attribute\n */\n @property({ type: Boolean }) accessor selected = false\n\n @queryAssignedElements({ flatten: true, slot: 'icon' }) protected accessor leadingIcons!: HTMLElement[]\n\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this)\n setDisabled(this, value)\n this.requestUpdate('disabled', old)\n }\n\n constructor() {\n super()\n this.actionController.cancelKeyboardEvents = true\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\n this.addEventListener('click', this.handleClick.bind(this))\n this.addEventListener('pointerdown', this.handlePointerDown.bind(this))\n this.addEventListener('pointerup', this.handlePointerUp.bind(this))\n this.addEventListener('pointercancel', this.handlePointerCancel.bind(this))\n this.addEventListener('pointerenter', this.handlePointerEnter.bind(this))\n this.addEventListener('pointerleave', this.handlePointerLeave.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'button')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.ripple.beginPress(options.positionEvent)\n }\n\n override endPress(options: EndPressConfig): void {\n super.endPress(options)\n this.ripple.endPress()\n\n if (!options.cancelled) {\n this.dispatchEvent(new Event('trigger', { bubbles: true, composed: true }))\n }\n }\n\n override handlePointerEnter(e: PointerEvent): void {\n this.ripple.beginHover(e)\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n this.ripple.endHover()\n }\n\n protected handleIconSlotChange(): void {\n this.requestUpdate()\n }\n\n protected override render(): TemplateResult {\n const { pressed = false, selected = false } = this\n const surfaceClasses = classMap({\n surface: true,\n pressed,\n selected,\n })\n\n return html`\n <div class=\"${surfaceClasses}\" ${ripple(() => this.ripple)}>\n ${this.renderRipple()}\n <div class=\"content\">\n ${this.leadingContent()}\n <slot></slot>\n </div>\n </div>\n `\n }\n\n protected leadingContent(): TemplateResult {\n const { leadingIcons } = this\n const classes: ClassInfo = {\n leading: true,\n visible: !!this.selected || !!leadingIcons.length,\n }\n return html` <div class=\"${classMap(classes)}\">${this.renderLeadingIcon()} ${this.renderChecked()}</div> `\n }\n\n protected renderLeadingIcon(): TemplateResult {\n const { leadingIcons } = this\n const classes: ClassInfo = {\n 'leading-icon': true,\n 'with-icon': !!leadingIcons.length,\n 'hidden': !!this.selected,\n }\n return html`\n <div class=\"${classMap(classes)}\"><slot name=\"icon\" @slotchange=\"${this.handleIconSlotChange}\"></slot></div>\n `\n }\n\n protected renderChecked(): TemplateResult {\n const iconClasses = classMap({\n 'check-mark': true,\n 'checked': !!this.selected,\n })\n return html`<span class=\"${iconClasses}\" role=\"presentation\">${check}</span>`\n }\n\n protected renderRipple = (): TemplateResult => {\n const { disabled } = this\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${disabled}\"></ui-ripple>`\n }\n}\n"]}
@@ -18,6 +18,6 @@
18
18
  <body>
19
19
  <div id="app"></div>
20
20
 
21
- <script type="module" src="/.tmp/demo/md/buttons/button.js"></script>
21
+ <script type="module" src="/.tmp/demo/md/buttons/index.js"></script>
22
22
  </body>
23
23
  </html>
@@ -34,6 +34,6 @@
34
34
  <body>
35
35
  <div id="app"></div>
36
36
 
37
- <script type="module" src="/.tmp/demo/md/inputs/checkbox.js"></script>
37
+ <script type="module" src="/.tmp/demo/md/checkbox/index.js"></script>
38
38
  </body>
39
39
  </html>
@@ -26,6 +26,6 @@
26
26
  <body>
27
27
  <div id="app"></div>
28
28
 
29
- <script type="module" src="/.tmp/demo/md/list/dropdown-list.js"></script>
29
+ <script type="module" src="/.tmp/demo/md/dropdown-list/index.js"></script>
30
30
  </body>
31
31
  </html>
@@ -6,6 +6,10 @@
6
6
  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0">
7
7
  <title>UI icon button</title>
8
8
  <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
9
+ <link
10
+ rel="stylesheet"
11
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"
12
+ />
9
13
  <link href="../../../src/styles/m3/tokens.css" rel="stylesheet" type="text/css" />
10
14
  <link href="../../../src/styles/m3/theme.css" rel="stylesheet" type="text/css" />
11
15
  <style>
@@ -23,6 +27,6 @@
23
27
  <body>
24
28
  <div id="app"></div>
25
29
 
26
- <script type="module" src="/.tmp/demo/md/buttons/icon-button.js"></script>
30
+ <script type="module" src="/.tmp/demo/md/icon-button/index.js"></script>
27
31
  </body>
28
32
  </html>
@@ -0,0 +1,236 @@
1
+ import { html, TemplateResult } from 'lit'
2
+ import { DemoPage } from '../../../src/demo/DemoPage.js'
3
+ import IconButtonElement from '../../../src/md/icon-button/internals/IconButton.js'
4
+
5
+ import '../../../src/md/icon-button/ui-icon-button.js'
6
+ import '../../../src/md/icon-button/ui-filled-icon-button.js'
7
+ import '../../../src/md/icon-button/ui-filled-tonal-icon-button.js'
8
+ import '../../../src/md/icon-button/ui-outlined-icon-button.js'
9
+ import '../../../src/md/icons/ui-icon.js'
10
+
11
+ import '@material/web/iconbutton/icon-button.js'
12
+ import '@material/web/iconbutton/filled-icon-button.js'
13
+ import '@material/web/iconbutton/filled-tonal-icon-button.js'
14
+ import '@material/web/iconbutton/outlined-icon-button.js'
15
+ import '@material/web/icon/icon.js'
16
+
17
+ class ComponentDemoPage extends DemoPage {
18
+ override accessor componentName = 'API icon button'
19
+
20
+ _clickHandler(e: Event): void {
21
+ const button = e.target as IconButtonElement
22
+ console.log(`A ${button.localName} button was clicked.`)
23
+ }
24
+
25
+ _activeHandler(e: Event): void {
26
+ const button = e.target as IconButtonElement
27
+ console.log(`A ${button.localName} button was ${button.active ? 'activated' : 'deactivated'}`)
28
+ }
29
+
30
+ contentTemplate(): TemplateResult {
31
+ return html`
32
+ <a href="../">Back</a>
33
+ <section class="demo-section">
34
+ <h2 class="title-large">Filled icon button</h2>
35
+
36
+ <h3 class="title-small">UI icon button</h3>
37
+ <div class="demo-row icons-demo-row">
38
+ <ui-filled-icon-button
39
+ @click="${this._clickHandler}"
40
+ @active="${this._activeHandler}"
41
+ aria-label="Settings: standard filled button"
42
+ ><ui-icon>settings</ui-icon></ui-filled-icon-button
43
+ >
44
+ <ui-filled-icon-button
45
+ toggle
46
+ @click="${this._clickHandler}"
47
+ @active="${this._activeHandler}"
48
+ aria-label="Settings: toggle filled button"
49
+ ><ui-icon>settings</ui-icon></ui-filled-icon-button
50
+ >
51
+ <ui-filled-icon-button
52
+ toggle
53
+ active
54
+ @click="${this._clickHandler}"
55
+ @active="${this._activeHandler}"
56
+ aria-label="Settings: toggle, active filled button"
57
+ ><ui-icon>settings</ui-icon></ui-filled-icon-button
58
+ >
59
+ <ui-filled-icon-button
60
+ disabled
61
+ @click="${this._clickHandler}"
62
+ @active="${this._activeHandler}"
63
+ aria-label="Settings: disabled filled button"
64
+ ><ui-icon>settings</ui-icon></ui-filled-icon-button
65
+ >
66
+
67
+ <p class="label-large">No toggle</p>
68
+ <p class="label-large">Toggle (unselected)</p>
69
+ <p class="label-large">Toggle (selected)</p>
70
+ <p class="label-large">Disabled</p>
71
+ </div>
72
+
73
+ <h3 class="title-small">MD icon button (reference)</h3>
74
+ <div class="demo-row icons-demo-row">
75
+ <md-filled-icon-button><md-icon>settings</md-icon></md-filled-icon-button>
76
+ <md-filled-icon-button toggle><md-icon>settings</md-icon></md-filled-icon-button>
77
+ <md-filled-icon-button toggle selected><md-icon>settings</md-icon></md-filled-icon-button>
78
+ <md-filled-icon-button disabled><md-icon>settings</md-icon></md-filled-icon-button>
79
+ <p class="label-large">No toggle</p>
80
+ <p class="label-large">Toggle (unselected)</p>
81
+ <p class="label-large">Toggle (selected)</p>
82
+ <p class="label-large">Disabled</p>
83
+ </div>
84
+ </section>
85
+
86
+ <section class="demo-section">
87
+ <h2 class="title-large">Filled tonal icon button</h2>
88
+ <h3 class="title-small">UI icon button</h3>
89
+ <div class="demo-row icons-demo-row">
90
+ <ui-filled-tonal-icon-button
91
+ @click="${this._clickHandler}"
92
+ @active="${this._activeHandler}"
93
+ aria-label="Settings: standard filled button"
94
+ ><ui-icon>settings</ui-icon></ui-filled-tonal-icon-button
95
+ >
96
+ <ui-filled-tonal-icon-button
97
+ toggle
98
+ @click="${this._clickHandler}"
99
+ @active="${this._activeHandler}"
100
+ aria-label="Settings: toggle filled button"
101
+ ><ui-icon>settings</ui-icon></ui-filled-tonal-icon-button
102
+ >
103
+ <ui-filled-tonal-icon-button
104
+ toggle
105
+ active
106
+ @click="${this._clickHandler}"
107
+ @active="${this._activeHandler}"
108
+ aria-label="Settings: toggle, active filled button"
109
+ ><ui-icon>settings</ui-icon></ui-filled-tonal-icon-button
110
+ >
111
+ <ui-filled-tonal-icon-button
112
+ disabled
113
+ @click="${this._clickHandler}"
114
+ @active="${this._activeHandler}"
115
+ aria-label="Settings: disabled filled button"
116
+ ><ui-icon>settings</ui-icon></ui-filled-tonal-icon-button
117
+ >
118
+
119
+ <p class="label-large">No toggle</p>
120
+ <p class="label-large">Toggle (unselected)</p>
121
+ <p class="label-large">Toggle (selected)</p>
122
+ <p class="label-large">Disabled</p>
123
+ </div>
124
+
125
+ <h3 class="title-small">MD icon button (reference)</h3>
126
+ <div class="demo-row icons-demo-row">
127
+ <md-filled-tonal-icon-button><md-icon>settings</md-icon></md-filled-tonal-icon-button>
128
+ <md-filled-tonal-icon-button toggle><md-icon>settings</md-icon></md-filled-tonal-icon-button>
129
+ <md-filled-tonal-icon-button toggle selected><md-icon>settings</md-icon></md-filled-tonal-icon-button>
130
+ <md-filled-tonal-icon-button disabled><md-icon>settings</md-icon></md-filled-tonal-icon-button>
131
+ <p class="label-large">No toggle</p>
132
+ <p class="label-large">Toggle (unselected)</p>
133
+ <p class="label-large">Toggle (selected)</p>
134
+ <p class="label-large">Disabled</p>
135
+ </div>
136
+ </section>
137
+
138
+ <section class="demo-section">
139
+ <h2 class="title-large">Outlined icon button</h2>
140
+ <h3 class="title-small">UI icon button</h3>
141
+
142
+ <div class="demo-row icons-demo-row">
143
+ <ui-outlined-icon-button
144
+ @click="${this._clickHandler}"
145
+ @active="${this._activeHandler}"
146
+ aria-labelledby="iont"
147
+ ><ui-icon>settings</ui-icon></ui-outlined-icon-button
148
+ >
149
+ <ui-outlined-icon-button
150
+ toggle
151
+ @click="${this._clickHandler}"
152
+ @active="${this._activeHandler}"
153
+ aria-labelledby="iotu"
154
+ ><ui-icon>settings</ui-icon></ui-outlined-icon-button
155
+ >
156
+ <ui-outlined-icon-button
157
+ active
158
+ toggle
159
+ @click="${this._clickHandler}"
160
+ @active="${this._activeHandler}"
161
+ aria-labelledby="iots"
162
+ ><ui-icon>settings</ui-icon></ui-outlined-icon-button
163
+ >
164
+ <ui-outlined-icon-button
165
+ disabled
166
+ @click="${this._clickHandler}"
167
+ @active="${this._activeHandler}"
168
+ aria-labelledby="iod"
169
+ ><ui-icon>settings</ui-icon></ui-outlined-icon-button
170
+ >
171
+
172
+ <p class="label-large" id="iont">No toggle</p>
173
+ <p class="label-large" id="iotu">Toggle (unselected)</p>
174
+ <p class="label-large" id="iots">Toggle (selected)</p>
175
+ <p class="label-large" id="iod">Disabled</p>
176
+ </div>
177
+
178
+ <h3 class="title-small">MD icon button (reference)</h3>
179
+ <div class="demo-row icons-demo-row">
180
+ <md-outlined-icon-button><md-icon>settings</md-icon></md-outlined-icon-button>
181
+ <md-outlined-icon-button toggle><md-icon>settings</md-icon></md-outlined-icon-button>
182
+ <md-outlined-icon-button toggle selected><md-icon>settings</md-icon></md-outlined-icon-button>
183
+ <md-outlined-icon-button disabled><md-icon>settings</md-icon></md-outlined-icon-button>
184
+ <p class="label-large">No toggle</p>
185
+ <p class="label-large">Toggle (unselected)</p>
186
+ <p class="label-large">Toggle (selected)</p>
187
+ <p class="label-large">Disabled</p>
188
+ </div>
189
+ </section>
190
+
191
+ <section class="demo-section">
192
+ <h2 class="title-large">Standard icon button</h2>
193
+ <h3 class="title-small">UI icon button</h3>
194
+ <div class="demo-row icons-demo-row">
195
+ <ui-icon-button @click="${this._clickHandler}" @active="${this._activeHandler}" aria-labelledby="isnt"
196
+ ><ui-icon>settings</ui-icon></ui-icon-button
197
+ >
198
+ <ui-icon-button toggle @click="${this._clickHandler}" @active="${this._activeHandler}" aria-labelledby="istu"
199
+ ><ui-icon>settings</ui-icon></ui-icon-button
200
+ >
201
+ <ui-icon-button
202
+ toggle
203
+ active
204
+ @click="${this._clickHandler}"
205
+ @active="${this._activeHandler}"
206
+ aria-labelledby="ists"
207
+ ><ui-icon>settings</ui-icon></ui-icon-button
208
+ >
209
+ <ui-icon-button disabled @click="${this._clickHandler}" @active="${this._activeHandler}" aria-labelledby="isd"
210
+ ><ui-icon>settings</ui-icon></ui-icon-button
211
+ >
212
+
213
+ <p class="label-large" id="isnt">No toggle</p>
214
+ <p class="label-large" id="istu">Toggle (unselected)</p>
215
+ <p class="label-large" id="ists">Toggle (selected)</p>
216
+ <p class="label-large" id="isd">Disabled</p>
217
+ </div>
218
+
219
+ <h3 class="title-small">MD icon button (reference)</h3>
220
+ <div class="demo-row icons-demo-row">
221
+ <md-icon-button><md-icon>settings</md-icon></md-icon-button>
222
+ <md-icon-button toggle><md-icon>settings</md-icon></md-icon-button>
223
+ <md-icon-button toggle selected><md-icon>settings</md-icon></md-icon-button>
224
+ <md-icon-button disabled><md-icon>settings</md-icon></md-icon-button>
225
+ <p class="label-large">No toggle</p>
226
+ <p class="label-large">Toggle (unselected)</p>
227
+ <p class="label-large">Toggle (selected)</p>
228
+ <p class="label-large">Disabled</p>
229
+ </div>
230
+ </section>
231
+ `
232
+ }
233
+ }
234
+
235
+ const instance = new ComponentDemoPage()
236
+ instance.render()