@primer/behaviors 0.0.0-20260106105613 → 0.0.0-20260106150803
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-zone.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export type FocusZoneSettings = IterateFocusableElements & {
|
|
|
28
28
|
focusInStrategy?: 'first' | 'closest' | 'previous' | 'initial' | ((previousFocusedElement: Element) => HTMLElement | undefined);
|
|
29
29
|
preventScroll?: boolean;
|
|
30
30
|
ignoreHoverEvents?: boolean;
|
|
31
|
+
focusPrependedElements?: boolean;
|
|
31
32
|
};
|
|
32
33
|
export declare const isActiveDescendantAttribute = "data-is-active-descendant";
|
|
33
34
|
export declare const activeDescendantActivatedDirectly = "activated-directly";
|
package/dist/cjs/focus-zone.js
CHANGED
|
@@ -131,7 +131,7 @@ const activeDescendantActivatedDirectly = 'activated-directly';
|
|
|
131
131
|
const activeDescendantActivatedIndirectly = 'activated-indirectly';
|
|
132
132
|
const hasActiveDescendantAttribute = 'data-has-active-descendant';
|
|
133
133
|
function focusZone(container, settings) {
|
|
134
|
-
var _a, _b, _c, _d, _e, _f;
|
|
134
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
135
135
|
const focusableElements = new indexedSet.IndexedSet();
|
|
136
136
|
const savedTabIndex = new WeakMap();
|
|
137
137
|
const bindKeys = (_a = settings === null || settings === void 0 ? void 0 : settings.bindKeys) !== null && _a !== void 0 ? _a : ((settings === null || settings === void 0 ? void 0 : settings.getNextFocusable) ? exports.FocusKeys.ArrowAll : exports.FocusKeys.ArrowVertical) | exports.FocusKeys.HomeAndEnd;
|
|
@@ -140,9 +140,10 @@ function focusZone(container, settings) {
|
|
|
140
140
|
const activeDescendantControl = settings === null || settings === void 0 ? void 0 : settings.activeDescendantControl;
|
|
141
141
|
const activeDescendantCallback = settings === null || settings === void 0 ? void 0 : settings.onActiveDescendantChanged;
|
|
142
142
|
const ignoreHoverEvents = (_d = settings === null || settings === void 0 ? void 0 : settings.ignoreHoverEvents) !== null && _d !== void 0 ? _d : false;
|
|
143
|
+
const focusPrependedElements = (_e = settings === null || settings === void 0 ? void 0 : settings.focusPrependedElements) !== null && _e !== void 0 ? _e : false;
|
|
143
144
|
let currentFocusedElement;
|
|
144
145
|
let wasDirectlyActivated = false;
|
|
145
|
-
const preventScroll = (
|
|
146
|
+
const preventScroll = (_f = settings === null || settings === void 0 ? void 0 : settings.preventScroll) !== null && _f !== void 0 ? _f : false;
|
|
146
147
|
const preventInitialFocus = focusInStrategy === 'initial' && (settings === null || settings === void 0 ? void 0 : settings.activeDescendantControl);
|
|
147
148
|
function getFirstFocusableElement() {
|
|
148
149
|
return focusableElements.get(0);
|
|
@@ -212,7 +213,8 @@ function focusZone(container, settings) {
|
|
|
212
213
|
}
|
|
213
214
|
element.setAttribute('tabindex', '-1');
|
|
214
215
|
}
|
|
215
|
-
|
|
216
|
+
const shouldFocusPrepended = focusPrependedElements && insertionIndex === 0 && !wasDirectlyActivated;
|
|
217
|
+
if (!preventInitialFocus && (!currentFocusedElement || shouldFocusPrepended)) {
|
|
216
218
|
updateFocusedElement(getFirstFocusableElement());
|
|
217
219
|
}
|
|
218
220
|
}
|
|
@@ -330,7 +332,7 @@ function focusZone(container, settings) {
|
|
|
330
332
|
attributeOldValue: true,
|
|
331
333
|
});
|
|
332
334
|
const controller = new AbortController();
|
|
333
|
-
const signal = (
|
|
335
|
+
const signal = (_g = settings === null || settings === void 0 ? void 0 : settings.abortSignal) !== null && _g !== void 0 ? _g : controller.signal;
|
|
334
336
|
signal.addEventListener('abort', () => {
|
|
335
337
|
observer.disconnect();
|
|
336
338
|
endFocusManagement(...focusableElements);
|
package/dist/esm/focus-zone.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export type FocusZoneSettings = IterateFocusableElements & {
|
|
|
28
28
|
focusInStrategy?: 'first' | 'closest' | 'previous' | 'initial' | ((previousFocusedElement: Element) => HTMLElement | undefined);
|
|
29
29
|
preventScroll?: boolean;
|
|
30
30
|
ignoreHoverEvents?: boolean;
|
|
31
|
+
focusPrependedElements?: boolean;
|
|
31
32
|
};
|
|
32
33
|
export declare const isActiveDescendantAttribute = "data-is-active-descendant";
|
|
33
34
|
export declare const activeDescendantActivatedDirectly = "activated-directly";
|
package/dist/esm/focus-zone.mjs
CHANGED
|
@@ -129,7 +129,7 @@ const activeDescendantActivatedDirectly = 'activated-directly';
|
|
|
129
129
|
const activeDescendantActivatedIndirectly = 'activated-indirectly';
|
|
130
130
|
const hasActiveDescendantAttribute = 'data-has-active-descendant';
|
|
131
131
|
function focusZone(container, settings) {
|
|
132
|
-
var _a, _b, _c, _d, _e, _f;
|
|
132
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
133
133
|
const focusableElements = new IndexedSet();
|
|
134
134
|
const savedTabIndex = new WeakMap();
|
|
135
135
|
const bindKeys = (_a = settings === null || settings === void 0 ? void 0 : settings.bindKeys) !== null && _a !== void 0 ? _a : ((settings === null || settings === void 0 ? void 0 : settings.getNextFocusable) ? FocusKeys.ArrowAll : FocusKeys.ArrowVertical) | FocusKeys.HomeAndEnd;
|
|
@@ -138,9 +138,10 @@ function focusZone(container, settings) {
|
|
|
138
138
|
const activeDescendantControl = settings === null || settings === void 0 ? void 0 : settings.activeDescendantControl;
|
|
139
139
|
const activeDescendantCallback = settings === null || settings === void 0 ? void 0 : settings.onActiveDescendantChanged;
|
|
140
140
|
const ignoreHoverEvents = (_d = settings === null || settings === void 0 ? void 0 : settings.ignoreHoverEvents) !== null && _d !== void 0 ? _d : false;
|
|
141
|
+
const focusPrependedElements = (_e = settings === null || settings === void 0 ? void 0 : settings.focusPrependedElements) !== null && _e !== void 0 ? _e : false;
|
|
141
142
|
let currentFocusedElement;
|
|
142
143
|
let wasDirectlyActivated = false;
|
|
143
|
-
const preventScroll = (
|
|
144
|
+
const preventScroll = (_f = settings === null || settings === void 0 ? void 0 : settings.preventScroll) !== null && _f !== void 0 ? _f : false;
|
|
144
145
|
const preventInitialFocus = focusInStrategy === 'initial' && (settings === null || settings === void 0 ? void 0 : settings.activeDescendantControl);
|
|
145
146
|
function getFirstFocusableElement() {
|
|
146
147
|
return focusableElements.get(0);
|
|
@@ -210,7 +211,8 @@ function focusZone(container, settings) {
|
|
|
210
211
|
}
|
|
211
212
|
element.setAttribute('tabindex', '-1');
|
|
212
213
|
}
|
|
213
|
-
|
|
214
|
+
const shouldFocusPrepended = focusPrependedElements && insertionIndex === 0 && !wasDirectlyActivated;
|
|
215
|
+
if (!preventInitialFocus && (!currentFocusedElement || shouldFocusPrepended)) {
|
|
214
216
|
updateFocusedElement(getFirstFocusableElement());
|
|
215
217
|
}
|
|
216
218
|
}
|
|
@@ -328,7 +330,7 @@ function focusZone(container, settings) {
|
|
|
328
330
|
attributeOldValue: true,
|
|
329
331
|
});
|
|
330
332
|
const controller = new AbortController();
|
|
331
|
-
const signal = (
|
|
333
|
+
const signal = (_g = settings === null || settings === void 0 ? void 0 : settings.abortSignal) !== null && _g !== void 0 ? _g : controller.signal;
|
|
332
334
|
signal.addEventListener('abort', () => {
|
|
333
335
|
observer.disconnect();
|
|
334
336
|
endFocusManagement(...focusableElements);
|