vrembem 4.0.0-next.23 → 4.0.0-next.24
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/dev/base.css +14 -12
- package/dev/base.css.map +1 -1
- package/dev/index.css +14 -12
- package/dev/index.css.map +1 -1
- package/dev/index.js +52 -34
- package/dev/index.js.map +1 -1
- package/dev/index.umd.cjs +52 -34
- package/dev/index.umd.cjs.map +1 -1
- package/dist/base.css +1 -1
- package/dist/base.css.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +624 -619
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +3 -3
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +22 -22
package/dev/index.js
CHANGED
|
@@ -82,29 +82,6 @@ class Collection {
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
const not = {
|
|
86
|
-
inert: ":not([inert]):not([inert] *)",
|
|
87
|
-
negTabIndex: ':not([tabindex^="-"])',
|
|
88
|
-
disabled: ":not(:disabled)"
|
|
89
|
-
};
|
|
90
|
-
const focusableSelectors = [
|
|
91
|
-
`a[href]${not.inert}${not.negTabIndex}`,
|
|
92
|
-
`area[href]${not.inert}${not.negTabIndex}`,
|
|
93
|
-
`input:not([type="hidden"]):not([type="radio"])${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
94
|
-
`input[type="radio"]${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
95
|
-
`select${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
96
|
-
`textarea${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
97
|
-
`button${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
98
|
-
`details${not.inert} > summary:first-of-type${not.negTabIndex}`,
|
|
99
|
-
// Discard until Firefox supports `:has()`
|
|
100
|
-
// See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
|
|
101
|
-
// `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
|
|
102
|
-
`iframe${not.inert}${not.negTabIndex}`,
|
|
103
|
-
`audio[controls]${not.inert}${not.negTabIndex}`,
|
|
104
|
-
`video[controls]${not.inert}${not.negTabIndex}`,
|
|
105
|
-
`[contenteditable]${not.inert}${not.negTabIndex}`,
|
|
106
|
-
`[tabindex]${not.inert}${not.negTabIndex}`
|
|
107
|
-
];
|
|
108
85
|
class FocusTrap {
|
|
109
86
|
constructor(el = null, selectorFocus = "[data-focus]") {
|
|
110
87
|
__privateAdd(this, _focusable);
|
|
@@ -154,7 +131,8 @@ class FocusTrap {
|
|
|
154
131
|
const focusable = [];
|
|
155
132
|
const initFocus = document.activeElement;
|
|
156
133
|
const initScrollTop = el.scrollTop;
|
|
157
|
-
const
|
|
134
|
+
const selector = focusableSelectors.join(",");
|
|
135
|
+
const els = el.querySelectorAll(selector);
|
|
158
136
|
els.forEach((el2) => {
|
|
159
137
|
el2.focus();
|
|
160
138
|
if (document.activeElement === el2) {
|
|
@@ -169,6 +147,24 @@ class FocusTrap {
|
|
|
169
147
|
_focusable = new WeakMap();
|
|
170
148
|
_handleFocusTrap = new WeakMap();
|
|
171
149
|
_handleFocusLock = new WeakMap();
|
|
150
|
+
const notInert = ":not([inert])";
|
|
151
|
+
const notNegTabIndex = ':not([tabindex^="-"])';
|
|
152
|
+
const notDisabled = ":not(:disabled)";
|
|
153
|
+
const focusableSelectors = [
|
|
154
|
+
`a[href]${notInert}${notNegTabIndex}`,
|
|
155
|
+
`area[href]${notInert}${notNegTabIndex}`,
|
|
156
|
+
`input:not([type="hidden"]):not([type="radio"])${notInert}${notNegTabIndex}${notDisabled}`,
|
|
157
|
+
`input[type="radio"]${notInert}${notNegTabIndex}${notDisabled}`,
|
|
158
|
+
`select${notInert}${notNegTabIndex}${notDisabled}`,
|
|
159
|
+
`textarea${notInert}${notNegTabIndex}${notDisabled}`,
|
|
160
|
+
`button${notInert}${notNegTabIndex}${notDisabled}`,
|
|
161
|
+
`details${notInert} > summary:first-of-type${notNegTabIndex}`,
|
|
162
|
+
`iframe${notInert}${notNegTabIndex}`,
|
|
163
|
+
`audio[controls]${notInert}${notNegTabIndex}`,
|
|
164
|
+
`video[controls]${notInert}${notNegTabIndex}`,
|
|
165
|
+
`[contenteditable]${notInert}${notNegTabIndex}`,
|
|
166
|
+
`[tabindex]${notInert}${notNegTabIndex}`
|
|
167
|
+
];
|
|
172
168
|
function handleFocusTrap(event) {
|
|
173
169
|
const isTab = event.key === "Tab" || event.keyCode === 9;
|
|
174
170
|
if (!isTab) return;
|
|
@@ -1192,6 +1188,7 @@ const defaults = {
|
|
|
1192
1188
|
autoMount: false,
|
|
1193
1189
|
// Selectors
|
|
1194
1190
|
selectorPopover: ".popover",
|
|
1191
|
+
selectorTooltip: ".popover_tooltip",
|
|
1195
1192
|
selectorArrow: ".popover__arrow",
|
|
1196
1193
|
// State classes
|
|
1197
1194
|
stateActive: "is-active",
|
|
@@ -1316,9 +1313,9 @@ function getPopoverElements(query) {
|
|
|
1316
1313
|
if (!trigger && !popover) {
|
|
1317
1314
|
return { error: new Error(`No popover elements found using the ID: "${id}".`) };
|
|
1318
1315
|
} else if (!trigger) {
|
|
1319
|
-
return { error: new Error(
|
|
1316
|
+
return { error: new Error(`No popover trigger associated with the provided popover: "${id}".`) };
|
|
1320
1317
|
} else if (!popover) {
|
|
1321
|
-
return { error: new Error(
|
|
1318
|
+
return { error: new Error(`No popover associated with the provided popover trigger: "${id}".`) };
|
|
1322
1319
|
} else {
|
|
1323
1320
|
return { popover, trigger };
|
|
1324
1321
|
}
|
|
@@ -1331,7 +1328,7 @@ async function close(query) {
|
|
|
1331
1328
|
if (popover && popover.state === "opened") {
|
|
1332
1329
|
popover.el.inert = true;
|
|
1333
1330
|
popover.el.classList.remove(this.settings.stateActive);
|
|
1334
|
-
if (popover.
|
|
1331
|
+
if (!popover.isTooltip) {
|
|
1335
1332
|
popover.trigger.setAttribute("aria-expanded", "false");
|
|
1336
1333
|
}
|
|
1337
1334
|
popover.popper.setOptions({
|
|
@@ -1360,10 +1357,11 @@ async function closeAll() {
|
|
|
1360
1357
|
function closeCheck(popover) {
|
|
1361
1358
|
if (popover.state != "opened") return;
|
|
1362
1359
|
setTimeout(() => {
|
|
1363
|
-
const isHovered = popover.el.
|
|
1364
|
-
|
|
1360
|
+
const isHovered = popover.el.matches(":hover") === popover.el || popover.trigger.matches(":hover") === popover.trigger;
|
|
1361
|
+
let isFocused = document.activeElement.closest(
|
|
1365
1362
|
`#${popover.id}, [aria-controls="${popover.id}"], [aria-describedby="${popover.id}"]`
|
|
1366
1363
|
);
|
|
1364
|
+
isFocused = isFocused ? isFocused.matches(":focus-visible") : false;
|
|
1367
1365
|
if (!isHovered && !isFocused) {
|
|
1368
1366
|
popover.close();
|
|
1369
1367
|
}
|
|
@@ -1371,6 +1369,16 @@ function closeCheck(popover) {
|
|
|
1371
1369
|
}, 1);
|
|
1372
1370
|
}
|
|
1373
1371
|
function handleClick(popover) {
|
|
1372
|
+
const tooltipId = popover.trigger.getAttribute("aria-describedby");
|
|
1373
|
+
if (tooltipId) {
|
|
1374
|
+
const entry = this.get(tooltipId);
|
|
1375
|
+
if (entry.isTooltip) {
|
|
1376
|
+
if (entry.toggleDelayId) {
|
|
1377
|
+
clearTimeout(entry.toggleDelayId);
|
|
1378
|
+
}
|
|
1379
|
+
entry.close();
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1374
1382
|
if (popover.state === "opened") {
|
|
1375
1383
|
popover.close();
|
|
1376
1384
|
} else {
|
|
@@ -1379,7 +1387,14 @@ function handleClick(popover) {
|
|
|
1379
1387
|
handleDocumentClick.call(this, popover);
|
|
1380
1388
|
}
|
|
1381
1389
|
}
|
|
1382
|
-
function handleMouseEnter(popover) {
|
|
1390
|
+
function handleMouseEnter(popover, event) {
|
|
1391
|
+
if (event.type == "focus" && !popover.trigger.matches(":focus-visible")) {
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
const isExpanded = popover.trigger.getAttribute("aria-expanded");
|
|
1395
|
+
if (isExpanded && isExpanded == "true") {
|
|
1396
|
+
return;
|
|
1397
|
+
}
|
|
1383
1398
|
if (popover.toggleDelayId) {
|
|
1384
1399
|
clearTimeout(popover.toggleDelayId);
|
|
1385
1400
|
}
|
|
@@ -2815,7 +2830,7 @@ async function open(query) {
|
|
|
2815
2830
|
const popover = getPopover.call(this, query);
|
|
2816
2831
|
popover.el.inert = false;
|
|
2817
2832
|
popover.el.classList.add(this.settings.stateActive);
|
|
2818
|
-
if (popover.
|
|
2833
|
+
if (!popover.isTooltip) {
|
|
2819
2834
|
popover.trigger.setAttribute("aria-expanded", "true");
|
|
2820
2835
|
}
|
|
2821
2836
|
popover.config = getConfig(popover.el, this.settings);
|
|
@@ -2842,7 +2857,7 @@ async function register(el, trigger) {
|
|
|
2842
2857
|
popper: createPopper(trigger, el),
|
|
2843
2858
|
config: getConfig(el, this.settings),
|
|
2844
2859
|
get isTooltip() {
|
|
2845
|
-
return
|
|
2860
|
+
return !!el.closest(root.settings.selectorTooltip) || el.getAttribute("role") == "tooltip";
|
|
2846
2861
|
},
|
|
2847
2862
|
open() {
|
|
2848
2863
|
return open.call(root, this);
|
|
@@ -2854,7 +2869,10 @@ async function register(el, trigger) {
|
|
|
2854
2869
|
return deregister.call(root, this);
|
|
2855
2870
|
}
|
|
2856
2871
|
};
|
|
2857
|
-
if (entry.
|
|
2872
|
+
if (entry.isTooltip) {
|
|
2873
|
+
entry.el.setAttribute("role", "tooltip");
|
|
2874
|
+
}
|
|
2875
|
+
if (!entry.isTooltip) {
|
|
2858
2876
|
entry.trigger.setAttribute("aria-expanded", "false");
|
|
2859
2877
|
}
|
|
2860
2878
|
registerEventListeners.call(this, entry);
|
|
@@ -2872,7 +2890,7 @@ async function register(el, trigger) {
|
|
|
2872
2890
|
}
|
|
2873
2891
|
function registerEventListeners(entry) {
|
|
2874
2892
|
if (!entry.__eventListeners) {
|
|
2875
|
-
const eventType = entry.config["event"];
|
|
2893
|
+
const eventType = entry.isTooltip ? "hover" : entry.config["event"];
|
|
2876
2894
|
if (eventType === "hover") {
|
|
2877
2895
|
entry.__eventListeners = [{
|
|
2878
2896
|
el: ["trigger"],
|