@momentum-design/components 0.104.4 → 0.104.5
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 +269 -275
- package/dist/browser/index.js.map +4 -4
- package/dist/components/dialog/dialog.component.d.ts +1 -10
- package/dist/components/dialog/dialog.component.js +13 -45
- package/dist/components/menubar/menubar.component.js +1 -1
- package/dist/components/menupopover/menupopover.component.js +2 -1
- package/dist/components/popover/popover.component.d.ts +13 -5
- package/dist/components/popover/popover.component.js +25 -20
- package/dist/components/popover/popover.constants.d.ts +1 -0
- package/dist/components/popover/popover.constants.js +1 -0
- package/dist/components/popover/popover.utils.d.ts +0 -2
- package/dist/components/popover/popover.utils.js +0 -29
- package/dist/components/select/select.component.d.ts +13 -0
- package/dist/components/select/select.component.js +19 -0
- package/dist/components/select/select.styles.js +1 -0
- package/dist/custom-elements.json +619 -150
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/utils/mixins/BackdropMixin.d.ts +14 -0
- package/dist/utils/mixins/BackdropMixin.js +99 -0
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
@@ -54,10 +54,10 @@ export { default as Radio } from './radio';
|
|
54
54
|
export { default as RadioGroup } from './radiogroup';
|
55
55
|
export { default as ScreenreaderAnnouncer } from './screenreaderannouncer';
|
56
56
|
export { default as Searchfield } from './searchfield';
|
57
|
-
export { default as Select } from './select';
|
58
57
|
export { default as Selectlistbox } from './selectlistbox';
|
59
|
-
export { default as
|
58
|
+
export { default as Select } from './select';
|
60
59
|
export { default as Skeleton } from './skeleton';
|
60
|
+
export { default as SideNavigation } from './sidenavigation';
|
61
61
|
export { default as Spinner } from './spinner';
|
62
62
|
export { default as StaticCheckbox } from './staticcheckbox';
|
63
63
|
export { default as StaticRadio } from './staticradio';
|
package/dist/react/index.js
CHANGED
@@ -54,10 +54,10 @@ export { default as Radio } from './radio';
|
|
54
54
|
export { default as RadioGroup } from './radiogroup';
|
55
55
|
export { default as ScreenreaderAnnouncer } from './screenreaderannouncer';
|
56
56
|
export { default as Searchfield } from './searchfield';
|
57
|
-
export { default as Select } from './select';
|
58
57
|
export { default as Selectlistbox } from './selectlistbox';
|
59
|
-
export { default as
|
58
|
+
export { default as Select } from './select';
|
60
59
|
export { default as Skeleton } from './skeleton';
|
60
|
+
export { default as SideNavigation } from './sidenavigation';
|
61
61
|
export { default as Spinner } from './spinner';
|
62
62
|
export { default as StaticCheckbox } from './staticcheckbox';
|
63
63
|
export { default as StaticRadio } from './staticradio';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { LitElement } from 'lit';
|
2
|
+
import type { Component } from '../../models';
|
3
|
+
import type { Constructor } from './index.types';
|
4
|
+
export declare abstract class BackdropMixinInterface {
|
5
|
+
abstract zIndex: number;
|
6
|
+
protected backdropElement: HTMLElement | null;
|
7
|
+
protected isBackdropInvisible?: boolean;
|
8
|
+
protected backdropAppendTo?: string;
|
9
|
+
protected createBackdrop(classNamePrefix: string): void;
|
10
|
+
protected removeBackdrop(): void;
|
11
|
+
protected keepElementAboveBackdrop(element?: HTMLElement | null): void;
|
12
|
+
protected moveElementBackAfterBackdropRemoval(element?: HTMLElement | null): void;
|
13
|
+
}
|
14
|
+
export declare const BackdropMixin: <T extends Constructor<LitElement>>(superClass: T) => Constructor<Component & BackdropMixinInterface> & T;
|
@@ -0,0 +1,99 @@
|
|
1
|
+
export const BackdropMixin = (superClass) => {
|
2
|
+
class Backdrop extends superClass {
|
3
|
+
constructor() {
|
4
|
+
super(...arguments);
|
5
|
+
/**
|
6
|
+
* Set this property to true to make the backdrop invisible.
|
7
|
+
* This is useful for components that do want a backdrop which stops interaction,
|
8
|
+
* but do not want the backdrop to be visible.
|
9
|
+
* @internal
|
10
|
+
*/
|
11
|
+
this.isBackdropInvisible = false;
|
12
|
+
/** @internal */
|
13
|
+
this.backdropElement = null;
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* Creates a backdrop element with the specified class name prefix.
|
17
|
+
*
|
18
|
+
* @param classNamePrefix - The prefix for the backdrop class name.
|
19
|
+
* @internal
|
20
|
+
*/
|
21
|
+
createBackdrop(classNamePrefix) {
|
22
|
+
const backdrop = document.createElement('div');
|
23
|
+
backdrop.classList.add(`${classNamePrefix}-backdrop`);
|
24
|
+
const styleElement = document.createElement('style');
|
25
|
+
styleElement.textContent = `
|
26
|
+
.${classNamePrefix}-backdrop {
|
27
|
+
position: fixed;
|
28
|
+
top: 0;
|
29
|
+
left: 0;
|
30
|
+
width: 100%;
|
31
|
+
height: 100%;
|
32
|
+
background: ${this.isBackdropInvisible ? `transparent` : `var(--mds-color-theme-common-overlays-secondary-normal)`};
|
33
|
+
z-index: ${this.zIndex - 1};
|
34
|
+
}
|
35
|
+
`;
|
36
|
+
backdrop.appendChild(styleElement);
|
37
|
+
const backdropAppendToElement = document.getElementById(this.backdropAppendTo);
|
38
|
+
const elementToAppendTo = backdropAppendToElement || this.parentElement;
|
39
|
+
elementToAppendTo === null || elementToAppendTo === void 0 ? void 0 : elementToAppendTo.appendChild(backdrop);
|
40
|
+
this.backdropElement = backdrop;
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* Removes the backdrop element if it exists.
|
44
|
+
* @internal
|
45
|
+
*/
|
46
|
+
removeBackdrop() {
|
47
|
+
if (this.backdropElement) {
|
48
|
+
this.backdropElement.remove();
|
49
|
+
this.backdropElement = null;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* Keeps the specified element above the backdrop by adjusting its z-index and position.
|
54
|
+
*
|
55
|
+
* This method stores the original z-index and position of the element,
|
56
|
+
* and sets the z-index to the component's zIndex value.
|
57
|
+
* If the element's position is not already set to 'fixed' or 'absolute',
|
58
|
+
* it will be set to 'relative'.
|
59
|
+
* @param element - The element to keep above the backdrop.
|
60
|
+
* @internal
|
61
|
+
*/
|
62
|
+
keepElementAboveBackdrop(element) {
|
63
|
+
if (!element) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
// Store the original z-index and position of the element
|
67
|
+
this.elementOriginalStyle = {
|
68
|
+
zIndex: element.style.zIndex,
|
69
|
+
position: element.style.position,
|
70
|
+
};
|
71
|
+
// Set the z-index and position to ensure the element is above the backdrop
|
72
|
+
element.style.zIndex = `${this.zIndex}`;
|
73
|
+
// Only set the position to relative if it is not already set to fixed or absolute
|
74
|
+
if (!['fixed', 'absolute'].includes(window.getComputedStyle(element).position)) {
|
75
|
+
element.style.position = 'relative';
|
76
|
+
}
|
77
|
+
}
|
78
|
+
/**
|
79
|
+
* Moves the element back to its original z-index and position after the backdrop is removed.
|
80
|
+
*
|
81
|
+
* This method restores the original z-index and position of the element
|
82
|
+
* that was kept above the backdrop (by using `keepElementAboveBackdrop`).
|
83
|
+
*
|
84
|
+
* @param element - The element which styling should be restored.
|
85
|
+
* @internal
|
86
|
+
*/
|
87
|
+
moveElementBackAfterBackdropRemoval(element) {
|
88
|
+
if (!element || !this.elementOriginalStyle) {
|
89
|
+
return;
|
90
|
+
}
|
91
|
+
// Restore the original z-index and position of the element
|
92
|
+
element.style.zIndex = this.elementOriginalStyle.zIndex;
|
93
|
+
element.style.position = this.elementOriginalStyle.position;
|
94
|
+
// Clear the stored original style
|
95
|
+
this.elementOriginalStyle = undefined;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
return Backdrop;
|
99
|
+
};
|