@momentum-design/components 0.100.0 → 0.100.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 (91) hide show
  1. package/dist/browser/index.js +1440 -1210
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/accordion/accordion.component.d.ts +74 -0
  4. package/dist/components/accordion/accordion.component.js +128 -0
  5. package/dist/components/accordion/accordion.constants.d.ts +2 -0
  6. package/dist/components/accordion/accordion.constants.js +3 -0
  7. package/dist/components/accordion/accordion.styles.d.ts +2 -0
  8. package/dist/components/accordion/accordion.styles.js +17 -0
  9. package/dist/components/accordion/index.d.ts +10 -0
  10. package/dist/components/accordion/index.js +7 -0
  11. package/dist/components/accordionbutton/accordionbutton.component.d.ts +119 -0
  12. package/dist/components/accordionbutton/accordionbutton.component.js +238 -0
  13. package/dist/components/accordionbutton/accordionbutton.constants.d.ts +17 -0
  14. package/dist/components/accordionbutton/accordionbutton.constants.js +19 -0
  15. package/dist/components/accordionbutton/accordionbutton.styles.d.ts +2 -0
  16. package/dist/components/accordionbutton/accordionbutton.styles.js +121 -0
  17. package/dist/components/accordionbutton/accordionbutton.types.d.ts +8 -0
  18. package/dist/components/accordionbutton/accordionbutton.types.js +1 -0
  19. package/dist/components/accordionbutton/index.d.ts +10 -0
  20. package/dist/components/accordionbutton/index.js +7 -0
  21. package/dist/components/accordiongroup/accordiongroup.component.d.ts +71 -0
  22. package/dist/components/accordiongroup/accordiongroup.component.js +132 -0
  23. package/dist/components/accordiongroup/accordiongroup.constants.d.ts +15 -0
  24. package/dist/components/accordiongroup/accordiongroup.constants.js +16 -0
  25. package/dist/components/accordiongroup/accordiongroup.styles.d.ts +2 -0
  26. package/dist/components/accordiongroup/accordiongroup.styles.js +48 -0
  27. package/dist/components/accordiongroup/accordiongroup.types.d.ts +5 -0
  28. package/dist/components/accordiongroup/accordiongroup.types.js +1 -0
  29. package/dist/components/accordiongroup/index.d.ts +7 -0
  30. package/dist/components/accordiongroup/index.js +4 -0
  31. package/dist/components/animation/animation.component.d.ts +1 -0
  32. package/dist/components/animation/animation.component.js +9 -0
  33. package/dist/components/cardcheckbox/cardcheckbox.component.js +3 -3
  34. package/dist/components/cardradio/cardradio.component.js +3 -3
  35. package/dist/components/dialog/dialog.component.js +5 -0
  36. package/dist/components/formfieldwrapper/formfieldwrapper.styles.js +1 -0
  37. package/dist/components/icon/icon.component.d.ts +2 -1
  38. package/dist/components/icon/icon.component.js +9 -1
  39. package/dist/components/linksimple/linksimple.component.js +11 -11
  40. package/dist/components/listitem/listitem.component.js +6 -6
  41. package/dist/components/listitem/listitem.events.js +3 -1
  42. package/dist/components/menubar/menubar.component.d.ts +9 -0
  43. package/dist/components/menubar/menubar.component.js +38 -4
  44. package/dist/components/menuitem/menuitem.component.js +1 -1
  45. package/dist/components/menuitemcheckbox/menuitemcheckbox.component.js +12 -12
  46. package/dist/components/menuitemradio/menuitemradio.component.js +13 -13
  47. package/dist/components/menupopover/menupopover.component.d.ts +30 -12
  48. package/dist/components/menupopover/menupopover.component.js +231 -179
  49. package/dist/components/menupopover/menupopover.utils.d.ts +2 -2
  50. package/dist/components/menupopover/menupopover.utils.js +2 -2
  51. package/dist/components/navmenuitem/navmenuitem.component.js +1 -1
  52. package/dist/components/popover/popover.component.d.ts +29 -9
  53. package/dist/components/popover/popover.component.js +277 -212
  54. package/dist/components/popover/popover.constants.d.ts +1 -0
  55. package/dist/components/popover/popover.constants.js +1 -0
  56. package/dist/components/popover/popover.types.d.ts +19 -6
  57. package/dist/components/popover/popover.utils.d.ts +7 -2
  58. package/dist/components/popover/popover.utils.js +19 -8
  59. package/dist/components/select/select.component.js +2 -0
  60. package/dist/components/select/select.styles.js +1 -1
  61. package/dist/components/select/select.types.d.ts +5 -1
  62. package/dist/components/sidenavigation/sidenavigation.component.js +1 -1
  63. package/dist/components/spinner/spinner.component.d.ts +1 -1
  64. package/dist/components/spinner/spinner.component.js +1 -1
  65. package/dist/components/tablist/tablist.component.d.ts +1 -0
  66. package/dist/components/tablist/tablist.component.js +284 -273
  67. package/dist/components/textarea/textarea.component.d.ts +2 -2
  68. package/dist/components/textarea/textarea.component.js +2 -2
  69. package/dist/components/tooltip/tooltip.component.d.ts +1 -1
  70. package/dist/components/tooltip/tooltip.component.js +14 -15
  71. package/dist/custom-elements.json +7364 -6056
  72. package/dist/index.d.ts +10 -7
  73. package/dist/index.js +10 -7
  74. package/dist/react/accordion/index.d.ts +53 -0
  75. package/dist/react/accordion/index.js +61 -0
  76. package/dist/react/accordionbutton/index.d.ts +50 -0
  77. package/dist/react/accordionbutton/index.js +58 -0
  78. package/dist/react/accordiongroup/index.d.ts +30 -0
  79. package/dist/react/accordiongroup/index.js +39 -0
  80. package/dist/react/coachmark/index.d.ts +12 -4
  81. package/dist/react/index.d.ts +9 -6
  82. package/dist/react/index.js +9 -6
  83. package/dist/react/menupopover/index.d.ts +12 -4
  84. package/dist/react/popover/index.d.ts +12 -4
  85. package/dist/react/toggletip/index.d.ts +12 -4
  86. package/dist/react/tooltip/index.d.ts +12 -4
  87. package/dist/utils/keys.d.ts +1 -0
  88. package/dist/utils/keys.js +1 -0
  89. package/dist/utils/roles.d.ts +2 -0
  90. package/dist/utils/roles.js +2 -0
  91. package/package.json +2 -2
