@m3e/icon-button 1.1.1 → 1.1.3

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.
@@ -948,6 +948,24 @@
948
948
  }
949
949
  ]
950
950
  },
951
+ {
952
+ "kind": "method",
953
+ "name": "#handlePressedChange",
954
+ "privacy": "private",
955
+ "return": {
956
+ "type": {
957
+ "text": "void"
958
+ }
959
+ },
960
+ "parameters": [
961
+ {
962
+ "name": "pressed",
963
+ "type": {
964
+ "text": "boolean"
965
+ }
966
+ }
967
+ ]
968
+ },
951
969
  {
952
970
  "kind": "method",
953
971
  "name": "#handleClick",
@@ -984,6 +1002,29 @@
984
1002
  }
985
1003
  ]
986
1004
  },
1005
+ {
1006
+ "kind": "field",
1007
+ "name": "#keyPressed",
1008
+ "privacy": "private",
1009
+ "type": {
1010
+ "text": "boolean"
1011
+ },
1012
+ "default": "false",
1013
+ "inheritedFrom": {
1014
+ "name": "KeyboardClick",
1015
+ "module": "../core/src/shared/mixins/KeyboardClick.ts"
1016
+ }
1017
+ },
1018
+ {
1019
+ "kind": "field",
1020
+ "name": "#keyDownHandler",
1021
+ "privacy": "private",
1022
+ "readonly": true,
1023
+ "inheritedFrom": {
1024
+ "name": "KeyboardClick",
1025
+ "module": "../core/src/shared/mixins/KeyboardClick.ts"
1026
+ }
1027
+ },
987
1028
  {
988
1029
  "kind": "field",
989
1030
  "name": "#keyUpHandler",
@@ -994,6 +1035,38 @@
994
1035
  "module": "../core/src/shared/mixins/KeyboardClick.ts"
995
1036
  }
996
1037
  },
