@primer/components 0.0.0-2021116165050 → 0.0.0-202111619107
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.esm.js +2 -2
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +2 -2
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.js +3 -3
- package/lib/ActionList/List.js +2 -2
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
- package/lib/Autocomplete/AutocompleteMenu.js +23 -11
- package/lib/Dialog/ConfirmationDialog.js +2 -2
- package/lib/Dialog/Dialog.js +2 -2
- package/lib/FilteredActionList/FilteredActionList.js +10 -3
- package/lib/Overlay.d.ts +1 -1
- package/lib/TextInputWithTokens.js +4 -4
- package/lib/hooks/useAnchoredPosition.d.ts +1 -1
- package/lib/hooks/useAnchoredPosition.js +2 -2
- package/lib/hooks/useFocusTrap.js +2 -2
- package/lib/hooks/useFocusZone.d.ts +1 -1
- package/lib/hooks/useFocusZone.js +2 -2
- package/lib/hooks/useOpenAndCloseFocus.js +2 -2
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -24
- package/lib-esm/ActionList/Item.js +1 -1
- package/lib-esm/ActionList/List.js +1 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
- package/lib-esm/Autocomplete/AutocompleteMenu.js +22 -7
- package/lib-esm/Dialog/ConfirmationDialog.js +1 -1
- package/lib-esm/Dialog/Dialog.js +1 -1
- package/lib-esm/FilteredActionList/FilteredActionList.js +9 -3
- package/lib-esm/Overlay.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.js +2 -2
- package/lib-esm/hooks/useAnchoredPosition.d.ts +1 -1
- package/lib-esm/hooks/useAnchoredPosition.js +1 -1
- package/lib-esm/hooks/useFocusTrap.js +1 -1
- package/lib-esm/hooks/useFocusZone.d.ts +1 -1
- package/lib-esm/hooks/useFocusZone.js +1 -1
- package/lib-esm/hooks/useOpenAndCloseFocus.js +1 -1
- package/lib-esm/index.d.ts +0 -3
- package/lib-esm/index.js +0 -3
- package/package.json +3 -6
- package/lib/CheckboxInputField.d.ts +0 -10
- package/lib/CheckboxInputField.js +0 -73
- package/lib/RadioInputField.d.ts +0 -9
- package/lib/RadioInputField.js +0 -74
- package/lib/TextInputField.d.ts +0 -583
- package/lib/TextInputField.js +0 -66
- package/lib/_InputCaption.d.ts +0 -13
- package/lib/_InputCaption.js +0 -26
- package/lib/_InputField/InputField.d.ts +0 -39
- package/lib/_InputField/InputField.js +0 -90
- package/lib/_InputField/InputFieldCaption.d.ts +0 -3
- package/lib/_InputField/InputFieldCaption.js +0 -30
- package/lib/_InputField/InputFieldLabel.d.ts +0 -9
- package/lib/_InputField/InputFieldLabel.js +0 -34
- package/lib/_InputField/InputFieldValidation.d.ts +0 -6
- package/lib/_InputField/InputFieldValidation.js +0 -17
- package/lib/_InputField/ToggleInputField.d.ts +0 -13
- package/lib/_InputField/ToggleInputField.js +0 -71
- package/lib/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
- package/lib/_InputField/ToggleInputLeadingVisual.js +0 -22
- package/lib/_InputField/ValidationAnimationContainer.d.ts +0 -6
- package/lib/_InputField/ValidationAnimationContainer.js +0 -48
- package/lib/_InputField/index.d.ts +0 -1
- package/lib/_InputField/index.js +0 -15
- package/lib/_InputField/slots.d.ts +0 -13
- package/lib/_InputField/slots.js +0 -17
- package/lib/_InputLabel.d.ts +0 -8
- package/lib/_InputLabel.js +0 -44
- package/lib/_InputValidation.d.ts +0 -8
- package/lib/_InputValidation.js +0 -56
- package/lib/_VisuallyHidden.d.ts +0 -6
- package/lib/_VisuallyHidden.js +0 -39
- package/lib/behaviors/anchoredPosition.d.ts +0 -89
- package/lib/behaviors/anchoredPosition.js +0 -316
- package/lib/behaviors/focusTrap.d.ts +0 -12
- package/lib/behaviors/focusTrap.js +0 -179
- package/lib/behaviors/focusZone.d.ts +0 -137
- package/lib/behaviors/focusZone.js +0 -578
- package/lib/behaviors/scrollIntoViewingArea.d.ts +0 -1
- package/lib/behaviors/scrollIntoViewingArea.js +0 -39
- package/lib/utils/iterateFocusableElements.d.ts +0 -42
- package/lib/utils/iterateFocusableElements.js +0 -113
- package/lib/utils/types/FormValidationStatus.d.ts +0 -1
- package/lib/utils/types/FormValidationStatus.js +0 -1
- package/lib/utils/uniqueId.d.ts +0 -1
- package/lib/utils/uniqueId.js +0 -12
- package/lib/utils/userAgent.d.ts +0 -1
- package/lib/utils/userAgent.js +0 -15
- package/lib-esm/CheckboxInputField.d.ts +0 -10
- package/lib-esm/CheckboxInputField.js +0 -56
- package/lib-esm/RadioInputField.d.ts +0 -9
- package/lib-esm/RadioInputField.js +0 -56
- package/lib-esm/TextInputField.d.ts +0 -583
- package/lib-esm/TextInputField.js +0 -50
- package/lib-esm/_InputCaption.d.ts +0 -13
- package/lib-esm/_InputCaption.js +0 -15
- package/lib-esm/_InputField/InputField.d.ts +0 -39
- package/lib-esm/_InputField/InputField.js +0 -70
- package/lib-esm/_InputField/InputFieldCaption.d.ts +0 -3
- package/lib-esm/_InputField/InputFieldCaption.js +0 -18
- package/lib-esm/_InputField/InputFieldLabel.d.ts +0 -9
- package/lib-esm/_InputField/InputFieldLabel.js +0 -22
- package/lib-esm/_InputField/InputFieldValidation.d.ts +0 -6
- package/lib-esm/_InputField/InputFieldValidation.js +0 -7
- package/lib-esm/_InputField/ToggleInputField.d.ts +0 -13
- package/lib-esm/_InputField/ToggleInputField.js +0 -54
- package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
- package/lib-esm/_InputField/ToggleInputLeadingVisual.js +0 -11
- package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +0 -6
- package/lib-esm/_InputField/ValidationAnimationContainer.js +0 -33
- package/lib-esm/_InputField/index.d.ts +0 -1
- package/lib-esm/_InputField/index.js +0 -1
- package/lib-esm/_InputField/slots.d.ts +0 -13
- package/lib-esm/_InputField/slots.js +0 -5
- package/lib-esm/_InputLabel.d.ts +0 -8
- package/lib-esm/_InputLabel.js +0 -32
- package/lib-esm/_InputValidation.d.ts +0 -8
- package/lib-esm/_InputValidation.js +0 -43
- package/lib-esm/_VisuallyHidden.d.ts +0 -6
- package/lib-esm/_VisuallyHidden.js +0 -26
- package/lib-esm/behaviors/anchoredPosition.d.ts +0 -89
- package/lib-esm/behaviors/anchoredPosition.js +0 -309
- package/lib-esm/behaviors/focusTrap.d.ts +0 -12
- package/lib-esm/behaviors/focusTrap.js +0 -170
- package/lib-esm/behaviors/focusZone.d.ts +0 -137
- package/lib-esm/behaviors/focusZone.js +0 -560
- package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +0 -1
- package/lib-esm/behaviors/scrollIntoViewingArea.js +0 -30
- package/lib-esm/utils/iterateFocusableElements.d.ts +0 -42
- package/lib-esm/utils/iterateFocusableElements.js +0 -102
- package/lib-esm/utils/types/FormValidationStatus.d.ts +0 -1
- package/lib-esm/utils/types/FormValidationStatus.js +0 -1
- package/lib-esm/utils/uniqueId.d.ts +0 -1
- package/lib-esm/utils/uniqueId.js +0 -5
- package/lib-esm/utils/userAgent.d.ts +0 -1
- package/lib-esm/utils/userAgent.js +0 -8
@@ -1,102 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Options to the focusable elements iterator
|
3
|
-
*/
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Returns an iterator over all of the focusable elements within `container`.
|
7
|
-
* Note: If `container` is itself focusable it will be included in the results.
|
8
|
-
* @param container The container over which to find focusable elements.
|
9
|
-
* @param reverse If true, iterate backwards through focusable elements.
|
10
|
-
*/
|
11
|
-
export function* iterateFocusableElements(container, options = {}) {
|
12
|
-
var _options$strict, _options$onlyTabbable;
|
13
|
-
|
14
|
-
const strict = (_options$strict = options.strict) !== null && _options$strict !== void 0 ? _options$strict : false;
|
15
|
-
const acceptFn = ((_options$onlyTabbable = options.onlyTabbable) !== null && _options$onlyTabbable !== void 0 ? _options$onlyTabbable : false) ? isTabbable : isFocusable;
|
16
|
-
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
17
|
-
acceptNode: node => node instanceof HTMLElement && acceptFn(node, strict) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
18
|
-
});
|
19
|
-
let nextNode = null; // Allow the container to participate
|
20
|
-
|
21
|
-
if (!options.reverse && acceptFn(container, strict)) {
|
22
|
-
yield container;
|
23
|
-
} // If iterating in reverse, continue traversing down into the last child until we reach
|
24
|
-
// a leaf DOM node
|
25
|
-
|
26
|
-
|
27
|
-
if (options.reverse) {
|
28
|
-
let lastChild = walker.lastChild();
|
29
|
-
|
30
|
-
while (lastChild) {
|
31
|
-
nextNode = lastChild;
|
32
|
-
lastChild = walker.lastChild();
|
33
|
-
}
|
34
|
-
} else {
|
35
|
-
nextNode = walker.firstChild();
|
36
|
-
}
|
37
|
-
|
38
|
-
while (nextNode instanceof HTMLElement) {
|
39
|
-
yield nextNode;
|
40
|
-
nextNode = options.reverse ? walker.previousNode() : walker.nextNode();
|
41
|
-
} // Allow the container to participate (in reverse)
|
42
|
-
|
43
|
-
|
44
|
-
if (options.reverse && acceptFn(container, strict)) {
|
45
|
-
yield container;
|
46
|
-
}
|
47
|
-
|
48
|
-
return undefined;
|
49
|
-
}
|
50
|
-
/**
|
51
|
-
* Determines whether the given element is focusable. If `strict` is true, we may
|
52
|
-
* perform additional checks that require a reflow (less performant).
|
53
|
-
* @param elem
|
54
|
-
* @param strict
|
55
|
-
*/
|
56
|
-
|
57
|
-
export function isFocusable(elem, strict = false) {
|
58
|
-
// Certain conditions cause an element to never be focusable, even if they have tabindex="0"
|
59
|
-
const disabledAttrInert = ['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA', 'OPTGROUP', 'OPTION', 'FIELDSET'].includes(elem.tagName) && elem.disabled;
|
60
|
-
const hiddenInert = elem.hidden;
|
61
|
-
const hiddenInputInert = elem instanceof HTMLInputElement && elem.type === 'hidden';
|
62
|
-
|
63
|
-
if (disabledAttrInert || hiddenInert || hiddenInputInert) {
|
64
|
-
return false;
|
65
|
-
} // Each of the conditions checked below require a reflow, thus are gated by the `strict`
|
66
|
-
// argument. If any are true, the element is not focusable, even if tabindex is set.
|
67
|
-
|
68
|
-
|
69
|
-
if (strict) {
|
70
|
-
const sizeInert = elem.offsetWidth === 0 || elem.offsetHeight === 0;
|
71
|
-
const visibilityInert = ['hidden', 'collapse'].includes(getComputedStyle(elem).visibility);
|
72
|
-
const clientRectsInert = elem.getClientRects().length === 0;
|
73
|
-
|
74
|
-
if (sizeInert || visibilityInert || clientRectsInert) {
|
75
|
-
return false;
|
76
|
-
}
|
77
|
-
} // Any element with `tabindex` explicitly set can be focusable, even if it's set to "-1"
|
78
|
-
|
79
|
-
|
80
|
-
if (elem.getAttribute('tabindex') != null) {
|
81
|
-
return true;
|
82
|
-
} // One last way `elem.tabIndex` can be wrong.
|
83
|
-
|
84
|
-
|
85
|
-
if (elem instanceof HTMLAnchorElement && elem.getAttribute('href') == null) {
|
86
|
-
return false;
|
87
|
-
}
|
88
|
-
|
89
|
-
return elem.tabIndex !== -1;
|
90
|
-
}
|
91
|
-
/**
|
92
|
-
* Determines whether the given element is tabbable. If `strict` is true, we may
|
93
|
-
* perform additional checks that require a reflow (less performant). This check
|
94
|
-
* ensures that the element is focusable and that its tabindex is not explicitly
|
95
|
-
* set to "-1" (which makes it focusable, but removes it from the tab order).
|
96
|
-
* @param elem
|
97
|
-
* @param strict
|
98
|
-
*/
|
99
|
-
|
100
|
-
export function isTabbable(elem, strict = false) {
|
101
|
-
return isFocusable(elem, strict) && elem.getAttribute('tabindex') !== '-1';
|
102
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare type FormValidationStatus = 'error' | 'success';
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare function uniqueId(): string;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare function isMacOS(): boolean;
|