@@ -31,12 +31,21 @@ declare class MenuBar extends Component {
31
31
  * Returns all menuitem elements, including those nested inside menusection.
32
32
  */
33
33
  get menuItems(): Array<HTMLElement>;
34
+ /** @internal */
35
+ private getVisibleSubMenusOfItems;
34
36
  /**
35
37
  * Returns all menupopovers, including direct and slotted ones .
36
38
  */
37
39
  private getAllPopovers;
38
40
  update(changedProperties: PropertyValues): void;
39
41
  firstUpdated(changedProperties: PropertyValues): void;
42
+ /**
43
+ * Closes all other submenus on the top level.
44
+ * This method is used to ensure that only one topolevel submenu is open at a time.
45
+ * It finds all other menu items with submenus and closes their submenus.
46
+ * @param target - The target menu item that was clicked.
47
+ */
48
+ private handleClick;
40
49
  /**
41
50
  * Resets all list items tabindex to -1 and sets the tabindex of the
42
51
  * element at the given index to 0, effectively setting the active
@@ -45,7 +45,8 @@ import styles from './menubar.styles';
45
45
  class MenuBar extends Component {
46
46
  constructor() {
47
47
  super();
48
- this.addEventListener('keydown', this.handleKeyDown);
48
+ this.addEventListener('click', this.handleClick.bind(this));
49
+ this.addEventListener('keydown', this.handleKeyDown.bind(this));
49
50
  }
50
51
  async connectedCallback() {
51
52
  var _a;
@@ -77,6 +78,23 @@ class MenuBar extends Component {
77
78
  assigned.forEach(collect);
78
79
  return items;
79
80
  }
81
+ /** @internal */
82
+ getVisibleSubMenusOfItems(items) {
83
+ const subMenus = [];
84
+ if (!items || items.length === 0)
85
+ return subMenus;
86
+ items.forEach(item => {
87
+ var _a;
88
+ const id = item.getAttribute('id');
89
+ if (!id)
90
+ return;
91
+ const submenu = (_a = this.querySelector) === null || _a === void 0 ? void 0 : _a.call(this, `${MENUPOPOVER_TAGNAME}[triggerid="${id}"]`);
92
+ if (submenu && submenu.visible) {
93
+ subMenus.push(submenu);
94
+ }
95
+ });
96
+ return subMenus;
97
+ }
80
98
  /**
81
99
  * Returns all menupopovers, including direct and slotted ones .
82
100
  */
@@ -110,6 +128,22 @@ class MenuBar extends Component {
110
128
  this.resetTabIndexAndSetActiveTabIndex(this.menuItems);
111
129
  this.updatePopoverPlacement();
112
130
  }
131
+ /**
132
+ * Closes all other submenus on the top level.
133
+ * This method is used to ensure that only one topolevel submenu is open at a time.
134
+ * It finds all other menu items with submenus and closes their submenus.
135
+ * @param target - The target menu item that was clicked.
136
+ */
137
+ handleClick(event) {
138
+ const target = event.target;
139
+ if (!target || !this.isTopLevelMenuItem(target))
140
+ return;
141
+ const otherMenuItemsOnTop = this.menuItems.filter(item => item !== target);
142
+ const otherOpenSubMenus = this.getVisibleSubMenusOfItems(otherMenuItemsOnTop);
143
+ otherOpenSubMenus.forEach(subMenu => {
144
+ subMenu.hide();
145
+ });
146
+ }
113
147
  /**
114
148
  * Resets all list items tabindex to -1 and sets the tabindex of the
115
149
  * element at the given index to 0, effectively setting the active
@@ -139,7 +173,7 @@ class MenuBar extends Component {
139
173
  return;
140
174
  const submenu = this.getSubmenu(triggerId);
141
175
  if (submenu)
142
- submenu.showPopover();
176
+ submenu.show();
143
177
  }
144
178
  updatePopoverPlacement() {
145
179
  const placement = POPOVER_PLACEMENT.RIGHT_START;
@@ -208,7 +242,7 @@ class MenuBar extends Component {
208
242
  while (popoverStack.peek()) {
209
243
  const popover = popoverStack.pop();
210
244
  if (popover) {
211
- popover.hidePopover();
245
+ popover.hide();
212
246
  popovers.push(popover);
213
247
  }
214
248
  }
@@ -222,7 +256,7 @@ class MenuBar extends Component {
222
256
  const triggerMenuItem = this.menuItems.find(item => item.getAttribute('id') === triggerId);
223
257
  if (triggerMenuItem) {
224
258
  if (this.isTopLevelMenuItem(triggerMenuItem)) {
225
- parentPopover === null || parentPopover === void 0 ? void 0 : parentPopover.hidePopover();
259
+ parentPopover === null || parentPopover === void 0 ? void 0 : parentPopover.hide();
226
260
  }
227
261
  await (parentPopover === null || parentPopover === void 0 ? void 0 : parentPopover.updateComplete);
228
262
  const parentMenuItemIndex = this.getCurrentIndex(triggerMenuItem);
@@ -58,7 +58,7 @@ class MenuItem extends ListItem {
58
58
  * It is typically used with checkbox and radio menu items, but can be handy for any menu item.
59
59
  */
60
60
  this.value = undefined;
61
- this.addEventListener('keyup', this.handleKeyUp);
61
+ this.addEventListener('keyup', this.handleKeyUp.bind(this));
62
62
  }
