@momentum-design/components 0.129.42 → 0.129.44
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.
- package/dist/browser/index.js +386 -386
- package/dist/browser/index.js.map +4 -4
- package/dist/components/accordionbutton/accordionbutton.component.d.ts +1 -1
- package/dist/components/accordionbutton/accordionbutton.component.js +4 -3
- package/dist/components/buttonsimple/buttonsimple.component.d.ts +1 -1
- package/dist/components/buttonsimple/buttonsimple.component.js +8 -6
- package/dist/components/cardcheckbox/cardcheckbox.component.d.ts +1 -1
- package/dist/components/cardcheckbox/cardcheckbox.component.js +7 -5
- package/dist/components/cardradio/cardradio.component.d.ts +1 -1
- package/dist/components/cardradio/cardradio.component.js +8 -7
- package/dist/components/checkbox/checkbox.component.d.ts +2 -1
- package/dist/components/checkbox/checkbox.component.js +7 -4
- package/dist/components/coachmark/coachmark.component.d.ts +14 -1
- package/dist/components/coachmark/coachmark.component.js +14 -1
- package/dist/components/coachmark/index.d.ts +0 -1
- package/dist/components/coachmark/index.js +0 -1
- package/dist/components/combobox/combobox.component.d.ts +1 -1
- package/dist/components/combobox/combobox.component.js +11 -11
- package/dist/components/input/input.component.d.ts +1 -1
- package/dist/components/input/input.component.js +3 -3
- package/dist/components/list/list.component.d.ts +1 -1
- package/dist/components/listbox/listbox.component.d.ts +1 -1
- package/dist/components/listitem/listitem.component.d.ts +1 -1
- package/dist/components/listitem/listitem.component.js +11 -5
- package/dist/components/menubar/menubar.component.d.ts +2 -2
- package/dist/components/menubar/menubar.component.js +10 -20
- package/dist/components/menuitem/menuitem.component.js +3 -3
- package/dist/components/menupopover/menupopover.component.d.ts +0 -10
- package/dist/components/menupopover/menupopover.component.js +15 -36
- package/dist/components/popover/popover.component.d.ts +26 -13
- package/dist/components/popover/popover.component.js +26 -12
- package/dist/components/popover/popover.constants.d.ts +5 -1
- package/dist/components/popover/popover.constants.js +6 -2
- package/dist/components/popover/popover.types.d.ts +3 -2
- package/dist/components/radio/radio.component.d.ts +1 -1
- package/dist/components/radio/radio.component.js +8 -7
- package/dist/components/searchfield/searchfield.component.d.ts +3 -0
- package/dist/components/searchfield/searchfield.component.js +18 -5
- package/dist/components/searchpopover/searchpopover.component.js +3 -4
- package/dist/components/select/select.component.d.ts +1 -1
- package/dist/components/select/select.component.js +9 -8
- package/dist/components/slider/slider.component.d.ts +2 -1
- package/dist/components/slider/slider.component.js +4 -3
- package/dist/components/stepperitem/stepperitem.component.d.ts +1 -1
- package/dist/components/stepperitem/stepperitem.component.js +8 -6
- package/dist/components/textarea/textarea.component.d.ts +1 -1
- package/dist/components/textarea/textarea.component.js +5 -4
- package/dist/components/toggle/toggle.component.d.ts +1 -1
- package/dist/components/toggle/toggle.component.js +5 -4
- package/dist/components/virtualizedlist/virtualizedlist.component.d.ts +1 -1
- package/dist/components/virtualizedlist/virtualizedlist.component.js +7 -6
- package/dist/custom-elements.json +1417 -1020
- package/dist/react/checkbox/index.d.ts +1 -0
- package/dist/react/checkbox/index.js +1 -0
- package/dist/react/coachmark/index.d.ts +14 -1
- package/dist/react/coachmark/index.js +14 -1
- package/dist/utils/mixins/KeyToActionMixin.d.ts +69 -0
- package/dist/utils/mixins/KeyToActionMixin.js +92 -0
- package/dist/utils/mixins/ListNavigationMixin.d.ts +2 -1
- package/dist/utils/mixins/ListNavigationMixin.js +10 -33
- package/package.json +1 -1
|
@@ -15,8 +15,8 @@ import { POPOVER_PLACEMENT } from '../popover/popover.constants';
|
|
|
15
15
|
import { TAG_NAME as MENUPOPOVER_TAGNAME } from '../menupopover/menupopover.constants';
|
|
16
16
|
import { TAG_NAME as MENUSECTION_TAGNAME } from '../menusection/menusection.constants';
|
|
17
17
|
import { TAG_NAME as SIDENAV_TAGNAME } from '../sidenavigation/sidenavigation.constants';
|
|
18
|
-
import { KEYS } from '../../utils/keys';
|
|
19
18
|
import { popoverStack } from '../popover/popover.stack';
|
|
19
|
+
import { ACTIONS, KeyToActionMixin } from '../../utils/mixins/KeyToActionMixin';
|
|
20
20
|
import { DEFAULTS, TAG_NAME as MENUBAR_TAGNAME } from './menubar.constants';
|
|
21
21
|
import styles from './menubar.styles';
|
|
22
22
|
/**
|
|
@@ -42,7 +42,7 @@ import styles from './menubar.styles';
|
|
|
42
42
|
* @tagname mdc-menubar
|
|
43
43
|
* @slot default - Contains the menu items and their associated popovers
|
|
44
44
|
*/
|
|
45
|
-
class MenuBar extends Component {
|
|
45
|
+
class MenuBar extends KeyToActionMixin(Component) {
|
|
46
46
|
constructor() {
|
|
47
47
|
super();
|
|
48
48
|
this.addEventListener('click', this.handleClick.bind(this));
|
|
@@ -206,16 +206,6 @@ class MenuBar extends Component {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
getKeyWithDirectionFix(originalKey) {
|
|
210
|
-
const isRtl = window.getComputedStyle(this).direction === 'rtl';
|
|
211
|
-
if (!isRtl)
|
|
212
|
-
return originalKey;
|
|
213
|
-
if (originalKey === KEYS.ARROW_LEFT)
|
|
214
|
-
return KEYS.ARROW_RIGHT;
|
|
215
|
-
if (originalKey === KEYS.ARROW_RIGHT)
|
|
216
|
-
return KEYS.ARROW_LEFT;
|
|
217
|
-
return originalKey;
|
|
218
|
-
}
|
|
219
209
|
/**
|
|
220
210
|
* Determines if a menuitem is a top-level menuitem (direct child of menubar or child of menusection whose parent is menubar)
|
|
221
211
|
*/
|
|
@@ -294,30 +284,30 @@ class MenuBar extends Component {
|
|
|
294
284
|
}
|
|
295
285
|
async handleKeyDown(event) {
|
|
296
286
|
const currentIndex = this.getCurrentIndex(event.target);
|
|
297
|
-
const
|
|
298
|
-
switch (
|
|
299
|
-
case
|
|
287
|
+
const action = this.getActionForKeyEvent(event, true);
|
|
288
|
+
switch (action) {
|
|
289
|
+
case ACTIONS.HOME:
|
|
300
290
|
this.updateTabIndexAndFocus(this.menuItems, currentIndex, 0);
|
|
301
291
|
break;
|
|
302
|
-
case
|
|
292
|
+
case ACTIONS.END:
|
|
303
293
|
this.updateTabIndexAndFocus(this.menuItems, currentIndex, this.menuItems.length - 1);
|
|
304
294
|
break;
|
|
305
|
-
case
|
|
295
|
+
case ACTIONS.LEFT: {
|
|
306
296
|
const element = currentIndex >= 0 ? this.menuItems[currentIndex] : event.target;
|
|
307
297
|
await this.crossMenubarNavigationOnLeft(element);
|
|
308
298
|
break;
|
|
309
299
|
}
|
|
310
|
-
case
|
|
300
|
+
case ACTIONS.RIGHT: {
|
|
311
301
|
const element = currentIndex >= 0 ? this.menuItems[currentIndex] : event.target;
|
|
312
302
|
await this.crossMenubarNavigationOnRight(element);
|
|
313
303
|
break;
|
|
314
304
|
}
|
|
315
|
-
case
|
|
305
|
+
case ACTIONS.UP: {
|
|
316
306
|
this.navigateToMenuItem(currentIndex, 'prev');
|
|
317
307
|
event.preventDefault();
|
|
318
308
|
break;
|
|
319
309
|
}
|
|
320
|
-
case
|
|
310
|
+
case ACTIONS.DOWN: {
|
|
321
311
|
this.navigateToMenuItem(currentIndex, 'next');
|
|
322
312
|
event.preventDefault();
|
|
323
313
|
break;
|
|
@@ -12,7 +12,7 @@ import { property } from 'lit/decorators.js';
|
|
|
12
12
|
import { ROLE } from '../../utils/roles';
|
|
13
13
|
import ListItem from '../listitem/listitem.component';
|
|
14
14
|
import { LISTITEM_VARIANTS } from '../listitem/listitem.constants';
|
|
15
|
-
import {
|
|
15
|
+
import { ACTIONS } from '../../utils/mixins/KeyToActionMixin';
|
|
16
16
|
import { ARROW_ICONS, ARROW_DIRECTIONS, ARROW_POSITIONS } from './menuitem.constants';
|
|
17
17
|
import styles from './menuitem.styles';
|
|
18
18
|
/**
|
|
@@ -77,7 +77,7 @@ class MenuItem extends ListItem {
|
|
|
77
77
|
* @param event - The keyboard event that triggered the action.
|
|
78
78
|
*/
|
|
79
79
|
handleKeyDown(event) {
|
|
80
|
-
if (event
|
|
80
|
+
if (this.getActionForKeyEvent(event) === ACTIONS.ENTER) {
|
|
81
81
|
this.triggerClickEvent(event);
|
|
82
82
|
event.preventDefault();
|
|
83
83
|
}
|
|
@@ -95,7 +95,7 @@ class MenuItem extends ListItem {
|
|
|
95
95
|
* @param event - The keyboard event that triggered the action.
|
|
96
96
|
*/
|
|
97
97
|
handleKeyUp(event) {
|
|
98
|
-
if (event
|
|
98
|
+
if (this.getActionForKeyEvent(event) === ACTIONS.SPACE) {
|
|
99
99
|
this.triggerClickEvent(event);
|
|
100
100
|
event.preventDefault();
|
|
101
101
|
}
|
|
@@ -154,16 +154,6 @@ declare class MenuPopover extends Popover {
|
|
|
154
154
|
private handleItemCreation;
|
|
155
155
|
private handleItemChangeEvent;
|
|
156
156
|
private resetMenuNavigation;
|
|
157
|
-
/**
|
|
158
|
-
* Resolves the key pressed by the user based on the direction of the layout.
|
|
159
|
-
* This method is used to handle keyboard navigation in a right-to-left (RTL) layout.
|
|
160
|
-
* It checks if the layout is RTL and adjusts the arrow keys accordingly.
|
|
161
|
-
* For example, in RTL, the left arrow key behaves like the right arrow key and vice versa.
|
|
162
|
-
* @param key - The key pressed by the user.
|
|
163
|
-
* @param isRtl - A boolean indicating if the layout is right-to-left (RTL).
|
|
164
|
-
* @returns - The resolved key based on the direction.
|
|
165
|
-
*/
|
|
166
|
-
private resolveDirectionKey;
|
|
167
157
|
/**
|
|
168
158
|
* Handles keydown events for keyboard navigation within the menu popover.
|
|
169
159
|
* This method allows users to navigate through the menu items using the keyboard.
|
|
@@ -8,7 +8,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { property } from 'lit/decorators.js';
|
|
11
|
-
import { KEYS } from '../../utils/keys';
|
|
12
11
|
import { ROLE } from '../../utils/roles';
|
|
13
12
|
import { TAG_NAME as MENUSECTION_TAGNAME } from '../menusection/menusection.constants';
|
|
14
13
|
import { TAG_NAME as NAVMENUITEM_TAGNAME } from '../navmenuitem/navmenuitem.constants';
|
|
@@ -18,6 +17,7 @@ import { TAG_NAME as MENUITEMRADIO_TAGNAME } from '../menuitemradio/menuitemradi
|
|
|
18
17
|
import Popover from '../popover/popover.component';
|
|
19
18
|
import { COLOR } from '../popover/popover.constants';
|
|
20
19
|
import { popoverStack } from '../popover/popover.stack';
|
|
20
|
+
import { ACTIONS } from '../../utils/mixins/KeyToActionMixin';
|
|
21
21
|
import { DEFAULTS, TAG_NAME as MENU_POPOVER } from './menupopover.constants';
|
|
22
22
|
import styles from './menupopover.styles';
|
|
23
23
|
import { isValidMenuItem, isValidMenuPopover } from './menupopover.utils';
|
|
@@ -173,36 +173,35 @@ class MenuPopover extends Popover {
|
|
|
173
173
|
if (currentIndex === -1)
|
|
174
174
|
return;
|
|
175
175
|
this.resetTabIndexes(currentIndex);
|
|
176
|
-
const
|
|
177
|
-
const targetKey = this.resolveDirectionKey(event.key, isRtl);
|
|
176
|
+
const targetKey = this.getActionForKeyEvent(event, true);
|
|
178
177
|
switch (targetKey) {
|
|
179
|
-
case
|
|
178
|
+
case ACTIONS.HOME: {
|
|
180
179
|
// Move focus to the first menu item
|
|
181
180
|
this.resetTabIndexAndSetFocus(0, currentIndex);
|
|
182
181
|
isKeyHandled = true;
|
|
183
182
|
break;
|
|
184
183
|
}
|
|
185
|
-
case
|
|
184
|
+
case ACTIONS.END: {
|
|
186
185
|
// Move focus to the last menu item
|
|
187
186
|
this.resetTabIndexAndSetFocus(this.menuItems.length - 1, currentIndex);
|
|
188
187
|
isKeyHandled = true;
|
|
189
188
|
break;
|
|
190
189
|
}
|
|
191
|
-
case
|
|
190
|
+
case ACTIONS.DOWN: {
|
|
192
191
|
// Move focus to the next menu item
|
|
193
192
|
const newIndex = currentIndex + 1 === this.menuItems.length ? 0 : currentIndex + 1;
|
|
194
193
|
this.resetTabIndexAndSetFocus(newIndex, currentIndex);
|
|
195
194
|
isKeyHandled = true;
|
|
196
195
|
break;
|
|
197
196
|
}
|
|
198
|
-
case
|
|
197
|
+
case ACTIONS.UP: {
|
|
199
198
|
// Move focus to the prev menu item
|
|
200
199
|
const newIndex = currentIndex - 1 === -1 ? this.menuItems.length - 1 : currentIndex - 1;
|
|
201
200
|
this.resetTabIndexAndSetFocus(newIndex, currentIndex);
|
|
202
201
|
isKeyHandled = true;
|
|
203
202
|
break;
|
|
204
203
|
}
|
|
205
|
-
case
|
|
204
|
+
case ACTIONS.RIGHT: {
|
|
206
205
|
// If there is a submenu, open it.
|
|
207
206
|
const subMenu = this.getSubMenuPopoverOfTarget(target);
|
|
208
207
|
if (subMenu) {
|
|
@@ -211,7 +210,7 @@ class MenuPopover extends Popover {
|
|
|
211
210
|
}
|
|
212
211
|
break;
|
|
213
212
|
}
|
|
214
|
-
case
|
|
213
|
+
case ACTIONS.LEFT: {
|
|
215
214
|
// If the current popover is a submenu then close this popover.
|
|
216
215
|
if (isValidMenuPopover(this.parentElement)) {
|
|
217
216
|
this.hide();
|
|
@@ -220,12 +219,12 @@ class MenuPopover extends Popover {
|
|
|
220
219
|
}
|
|
221
220
|
break;
|
|
222
221
|
}
|
|
223
|
-
case
|
|
222
|
+
case ACTIONS.ESCAPE: {
|
|
224
223
|
this.resetTabIndexAndSetFocus(0, currentIndex);
|
|
225
224
|
isKeyHandled = true;
|
|
226
225
|
break;
|
|
227
226
|
}
|
|
228
|
-
case
|
|
227
|
+
case ACTIONS.ENTER: {
|
|
229
228
|
if (!this.getSubMenuPopoverOfTarget(target) && !target.hasAttribute('soft-disabled')) {
|
|
230
229
|
this.closeAllMenuPopovers();
|
|
231
230
|
this.fireMenuItemAction(target);
|
|
@@ -233,7 +232,7 @@ class MenuPopover extends Popover {
|
|
|
233
232
|
}
|
|
234
233
|
break;
|
|
235
234
|
}
|
|
236
|
-
case
|
|
235
|
+
case ACTIONS.SPACE: {
|
|
237
236
|
// Prevent page scroll when space is pressed down
|
|
238
237
|
isKeyHandled = true;
|
|
239
238
|
break;
|
|
@@ -264,10 +263,11 @@ class MenuPopover extends Popover {
|
|
|
264
263
|
this.handleKeyUp = (event) => {
|
|
265
264
|
let isKeyHandled = false;
|
|
266
265
|
const target = event.target;
|
|
267
|
-
switch (event
|
|
268
|
-
case
|
|
266
|
+
switch (this.getActionForKeyEvent(event)) {
|
|
267
|
+
case ACTIONS.SPACE: {
|
|
269
268
|
// If the target is a menu item, trigger its click event
|
|
270
|
-
if (!target.matches(`${MENUITEMRADIO_TAGNAME}, ${MENUITEMCHECKBOX_TAGNAME}`) &&
|
|
269
|
+
if (!target.matches(`${MENUITEMRADIO_TAGNAME}, ${MENUITEMCHECKBOX_TAGNAME}`) &&
|
|
270
|
+
!target.hasAttribute('soft-disabled')) {
|
|
271
271
|
// only close all menu popovers if the target is not opening a menu popover
|
|
272
272
|
if (!this.getSubMenuPopoverOfTarget(target)) {
|
|
273
273
|
this.closeAllMenuPopovers();
|
|
@@ -483,27 +483,6 @@ class MenuPopover extends Popover {
|
|
|
483
483
|
this.closeAllMenuPopovers();
|
|
484
484
|
this.fireMenuItemAction(target);
|
|
485
485
|
}
|
|
486
|
-
/**
|
|
487
|
-
* Resolves the key pressed by the user based on the direction of the layout.
|
|
488
|
-
* This method is used to handle keyboard navigation in a right-to-left (RTL) layout.
|
|
489
|
-
* It checks if the layout is RTL and adjusts the arrow keys accordingly.
|
|
490
|
-
* For example, in RTL, the left arrow key behaves like the right arrow key and vice versa.
|
|
491
|
-
* @param key - The key pressed by the user.
|
|
492
|
-
* @param isRtl - A boolean indicating if the layout is right-to-left (RTL).
|
|
493
|
-
* @returns - The resolved key based on the direction.
|
|
494
|
-
*/
|
|
495
|
-
resolveDirectionKey(key, isRtl) {
|
|
496
|
-
if (!isRtl)
|
|
497
|
-
return key;
|
|
498
|
-
switch (key) {
|
|
499
|
-
case KEYS.ARROW_LEFT:
|
|
500
|
-
return KEYS.ARROW_RIGHT;
|
|
501
|
-
case KEYS.ARROW_RIGHT:
|
|
502
|
-
return KEYS.ARROW_LEFT;
|
|
503
|
-
default:
|
|
504
|
-
return key;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
486
|
}
|
|
508
487
|
MenuPopover.styles = [...Popover.styles, ...styles];
|
|
509
488
|
__decorate([
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CSSResult, PropertyValues } from 'lit';
|
|
2
2
|
import { Component } from '../../models';
|
|
3
|
-
import type { PopoverColor, PopoverPlacement, PopoverStrategy, PopoverTrigger } from './popover.types';
|
|
4
|
-
declare const Popover_base: import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/BackdropMixin").BackdropMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/PreventScrollMixin").PreventScrollMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/FocusTrapMixin").FocusTrapClassInterface> & typeof Component;
|
|
3
|
+
import type { PopoverBoundaryRoot, PopoverColor, PopoverPlacement, PopoverStrategy, PopoverTrigger } from './popover.types';
|
|
4
|
+
declare const Popover_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/BackdropMixin").BackdropMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/PreventScrollMixin").PreventScrollMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/FocusTrapMixin").FocusTrapClassInterface> & typeof Component;
|
|
5
5
|
/**
|
|
6
6
|
* Popover is generic overlay which can be triggered by any actionable element.
|
|
7
7
|
*
|
|
@@ -156,7 +156,7 @@ declare class Popover extends Popover_base {
|
|
|
156
156
|
*
|
|
157
157
|
* @see [Floating UI - rootBoundary](https://floating-ui.com/docs/detectOverflow#rootboundary)
|
|
158
158
|
*/
|
|
159
|
-
boundaryRoot:
|
|
159
|
+
boundaryRoot: PopoverBoundaryRoot;
|
|
160
160
|
/**
|
|
161
161
|
* Virtual padding around the boundary to check for overflow.
|
|
162
162
|
* So the popover will not be placed on top of the edge of the boundary.
|
|
@@ -374,12 +374,12 @@ declare class Popover extends Popover_base {
|
|
|
374
374
|
/**
|
|
375
375
|
* Get trigger element on-demand
|
|
376
376
|
* It is necessary because trigger might appear later in the DOM, or it could be replaced completely.
|
|
377
|
-
*
|
|
378
|
-
* @internal
|
|
379
377
|
*/
|
|
380
378
|
get triggerElement(): HTMLElement | null;
|
|
379
|
+
/** @internal */
|
|
381
380
|
private timers;
|
|
382
381
|
constructor();
|
|
382
|
+
/** @internal */
|
|
383
383
|
private parseTrigger;
|
|
384
384
|
protected firstUpdated(changedProperties: PropertyValues): Promise<void>;
|
|
385
385
|
connectedCallback(): void;
|
|
@@ -390,14 +390,17 @@ declare class Popover extends Popover_base {
|
|
|
390
390
|
*
|
|
391
391
|
* We are using capture phase for to make sure we capture trigger events even when they are not propagated during the
|
|
392
392
|
* bubble phase (e.g.: buttons in list item)
|
|
393
|
+
* @internal
|
|
393
394
|
*/
|
|
394
395
|
private setupTriggerListeners;
|
|
395
396
|
/**
|
|
396
397
|
* Removes the trigger related event listeners.
|
|
398
|
+
* @internal
|
|
397
399
|
*/
|
|
398
400
|
private removeTriggerListeners;
|
|
399
401
|
/**
|
|
400
402
|
* Removes all event listeners related to the popover.
|
|
403
|
+
* @internal
|
|
401
404
|
*/
|
|
402
405
|
private removeAllListeners;
|
|
403
406
|
protected updated(changedProperties: PropertyValues): Promise<void>;
|
|
@@ -405,6 +408,7 @@ declare class Popover extends Popover_base {
|
|
|
405
408
|
* Handles the outside click event to close the popover.
|
|
406
409
|
*
|
|
407
410
|
* @param event - The mouse event.
|
|
411
|
+
* @internal
|
|
408
412
|
*/
|
|
409
413
|
protected onOutsidePopoverClick: (event: MouseEvent) => void;
|
|
410
414
|
/**
|
|
@@ -413,12 +417,14 @@ declare class Popover extends Popover_base {
|
|
|
413
417
|
* This method is attached to the document.
|
|
414
418
|
*
|
|
415
419
|
* @param event - The keyboard event.
|
|
420
|
+
* @internal
|
|
416
421
|
*/
|
|
417
422
|
private onEscapeKeydown;
|
|
418
423
|
/**
|
|
419
424
|
* Handles the popover focus out event.
|
|
420
425
|
*
|
|
421
426
|
* @param event - The focus event.
|
|
427
|
+
* @internal
|
|
422
428
|
*/
|
|
423
429
|
private onPopoverFocusOut;
|
|
424
430
|
/**
|
|
@@ -430,37 +436,43 @@ declare class Popover extends Popover_base {
|
|
|
430
436
|
*/
|
|
431
437
|
protected isOpenUpdated(oldValue: boolean, newValue: boolean): Promise<void>;
|
|
432
438
|
/**
|
|
433
|
-
*
|
|
434
|
-
*
|
|
439
|
+
* Handles mouse enter event on the trigger element.
|
|
440
|
+
* This method sets the `isHovered` flag to true and shows the popover
|
|
441
|
+
* @internal
|
|
435
442
|
*/
|
|
436
443
|
private handleMouseEnter;
|
|
437
444
|
/**
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
*
|
|
445
|
+
* Handles mouse leave event on the trigger element.
|
|
446
|
+
* This method sets the `isHovered` flag to false and starts the close delay
|
|
447
|
+
* timer to hide the popover.
|
|
448
|
+
* @internal
|
|
441
449
|
*/
|
|
442
450
|
private handleMouseLeave;
|
|
443
451
|
/**
|
|
444
|
-
* Handles focus out event on the trigger element.
|
|
445
452
|
* Closes based on hideOnBlur property or hover state.
|
|
453
|
+
* @internal
|
|
446
454
|
*/
|
|
447
455
|
private handleFocusOut;
|
|
448
456
|
/**
|
|
449
|
-
*
|
|
450
|
-
*
|
|
457
|
+
* Handles focus in event on the trigger element.
|
|
458
|
+
* This method checks if the trigger element has visible focus or is being hovered.
|
|
459
|
+
* @internal
|
|
451
460
|
*/
|
|
452
461
|
private handleFocusIn;
|
|
453
462
|
/**
|
|
454
463
|
* Cancels the open delay timer.
|
|
464
|
+
* @internal
|
|
455
465
|
*/
|
|
456
466
|
private cancelOpenDelay;
|
|
457
467
|
/**
|
|
458
468
|
* Starts the close delay timer.
|
|
459
469
|
* If the popover is not interactive, it will close the popover after the delay.
|
|
470
|
+
* @internal
|
|
460
471
|
*/
|
|
461
472
|
private startCloseDelay;
|
|
462
473
|
/**
|
|
463
474
|
* Cancels the close delay timer.
|
|
475
|
+
* @internal
|
|
464
476
|
*/
|
|
465
477
|
private cancelCloseDelay;
|
|
466
478
|
/**
|
|
@@ -479,6 +491,7 @@ declare class Popover extends Popover_base {
|
|
|
479
491
|
* Positions the popover based on the trigger element.
|
|
480
492
|
* It also handles the flip, size and arrow placement.
|
|
481
493
|
* It uses the floating-ui/dom library to calculate the position.
|
|
494
|
+
* @internal
|
|
482
495
|
*/
|
|
483
496
|
private positionPopover;
|
|
484
497
|
protected isEventFromTrigger(event: Event): boolean;
|
|
@@ -17,6 +17,7 @@ import { BackdropMixin } from '../../utils/mixins/BackdropMixin';
|
|
|
17
17
|
import { FocusTrapMixin } from '../../utils/mixins/FocusTrapMixin';
|
|
18
18
|
import { PreventScrollMixin } from '../../utils/mixins/PreventScrollMixin';
|
|
19
19
|
import { Timers } from '../../utils/controllers/Timers';
|
|
20
|
+
import { ACTIONS, KeyToActionMixin } from '../../utils/mixins/KeyToActionMixin';
|
|
20
21
|
import { COLOR, DEFAULTS, POPOVER_PLACEMENT, TIMEOUTS, TRIGGER } from './popover.constants';
|
|
21
22
|
import { PopoverEventManager } from './popover.events';
|
|
22
23
|
import { popoverStack } from './popover.stack';
|
|
@@ -96,7 +97,7 @@ import { PopoverUtils } from './popover.utils';
|
|
|
96
97
|
* @csspart popover-content - The content of the popover.
|
|
97
98
|
* @csspart popover-hover-bridge - The hover bridge of the popover.
|
|
98
99
|
*/
|
|
99
|
-
class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component))) {
|
|
100
|
+
class Popover extends KeyToActionMixin(BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)))) {
|
|
100
101
|
/**
|
|
101
102
|
* The effective z-index of the popover.
|
|
102
103
|
*
|
|
@@ -129,8 +130,6 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
129
130
|
/**
|
|
130
131
|
* Get trigger element on-demand
|
|
131
132
|
* It is necessary because trigger might appear later in the DOM, or it could be replaced completely.
|
|
132
|
-
*
|
|
133
|
-
* @internal
|
|
134
133
|
*/
|
|
135
134
|
get triggerElement() {
|
|
136
135
|
return this.getRootNode().querySelector(`[id="${this.triggerID}"]`);
|
|
@@ -384,7 +383,9 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
384
383
|
* @internal
|
|
385
384
|
*/
|
|
386
385
|
this.popoverDepth = 0;
|
|
386
|
+
/** @internal */
|
|
387
387
|
this.timers = new Timers(this);
|
|
388
|
+
/** @internal */
|
|
388
389
|
this.parseTrigger = () => {
|
|
389
390
|
var _a;
|
|
390
391
|
const triggers = ((_a = this.trigger) === null || _a === void 0 ? void 0 : _a.split(' ')) || [];
|
|
@@ -411,6 +412,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
411
412
|
*
|
|
412
413
|
* We are using capture phase for to make sure we capture trigger events even when they are not propagated during the
|
|
413
414
|
* bubble phase (e.g.: buttons in list item)
|
|
415
|
+
* @internal
|
|
414
416
|
*/
|
|
415
417
|
this.setupTriggerListeners = () => {
|
|
416
418
|
if (this.trigger.includes('click')) {
|
|
@@ -436,6 +438,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
436
438
|
};
|
|
437
439
|
/**
|
|
438
440
|
* Removes the trigger related event listeners.
|
|
441
|
+
* @internal
|
|
439
442
|
*/
|
|
440
443
|
this.removeTriggerListeners = () => {
|
|
441
444
|
// click trigger
|
|
@@ -453,6 +456,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
453
456
|
};
|
|
454
457
|
/**
|
|
455
458
|
* Removes all event listeners related to the popover.
|
|
459
|
+
* @internal
|
|
456
460
|
*/
|
|
457
461
|
this.removeAllListeners = () => {
|
|
458
462
|
this.removeTriggerListeners();
|
|
@@ -471,6 +475,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
471
475
|
* Handles the outside click event to close the popover.
|
|
472
476
|
*
|
|
473
477
|
* @param event - The mouse event.
|
|
478
|
+
* @internal
|
|
474
479
|
*/
|
|
475
480
|
this.onOutsidePopoverClick = (event) => {
|
|
476
481
|
if (popoverStack.peek() !== this)
|
|
@@ -489,9 +494,10 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
489
494
|
* This method is attached to the document.
|
|
490
495
|
*
|
|
491
496
|
* @param event - The keyboard event.
|
|
497
|
+
* @internal
|
|
492
498
|
*/
|
|
493
499
|
this.onEscapeKeydown = (event) => {
|
|
494
|
-
if (!this.visible || event
|
|
500
|
+
if (!this.visible || this.getActionForKeyEvent(event) !== ACTIONS.ESCAPE) {
|
|
495
501
|
return;
|
|
496
502
|
}
|
|
497
503
|
if (!this.propagateEventOnEscape) {
|
|
@@ -506,6 +512,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
506
512
|
* Handles the popover focus out event.
|
|
507
513
|
*
|
|
508
514
|
* @param event - The focus event.
|
|
515
|
+
* @internal
|
|
509
516
|
*/
|
|
510
517
|
this.onPopoverFocusOut = (event) => {
|
|
511
518
|
if (!this.contains(event.relatedTarget)) {
|
|
@@ -513,8 +520,9 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
513
520
|
}
|
|
514
521
|
};
|
|
515
522
|
/**
|
|
516
|
-
*
|
|
517
|
-
*
|
|
523
|
+
* Handles mouse enter event on the trigger element.
|
|
524
|
+
* This method sets the `isHovered` flag to true and shows the popover
|
|
525
|
+
* @internal
|
|
518
526
|
*/
|
|
519
527
|
this.handleMouseEnter = (event) => {
|
|
520
528
|
if (!this.isEventFromTrigger(event))
|
|
@@ -523,9 +531,10 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
523
531
|
this.show();
|
|
524
532
|
};
|
|
525
533
|
/**
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
534
|
+
* Handles mouse leave event on the trigger element.
|
|
535
|
+
* This method sets the `isHovered` flag to false and starts the close delay
|
|
536
|
+
* timer to hide the popover.
|
|
537
|
+
* @internal
|
|
529
538
|
*/
|
|
530
539
|
this.handleMouseLeave = (event) => {
|
|
531
540
|
if (!this.isEventFromTrigger(event))
|
|
@@ -534,8 +543,8 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
534
543
|
this.startCloseDelay();
|
|
535
544
|
};
|
|
536
545
|
/**
|
|
537
|
-
* Handles focus out event on the trigger element.
|
|
538
546
|
* Closes based on hideOnBlur property or hover state.
|
|
547
|
+
* @internal
|
|
539
548
|
*/
|
|
540
549
|
this.handleFocusOut = (event) => {
|
|
541
550
|
if (!this.isEventFromTrigger(event))
|
|
@@ -553,8 +562,9 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
553
562
|
}
|
|
554
563
|
};
|
|
555
564
|
/**
|
|
556
|
-
*
|
|
557
|
-
*
|
|
565
|
+
* Handles focus in event on the trigger element.
|
|
566
|
+
* This method checks if the trigger element has visible focus or is being hovered.
|
|
567
|
+
* @internal
|
|
558
568
|
*/
|
|
559
569
|
this.handleFocusIn = (event) => {
|
|
560
570
|
var _a, _b, _c, _d;
|
|
@@ -568,6 +578,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
568
578
|
};
|
|
569
579
|
/**
|
|
570
580
|
* Cancels the open delay timer.
|
|
581
|
+
* @internal
|
|
571
582
|
*/
|
|
572
583
|
this.cancelOpenDelay = () => {
|
|
573
584
|
this.timers.clearTimeout(TIMEOUTS.OPEN);
|
|
@@ -575,6 +586,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
575
586
|
/**
|
|
576
587
|
* Starts the close delay timer.
|
|
577
588
|
* If the popover is not interactive, it will close the popover after the delay.
|
|
589
|
+
* @internal
|
|
578
590
|
*/
|
|
579
591
|
this.startCloseDelay = () => {
|
|
580
592
|
this.cancelOpenDelay();
|
|
@@ -596,6 +608,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
596
608
|
};
|
|
597
609
|
/**
|
|
598
610
|
* Cancels the close delay timer.
|
|
611
|
+
* @internal
|
|
599
612
|
*/
|
|
600
613
|
this.cancelCloseDelay = () => {
|
|
601
614
|
this.timers.clearTimeout(TIMEOUTS.HOVER);
|
|
@@ -656,6 +669,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
|
|
|
656
669
|
* Positions the popover based on the trigger element.
|
|
657
670
|
* It also handles the flip, size and arrow placement.
|
|
658
671
|
* It uses the floating-ui/dom library to calculate the position.
|
|
672
|
+
* @internal
|
|
659
673
|
*/
|
|
660
674
|
this.positionPopover = () => {
|
|
661
675
|
const { triggerElement } = this;
|
|
@@ -27,6 +27,10 @@ declare const STRATEGY: {
|
|
|
27
27
|
readonly ABSOLUTE: "absolute";
|
|
28
28
|
readonly FIXED: "fixed";
|
|
29
29
|
};
|
|
30
|
+
declare const BOUNDARY_ROOT: {
|
|
31
|
+
readonly VIEWPORT: "viewport";
|
|
32
|
+
readonly DOCUMENT: "document";
|
|
33
|
+
};
|
|
30
34
|
declare const DEFAULTS: {
|
|
31
35
|
readonly PLACEMENT: "bottom";
|
|
32
36
|
readonly TRIGGER: "click";
|
|
@@ -63,4 +67,4 @@ declare const TIMEOUTS: {
|
|
|
63
67
|
readonly HOVER: "hover";
|
|
64
68
|
readonly CLOSE: "close";
|
|
65
69
|
};
|
|
66
|
-
export { TAG_NAME, POPOVER_PLACEMENT, COLOR, STRATEGY, TRIGGER, DEFAULTS, TIMEOUTS };
|
|
70
|
+
export { TAG_NAME, POPOVER_PLACEMENT, COLOR, STRATEGY, TRIGGER, BOUNDARY_ROOT, DEFAULTS, TIMEOUTS };
|
|
@@ -29,6 +29,10 @@ const STRATEGY = {
|
|
|
29
29
|
ABSOLUTE: 'absolute',
|
|
30
30
|
FIXED: 'fixed',
|
|
31
31
|
};
|
|
32
|
+
const BOUNDARY_ROOT = {
|
|
33
|
+
VIEWPORT: 'viewport',
|
|
34
|
+
DOCUMENT: 'document',
|
|
35
|
+
};
|
|
32
36
|
const DEFAULTS = {
|
|
33
37
|
PLACEMENT: POPOVER_PLACEMENT.BOTTOM,
|
|
34
38
|
TRIGGER: TRIGGER.CLICK,
|
|
@@ -36,7 +40,7 @@ const DEFAULTS = {
|
|
|
36
40
|
STRATEGY: STRATEGY.ABSOLUTE,
|
|
37
41
|
OFFSET: 4,
|
|
38
42
|
BOUNDARY: 'clippingAncestors',
|
|
39
|
-
BOUNDARY_ROOT:
|
|
43
|
+
BOUNDARY_ROOT: BOUNDARY_ROOT.VIEWPORT,
|
|
40
44
|
BOUNDARY_PADDING: 0,
|
|
41
45
|
VISIBLE: false,
|
|
42
46
|
ARROW: false,
|
|
@@ -65,4 +69,4 @@ const TIMEOUTS = {
|
|
|
65
69
|
HOVER: 'hover',
|
|
66
70
|
CLOSE: 'close',
|
|
67
71
|
};
|
|
68
|
-
export { TAG_NAME, POPOVER_PLACEMENT, COLOR, STRATEGY, TRIGGER, DEFAULTS, TIMEOUTS };
|
|
72
|
+
export { TAG_NAME, POPOVER_PLACEMENT, COLOR, STRATEGY, TRIGGER, BOUNDARY_ROOT, DEFAULTS, TIMEOUTS };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ValueOf, TypedCustomEvent } from '../../utils/types';
|
|
2
2
|
import type Popover from './popover.component';
|
|
3
|
-
import { POPOVER_PLACEMENT, TRIGGER, COLOR, STRATEGY } from './popover.constants';
|
|
3
|
+
import { POPOVER_PLACEMENT, TRIGGER, COLOR, STRATEGY, BOUNDARY_ROOT } from './popover.constants';
|
|
4
4
|
type PopoverPlacement = ValueOf<typeof POPOVER_PLACEMENT>;
|
|
5
5
|
type PopoverColor = ValueOf<typeof COLOR>;
|
|
6
6
|
type PopoverStrategy = ValueOf<typeof STRATEGY>;
|
|
7
|
+
type PopoverBoundaryRoot = ValueOf<typeof BOUNDARY_ROOT>;
|
|
7
8
|
type PopoverTrigger = ValueOf<typeof TRIGGER> | `${ValueOf<typeof TRIGGER>} ${ValueOf<typeof TRIGGER>}`;
|
|
8
9
|
type PopoverShownEvent = TypedCustomEvent<Popover, {
|
|
9
10
|
show: boolean;
|
|
@@ -23,4 +24,4 @@ interface Events {
|
|
|
23
24
|
onCreatedEvent: PopoverCreatedEvent;
|
|
24
25
|
onDestroyedEvent: PopoverDestroyedEvent;
|
|
25
26
|
}
|
|
26
|
-
export type { PopoverPlacement, PopoverColor, PopoverStrategy, PopoverTrigger, Events, PopoverShownEvent, PopoverHiddenEvent, };
|
|
27
|
+
export type { PopoverPlacement, PopoverColor, PopoverStrategy, PopoverBoundaryRoot, PopoverTrigger, Events, PopoverShownEvent, PopoverHiddenEvent, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CSSResult, PropertyValueMap, PropertyValues } from 'lit';
|
|
2
2
|
import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
|
|
3
3
|
import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
|
|
4
|
-
declare const Radio_base: import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
|
|
4
|
+
declare const Radio_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
|
|
5
5
|
/**
|
|
6
6
|
* The Radio component allows users to select a single option from a group of mutually exclusive choices.
|
|
7
7
|
* Unlike checkboxes which allow multiple selections, radio buttons ensure only one option can be selected
|