@mgdis/mg-components 4.2.0 → 5.0.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.
- package/dist/cjs/{index-64cee0c8.js → index-94497267.js} +220 -202
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{mg-badge_23.cjs.entry.js → mg-badge_24.cjs.entry.js} +2028 -26
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-modal.cjs.entry.js +6 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +0 -2
- package/dist/collection/components/atoms/mg-button/mg-button.css +106 -68
- package/dist/collection/components/atoms/mg-button/mg-button.js +51 -64
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +3 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +2 -3
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +2 -1
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.css +15 -7
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +27 -2
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +1 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +2 -2
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +4 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +4 -3
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +1 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +8 -7
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +5 -7
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +7 -8
- package/dist/collection/variables.css +6 -0
- package/dist/components/mg-button2.js +44 -13
- package/dist/components/mg-form.js +2 -3
- package/dist/components/mg-icon2.js +3 -0
- package/dist/components/mg-illustrated-message.js +12 -4
- package/dist/components/mg-input-numeric.js +1 -1
- package/dist/components/mg-modal.js +5 -1
- package/dist/components/mg-pagination.js +4 -3
- package/dist/components/mg-panel.js +2 -2
- package/dist/components/mg-popover.js +9 -9
- package/dist/components/mg-tooltip2.js +5 -4
- package/dist/components/popper.js +60 -49
- package/dist/esm/{index-120f47fd.js → index-aad0184c.js} +220 -202
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{mg-badge_23.entry.js → mg-badge_24.entry.js} +2027 -26
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-modal.entry.js +6 -2
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-3899d5d2.js +2 -0
- package/dist/mg-components/p-b60a4c53.entry.js +1 -0
- package/dist/mg-components/p-df947fa5.entry.js +1 -0
- package/dist/mg-components/variables.css +6 -0
- package/dist/types/components/atoms/mg-button/doc/mg-button.stories.d.ts +2 -2
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +5 -1
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +19 -17
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +4 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +1 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +1 -0
- package/dist/types/components.d.ts +13 -29
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/package.json +2 -2
- package/dist/cjs/mg-popover.cjs.entry.js +0 -171
- package/dist/cjs/popper-71bf3058.js +0 -1790
- package/dist/collection/variables.scss +0 -212
- package/dist/esm/mg-popover.entry.js +0 -167
- package/dist/esm/popper-93ecb064.js +0 -1788
- package/dist/mg-components/p-21991be8.entry.js +0 -1
- package/dist/mg-components/p-36a64f8c.entry.js +0 -1
- package/dist/mg-components/p-4c66f794.js +0 -1
- package/dist/mg-components/p-7bc32a2f.js +0 -2
- package/dist/mg-components/p-b380a0df.entry.js +0 -1
- package/dist/mg-components/variables.scss +0 -212
|
@@ -81,10 +81,11 @@ const MgPagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
81
81
|
* Go to 'previous/next' page button handler
|
|
82
82
|
*
|
|
83
83
|
* @param {string} action navigation action
|
|
84
|
+
* @param {boolean} disabled button disable state
|
|
84
85
|
* @returns {void}
|
|
85
86
|
*/
|
|
86
|
-
this.handleGoToPage = (action) => {
|
|
87
|
-
this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
87
|
+
this.handleGoToPage = (action, disabled) => {
|
|
88
|
+
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
91
|
validateTotalPages(newValue) {
|
|
@@ -128,7 +129,7 @@ const MgPagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
128
129
|
render() {
|
|
129
130
|
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
|
|
130
131
|
// eslint-disable-next-line react/jsx-no-bind
|
|
131
|
-
onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" }, action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }), this.messages.general[action], action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
|
|
132
|
+
onClick: () => this.handleGoToPage(action, disabled), disabled: disabled, variant: "flat" }, action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }), this.messages.general[action], action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
|
|
132
133
|
return (h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination" }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), h("span", { class: "sr-only" }, this.messages.pagination.page, " ", this.currentPage), h("span", null, "/ ", this.totalPages, " ", this.totalPages > 1 ? this.messages.pagination.pages : this.messages.pagination.page), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
|
|
133
134
|
}
|
|
134
135
|
get element() { return this; }
|
|
@@ -8,7 +8,7 @@ import { d as defineCustomElement$4 } from './mg-input-text2.js';
|
|
|
8
8
|
import { d as defineCustomElement$3 } from './mg-input-title2.js';
|
|
9
9
|
import { d as defineCustomElement$2 } from './mg-tooltip2.js';
|
|
10
10
|
|
|
11
|
-
const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);box-shadow:var(--box-shadow)}.mg-panel__header{display:flex;flex-wrap:wrap;justify-content:space-between;padding:0 1rem 0 0.3rem;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:flex;margin:0.3rem 0}.mg-panel__header-left--full{flex:1 1 auto}.mg-panel__header-right{flex:1 auto}.mg-panel__header-left mg-input-text{flex-grow:1}.mg-panel__header-left mg-button:not([slot=append-input]){margin:0
|
|
11
|
+
const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);box-shadow:var(--box-shadow)}.mg-panel__header{display:flex;flex-wrap:wrap;justify-content:space-between;padding:0 1rem 0 0.3rem;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:flex;margin:0.3rem 0}.mg-panel__header-left--full{flex:1 1 auto}.mg-panel__header-right{padding-left:0.3rem;flex:1 auto}.mg-panel__header-left mg-input-text{flex-grow:1;margin-left:0.3rem}.mg-panel__header-left mg-button+mg-button:not([slot=append-input]){margin-left:0.3rem}.mg-panel__collapse-button-content{--font-size:1.4rem;--mg-button-font-weight:600}.mg-panel__content{padding:var(--mg-panel-content-padding)}.mg-panel ::slotted([slot=header-right]){display:flex;flex-wrap:wrap;gap:1rem;margin-left:auto}";
|
|
12
12
|
|
|
13
13
|
const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
14
14
|
constructor() {
|
|
@@ -107,7 +107,7 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
107
107
|
* @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
|
|
108
108
|
*/
|
|
109
109
|
this.headerLeft = () => {
|
|
110
|
-
const collapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", identifier: `${this.identifier}-collapse-button`, expanded: this.expanded, controls: `${this.identifier}-content`, disabled: this.expandToggleDisabled }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle));
|
|
110
|
+
const collapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", identifier: `${this.identifier}-collapse-button`, "aria-expanded": this.expanded !== undefined && this.expanded.toString(), "aria-controls": `${this.identifier}-content`, disabled: this.expandToggleDisabled }, h("span", { class: "mg-panel__collapse-button-content" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle)));
|
|
111
111
|
if (this.titleEditable && !this.isEditing) {
|
|
112
112
|
return [
|
|
113
113
|
collapseButton(),
|
|
@@ -5,12 +5,13 @@ import { d as defineCustomElement$3 } from './mg-button2.js';
|
|
|
5
5
|
import { d as defineCustomElement$2 } from './mg-icon2.js';
|
|
6
6
|
import { c as createPopper } from './popper.js';
|
|
7
7
|
|
|
8
|
-
const mgPopoverCss = "mg-popover
|
|
8
|
+
const mgPopoverCss = "mg-popover{display:contents}mg-popover::slotted(*){display:inline-block}.mg-popover{display:none;padding:1.5rem;z-index:9999;border-radius:0.5rem;background-color:hsl(var(--mg-popover-background-color));box-shadow:var(--box-shadow);color:hsl(var(--mg-popover-font-color))}.mg-popover[data-show]{display:block}.mg-popover mg-button{float:right;margin-right:calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);margin-top:calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);margin-left:3rem}.mg-popover__arrow,.mg-popover__arrow::before{position:absolute;width:2rem;height:2rem;z-index:-1;background:inherit}.mg-popover__arrow{visibility:hidden}.mg-popover__arrow::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow{bottom:-6px}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{top:-6px}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow{right:-6px}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{left:-6px}.mg-popover__title ::slotted([slot=title]){margin:0 0 1rem !important;font-size:var(--mg-popover-title-font-size) !important;font-weight:600}";
|
|
9
9
|
|
|
10
10
|
const MgPopover$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
11
11
|
constructor() {
|
|
12
12
|
super();
|
|
13
13
|
this.__registerHost();
|
|
14
|
+
this.__attachShadow();
|
|
14
15
|
this.displayChange = createEvent(this, "display-change", 7);
|
|
15
16
|
this.closeButtonId = '';
|
|
16
17
|
/**
|
|
@@ -41,8 +42,7 @@ const MgPopover$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
41
42
|
* @returns {void}
|
|
42
43
|
*/
|
|
43
44
|
this.clickOutside = (event) => {
|
|
44
|
-
|
|
45
|
-
if (!this.disabled && ((_a = event.target.closest(`#${this.identifier}`)) === null || _a === void 0 ? void 0 : _a.parentElement.nodeName) !== 'MG-POPOVER') {
|
|
45
|
+
if (!this.disabled && event.target.closest(`mg-popover`) !== this.element) {
|
|
46
46
|
this.display = false;
|
|
47
47
|
}
|
|
48
48
|
};
|
|
@@ -114,8 +114,8 @@ const MgPopover$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
114
114
|
*/
|
|
115
115
|
componentDidLoad() {
|
|
116
116
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
117
|
+
const slottedTitleElement = this.element.querySelector('[slot="title"]');
|
|
118
|
+
if (slottedTitleElement && !isTagName(slottedTitleElement, headingTags)) {
|
|
119
119
|
throw new Error(`<mg-popover> Slotted title must be a heading: ${headingTags.join(', ')}`);
|
|
120
120
|
}
|
|
121
121
|
// Set close button id
|
|
@@ -123,9 +123,9 @@ const MgPopover$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
123
123
|
this.closeButtonId = `${this.identifier}-close-button`;
|
|
124
124
|
}
|
|
125
125
|
// Get popover content
|
|
126
|
-
this.popover = this.element.querySelector(`#${this.identifier}`);
|
|
127
|
-
//Get interactive element
|
|
128
|
-
const interactiveElement = this.element.
|
|
126
|
+
this.popover = this.element.shadowRoot.querySelector(`#${this.identifier}`);
|
|
127
|
+
//Get interactive element (first element without slot attribute)
|
|
128
|
+
const interactiveElement = this.element.querySelector(':not([slot])');
|
|
129
129
|
// Add aria attributes
|
|
130
130
|
interactiveElement.setAttribute('aria-controls', this.identifier);
|
|
131
131
|
interactiveElement.setAttribute('aria-expanded', `${this.display}`);
|
|
@@ -166,7 +166,7 @@ const MgPopover$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
166
166
|
"display": ["handleDisplay"]
|
|
167
167
|
}; }
|
|
168
168
|
static get style() { return mgPopoverCss; }
|
|
169
|
-
}, [
|
|
169
|
+
}, [1, "mg-popover", {
|
|
170
170
|
"identifier": [1],
|
|
171
171
|
"placement": [1],
|
|
172
172
|
"closeButton": [4, "close-button"],
|
|
@@ -12,12 +12,13 @@ var Guard;
|
|
|
12
12
|
Guard["HOVER_TOOLTIPED_ELEMENT"] = "hoverTooltipedGuard";
|
|
13
13
|
})(Guard || (Guard = {}));
|
|
14
14
|
|
|
15
|
-
const mgTooltipCss = "
|
|
15
|
+
const mgTooltipCss = ":host{display:inline-block}.mg-tooltip{display:none;padding:0.5rem 0.8rem;z-index:9999;border-radius:var(--mg-tooltip-border-radius);background-color:hsl(var(--mg-tooltip-background-color));color:hsl(var(--mg-tooltip-font-color));text-align:start}.mg-tooltip[data-show]{display:block}.mg-tooltip .mg-tooltip__arrow,.mg-tooltip .mg-tooltip__arrow::before{position:absolute;width:0.8rem;height:0.8rem;z-index:9999;background:inherit}.mg-tooltip .mg-tooltip__arrow{visibility:hidden}.mg-tooltip .mg-tooltip__arrow::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-tooltip[data-popper-placement^=top]>.mg-tooltip__arrow{bottom:-4px}.mg-tooltip[data-popper-placement^=bottom]>.mg-tooltip__arrow{top:-4px}.mg-tooltip[data-popper-placement^=left]>.mg-tooltip__arrow{right:-4px}.mg-tooltip[data-popper-placement^=right]>.mg-tooltip__arrow{left:-4px}";
|
|
16
16
|
|
|
17
17
|
const MgTooltip = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
18
18
|
constructor() {
|
|
19
19
|
super();
|
|
20
20
|
this.__registerHost();
|
|
21
|
+
this.__attachShadow();
|
|
21
22
|
/**
|
|
22
23
|
* Sets an `id` attribute.
|
|
23
24
|
* Needed by the input for accessibility `aria-decribedby`.
|
|
@@ -128,12 +129,12 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
128
129
|
componentDidLoad() {
|
|
129
130
|
var _a;
|
|
130
131
|
// Get tooltip element
|
|
131
|
-
this.tooltip = this.element.querySelector(`#${this.identifier}`);
|
|
132
|
+
this.tooltip = this.element.shadowRoot.querySelector(`#${this.identifier}`);
|
|
132
133
|
// get slotted element
|
|
133
134
|
const slotElement = this.element.firstElementChild;
|
|
134
135
|
// Get interactive element
|
|
135
136
|
const interactiveElements = ['a', 'button', 'input', 'textarea', 'select']; //! Might needs updates
|
|
136
|
-
const interactiveElement = this.element.querySelector(interactiveElements.join(',')) || ((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
|
|
137
|
+
const interactiveElement = this.element.shadowRoot.querySelector(interactiveElements.join(',')) || ((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
|
|
137
138
|
// define selected element to become tooltip selector
|
|
138
139
|
const tooltipedElement = interactiveElement || slotElement;
|
|
139
140
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
@@ -203,7 +204,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
203
204
|
"display": ["handleDisplay"]
|
|
204
205
|
}; }
|
|
205
206
|
static get style() { return mgTooltipCss; }
|
|
206
|
-
}, [
|
|
207
|
+
}, [1, "mg-tooltip", {
|
|
207
208
|
"identifier": [1],
|
|
208
209
|
"message": [1],
|
|
209
210
|
"placement": [1],
|
|
@@ -158,38 +158,57 @@ var max = Math.max;
|
|
|
158
158
|
var min = Math.min;
|
|
159
159
|
var round = Math.round;
|
|
160
160
|
|
|
161
|
-
function
|
|
161
|
+
function getUAString() {
|
|
162
|
+
var uaData = navigator.userAgentData;
|
|
163
|
+
|
|
164
|
+
if (uaData != null && uaData.brands) {
|
|
165
|
+
return uaData.brands.map(function (item) {
|
|
166
|
+
return item.brand + "/" + item.version;
|
|
167
|
+
}).join(' ');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return navigator.userAgent;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function isLayoutViewport() {
|
|
174
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
162
178
|
if (includeScale === void 0) {
|
|
163
179
|
includeScale = false;
|
|
164
180
|
}
|
|
165
181
|
|
|
166
|
-
|
|
182
|
+
if (isFixedStrategy === void 0) {
|
|
183
|
+
isFixedStrategy = false;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
var clientRect = element.getBoundingClientRect();
|
|
167
187
|
var scaleX = 1;
|
|
168
188
|
var scaleY = 1;
|
|
169
189
|
|
|
170
|
-
if (isHTMLElement(element)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// Fallback to 1 in case both values are `0`
|
|
174
|
-
|
|
175
|
-
if (offsetWidth > 0) {
|
|
176
|
-
scaleX = round(rect.width) / offsetWidth || 1;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (offsetHeight > 0) {
|
|
180
|
-
scaleY = round(rect.height) / offsetHeight || 1;
|
|
181
|
-
}
|
|
190
|
+
if (includeScale && isHTMLElement(element)) {
|
|
191
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
192
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
182
193
|
}
|
|
183
194
|
|
|
195
|
+
var _ref = isElement(element) ? getWindow(element) : window,
|
|
196
|
+
visualViewport = _ref.visualViewport;
|
|
197
|
+
|
|
198
|
+
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
199
|
+
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
|
200
|
+
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
|
201
|
+
var width = clientRect.width / scaleX;
|
|
202
|
+
var height = clientRect.height / scaleY;
|
|
184
203
|
return {
|
|
185
|
-
width:
|
|
186
|
-
height:
|
|
187
|
-
top:
|
|
188
|
-
right:
|
|
189
|
-
bottom:
|
|
190
|
-
left:
|
|
191
|
-
x:
|
|
192
|
-
y:
|
|
204
|
+
width: width,
|
|
205
|
+
height: height,
|
|
206
|
+
top: y,
|
|
207
|
+
right: x + width,
|
|
208
|
+
bottom: y + height,
|
|
209
|
+
left: x,
|
|
210
|
+
x: x,
|
|
211
|
+
y: y
|
|
193
212
|
};
|
|
194
213
|
}
|
|
195
214
|
|
|
@@ -284,8 +303,8 @@ function getTrueOffsetParent(element) {
|
|
|
284
303
|
|
|
285
304
|
|
|
286
305
|
function getContainingBlock(element) {
|
|
287
|
-
var isFirefox =
|
|
288
|
-
var isIE =
|
|
306
|
+
var isFirefox = /firefox/i.test(getUAString());
|
|
307
|
+
var isIE = /Trident/i.test(getUAString());
|
|
289
308
|
|
|
290
309
|
if (isIE && isHTMLElement(element)) {
|
|
291
310
|
// In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
|
|
@@ -706,31 +725,21 @@ function getWindowScrollBarX(element) {
|
|
|
706
725
|
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
|
707
726
|
}
|
|
708
727
|
|
|
709
|
-
function getViewportRect(element) {
|
|
728
|
+
function getViewportRect(element, strategy) {
|
|
710
729
|
var win = getWindow(element);
|
|
711
730
|
var html = getDocumentElement(element);
|
|
712
731
|
var visualViewport = win.visualViewport;
|
|
713
732
|
var width = html.clientWidth;
|
|
714
733
|
var height = html.clientHeight;
|
|
715
734
|
var x = 0;
|
|
716
|
-
var y = 0;
|
|
717
|
-
// can be obscured underneath it.
|
|
718
|
-
// Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
|
|
719
|
-
// if it isn't open, so if this isn't available, the popper will be detected
|
|
720
|
-
// to overflow the bottom of the screen too early.
|
|
735
|
+
var y = 0;
|
|
721
736
|
|
|
722
737
|
if (visualViewport) {
|
|
723
738
|
width = visualViewport.width;
|
|
724
|
-
height = visualViewport.height;
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
// Feature detection fails in mobile emulation mode in Chrome.
|
|
729
|
-
// Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
|
|
730
|
-
// 0.001
|
|
731
|
-
// Fallback here: "Not Safari" userAgent
|
|
732
|
-
|
|
733
|
-
if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
|
|
739
|
+
height = visualViewport.height;
|
|
740
|
+
var layoutViewport = isLayoutViewport();
|
|
741
|
+
|
|
742
|
+
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
734
743
|
x = visualViewport.offsetLeft;
|
|
735
744
|
y = visualViewport.offsetTop;
|
|
736
745
|
}
|
|
@@ -824,8 +833,8 @@ function rectToClientRect(rect) {
|
|
|
824
833
|
});
|
|
825
834
|
}
|
|
826
835
|
|
|
827
|
-
function getInnerBoundingClientRect(element) {
|
|
828
|
-
var rect = getBoundingClientRect(element);
|
|
836
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
837
|
+
var rect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
829
838
|
rect.top = rect.top + element.clientTop;
|
|
830
839
|
rect.left = rect.left + element.clientLeft;
|
|
831
840
|
rect.bottom = rect.top + element.clientHeight;
|
|
@@ -837,8 +846,8 @@ function getInnerBoundingClientRect(element) {
|
|
|
837
846
|
return rect;
|
|
838
847
|
}
|
|
839
848
|
|
|
840
|
-
function getClientRectFromMixedType(element, clippingParent) {
|
|
841
|
-
return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
849
|
+
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
|
850
|
+
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
842
851
|
} // A "clipping parent" is an overflowable container with the characteristic of
|
|
843
852
|
// clipping (or hiding) overflowing elements with a position different from
|
|
844
853
|
// `initial`
|
|
@@ -861,18 +870,18 @@ function getClippingParents(element) {
|
|
|
861
870
|
// clipping parents
|
|
862
871
|
|
|
863
872
|
|
|
864
|
-
function getClippingRect(element, boundary, rootBoundary) {
|
|
873
|
+
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
|
865
874
|
var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
|
866
875
|
var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
|
|
867
876
|
var firstClippingParent = clippingParents[0];
|
|
868
877
|
var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
|
|
869
|
-
var rect = getClientRectFromMixedType(element, clippingParent);
|
|
878
|
+
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
|
870
879
|
accRect.top = max(rect.top, accRect.top);
|
|
871
880
|
accRect.right = min(rect.right, accRect.right);
|
|
872
881
|
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
873
882
|
accRect.left = max(rect.left, accRect.left);
|
|
874
883
|
return accRect;
|
|
875
|
-
}, getClientRectFromMixedType(element, firstClippingParent));
|
|
884
|
+
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
|
876
885
|
clippingRect.width = clippingRect.right - clippingRect.left;
|
|
877
886
|
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|
878
887
|
clippingRect.x = clippingRect.left;
|
|
@@ -953,6 +962,8 @@ function detectOverflow(state, options) {
|
|
|
953
962
|
var _options = options,
|
|
954
963
|
_options$placement = _options.placement,
|
|
955
964
|
placement = _options$placement === void 0 ? state.placement : _options$placement,
|
|
965
|
+
_options$strategy = _options.strategy,
|
|
966
|
+
strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
|
|
956
967
|
_options$boundary = _options.boundary,
|
|
957
968
|
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
|
|
958
969
|
_options$rootBoundary = _options.rootBoundary,
|
|
@@ -967,7 +978,7 @@ function detectOverflow(state, options) {
|
|
|
967
978
|
var altContext = elementContext === popper ? reference : popper;
|
|
968
979
|
var popperRect = state.rects.popper;
|
|
969
980
|
var element = state.elements[altBoundary ? altContext : elementContext];
|
|
970
|
-
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
|
|
981
|
+
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
|
971
982
|
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
|
972
983
|
var popperOffsets = computeOffsets({
|
|
973
984
|
reference: referenceClientRect,
|
|
@@ -1481,7 +1492,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
|
1481
1492
|
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1482
1493
|
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
|
1483
1494
|
var documentElement = getDocumentElement(offsetParent);
|
|
1484
|
-
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
|
|
1495
|
+
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
|
1485
1496
|
var scroll = {
|
|
1486
1497
|
scrollLeft: 0,
|
|
1487
1498
|
scrollTop: 0
|