@primer/behaviors 0.0.0-20250203222638 → 0.0.0-20250710060721
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/focus-trap.js +8 -16
- package/dist/esm/focus-trap.mjs +8 -16
- package/package.json +8 -7
package/dist/cjs/focus-trap.js
CHANGED
|
@@ -62,8 +62,11 @@ function focusTrap(container, initialFocus, abortSignal) {
|
|
|
62
62
|
const firstFocusableChild = iterateFocusableElements.getFocusableChild(container);
|
|
63
63
|
firstFocusableChild === null || firstFocusableChild === void 0 ? void 0 : firstFocusableChild.focus();
|
|
64
64
|
};
|
|
65
|
-
container.
|
|
66
|
-
|
|
65
|
+
const existingSentinels = Array.from(container.children).filter(e => e.classList.contains('sentinel') && e.tagName === 'SPAN');
|
|
66
|
+
if (!existingSentinels.length) {
|
|
67
|
+
container.prepend(sentinelStart);
|
|
68
|
+
container.append(sentinelEnd);
|
|
69
|
+
}
|
|
67
70
|
const observer = observeFocusTrap(container, [sentinelStart, sentinelEnd]);
|
|
68
71
|
let lastFocusedChild = undefined;
|
|
69
72
|
function ensureTrapZoneHasFocus(focusedElement) {
|
|
@@ -73,33 +76,22 @@ function focusTrap(container, initialFocus, abortSignal) {
|
|
|
73
76
|
return;
|
|
74
77
|
}
|
|
75
78
|
else {
|
|
76
|
-
const focusDelay = suspendedTrapStack.length > 0 ? 100 : undefined;
|
|
77
79
|
if (lastFocusedChild && iterateFocusableElements.isTabbable(lastFocusedChild) && container.contains(lastFocusedChild)) {
|
|
78
|
-
|
|
80
|
+
lastFocusedChild.focus();
|
|
79
81
|
return;
|
|
80
82
|
}
|
|
81
83
|
else if (initialFocus && container.contains(initialFocus)) {
|
|
82
|
-
|
|
84
|
+
initialFocus.focus();
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
87
|
else {
|
|
86
88
|
const firstFocusableChild = iterateFocusableElements.getFocusableChild(container);
|
|
87
|
-
|
|
89
|
+
firstFocusableChild === null || firstFocusableChild === void 0 ? void 0 : firstFocusableChild.focus();
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
|
-
function handleFocus(focusTarget, delay) {
|
|
94
|
-
if (!focusTarget)
|
|
95
|
-
return;
|
|
96
|
-
if (delay) {
|
|
97
|
-
setTimeout(() => {
|
|
98
|
-
focusTarget.focus();
|
|
99
|
-
}, delay);
|
|
100
|
-
}
|
|
101
|
-
focusTarget.focus();
|
|
102
|
-
}
|
|
103
95
|
const wrappingController = followSignal(signal);
|
|
104
96
|
if (activeTrap) {
|
|
105
97
|
const suspendedTrap = activeTrap;
|
package/dist/esm/focus-trap.mjs
CHANGED
|
@@ -60,8 +60,11 @@ function focusTrap(container, initialFocus, abortSignal) {
|
|
|
60
60
|
const firstFocusableChild = getFocusableChild(container);
|
|
61
61
|
firstFocusableChild === null || firstFocusableChild === void 0 ? void 0 : firstFocusableChild.focus();
|
|
62
62
|
};
|
|
63
|
-
container.
|
|
64
|
-
|
|
63
|
+
const existingSentinels = Array.from(container.children).filter(e => e.classList.contains('sentinel') && e.tagName === 'SPAN');
|
|
64
|
+
if (!existingSentinels.length) {
|
|
65
|
+
container.prepend(sentinelStart);
|
|
66
|
+
container.append(sentinelEnd);
|
|
67
|
+
}
|
|
65
68
|
const observer = observeFocusTrap(container, [sentinelStart, sentinelEnd]);
|
|
66
69
|
let lastFocusedChild = undefined;
|
|
67
70
|
function ensureTrapZoneHasFocus(focusedElement) {
|
|
@@ -71,33 +74,22 @@ function focusTrap(container, initialFocus, abortSignal) {
|
|
|
71
74
|
return;
|
|
72
75
|
}
|
|
73
76
|
else {
|
|
74
|
-
const focusDelay = suspendedTrapStack.length > 0 ? 100 : undefined;
|
|
75
77
|
if (lastFocusedChild && isTabbable(lastFocusedChild) && container.contains(lastFocusedChild)) {
|
|
76
|
-
|
|
78
|
+
lastFocusedChild.focus();
|
|
77
79
|
return;
|
|
78
80
|
}
|
|
79
81
|
else if (initialFocus && container.contains(initialFocus)) {
|
|
80
|
-
|
|
82
|
+
initialFocus.focus();
|
|
81
83
|
return;
|
|
82
84
|
}
|
|
83
85
|
else {
|
|
84
86
|
const firstFocusableChild = getFocusableChild(container);
|
|
85
|
-
|
|
87
|
+
firstFocusableChild === null || firstFocusableChild === void 0 ? void 0 : firstFocusableChild.focus();
|
|
86
88
|
return;
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
|
-
function handleFocus(focusTarget, delay) {
|
|
92
|
-
if (!focusTarget)
|
|
93
|
-
return;
|
|
94
|
-
if (delay) {
|
|
95
|
-
setTimeout(() => {
|
|
96
|
-
focusTarget.focus();
|
|
97
|
-
}, delay);
|
|
98
|
-
}
|
|
99
|
-
focusTarget.focus();
|
|
100
|
-
}
|
|
101
93
|
const wrappingController = followSignal(signal);
|
|
102
94
|
if (activeTrap) {
|
|
103
95
|
const suspendedTrap = activeTrap;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/behaviors",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20250710060721",
|
|
4
4
|
"description": "Shared behaviors for JavaScript components",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
}
|
|
70
70
|
],
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@arethetypeswrong/cli": "^0.
|
|
72
|
+
"@arethetypeswrong/cli": "^0.18.0",
|
|
73
73
|
"@changesets/changelog-github": "^0.5.0",
|
|
74
74
|
"@changesets/cli": "^2.18.1",
|
|
75
75
|
"@github/prettier-config": "^0.0.6",
|
|
@@ -78,22 +78,23 @@
|
|
|
78
78
|
"@size-limit/preset-small-lib": "^11.1.4",
|
|
79
79
|
"@testing-library/react": "^16.0.0",
|
|
80
80
|
"@testing-library/user-event": "^14.5.1",
|
|
81
|
-
"@types/jest": "^
|
|
82
|
-
"@types/node": "^
|
|
81
|
+
"@types/jest": "^30.0.0",
|
|
82
|
+
"@types/node": "^24.0.10",
|
|
83
83
|
"@types/react": "^19.0.1",
|
|
84
|
-
"esbuild": "^0.
|
|
84
|
+
"esbuild": "^0.25.0",
|
|
85
85
|
"esbuild-jest": "^0.5.0",
|
|
86
86
|
"eslint": "^8.50.0",
|
|
87
87
|
"eslint-plugin-github": "^5.0.0",
|
|
88
88
|
"eslint-plugin-prettier": "^5.0.0",
|
|
89
|
-
"jest": "^
|
|
90
|
-
"jest-environment-jsdom": "^
|
|
89
|
+
"jest": "^30.0.4",
|
|
90
|
+
"jest-environment-jsdom": "^30.0.4",
|
|
91
91
|
"prettier": "^3.0.3",
|
|
92
92
|
"react": "^19.0.0",
|
|
93
93
|
"react-dom": "^19.0.0",
|
|
94
94
|
"rimraf": "^6.0.1",
|
|
95
95
|
"rollup": "^4.18.0",
|
|
96
96
|
"size-limit": "^11.1.4",
|
|
97
|
+
"tslib": "^2.8.1",
|
|
97
98
|
"typescript": "^5.2.2"
|
|
98
99
|
}
|
|
99
100
|
}
|