@m3e/button 1.1.2 → 1.1.4

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.
@@ -1469,6 +1469,47 @@
1469
1469
  }
1470
1470
  ]
1471
1471
  },
1472
+ {
1473
+ "kind": "method",
1474
+ "name": "#handlePressedChange",
1475
+ "privacy": "private",
1476
+ "return": {
1477
+ "type": {
1478
+ "text": "void"
1479
+ }
1480
+ },
1481
+ "parameters": [
1482
+ {
1483
+ "name": "pressed",
1484
+ "type": {
1485
+ "text": "boolean"
1486
+ }
1487
+ }
1488
+ ]
1489
+ },
1490
+ {
1491
+ "kind": "field",
1492
+ "name": "#keyPressed",
1493
+ "privacy": "private",
1494
+ "type": {
1495
+ "text": "boolean"
1496
+ },
1497
+ "default": "false",
1498
+ "inheritedFrom": {
1499
+ "name": "KeyboardClick",
1500
+ "module": "../core/src/shared/mixins/KeyboardClick.ts"
1501
+ }
1502
+ },
1503
+ {
1504
+ "kind": "field",
1505
+ "name": "#keyDownHandler",
1506
+ "privacy": "private",
1507
+ "readonly": true,
1508
+ "inheritedFrom": {
1509
+ "name": "KeyboardClick",
1510
+ "module": "../core/src/shared/mixins/KeyboardClick.ts"
1511
+ }
1512
+ },
1472
1513
  {
1473
1514
  "kind": "field",
1474
1515
  "name": "#keyUpHandler",
@@ -1479,6 +1520,38 @@
1479
1520
  "module": "../core/src/shared/mixins/KeyboardClick.ts"
1480
1521
  }
1481
1522
  },