63
63
  /**
64
64
  * Handles the keydown event for the menu item.
@@ -72,23 +72,23 @@ class MenuItemCheckbox extends MenuItem {
72
72
  * @default 'checkbox'
73
73
  */
74
74
  this.indicator = DEFAULTS.INDICATOR;
75
- /**
76
- * Handles click events to toggle checked state
77
- * If the menuitemcheckbox is disabled, it does nothing.
78
- * If the menuitemcheckbox is not disabled, it toggles the `checked` state between `true` and `false`.
79
- */
80
- this.handleMouseClick = () => {
81
- if (this.disabled)
82
- return;
83
- this.checked = !this.checked;
84
- this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
85
- };
86
- this.addEventListener('click', this.handleMouseClick);
75
+ this.addEventListener('click', this.handleMouseClick.bind(this));
87
76
  }
88
77
  connectedCallback() {
89
78
  super.connectedCallback();
90
79
  this.role = ROLE.MENUITEMCHECKBOX;
91
80
  }
81
+ /**
82
+ * Handles click events to toggle checked state
83
+ * 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
+ */
86
+ handleMouseClick() {
87
+ if (this.disabled)
88
+ return;
89
+ this.checked = !this.checked;
90
+ this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
91
+ }
92
92
  update(changedProperties) {
93
93
  super.update(changedProperties);
94
94
  if (changedProperties.has('checked')) {
@@ -75,19 +75,7 @@ class MenuItemRadio extends MenuItem {
75
75
  * @default 'radio'
76
76
  */
77
77
  this.indicator = DEFAULTS.INDICATOR;
78
- /**
79
- * Handles click events to set checked state and uncheck siblings in the same group and container.
80
- * If the menuitemradio is not checked, it sets its checked state to `true`
81
- * and sets all other menuitemradio elements of the same group with checked state to `false`.
82
- */
83
- this.handleMouseClick = () => {
84
- if (this.disabled || this.checked)
85
- return;
86
- this.updateOtherRadiosCheckedState();
87
- this.checked = true;
88
- this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
89
- };
90
- this.addEventListener('click', this.handleMouseClick);
78
+ this.addEventListener('click', this.handleMouseClick.bind(this));
91
79
  }
92
80
  connectedCallback() {
93
81
  super.connectedCallback();
@@ -115,6 +103,18 @@ class MenuItemRadio extends MenuItem {
115
103
  }
116
104
  });
117
105
  }
