@momentum-design/components 0.111.2 → 0.112.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import type { PropertyValues, CSSResult, TemplateResult } from 'lit';
2
2
  import MenuItem from '../menuitem/menuitem.component';
3
3
  import type { Indicator } from './menuitemcheckbox.types';
4
+ declare const MenuItemCheckbox_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/ControlledMixin").ControlledMixinInterface> & typeof MenuItem;
4
5
  /**
5
6
  * A menuitemcheckbox component is a checkable menuitem.
6
7
  * There should be no focusable descendants inside this menuitemcheckbox component.
@@ -44,7 +45,7 @@ import type { Indicator } from './menuitemcheckbox.types';
44
45
  * @event click - (React: onClick) This event is dispatched when the menuitemcheckbox is clicked.
45
46
  * @event focus - (React: onFocus) This event is dispatched when the menuitemcheckbox receives focus.
46
47
  */
47
- declare class MenuItemCheckbox extends MenuItem {
48
+ declare class MenuItemCheckbox extends MenuItemCheckbox_base {
48
49
  /**
49
50
  * The checked attribute is used to indicate that the menuitemcheckbox is checked or not.
50
51
  * @default false
@@ -60,7 +61,7 @@ declare class MenuItemCheckbox extends MenuItem {
60
61
  /**
61
62
  * Handles click events to toggle checked state
62
63
  * If the menuitemcheckbox is disabled, it does nothing.
63
- * If the menuitemcheckbox is not disabled, it toggles the `checked` state between `true` and `false`.
64
+ * If the menuitemcheckbox is not disabled, it toggles checked if uncontrolled, and dispatches the 'change' event.
64
65
  */
65
66
  private handleMouseClick;
66
67
  update(changedProperties: PropertyValues): void;
@@ -14,6 +14,7 @@ import { ROLE } from '../../utils/roles';
14
14
  import MenuItem from '../menuitem/menuitem.component';
15
15
  import { TYPE } from '../text/text.constants';
16
16
  import { TOGGLE_SIZE } from '../toggle/toggle.constants';
17
+ import { ControlledMixin } from '../../utils/mixins/ControlledMixin';
17
18
  import { DEFAULTS, INDICATOR } from './menuitemcheckbox.constants';
18
19
  import styles from './menuitemcheckbox.styles';
19
20
  /**
@@ -59,7 +60,7 @@ import styles from './menuitemcheckbox.styles';
59
60
  * @event click - (React: onClick) This event is dispatched when the menuitemcheckbox is clicked.
60
61
  * @event focus - (React: onFocus) This event is dispatched when the menuitemcheckbox receives focus.
61
62
  */
62
- class MenuItemCheckbox extends MenuItem {
63
+ class MenuItemCheckbox extends ControlledMixin(MenuItem) {
63
64
  constructor() {
64
65
  super();
65
66
  /**
@@ -81,12 +82,14 @@ class MenuItemCheckbox extends MenuItem {
81
82
  /**
82
83
  * Handles click events to toggle checked state
83
84
  * If the menuitemcheckbox is disabled, it does nothing.
84
- * If the menuitemcheckbox is not disabled, it toggles the `checked` state between `true` and `false`.
85
+ * If the menuitemcheckbox is not disabled, it toggles checked if uncontrolled, and dispatches the 'change' event.
85
86
  */
86
87
  handleMouseClick() {
87
88
  if (this.disabled)
88
89
  return;
89
- this.checked = !this.checked;
90
+ if (!this.controlled) {
91
+ this.checked = !this.checked;
92
+ }
90
93
  this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
91
94
  }
92
95
  update(changedProperties) {