1523
+ {
1524
+ "kind": "field",
1525
+ "name": "#focusOutHandler",
1526
+ "privacy": "private",
1527
+ "readonly": true,
1528
+ "inheritedFrom": {
1529
+ "name": "KeyboardClick",
1530
+ "module": "../core/src/shared/mixins/KeyboardClick.ts"
1531
+ }
1532
+ },
1533
+ {
1534
+ "kind": "method",
1535
+ "name": "#handleKeyDown",
1536
+ "privacy": "private",
1537
+ "return": {
1538
+ "type": {
1539
+ "text": "void"
1540
+ }
1541
+ },
1542
+ "parameters": [
1543
+ {
1544
+ "name": "e",
1545
+ "type": {
1546
+ "text": "KeyboardEvent"
1547
+ }
1548
+ }
1549
+ ],
1550
+ "inheritedFrom": {
1551
+ "name": "KeyboardClick",
1552
+ "module": "../core/src/shared/mixins/KeyboardClick.ts"
1553
+ }
1554
+ },
1482
1555
  {
1483
1556
  "kind": "method",
1484
1557
  "name": "#handleKeyUp",
@@ -3738,12 +3811,51 @@
3738
3811
  "description": "Mixin to augment an element with behavior emits a click event on keyboard events.",
3739
3812
  "name": "KeyboardClick",
3740
3813
  "members": [
3814
+ {
3815
+ "kind": "field",
3816
+ "name": "#keyPressed",
3817
+ "privacy": "private",
3818
+ "type": {
3819
+ "text": "boolean"
3820
+ },
3821
+ "default": "false"
3822
+ },
3823
+ {
3824
+ "kind": "field",
3825
+ "name": "#keyDownHandler",
3826
+ "privacy": "private",
3827
+ "readonly": true
3828
+ },
3741
3829
  {
3742
3830
  "kind": "field",
3743
3831
  "name": "#keyUpHandler",
3744
3832
  "privacy": "private",
3745
3833
  "readonly": true
3746
3834
  },
3835
+ {
3836
+ "kind": "field",
3837
+ "name": "#focusOutHandler",
3838
+ "privacy": "private",
3839
+ "readonly": true
3840
+ },
3841
+ {
3842
+ "kind": "method",
3843
+ "name": "#handleKeyDown",
3844
+ "privacy": "private",
3845
+ "return": {
3846
+ "type": {
3847
+ "text": "void"
3848
+ }
3849
+ },
3850
+ "parameters": [
3851
+ {
3852
+ "name": "e",
3853
+ "type": {
3854
+ "text": "KeyboardEvent"
3855
+ }
3856
+ }
3857
+ ]
3858
+ },
3747
3859
  {
3748
3860
  "kind": "method",
3749
3861
  "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.
@@ -1115,7 +1115,7 @@ function buttonVariantStyle(variant) {
1115
1115
  */
1116
1116
  const ButtonVariantStyle = [buttonVariantStyle("text"), buttonVariantStyle("elevated"), buttonVariantStyle("outlined"), buttonVariantStyle("filled"), buttonVariantStyle("tonal"), css`:host([variant="outlined"]) .base { outline-style: solid; }`];
1117
1117
 
1118
- var _M3eButtonElement_instances, _M3eButtonElement_clickHandler, _M3eButtonElement_handleClick, _M3eButtonElement_handleSelectedIconSlotChange, _M3eButtonElement_updateButtonShape;
1118
+ var _M3eButtonElement_instances, _M3eButtonElement_clickHandler, _M3eButtonElement_handleClick, _M3eButtonElement_handleSelectedIconSlotChange, _M3eButtonElement_updateButtonShape, _M3eButtonElement_handlePressedChange;
1119
1119
  /**
1120
1120
  * A button users interact with to perform an action.
1121
1121
  *
@@ -1523,12 +1523,8 @@ let M3eButtonElement = class M3eButtonElement extends KeyboardClick(LinkButton(F
1523
1523
  });
1524
1524
  new FocusController(this, {
1525
1525
  callback: focused => {
1526
- if (!this.disabledInteractive && this._base) {
1527
- if (focused) {
1528
- __classPrivateFieldGet(this, _M3eButtonElement_instances, "m", _M3eButtonElement_updateButtonShape).call(this);
1529
- } else if (!this.grouped) {
1530
- this._base?.style.removeProperty("--_button-shape");
1531
- }
1526
+ if (!this.disabledInteractive && !focused && !this.grouped) {
1527
+ this._base?.style.removeProperty("--_button-shape");
1532
1528
  }
1533
1529
  }
1534
1530
  });
@@ -1537,26 +1533,15 @@ let M3eButtonElement = class M3eButtonElement extends KeyboardClick(LinkButton(F
1537
1533
  minPressedDuration: 150,
1538
1534
  callback: pressed => {
1539
1535
  if (!this.disabled && !this.disabledInteractive) {
1540
- this.classList.toggle("-pressed", pressed);
1541
- this.classList.toggle("-resting", !pressed);
1542
- const group = this.closest("m3e-button-group");
1543
- if (group) {
1544
- const clientWidth = this.getBoundingClientRect().width;
1545
- const buttons = [...group.querySelectorAll("m3e-button,m3e-icon-button")];
1546
- const index = buttons.indexOf(this);
1547
- for (let i = 0; i < buttons.length; i++) {
1548
- const button = buttons[i];
1549
- if (i === index - 1) {
1550
- button.style.setProperty("--_adjacent-button-width", `${clientWidth}px`);
1551
- button.classList.toggle("-adjacent-pressed", pressed);
1552
- } else if (i === index + 1) {
1553
- button.style.setProperty("--_adjacent-button-width", `${clientWidth}px`);
1554
- button.classList.toggle("-adjacent-pressed", pressed);
1555
- } else {
1556
- button.style.removeProperty("--_adjacent-button-width");
1557
- button.classList.remove("-adjacent-pressed");
1558
- }
1536
+ if (pressed) {
1537
+ __classPrivateFieldGet(this, _M3eButtonElement_instances, "m", _M3eButtonElement_updateButtonShape).call(this);
1538
+ if (prefersReducedMotion()) {
1539
+ __classPrivateFieldGet(this, _M3eButtonElement_instances, "m", _M3eButtonElement_handlePressedChange).call(this, true);
1540
+ } else {
1541
+ requestAnimationFrame(() => __classPrivateFieldGet(this, _M3eButtonElement_instances, "m", _M3eButtonElement_handlePressedChange).call(this, true));
1559
1542
  }
1543
+ } else {
1544
+ __classPrivateFieldGet(this, _M3eButtonElement_instances, "m", _M3eButtonElement_handlePressedChange).call(this, false);
1560
1545
  }
1561
1546
  }
1562
1547
  }
@@ -1651,6 +1636,29 @@ _M3eButtonElement_updateButtonShape = function _M3eButtonElement_updateButtonSha
1651
1636
  }
1652
1637
  }
1653
1638
  };
1639
+ _M3eButtonElement_handlePressedChange = function _M3eButtonElement_handlePressedChange(pressed) {
1640
+ this.classList.toggle("-pressed", pressed);
1641
+ this.classList.toggle("-resting", !pressed);
1642
+ const group = this.closest("m3e-button-group");
1643
+ if (group) {
1644
+ const clientWidth = this.getBoundingClientRect().width;
1645
+ const buttons = [...group.querySelectorAll("m3e-button,m3e-icon-button")];
1646
+ const index = buttons.indexOf(this);
1647
+ for (let i = 0; i < buttons.length; i++) {
1648
+ const button = buttons[i];
1649
+ if (i === index - 1) {
1650
+ button.style.setProperty("--_adjacent-button-width", `${clientWidth}px`);
1651
+ button.classList.toggle("-adjacent-pressed", pressed);
1652
+ } else if (i === index + 1) {
1653
+ button.style.setProperty("--_adjacent-button-width", `${clientWidth}px`);
1654
+ button.classList.toggle("-adjacent-pressed", pressed);
1655
+ } else {
1656
+ button.style.removeProperty("--_adjacent-button-width");
1657
+ button.classList.remove("-adjacent-pressed");
1658
+ }
1659
+ }
1660
+ }
1661
+ };
1654
1662
  /** The styles of the element. */
1655
1663
  M3eButtonElement.styles = [ButtonSizeStyle, ButtonVariantStyle, ButtonStyle];
1656
1664
  __decorate([e(".base")], M3eButtonElement.prototype, "_base", void 0);