106
+ /**
107
+ * Handles click events to set checked state and uncheck siblings in the same group and container.
108
+ * If the menuitemradio is not checked, it sets its checked state to `true`
109
+ * and sets all other menuitemradio elements of the same group with checked state to `false`.
110
+ */
111
+ handleMouseClick() {
112
+ if (this.disabled || this.checked)
113
+ return;
114
+ this.updateOtherRadiosCheckedState();
115
+ this.checked = true;
116
+ this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
117
+ }
118
118
  update(changedProperties) {
119
119
  super.update(changedProperties);
120
120
  if (changedProperties.has('checked')) {
@@ -64,9 +64,21 @@ declare class MenuPopover extends Popover {
64
64
  */
65
65
  placement: PopoverPlacement;
66
66
  private menuItems;
67
+ private menuItemsWithSubMenus;
67
68
  constructor();
69
+ /**
70
+ * Retrieves the submenu popover associated with a given target element.
71
+ * This method checks if the target element has an `id` attribute and uses it to find the corresponding submenu popover.
72
+ * If a submenu popover is found, it returns it; otherwise, it returns `undefined` or `null`.
73
+ * @param target - The target element for which to find the submenu popover.
74
+ * @returns - The submenu popover instance or `undefined`/`null` if not found.
75
+ * @internal
76
+ */
77
+ private getSubMenuPopoverOfTarget;
68
78
  /** @internal */
69
- collectMenuItems(): void;
79
+ private collectMenuItems;
80
+ /** @internal */
81
+ private getOpenSubMenusOfItems;
70
82
  connectedCallback(): void;
71
83
  protected isOpenUpdated(oldValue: boolean, newValue: boolean): Promise<void>;
72
84
  firstUpdated(changedProperties: PropertyValues): Promise<void>;
@@ -107,21 +119,27 @@ declare class MenuPopover extends Popover {
107
119
  */
108
120
  onOutsidePopoverClick: (event: MouseEvent) => void;
109
121
  /**
110
- * Checks if the menu popover has a submenu with the specified trigger ID.
111
- * This method is used to determine if a menu item has a submenu associated with it,
112
- * which is indicated by the presence of a `triggerid` attribute in the submenu popover.
113
- * It queries the parent element for any popover with the specified trigger ID.
114
- * @param id - The ID of the menu item to check for a submenu.
115
- * @returns - A boolean indicating whether a submenu with the specified trigger ID exists.
122
+ * Toggles the visibility of the popover.
123
+ * This method checks if the trigger element has the `soft-disabled` attribute.
124
+ * If it does, the popover will not be toggled.
125
+ * If the popover is currently visible, it hides the popover; otherwise, it shows the popover.
126
+ * @returns - This method does not return anything.
116
127
  */
117
- private hasSubmenuWithTriggerId;
118
128
  togglePopoverVisible: () => void;
119
129
  /**
120
- * Determines whether to close the menu based on the clicked target.
121
- *
122
- * @param target - The target element that was clicked.
130
+ * Closes all other submenus on the same level as the target menu item.
131
+ * This method is used to ensure that only one submenu is open at a time.
132
+ * It finds all other menu items with submenus and closes their submenus.
133
+ * @param target - The target menu item that was clicked.
134
+ */
135
+ private closeOtherSubMenusOnSameLevel;
136
+ /**
137
+ * Fires the 'action' event on the target menu item.
138
+ * This method is used to trigger the action associated with a menu item when it is clicked or activated.
139
+ * It checks if the target element matches the `MENUITEM_TAGNAME` and dispatches an 'action' event.
140
+ * @param target - The target menu item that was clicked or activated.
123
141
  */
124
- private closeMenu;
142
+ private fireMenuItemAction;
125
143
  /**
126
144
  * Handles mouse click events on the menu items.
127
145
  * This method checks if the clicked element is a valid menu item and not a submenu trigger.