@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
package/lib/ActionList/Item.js
CHANGED
@@ -23,7 +23,7 @@ var _Divider = require("./Divider");
|
|
23
23
|
|
24
24
|
var _ThemeProvider = require("../ThemeProvider");
|
25
25
|
|
26
|
-
var
|
26
|
+
var _behaviors = require("@primer/behaviors");
|
27
27
|
|
28
28
|
var _ssr = require("@react-aria/ssr");
|
29
29
|
|
@@ -98,10 +98,10 @@ const StyledItem = _styledComponents.default.div.withConfig({
|
|
98
98
|
showDivider
|
99
99
|
}) => showDivider ? `1px` : '0', DividedContent, (0, _constants.get)('colors.border.muted'), ({
|
100
100
|
showDivider
|
101
|
-
}) => showDivider ? `1px` : '0', DividedContent, DividedContent, DividedContent, DividedContent,
|
101
|
+
}) => showDivider ? `1px` : '0', DividedContent, DividedContent, DividedContent, DividedContent, _behaviors.isActiveDescendantAttribute, DividedContent, _behaviors.isActiveDescendantAttribute, DividedContent, _behaviors.isActiveDescendantAttribute, _behaviors.activeDescendantActivatedDirectly, ({
|
102
102
|
variant,
|
103
103
|
item
|
104
|
-
}) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).focusBg,
|
104
|
+
}) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).focusBg, _behaviors.isActiveDescendantAttribute, _behaviors.activeDescendantActivatedIndirectly, ({
|
105
105
|
variant,
|
106
106
|
item
|
107
107
|
}) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).hoverBg, ({
|
package/lib/ActionList/List.js
CHANGED
@@ -17,7 +17,7 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
17
17
|
|
18
18
|
var _constants = require("../constants");
|
19
19
|
|
20
|
-
var
|
20
|
+
var _behaviors = require("@primer/behaviors");
|
21
21
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
23
|
|
@@ -38,7 +38,7 @@ function isGroupedListProps(props) {
|
|
38
38
|
const StyledList = _styledComponents.default.div.withConfig({
|
39
39
|
displayName: "List__StyledList",
|
40
40
|
componentId: "sc-yr2k7d-0"
|
41
|
-
})(["font-size:", ";line-height:20px;&[", "],&:focus-within{--item-hover-bg-override:none;--item-hover-divider-border-color-override:", ";}"], (0, _constants.get)('fontSizes.1'),
|
41
|
+
})(["font-size:", ";line-height:20px;&[", "],&:focus-within{--item-hover-bg-override:none;--item-hover-divider-border-color-override:", ";}"], (0, _constants.get)('fontSizes.1'), _behaviors.hasActiveDescendantAttribute, (0, _constants.get)('colors.border.muted'));
|
42
42
|
/**
|
43
43
|
* Returns `sx` prop values for `List` children matching the given `List` style variation.
|
44
44
|
* @param variant `List` style variation.
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import { OverlayProps } from '../Overlay';
|
3
3
|
import { FocusTrapHookSettings } from '../hooks/useFocusTrap';
|
4
4
|
import { FocusZoneHookSettings } from '../hooks/useFocusZone';
|
5
|
-
import { PositionSettings } from '
|
5
|
+
import type { PositionSettings } from '@primer/behaviors';
|
6
6
|
interface AnchoredOverlayPropsWithAnchor {
|
7
7
|
/**
|
8
8
|
* A custom function component used to render the anchor element.
|
@@ -17,13 +17,9 @@ var _AutocompleteContext = require("./AutocompleteContext");
|
|
17
17
|
|
18
18
|
var _octiconsReact = require("@primer/octicons-react");
|
19
19
|
|
20
|
-
var
|
20
|
+
var _utils = require("@primer/behaviors/utils");
|
21
21
|
|
22
|
-
var
|
23
|
-
|
24
|
-
var _VisuallyHidden = _interopRequireDefault(require("../_VisuallyHidden"));
|
25
|
-
|
26
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
22
|
+
var _behaviors = require("@primer/behaviors");
|
27
23
|
|
28
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
29
25
|
|
@@ -31,6 +27,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
31
27
|
|
32
28
|
const getDefaultSortFn = isItemSelectedFn => (itemIdA, itemIdB) => isItemSelectedFn(itemIdA) === isItemSelectedFn(itemIdB) ? 0 : isItemSelectedFn(itemIdA) ? -1 : 1;
|
33
29
|
|
30
|
+
const menuScrollMargins = {
|
31
|
+
startMargin: 0,
|
32
|
+
endMargin: 8
|
33
|
+
};
|
34
|
+
|
34
35
|
function getDefaultItemFilter(filterValue) {
|
35
36
|
return function (item, _i) {
|
36
37
|
var _item$text;
|
@@ -129,7 +130,7 @@ function AutocompleteMenu(props) {
|
|
129
130
|
onAction: item => {
|
130
131
|
// TODO: make it possible to pass a leadingVisual when using `addNewItem`
|
131
132
|
addNewItem.handleAddItem({ ...item,
|
132
|
-
id: item.id || (0,
|
133
|
+
id: item.id || (0, _utils.uniqueId)(),
|
133
134
|
leadingVisual: undefined
|
134
135
|
});
|
135
136
|
|
@@ -156,9 +157,9 @@ function AutocompleteMenu(props) {
|
|
156
157
|
}
|
157
158
|
|
158
159
|
if (current && customScrollContainerRef && customScrollContainerRef.current && directlyActivated) {
|
159
|
-
(0,
|
160
|
+
(0, _behaviors.scrollIntoView)(current, customScrollContainerRef.current, menuScrollMargins);
|
160
161
|
} else if (current && scrollContainerRef.current && directlyActivated) {
|
161
|
-
(0,
|
162
|
+
(0, _behaviors.scrollIntoView)(current, scrollContainerRef.current, menuScrollMargins);
|
162
163
|
}
|
163
164
|
}
|
164
165
|
}, [loading]);
|
@@ -186,8 +187,19 @@ function AutocompleteMenu(props) {
|
|
186
187
|
setSelectedItemLength(selectedItemIds.length);
|
187
188
|
}
|
188
189
|
}, [selectedItemIds, setSelectedItemLength]);
|
189
|
-
return /*#__PURE__*/_react.default.createElement(
|
190
|
-
|
190
|
+
return /*#__PURE__*/_react.default.createElement(_.Box, {
|
191
|
+
sx: !showMenu ? {
|
192
|
+
// visually hides this label for sighted users
|
193
|
+
position: 'absolute',
|
194
|
+
width: '1px',
|
195
|
+
height: '1px',
|
196
|
+
padding: '0',
|
197
|
+
margin: '-1px',
|
198
|
+
overflow: 'hidden',
|
199
|
+
clip: 'rect(0, 0, 0, 0)',
|
200
|
+
whiteSpace: 'nowrap',
|
201
|
+
borderWidth: '0'
|
202
|
+
} : {}
|
191
203
|
}, loading ? /*#__PURE__*/_react.default.createElement(_.Box, {
|
192
204
|
p: 3,
|
193
205
|
display: "flex",
|
@@ -16,7 +16,7 @@ var _Box = _interopRequireDefault(require("../Box"));
|
|
16
16
|
|
17
17
|
var _ThemeProvider = require("../ThemeProvider");
|
18
18
|
|
19
|
-
var
|
19
|
+
var _behaviors = require("@primer/behaviors");
|
20
20
|
|
21
21
|
var _constants = require("../constants");
|
22
22
|
|
@@ -81,7 +81,7 @@ const ConfirmationFooter = ({
|
|
81
81
|
const {
|
82
82
|
containerRef: footerRef
|
83
83
|
} = (0, _useFocusZone.useFocusZone)({
|
84
|
-
bindKeys:
|
84
|
+
bindKeys: _behaviors.FocusKeys.ArrowHorizontal | _behaviors.FocusKeys.Tab,
|
85
85
|
focusInStrategy: 'closest'
|
86
86
|
}); // Must have exactly 2 buttons!
|
87
87
|
|
package/lib/Dialog/Dialog.js
CHANGED
@@ -27,7 +27,7 @@ var _octiconsReact = require("@primer/octicons-react");
|
|
27
27
|
|
28
28
|
var _useFocusZone = require("../hooks/useFocusZone");
|
29
29
|
|
30
|
-
var
|
30
|
+
var _behaviors = require("@primer/behaviors");
|
31
31
|
|
32
32
|
var _Portal = _interopRequireDefault(require("../Portal"));
|
33
33
|
|
@@ -121,7 +121,7 @@ const DefaultFooter = ({
|
|
121
121
|
const {
|
122
122
|
containerRef: footerRef
|
123
123
|
} = (0, _useFocusZone.useFocusZone)({
|
124
|
-
bindKeys:
|
124
|
+
bindKeys: _behaviors.FocusKeys.ArrowHorizontal | _behaviors.FocusKeys.Tab,
|
125
125
|
focusInStrategy: 'closest'
|
126
126
|
});
|
127
127
|
return footerButtons ? /*#__PURE__*/_react.default.createElement(Dialog.Footer, {
|
@@ -29,7 +29,7 @@ var _useProvidedRefOrCreate = require("../hooks/useProvidedRefOrCreate");
|
|
29
29
|
|
30
30
|
var _useScrollFlash = _interopRequireDefault(require("../hooks/useScrollFlash"));
|
31
31
|
|
32
|
-
var
|
32
|
+
var _behaviors = require("@primer/behaviors");
|
33
33
|
|
34
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
35
35
|
|
@@ -39,6 +39,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
39
39
|
|
40
40
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
41
41
|
|
42
|
+
const menuScrollMargins = {
|
43
|
+
startMargin: 0,
|
44
|
+
endMargin: 8
|
45
|
+
};
|
46
|
+
|
42
47
|
const StyledHeader = _styledComponents.default.div.withConfig({
|
43
48
|
displayName: "FilteredActionList__StyledHeader",
|
44
49
|
componentId: "sc-yg3jkv-0"
|
@@ -86,7 +91,7 @@ function FilteredActionList({
|
|
86
91
|
activeDescendantRef.current = current;
|
87
92
|
|
88
93
|
if (current && scrollContainerRef.current && directlyActivated) {
|
89
|
-
(0,
|
94
|
+
(0, _behaviors.scrollIntoView)(current, scrollContainerRef.current, menuScrollMargins);
|
90
95
|
}
|
91
96
|
}
|
92
97
|
}, [// List ref isn't set while loading. Need to re-bind focus zone when it changes
|
@@ -94,7 +99,9 @@ function FilteredActionList({
|
|
94
99
|
(0, _react.useEffect)(() => {
|
95
100
|
// if items changed, we want to instantly move active descendant into view
|
96
101
|
if (activeDescendantRef.current && scrollContainerRef.current) {
|
97
|
-
(0,
|
102
|
+
(0, _behaviors.scrollIntoView)(activeDescendantRef.current, scrollContainerRef.current, { ...menuScrollMargins,
|
103
|
+
behavior: 'auto'
|
104
|
+
});
|
98
105
|
}
|
99
106
|
}, [items]);
|
100
107
|
(0, _useScrollFlash.default)(scrollContainerRef);
|
package/lib/Overlay.d.ts
CHANGED
@@ -2,7 +2,7 @@ import React, { ComponentPropsWithRef } from 'react';
|
|
2
2
|
import { AriaRole, Merge } from './utils/types';
|
3
3
|
import { TouchOrMouseEvent } from './hooks';
|
4
4
|
import { SxProp } from './sx';
|
5
|
-
import { AnchorSide } from '
|
5
|
+
import type { AnchorSide } from '@primer/behaviors';
|
6
6
|
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
7
7
|
declare type StyledOverlayProps = {
|
8
8
|
width?: keyof typeof widthMap;
|
@@ -9,7 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
10
10
|
var _props = require("@styled-system/props");
|
11
11
|
|
12
|
-
var
|
12
|
+
var _behaviors = require("@primer/behaviors");
|
13
13
|
|
14
14
|
var _useCombinedRefs = require("./hooks/useCombinedRefs");
|
15
15
|
|
@@ -27,7 +27,7 @@ var _Box = _interopRequireDefault(require("./Box"));
|
|
27
27
|
|
28
28
|
var _Text = _interopRequireDefault(require("./Text"));
|
29
29
|
|
30
|
-
var
|
30
|
+
var _utils = require("@primer/behaviors/utils");
|
31
31
|
|
32
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
33
33
|
|
@@ -81,7 +81,7 @@ function TextInputWithTokensInnerComponent({
|
|
81
81
|
containerRef
|
82
82
|
} = (0, _useFocusZone.useFocusZone)({
|
83
83
|
focusOutBehavior: 'wrap',
|
84
|
-
bindKeys:
|
84
|
+
bindKeys: _behaviors.FocusKeys.ArrowHorizontal | _behaviors.FocusKeys.HomeAndEnd,
|
85
85
|
focusableElementFilter: element => {
|
86
86
|
return !element.getAttributeNames().includes('aria-hidden');
|
87
87
|
},
|
@@ -119,7 +119,7 @@ function TextInputWithTokensInnerComponent({
|
|
119
119
|
const nextElementToFocus = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children[selectedTokenIndex || 0]; // when removing the first token by keying "Backspace" or "Delete",
|
120
120
|
// `nextFocusableElement` is the div that wraps the input
|
121
121
|
|
122
|
-
const firstFocusable = nextElementToFocus && (0,
|
122
|
+
const firstFocusable = nextElementToFocus && (0, _utils.isFocusable)(nextElementToFocus) ? nextElementToFocus : Array.from(((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.children) || []).find(el => (0, _utils.isFocusable)(el));
|
123
123
|
|
124
124
|
if (firstFocusable) {
|
125
125
|
firstFocusable.focus();
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
2
|
+
import type { AnchorPosition, PositionSettings } from '@primer/behaviors';
|
3
3
|
export interface AnchoredPositionHookSettings extends Partial<PositionSettings> {
|
4
4
|
floatingElementRef?: React.RefObject<Element>;
|
5
5
|
anchorElementRef?: React.RefObject<Element>;
|
@@ -7,7 +7,7 @@ exports.useAnchoredPosition = useAnchoredPosition;
|
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
10
|
-
var
|
10
|
+
var _behaviors = require("@primer/behaviors");
|
11
11
|
|
12
12
|
var _useProvidedRefOrCreate = require("./useProvidedRefOrCreate");
|
13
13
|
|
@@ -34,7 +34,7 @@ function useAnchoredPosition(settings, dependencies = []) {
|
|
34
34
|
|
35
35
|
const updatePosition = _react.default.useCallback(() => {
|
36
36
|
if (floatingElementRef.current instanceof Element && anchorElementRef.current instanceof Element) {
|
37
|
-
setPosition((0,
|
37
|
+
setPosition((0, _behaviors.getAnchoredPosition)(floatingElementRef.current, anchorElementRef.current, settings));
|
38
38
|
} else {
|
39
39
|
setPosition(undefined);
|
40
40
|
}
|
@@ -7,7 +7,7 @@ exports.useFocusTrap = useFocusTrap;
|
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
10
|
-
var
|
10
|
+
var _behaviors = require("@primer/behaviors");
|
11
11
|
|
12
12
|
var _useProvidedRefOrCreate = require("./useProvidedRefOrCreate");
|
13
13
|
|
@@ -51,7 +51,7 @@ function useFocusTrap(settings, dependencies = []) {
|
|
51
51
|
if (!disabled) {
|
52
52
|
var _initialFocusRef$curr;
|
53
53
|
|
54
|
-
abortController.current = (0,
|
54
|
+
abortController.current = (0, _behaviors.focusTrap)(containerRef.current, (_initialFocusRef$curr = initialFocusRef.current) !== null && _initialFocusRef$curr !== void 0 ? _initialFocusRef$curr : undefined);
|
55
55
|
return () => {
|
56
56
|
disableTrap();
|
57
57
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { FocusZoneSettings } from '
|
2
|
+
import type { FocusZoneSettings } from '@primer/behaviors';
|
3
3
|
export interface FocusZoneHookSettings extends Omit<FocusZoneSettings, 'activeDescendantControl'> {
|
4
4
|
/**
|
5
5
|
* Optional ref for the container that holds all elements participating in arrow key focus.
|
@@ -7,7 +7,7 @@ exports.useFocusZone = useFocusZone;
|
|
7
7
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
9
9
|
|
10
|
-
var
|
10
|
+
var _behaviors = require("@primer/behaviors");
|
11
11
|
|
12
12
|
var _useProvidedRefOrCreate = require("./useProvidedRefOrCreate");
|
13
13
|
|
@@ -32,7 +32,7 @@ function useFocusZone(settings = {}, dependencies = []) {
|
|
32
32
|
const vanillaSettings = { ...settings,
|
33
33
|
activeDescendantControl: (_activeDescendantCont = activeDescendantControlRef.current) !== null && _activeDescendantCont !== void 0 ? _activeDescendantCont : undefined
|
34
34
|
};
|
35
|
-
abortController.current = (0,
|
35
|
+
abortController.current = (0, _behaviors.focusZone)(containerRef.current, vanillaSettings);
|
36
36
|
return () => {
|
37
37
|
var _abortController$curr;
|
38
38
|
|
@@ -7,7 +7,7 @@ exports.useOpenAndCloseFocus = useOpenAndCloseFocus;
|
|
7
7
|
|
8
8
|
var _react = require("react");
|
9
9
|
|
10
|
-
var
|
10
|
+
var _utils = require("@primer/behaviors/utils");
|
11
11
|
|
12
12
|
function useOpenAndCloseFocus({
|
13
13
|
initialFocusRef,
|
@@ -25,7 +25,7 @@ function useOpenAndCloseFocus({
|
|
25
25
|
if (initialFocusRef && initialFocusRef.current) {
|
26
26
|
initialFocusRef.current.focus();
|
27
27
|
} else if (containerRef.current) {
|
28
|
-
const firstItem = (0,
|
28
|
+
const firstItem = (0, _utils.iterateFocusableElements)(containerRef.current).next().value;
|
29
29
|
firstItem === null || firstItem === void 0 ? void 0 : firstItem.focus();
|
30
30
|
}
|
31
31
|
|
package/lib/index.d.ts
CHANGED
@@ -48,7 +48,6 @@ export { default as CircleBadge } from './CircleBadge';
|
|
48
48
|
export type { CircleBadgeProps, CircleBadgeIconProps } from './CircleBadge';
|
49
49
|
export { default as CircleOcticon } from './CircleOcticon';
|
50
50
|
export type { CircleOcticonProps } from './CircleOcticon';
|
51
|
-
export { default as CheckboxInputField } from './CheckboxInputField';
|
52
51
|
export { default as CounterLabel } from './CounterLabel';
|
53
52
|
export type { CounterLabelProps } from './CounterLabel';
|
54
53
|
export { default as Details } from './Details';
|
@@ -89,7 +88,6 @@ export { default as Popover } from './Popover';
|
|
89
88
|
export type { PopoverProps, PopoverContentProps } from './Popover';
|
90
89
|
export { default as ProgressBar } from './ProgressBar';
|
91
90
|
export type { ProgressBarProps } from './ProgressBar';
|
92
|
-
export { default as RadioInputField } from './RadioInputField';
|
93
91
|
export { default as SelectMenu } from './SelectMenu';
|
94
92
|
export type { SelectMenuProps, SelectMenuDividerProps, SelectMenuFilterProps, SelectMenuFooterProps, SelectMenuItemProps, SelectMenuListProps, SelectMenuModalProps, SelectMenuTabsProps, SelectMenuHeaderProps, SelectMenuTabProps, SelectMenuTabPanelProps, SelectMenuLoadingAnimationProps } from './SelectMenu';
|
95
93
|
export { default as SideNav } from './SideNav';
|
@@ -106,7 +104,6 @@ export { default as TabNav } from './TabNav';
|
|
106
104
|
export type { TabNavProps, TabNavLinkProps } from './TabNav';
|
107
105
|
export { default as TextInput } from './TextInput';
|
108
106
|
export type { TextInputProps } from './TextInput';
|
109
|
-
export { default as TextInputField } from './TextInputField';
|
110
107
|
export { default as TextInputWithTokens } from './TextInputWithTokens';
|
111
108
|
export type { TextInputWithTokensProps } from './TextInputWithTokens';
|
112
109
|
export { default as Text } from './Text';
|
package/lib/index.js
CHANGED
@@ -273,12 +273,6 @@ Object.defineProperty(exports, "CircleOcticon", {
|
|
273
273
|
return _CircleOcticon.default;
|
274
274
|
}
|
275
275
|
});
|
276
|
-
Object.defineProperty(exports, "CheckboxInputField", {
|
277
|
-
enumerable: true,
|
278
|
-
get: function () {
|
279
|
-
return _CheckboxInputField.default;
|
280
|
-
}
|
281
|
-
});
|
282
276
|
Object.defineProperty(exports, "CounterLabel", {
|
283
277
|
enumerable: true,
|
284
278
|
get: function () {
|
@@ -405,12 +399,6 @@ Object.defineProperty(exports, "ProgressBar", {
|
|
405
399
|
return _ProgressBar.default;
|
406
400
|
}
|
407
401
|
});
|
408
|
-
Object.defineProperty(exports, "RadioInputField", {
|
409
|
-
enumerable: true,
|
410
|
-
get: function () {
|
411
|
-
return _RadioInputField.default;
|
412
|
-
}
|
413
|
-
});
|
414
402
|
Object.defineProperty(exports, "SelectMenu", {
|
415
403
|
enumerable: true,
|
416
404
|
get: function () {
|
@@ -459,12 +447,6 @@ Object.defineProperty(exports, "TextInput", {
|
|
459
447
|
return _TextInput.default;
|
460
448
|
}
|
461
449
|
});
|
462
|
-
Object.defineProperty(exports, "TextInputField", {
|
463
|
-
enumerable: true,
|
464
|
-
get: function () {
|
465
|
-
return _TextInputField.default;
|
466
|
-
}
|
467
|
-
});
|
468
450
|
Object.defineProperty(exports, "TextInputWithTokens", {
|
469
451
|
enumerable: true,
|
470
452
|
get: function () {
|
@@ -598,8 +580,6 @@ var _CircleBadge = _interopRequireDefault(require("./CircleBadge"));
|
|
598
580
|
|
599
581
|
var _CircleOcticon = _interopRequireDefault(require("./CircleOcticon"));
|
600
582
|
|
601
|
-
var _CheckboxInputField = _interopRequireDefault(require("./CheckboxInputField"));
|
602
|
-
|
603
583
|
var _CounterLabel = _interopRequireDefault(require("./CounterLabel"));
|
604
584
|
|
605
585
|
var _Details = _interopRequireDefault(require("./Details"));
|
@@ -640,8 +620,6 @@ var _Popover = _interopRequireDefault(require("./Popover"));
|
|
640
620
|
|
641
621
|
var _ProgressBar = _interopRequireDefault(require("./ProgressBar"));
|
642
622
|
|
643
|
-
var _RadioInputField = _interopRequireDefault(require("./RadioInputField"));
|
644
|
-
|
645
623
|
var _SelectMenu = _interopRequireDefault(require("./SelectMenu"));
|
646
624
|
|
647
625
|
var _SideNav = _interopRequireDefault(require("./SideNav"));
|
@@ -658,8 +636,6 @@ var _TabNav = _interopRequireDefault(require("./TabNav"));
|
|
658
636
|
|
659
637
|
var _TextInput = _interopRequireDefault(require("./TextInput"));
|
660
638
|
|
661
|
-
var _TextInputField = _interopRequireDefault(require("./TextInputField"));
|
662
|
-
|
663
639
|
var _TextInputWithTokens = _interopRequireDefault(require("./TextInputWithTokens"));
|
664
640
|
|
665
641
|
var _Text = _interopRequireDefault(require("./Text"));
|
@@ -9,7 +9,7 @@ import styled from 'styled-components';
|
|
9
9
|
import { StyledHeader } from './Header';
|
10
10
|
import { StyledDivider } from './Divider';
|
11
11
|
import { useTheme } from '../ThemeProvider';
|
12
|
-
import { activeDescendantActivatedDirectly, activeDescendantActivatedIndirectly, isActiveDescendantAttribute } from '
|
12
|
+
import { activeDescendantActivatedDirectly, activeDescendantActivatedIndirectly, isActiveDescendantAttribute } from '@primer/behaviors';
|
13
13
|
import { useSSRSafeId } from '@react-aria/ssr';
|
14
14
|
|
15
15
|
const getItemVariant = (variant = 'default', disabled) => {
|
@@ -6,7 +6,7 @@ import { Item } from './Item';
|
|
6
6
|
import { Divider } from './Divider';
|
7
7
|
import styled from 'styled-components';
|
8
8
|
import { get } from '../constants';
|
9
|
-
import { hasActiveDescendantAttribute } from '
|
9
|
+
import { hasActiveDescendantAttribute } from '@primer/behaviors';
|
10
10
|
|
11
11
|
/**
|
12
12
|
* Asserts that the given value fulfills the `GroupedListProps` contract.
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import { OverlayProps } from '../Overlay';
|
3
3
|
import { FocusTrapHookSettings } from '../hooks/useFocusTrap';
|
4
4
|
import { FocusZoneHookSettings } from '../hooks/useFocusZone';
|
5
|
-
import { PositionSettings } from '
|
5
|
+
import type { PositionSettings } from '@primer/behaviors';
|
6
6
|
interface AnchoredOverlayPropsWithAnchor {
|
7
7
|
/**
|
8
8
|
* A custom function component used to render the anchor element.
|
@@ -4,12 +4,16 @@ import { useFocusZone } from '../hooks/useFocusZone';
|
|
4
4
|
import { Box, Spinner } from '../';
|
5
5
|
import { AutocompleteContext } from './AutocompleteContext';
|
6
6
|
import { PlusIcon } from '@primer/octicons-react';
|
7
|
-
import { uniqueId } from '
|
8
|
-
import {
|
9
|
-
import VisuallyHidden from '../_VisuallyHidden';
|
7
|
+
import { uniqueId } from '@primer/behaviors/utils';
|
8
|
+
import { scrollIntoView } from '@primer/behaviors';
|
10
9
|
|
11
10
|
const getDefaultSortFn = isItemSelectedFn => (itemIdA, itemIdB) => isItemSelectedFn(itemIdA) === isItemSelectedFn(itemIdB) ? 0 : isItemSelectedFn(itemIdA) ? -1 : 1;
|
12
11
|
|
12
|
+
const menuScrollMargins = {
|
13
|
+
startMargin: 0,
|
14
|
+
endMargin: 8
|
15
|
+
};
|
16
|
+
|
13
17
|
function getDefaultItemFilter(filterValue) {
|
14
18
|
return function (item, _i) {
|
15
19
|
var _item$text;
|
@@ -135,9 +139,9 @@ function AutocompleteMenu(props) {
|
|
135
139
|
}
|
136
140
|
|
137
141
|
if (current && customScrollContainerRef && customScrollContainerRef.current && directlyActivated) {
|
138
|
-
|
142
|
+
scrollIntoView(current, customScrollContainerRef.current, menuScrollMargins);
|
139
143
|
} else if (current && scrollContainerRef.current && directlyActivated) {
|
140
|
-
|
144
|
+
scrollIntoView(current, scrollContainerRef.current, menuScrollMargins);
|
141
145
|
}
|
142
146
|
}
|
143
147
|
}, [loading]);
|
@@ -165,8 +169,19 @@ function AutocompleteMenu(props) {
|
|
165
169
|
setSelectedItemLength(selectedItemIds.length);
|
166
170
|
}
|
167
171
|
}, [selectedItemIds, setSelectedItemLength]);
|
168
|
-
return /*#__PURE__*/React.createElement(
|
169
|
-
|
172
|
+
return /*#__PURE__*/React.createElement(Box, {
|
173
|
+
sx: !showMenu ? {
|
174
|
+
// visually hides this label for sighted users
|
175
|
+
position: 'absolute',
|
176
|
+
width: '1px',
|
177
|
+
height: '1px',
|
178
|
+
padding: '0',
|
179
|
+
margin: '-1px',
|
180
|
+
overflow: 'hidden',
|
181
|
+
clip: 'rect(0, 0, 0, 0)',
|
182
|
+
whiteSpace: 'nowrap',
|
183
|
+
borderWidth: '0'
|
184
|
+
} : {}
|
170
185
|
}, loading ? /*#__PURE__*/React.createElement(Box, {
|
171
186
|
p: 3,
|
172
187
|
display: "flex",
|
@@ -5,7 +5,7 @@ import ReactDOM from 'react-dom';
|
|
5
5
|
import styled from 'styled-components';
|
6
6
|
import Box from '../Box';
|
7
7
|
import { ThemeProvider, useTheme } from '../ThemeProvider';
|
8
|
-
import { FocusKeys } from '
|
8
|
+
import { FocusKeys } from '@primer/behaviors';
|
9
9
|
import { get } from '../constants';
|
10
10
|
import { Dialog } from '../Dialog/Dialog';
|
11
11
|
import { useFocusZone } from '../hooks/useFocusZone';
|
package/lib-esm/Dialog/Dialog.js
CHANGED
@@ -11,7 +11,7 @@ import sx from '../sx';
|
|
11
11
|
import StyledOcticon from '../StyledOcticon';
|
12
12
|
import { XIcon } from '@primer/octicons-react';
|
13
13
|
import { useFocusZone } from '../hooks/useFocusZone';
|
14
|
-
import { FocusKeys } from '
|
14
|
+
import { FocusKeys } from '@primer/behaviors';
|
15
15
|
import Portal from '../Portal';
|
16
16
|
import { useCombinedRefs } from '../hooks/useCombinedRefs';
|
17
17
|
import { useSSRSafeId } from '@react-aria/ssr';
|
@@ -12,7 +12,11 @@ import styled from 'styled-components';
|
|
12
12
|
import { get } from '../constants';
|
13
13
|
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate';
|
14
14
|
import useScrollFlash from '../hooks/useScrollFlash';
|
15
|
-
import {
|
15
|
+
import { scrollIntoView } from '@primer/behaviors';
|
16
|
+
const menuScrollMargins = {
|
17
|
+
startMargin: 0,
|
18
|
+
endMargin: 8
|
19
|
+
};
|
16
20
|
const StyledHeader = styled.div.withConfig({
|
17
21
|
displayName: "FilteredActionList__StyledHeader",
|
18
22
|
componentId: "sc-yg3jkv-0"
|
@@ -59,7 +63,7 @@ export function FilteredActionList({
|
|
59
63
|
activeDescendantRef.current = current;
|
60
64
|
|
61
65
|
if (current && scrollContainerRef.current && directlyActivated) {
|
62
|
-
|
66
|
+
scrollIntoView(current, scrollContainerRef.current, menuScrollMargins);
|
63
67
|
}
|
64
68
|
}
|
65
69
|
}, [// List ref isn't set while loading. Need to re-bind focus zone when it changes
|
@@ -67,7 +71,9 @@ export function FilteredActionList({
|
|
67
71
|
useEffect(() => {
|
68
72
|
// if items changed, we want to instantly move active descendant into view
|
69
73
|
if (activeDescendantRef.current && scrollContainerRef.current) {
|
70
|
-
|
74
|
+
scrollIntoView(activeDescendantRef.current, scrollContainerRef.current, { ...menuScrollMargins,
|
75
|
+
behavior: 'auto'
|
76
|
+
});
|
71
77
|
}
|
72
78
|
}, [items]);
|
73
79
|
useScrollFlash(scrollContainerRef);
|
package/lib-esm/Overlay.d.ts
CHANGED
@@ -2,7 +2,7 @@ import React, { ComponentPropsWithRef } from 'react';
|
|
2
2
|
import { AriaRole, Merge } from './utils/types';
|
3
3
|
import { TouchOrMouseEvent } from './hooks';
|
4
4
|
import { SxProp } from './sx';
|
5
|
-
import { AnchorSide } from '
|
5
|
+
import type { AnchorSide } from '@primer/behaviors';
|
6
6
|
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
7
7
|
declare type StyledOverlayProps = {
|
8
8
|
width?: keyof typeof widthMap;
|
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
2
2
|
|
3
3
|
import React, { useRef, useState } from 'react';
|
4
4
|
import { omit } from '@styled-system/props';
|
5
|
-
import { FocusKeys } from '
|
5
|
+
import { FocusKeys } from '@primer/behaviors';
|
6
6
|
import { useCombinedRefs } from './hooks/useCombinedRefs';
|
7
7
|
import { useFocusZone } from './hooks/useFocusZone';
|
8
8
|
import Token from './Token/Token';
|
@@ -11,7 +11,7 @@ import UnstyledTextInput from './_UnstyledTextInput';
|
|
11
11
|
import TextInputWrapper from './_TextInputWrapper';
|
12
12
|
import Box from './Box';
|
13
13
|
import Text from './Text';
|
14
|
-
import { isFocusable } from '
|
14
|
+
import { isFocusable } from '@primer/behaviors/utils'; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
15
15
|
|
16
16
|
const overflowCountFontSizeMap = {
|
17
17
|
small: 0,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
2
|
+
import type { AnchorPosition, PositionSettings } from '@primer/behaviors';
|
3
3
|
export interface AnchoredPositionHookSettings extends Partial<PositionSettings> {
|
4
4
|
floatingElementRef?: React.RefObject<Element>;
|
5
5
|
anchorElementRef?: React.RefObject<Element>;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { getAnchoredPosition } from '
|
2
|
+
import { getAnchoredPosition } from '@primer/behaviors';
|
3
3
|
import { useProvidedRefOrCreate } from './useProvidedRefOrCreate';
|
4
4
|
import { useResizeObserver } from './useResizeObserver';
|
5
5
|
import useLayoutEffect from '../utils/useIsomorphicLayoutEffect';
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { FocusZoneSettings } from '
|
2
|
+
import type { FocusZoneSettings } from '@primer/behaviors';
|
3
3
|
export interface FocusZoneHookSettings extends Omit<FocusZoneSettings, 'activeDescendantControl'> {
|
4
4
|
/**
|
5
5
|
* Optional ref for the container that holds all elements participating in arrow key focus.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React, { useEffect } from 'react';
|
2
|
-
import { focusZone } from '
|
2
|
+
import { focusZone } from '@primer/behaviors';
|
3
3
|
import { useProvidedRefOrCreate } from './useProvidedRefOrCreate';
|
4
4
|
export function useFocusZone(settings = {}, dependencies = []) {
|
5
5
|
const containerRef = useProvidedRefOrCreate(settings.containerRef);
|