1038
+ {
1039
+ "kind": "field",
1040
+ "name": "#focusOutHandler",
1041
+ "privacy": "private",
1042
+ "readonly": true,
1043
+ "inheritedFrom": {
1044
+ "name": "KeyboardClick",
1045
+ "module": "../core/src/shared/mixins/KeyboardClick.ts"
1046
+ }
1047
+ },
1048
+ {
1049
+ "kind": "method",
1050
+ "name": "#handleKeyDown",
1051
+ "privacy": "private",
1052
+ "return": {
1053
+ "type": {
1054
+ "text": "void"
1055
+ }
1056
+ },
1057
+ "parameters": [
1058
+ {
1059
+ "name": "e",
1060
+ "type": {
1061
+ "text": "KeyboardEvent"
1062
+ }
1063
+ }
1064
+ ],
1065
+ "inheritedFrom": {
1066
+ "name": "KeyboardClick",
1067
+ "module": "../core/src/shared/mixins/KeyboardClick.ts"
1068
+ }
1069
+ },
997
1070
  {
998
1071
  "kind": "method",
999
1072
  "name": "#handleKeyUp",
@@ -3276,12 +3349,51 @@
3276
3349
  "description": "Mixin to augment an element with behavior emits a click event on keyboard events.",
3277
3350
  "name": "KeyboardClick",
3278
3351
  "members": [
3352
+ {
3353
+ "kind": "field",
3354
+ "name": "#keyPressed",
3355
+ "privacy": "private",
3356
+ "type": {
3357
+ "text": "boolean"
3358
+ },
3359
+ "default": "false"
3360
+ },
3361
+ {
3362
+ "kind": "field",
3363
+ "name": "#keyDownHandler",
3364
+ "privacy": "private",
3365
+ "readonly": true
3366
+ },
3279
3367
  {
3280
3368
  "kind": "field",
3281
3369
  "name": "#keyUpHandler",
3282
3370
  "privacy": "private",
3283
3371
  "readonly": true
3284
3372
  },
3373
+ {
3374
+ "kind": "field",
3375
+ "name": "#focusOutHandler",
3376
+ "privacy": "private",
3377
+ "readonly": true
3378
+ },
3379
+ {
3380
+ "kind": "method",
3381
+ "name": "#handleKeyDown",
3382
+ "privacy": "private",
3383
+ "return": {
3384
+ "type": {
3385
+ "text": "void"
3386
+ }
3387
+ },
3388
+ "parameters": [
3389
+ {
3390
+ "name": "e",
3391
+ "type": {
3392
+ "text": "KeyboardEvent"
3393
+ }
3394
+ }
3395
+ ]
3396
+ },
3285
3397
  {
3286
3398
  "kind": "method",
3287
3399
  "name": "#handleKeyUp",
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * See LICENSE file in the project root for full license text.
5
5
  */
6
6
  import { unsafeCSS, css, LitElement, nothing, html } from 'lit';
7
- import { DesignToken, KeyboardClick, LinkButton, FormSubmitter, Focusable, DisabledInteractive, Disabled, AttachInternals, Role, ResizeController, FocusController, PressedController, renderPseudoLink, debounce, hasAssignedNodes } from '@m3e/core';
7
+ import { DesignToken, KeyboardClick, LinkButton, FormSubmitter, Focusable, DisabledInteractive, Disabled, AttachInternals, Role, ResizeController, FocusController, PressedController, prefersReducedMotion, renderPseudoLink, debounce, hasAssignedNodes } from '@m3e/core';
8
8
 
9
9
  /******************************************************************************
10
10
  Copyright (c) Microsoft Corporation.
@@ -955,7 +955,7 @@ function iconButtonVariantStyle(variant) {
955
955
  */
956
956
  const IconButtonVariantStyle = [iconButtonVariantStyle("standard"), iconButtonVariantStyle("outlined"), iconButtonVariantStyle("filled"), iconButtonVariantStyle("tonal"), iconButtonVariantStyle("elevated"), css`:host([variant="outlined"]) .base { outline-style: solid; }`];
957
957
 
958
- var _M3eIconButtonElement_instances, _M3eIconButtonElement_clickHandler, _M3eIconButtonElement_updateButtonShape, _M3eIconButtonElement_handleClick, _M3eIconButtonElement_handleSelectedIconSlotChange;
958
+ var _M3eIconButtonElement_instances, _M3eIconButtonElement_clickHandler, _M3eIconButtonElement_updateButtonShape, _M3eIconButtonElement_handlePressedChange, _M3eIconButtonElement_handleClick, _M3eIconButtonElement_handleSelectedIconSlotChange;
959
959
  /**
960
960
  * An icon button users interact with to perform a supplementary action.
961
961
  *
@@ -1249,12 +1249,8 @@ let M3eIconButtonElement = class M3eIconButtonElement extends KeyboardClick(Link
1249
1249
  });
1250
1250
  new FocusController(this, {
1251
1251
  callback: focused => {
1252
- if (!this.disabledInteractive && this._base) {
1253
- if (focused) {
1254
- __classPrivateFieldGet(this, _M3eIconButtonElement_instances, "m", _M3eIconButtonElement_updateButtonShape).call(this);
1255
- } else if (!this.grouped) {
1256
- this._base?.style.removeProperty("--_button-shape");
1257
- }
1252
+ if (!this.disabledInteractive && !focused && !this.grouped) {
1253
+ this._base?.style.removeProperty("--_button-shape");
1258
1254
  }
1259
1255
  }
1260
1256
  });
@@ -1263,26 +1259,15 @@ let M3eIconButtonElement = class M3eIconButtonElement extends KeyboardClick(Link
1263
1259
  minPressedDuration: 150,
1264
1260
  callback: pressed => {
1265
1261
  if (!this.disabled && !this.disabledInteractive) {
1266
- this.classList.toggle("-pressed", pressed);
1267
- this.classList.toggle("-resting", !pressed);
1268
- const group = this.closest("m3e-button-group");
1269
- if (group) {
1270
- const clientWidth = this.getBoundingClientRect().width;
1271
- const buttons = [...group.querySelectorAll("m3e-button,m3e-icon-button")];
1272
- const index = buttons.indexOf(this);
1273
- for (let i = 0; i < buttons.length; i++) {
1274
- const button = buttons[i];
1275
- if (i === index - 1) {
1276
- button.style.setProperty("--_adjacent-button-width", `${clientWidth}px`);
1277
- button.classList.toggle("-adjacent-pressed", pressed);
1278
- } else if (i === index + 1) {
1279
- button.style.setProperty("--_adjacent-button-width", `${clientWidth}px`);
1280
- button.classList.toggle("-adjacent-pressed", pressed);
1281
- } else {
1282
- button.style.removeProperty("--_adjacent-button-width");
1283
- button.classList.remove("-adjacent-pressed");
1284
- }
1262
+ if (pressed) {
1263
+ __classPrivateFieldGet(this, _M3eIconButtonElement_instances, "m", _M3eIconButtonElement_updateButtonShape).call(this);
1264
+ if (prefersReducedMotion()) {
1265
+ __classPrivateFieldGet(this, _M3eIconButtonElement_instances, "m", _M3eIconButtonElement_handlePressedChange).call(this, true);
1266
+ } else {
1267
+ requestAnimationFrame(() => __classPrivateFieldGet(this, _M3eIconButtonElement_instances, "m", _M3eIconButtonElement_handlePressedChange).call(this, true));
1285
1268
  }
1269
+ } else {
1270
+ __classPrivateFieldGet(this, _M3eIconButtonElement_instances, "m", _M3eIconButtonElement_handlePressedChange).call(this, false);
1286
1271
  }
1287
1272
  }
1288
1273
  }
@@ -1352,6 +1337,29 @@ _M3eIconButtonElement_updateButtonShape = function _M3eIconButtonElement_updateB
1352
1337
  }
1353
1338
  }
1354
1339
  };
1340
+ _M3eIconButtonElement_handlePressedChange = function _M3eIconButtonElement_handlePressedChange(pressed) {
1341
+ this.classList.toggle("-pressed", pressed);
1342
+ this.classList.toggle("-resting", !pressed);
1343
+ const group = this.closest("m3e-button-group");
1344
+ if (group) {
1345
+ const clientWidth = this.getBoundingClientRect().width;
1346
+ const buttons = [...group.querySelectorAll("m3e-button,m3e-icon-button")];
1347
+ const index = buttons.indexOf(this);
1348
+ for (let i = 0; i < buttons.length; i++) {
1349
+ const button = buttons[i];
1350
+ if (i === index - 1) {
1351
+ button.style.setProperty("--_adjacent-button-width", `${clientWidth}px`);
1352
+ button.classList.toggle("-adjacent-pressed", pressed);
1353
+ } else if (i === index + 1) {
1354
+ button.style.setProperty("--_adjacent-button-width", `${clientWidth}px`);
1355
+ button.classList.toggle("-adjacent-pressed", pressed);
1356
+ } else {
1357
+ button.style.removeProperty("--_adjacent-button-width");
1358
+ button.classList.remove("-adjacent-pressed");
1359
+ }
1360
+ }
1361
+ }
1362
+ };
1355
1363
  _M3eIconButtonElement_handleClick = function _M3eIconButtonElement_handleClick(e) {
1356
1364
  if (this.disabled || this.disabledInteractive) {
1357
1365
  e.preventDefault();