@primer/components 0.0.0-20219151326 → 0.0.0-202191524113
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/CHANGELOG.md +27 -3
- package/codemods/deprecateUtilityComponents.js +1 -1
- package/dist/browser.esm.js +874 -769
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +877 -772
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Header.js +1 -1
- package/lib/ActionList/Item.js +8 -8
- package/lib/ActionList/List.d.ts +2 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.js +11 -3
- package/lib/Autocomplete/Autocomplete.d.ts +304 -0
- package/lib/Autocomplete/Autocomplete.js +145 -0
- package/lib/Autocomplete/AutocompleteContext.d.ts +17 -0
- package/lib/Autocomplete/AutocompleteContext.js +11 -0
- package/lib/Autocomplete/AutocompleteInput.d.ts +292 -0
- package/lib/Autocomplete/AutocompleteInput.js +157 -0
- package/lib/Autocomplete/AutocompleteMenu.d.ts +72 -0
- package/lib/Autocomplete/AutocompleteMenu.js +224 -0
- package/lib/Autocomplete/AutocompleteOverlay.d.ts +20 -0
- package/lib/Autocomplete/AutocompleteOverlay.js +80 -0
- package/lib/Autocomplete/index.d.ts +2 -0
- package/lib/Autocomplete/index.js +15 -0
- package/lib/BaseStyles.js +1 -1
- package/lib/BorderBox.js +1 -1
- package/lib/BranchName.js +1 -1
- package/lib/Breadcrumbs.js +1 -1
- package/lib/Button/Button.js +1 -1
- package/lib/Button/ButtonClose.js +1 -1
- package/lib/Button/ButtonInvisible.js +1 -1
- package/lib/Button/ButtonTableList.js +1 -1
- package/lib/Caret.js +2 -2
- package/lib/Dialog/ConfirmationDialog.js +1 -1
- package/lib/Dialog/Dialog.js +2 -2
- package/lib/Dialog.js +1 -1
- package/lib/FilterList.js +1 -1
- package/lib/FilteredActionList/FilteredActionList.d.ts +3 -2
- package/lib/FilteredActionList/FilteredActionList.js +8 -32
- package/lib/Flash.js +16 -16
- package/lib/Label.js +2 -2
- package/lib/Link.js +1 -1
- package/lib/Overlay.d.ts +1 -0
- package/lib/Overlay.js +3 -1
- package/lib/Pagination/Pagination.js +1 -1
- package/lib/ProgressBar.js +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +10 -10
- package/lib/SelectMenu/SelectMenuDivider.js +1 -1
- package/lib/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib/SelectMenu/SelectMenuItem.js +1 -1
- package/lib/SelectMenu/SelectMenuTab.js +1 -1
- package/lib/SelectPanel/SelectPanel.d.ts +1 -1
- package/lib/SelectPanel/SelectPanel.js +9 -11
- package/lib/StateLabel.js +13 -19
- package/lib/SubNav.js +1 -1
- package/lib/TextInput.d.ts +5 -13
- package/lib/TextInput.js +4 -46
- package/lib/TextInputWithTokens.d.ts +323 -0
- package/lib/TextInputWithTokens.js +245 -0
- package/lib/Timeline.js +2 -2
- package/lib/Token/AvatarToken.d.ts +7 -0
- package/lib/Token/AvatarToken.js +64 -0
- package/lib/Token/IssueLabelToken.d.ts +14 -0
- package/lib/Token/IssueLabelToken.js +144 -0
- package/lib/Token/Token.d.ts +15 -0
- package/lib/Token/Token.js +94 -0
- package/lib/Token/TokenBase.d.ts +31 -0
- package/lib/Token/TokenBase.js +108 -0
- package/lib/Token/_RemoveTokenButton.d.ts +12 -0
- package/lib/Token/_RemoveTokenButton.js +77 -0
- package/lib/Token/_TokenTextContainer.d.ts +3 -0
- package/lib/Token/_TokenTextContainer.js +17 -0
- package/lib/Token/index.d.ts +3 -0
- package/lib/Token/index.js +31 -0
- package/lib/UnderlineNav.js +1 -1
- package/lib/_TextInputWrapper.d.ts +10 -0
- package/lib/_TextInputWrapper.js +51 -0
- package/lib/_UnstyledTextInput.d.ts +2 -0
- package/lib/_UnstyledTextInput.js +20 -0
- package/lib/behaviors/scrollIntoViewingArea.d.ts +1 -0
- package/lib/behaviors/scrollIntoViewingArea.js +39 -0
- package/lib/hooks/useOpenAndCloseFocus.d.ts +2 -1
- package/lib/hooks/useOpenAndCloseFocus.js +7 -2
- package/lib/hooks/useOverlay.d.ts +2 -1
- package/lib/hooks/useOverlay.js +4 -2
- package/lib/index.d.ts +5 -0
- package/lib/index.js +36 -0
- package/lib/theme-preval.js +370 -3100
- package/lib/utils/testing.d.ts +50 -493
- package/lib/utils/{types.d.ts → types/AriaRole.d.ts} +0 -13
- package/lib/utils/{types.js → types/AriaRole.js} +0 -0
- package/lib/utils/types/ComponentProps.d.ts +9 -0
- package/lib/utils/types/ComponentProps.js +1 -0
- package/lib/utils/types/Flatten.d.ts +4 -0
- package/lib/utils/types/Flatten.js +1 -0
- package/lib/utils/types/MandateProps.d.ts +3 -0
- package/lib/utils/types/MandateProps.js +1 -0
- package/lib/utils/types/Merge.d.ts +19 -0
- package/lib/utils/types/Merge.js +1 -0
- package/lib/utils/types/index.d.ts +5 -0
- package/lib/utils/types/index.js +70 -0
- package/lib-esm/ActionList/Header.js +1 -1
- package/lib-esm/ActionList/Item.js +8 -8
- package/lib-esm/ActionList/List.d.ts +2 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +11 -3
- package/lib-esm/Autocomplete/Autocomplete.d.ts +304 -0
- package/lib-esm/Autocomplete/Autocomplete.js +123 -0
- package/lib-esm/Autocomplete/AutocompleteContext.d.ts +17 -0
- package/lib-esm/Autocomplete/AutocompleteContext.js +2 -0
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +292 -0
- package/lib-esm/Autocomplete/AutocompleteInput.js +138 -0
- package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +72 -0
- package/lib-esm/Autocomplete/AutocompleteMenu.js +205 -0
- package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +20 -0
- package/lib-esm/Autocomplete/AutocompleteOverlay.js +62 -0
- package/lib-esm/Autocomplete/index.d.ts +2 -0
- package/lib-esm/Autocomplete/index.js +1 -0
- package/lib-esm/BaseStyles.js +1 -1
- package/lib-esm/BorderBox.js +1 -1
- package/lib-esm/BranchName.js +1 -1
- package/lib-esm/Breadcrumbs.js +1 -1
- package/lib-esm/Button/Button.js +1 -1
- package/lib-esm/Button/ButtonClose.js +1 -1
- package/lib-esm/Button/ButtonInvisible.js +1 -1
- package/lib-esm/Button/ButtonTableList.js +1 -1
- package/lib-esm/Caret.js +2 -2
- package/lib-esm/Dialog/ConfirmationDialog.js +1 -1
- package/lib-esm/Dialog/Dialog.js +2 -2
- package/lib-esm/Dialog.js +1 -1
- package/lib-esm/FilterList.js +1 -1
- package/lib-esm/FilteredActionList/FilteredActionList.d.ts +3 -2
- package/lib-esm/FilteredActionList/FilteredActionList.js +6 -32
- package/lib-esm/Flash.js +16 -16
- package/lib-esm/Label.js +2 -2
- package/lib-esm/Link.js +1 -1
- package/lib-esm/Overlay.d.ts +1 -0
- package/lib-esm/Overlay.js +3 -1
- package/lib-esm/Pagination/Pagination.js +1 -1
- package/lib-esm/ProgressBar.js +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +10 -10
- package/lib-esm/SelectMenu/SelectMenuDivider.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuItem.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuTab.js +1 -1
- package/lib-esm/SelectPanel/SelectPanel.d.ts +1 -1
- package/lib-esm/SelectPanel/SelectPanel.js +9 -8
- package/lib-esm/StateLabel.js +13 -19
- package/lib-esm/SubNav.js +1 -1
- package/lib-esm/TextInput.d.ts +5 -13
- package/lib-esm/TextInput.js +4 -37
- package/lib-esm/TextInputWithTokens.d.ts +323 -0
- package/lib-esm/TextInputWithTokens.js +220 -0
- package/lib-esm/Timeline.js +2 -2
- package/lib-esm/Token/AvatarToken.d.ts +7 -0
- package/lib-esm/Token/AvatarToken.js +43 -0
- package/lib-esm/Token/IssueLabelToken.d.ts +14 -0
- package/lib-esm/Token/IssueLabelToken.js +124 -0
- package/lib-esm/Token/Token.d.ts +15 -0
- package/lib-esm/Token/Token.js +73 -0
- package/lib-esm/Token/TokenBase.d.ts +31 -0
- package/lib-esm/Token/TokenBase.js +87 -0
- package/lib-esm/Token/_RemoveTokenButton.d.ts +12 -0
- package/lib-esm/Token/_RemoveTokenButton.js +60 -0
- package/lib-esm/Token/_TokenTextContainer.d.ts +3 -0
- package/lib-esm/Token/_TokenTextContainer.js +6 -0
- package/lib-esm/Token/index.d.ts +3 -0
- package/lib-esm/Token/index.js +3 -0
- package/lib-esm/UnderlineNav.js +1 -1
- package/lib-esm/_TextInputWrapper.d.ts +10 -0
- package/lib-esm/_TextInputWrapper.js +31 -0
- package/lib-esm/_UnstyledTextInput.d.ts +2 -0
- package/lib-esm/_UnstyledTextInput.js +7 -0
- package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +1 -0
- package/lib-esm/behaviors/scrollIntoViewingArea.js +30 -0
- package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +2 -1
- package/lib-esm/hooks/useOpenAndCloseFocus.js +7 -2
- package/lib-esm/hooks/useOverlay.d.ts +2 -1
- package/lib-esm/hooks/useOverlay.js +4 -2
- package/lib-esm/index.d.ts +5 -0
- package/lib-esm/index.js +3 -0
- package/lib-esm/theme-preval.js +370 -3100
- package/lib-esm/utils/testing.d.ts +50 -493
- package/lib-esm/utils/{types.d.ts → types/AriaRole.d.ts} +0 -13
- package/lib-esm/utils/{types.js → types/AriaRole.js} +0 -0
- package/lib-esm/utils/types/ComponentProps.d.ts +9 -0
- package/lib-esm/utils/types/ComponentProps.js +1 -0
- package/lib-esm/utils/types/Flatten.d.ts +4 -0
- package/lib-esm/utils/types/Flatten.js +1 -0
- package/lib-esm/utils/types/MandateProps.d.ts +3 -0
- package/lib-esm/utils/types/MandateProps.js +1 -0
- package/lib-esm/utils/types/Merge.d.ts +19 -0
- package/lib-esm/utils/types/Merge.js +1 -0
- package/lib-esm/utils/types/index.d.ts +5 -0
- package/lib-esm/utils/types/index.js +5 -0
- package/package.json +4 -3
- package/lib/ActionList2/Description.d.ts +0 -5
- package/lib/ActionList2/Description.js +0 -54
- package/lib/ActionList2/Divider.d.ts +0 -8
- package/lib/ActionList2/Divider.js +0 -42
- package/lib/ActionList2/Group.d.ts +0 -8
- package/lib/ActionList2/Group.js +0 -39
- package/lib/ActionList2/Header.d.ts +0 -26
- package/lib/ActionList2/Header.js +0 -55
- package/lib/ActionList2/Item.d.ts +0 -52
- package/lib/ActionList2/Item.js +0 -188
- package/lib/ActionList2/List.d.ts +0 -18
- package/lib/ActionList2/List.js +0 -52
- package/lib/ActionList2/Selection.d.ts +0 -5
- package/lib/ActionList2/Selection.js +0 -67
- package/lib/ActionList2/Visuals.d.ts +0 -12
- package/lib/ActionList2/Visuals.js +0 -91
- package/lib/ActionList2/hacks.d.ts +0 -30
- package/lib/ActionList2/hacks.js +0 -38
- package/lib/ActionList2/index.d.ts +0 -26
- package/lib/ActionList2/index.js +0 -36
- package/lib-esm/ActionList2/Description.d.ts +0 -5
- package/lib-esm/ActionList2/Description.js +0 -38
- package/lib-esm/ActionList2/Divider.d.ts +0 -8
- package/lib-esm/ActionList2/Divider.js +0 -30
- package/lib-esm/ActionList2/Group.d.ts +0 -8
- package/lib-esm/ActionList2/Group.js +0 -29
- package/lib-esm/ActionList2/Header.d.ts +0 -26
- package/lib-esm/ActionList2/Header.js +0 -45
- package/lib-esm/ActionList2/Item.d.ts +0 -52
- package/lib-esm/ActionList2/Item.js +0 -184
- package/lib-esm/ActionList2/List.d.ts +0 -18
- package/lib-esm/ActionList2/List.js +0 -42
- package/lib-esm/ActionList2/Selection.d.ts +0 -5
- package/lib-esm/ActionList2/Selection.js +0 -50
- package/lib-esm/ActionList2/Visuals.d.ts +0 -12
- package/lib-esm/ActionList2/Visuals.js +0 -68
- package/lib-esm/ActionList2/hacks.d.ts +0 -30
- package/lib-esm/ActionList2/hacks.js +0 -30
- package/lib-esm/ActionList2/index.d.ts +0 -26
- package/lib-esm/ActionList2/index.js +0 -23
@@ -0,0 +1,224 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
9
|
+
|
10
|
+
var _ActionList = require("../ActionList");
|
11
|
+
|
12
|
+
var _useFocusZone = require("../hooks/useFocusZone");
|
13
|
+
|
14
|
+
var _ = require("../");
|
15
|
+
|
16
|
+
var _AutocompleteContext = require("./AutocompleteContext");
|
17
|
+
|
18
|
+
var _octiconsReact = require("@primer/octicons-react");
|
19
|
+
|
20
|
+
var _uniqueId = require("../utils/uniqueId");
|
21
|
+
|
22
|
+
var _scrollIntoViewingArea = require("../behaviors/scrollIntoViewingArea");
|
23
|
+
|
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); }
|
25
|
+
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
27
|
+
|
28
|
+
const getDefaultSortFn = isItemSelectedFn => (itemIdA, itemIdB) => isItemSelectedFn(itemIdA) === isItemSelectedFn(itemIdB) ? 0 : isItemSelectedFn(itemIdA) ? -1 : 1;
|
29
|
+
|
30
|
+
function getDefaultItemFilter(filterValue) {
|
31
|
+
return function (item, _i) {
|
32
|
+
var _item$text;
|
33
|
+
|
34
|
+
return Boolean((_item$text = item.text) === null || _item$text === void 0 ? void 0 : _item$text.toLowerCase().startsWith(filterValue.toLowerCase()));
|
35
|
+
};
|
36
|
+
}
|
37
|
+
|
38
|
+
function getDefaultOnSelectionChange(setInputValueFn) {
|
39
|
+
return function (itemOrItems) {
|
40
|
+
const {
|
41
|
+
text = ''
|
42
|
+
} = Array.isArray(itemOrItems) ? itemOrItems.slice(-1)[0] : itemOrItems;
|
43
|
+
setInputValueFn(text);
|
44
|
+
};
|
45
|
+
}
|
46
|
+
|
47
|
+
const isItemSelected = (itemId, selectedItemIds) => selectedItemIds.includes(itemId);
|
48
|
+
|
49
|
+
function getItemById(itemId, items) {
|
50
|
+
return items.find(item => item.id === itemId);
|
51
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
52
|
+
|
53
|
+
|
54
|
+
function AutocompleteMenu(props) {
|
55
|
+
const autocompleteContext = (0, _react.useContext)(_AutocompleteContext.AutocompleteContext);
|
56
|
+
|
57
|
+
if (autocompleteContext === null) {
|
58
|
+
throw new Error('AutocompleteContext returned null values');
|
59
|
+
}
|
60
|
+
|
61
|
+
const {
|
62
|
+
activeDescendantRef,
|
63
|
+
id,
|
64
|
+
inputRef,
|
65
|
+
inputValue = '',
|
66
|
+
scrollContainerRef,
|
67
|
+
setAutocompleteSuggestion,
|
68
|
+
setShowMenu,
|
69
|
+
setInputValue,
|
70
|
+
setIsMenuDirectlyActivated,
|
71
|
+
setSelectedItemLength,
|
72
|
+
showMenu
|
73
|
+
} = autocompleteContext;
|
74
|
+
const {
|
75
|
+
items,
|
76
|
+
selectedItemIds,
|
77
|
+
sortOnCloseFn,
|
78
|
+
emptyStateText,
|
79
|
+
addNewItem,
|
80
|
+
loading,
|
81
|
+
selectionVariant,
|
82
|
+
filterFn,
|
83
|
+
'aria-labelledby': ariaLabelledBy,
|
84
|
+
onOpenChange,
|
85
|
+
onSelectedChange,
|
86
|
+
customScrollContainerRef
|
87
|
+
} = props;
|
88
|
+
const listContainerRef = (0, _react.useRef)(null);
|
89
|
+
const [highlightedItem, setHighlightedItem] = (0, _react.useState)();
|
90
|
+
const [sortedItemIds, setSortedItemIds] = (0, _react.useState)(items.map(({
|
91
|
+
id: itemId
|
92
|
+
}) => itemId));
|
93
|
+
const selectableItems = (0, _react.useMemo)(() => items.map(selectableItem => {
|
94
|
+
return { ...selectableItem,
|
95
|
+
role: 'option',
|
96
|
+
id: selectableItem.id,
|
97
|
+
selected: selectionVariant === 'multiple' ? selectedItemIds.includes(selectableItem.id) : undefined,
|
98
|
+
onAction: item => {
|
99
|
+
const otherSelectedItemIds = selectedItemIds.filter(selectedItemId => selectedItemId !== item.id);
|
100
|
+
const newSelectedItemIds = selectedItemIds.includes(item.id) ? otherSelectedItemIds : [...otherSelectedItemIds, item.id];
|
101
|
+
const onSelectedChangeFn = onSelectedChange ? onSelectedChange : getDefaultOnSelectionChange(setInputValue);
|
102
|
+
onSelectedChangeFn(newSelectedItemIds.map(newSelectedItemId => getItemById(newSelectedItemId, items)));
|
103
|
+
|
104
|
+
if (selectionVariant === 'multiple') {
|
105
|
+
setInputValue('');
|
106
|
+
setAutocompleteSuggestion('');
|
107
|
+
} else {
|
108
|
+
var _inputRef$current;
|
109
|
+
|
110
|
+
setShowMenu(false);
|
111
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.setSelectionRange(inputRef.current.value.length, inputRef.current.value.length);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
};
|
115
|
+
}), [items, selectedItemIds, inputRef, onSelectedChange, selectionVariant, setAutocompleteSuggestion, setInputValue, setShowMenu]);
|
116
|
+
const itemSortOrderData = (0, _react.useMemo)(() => sortedItemIds.reduce((acc, curr, i) => {
|
117
|
+
acc[curr] = i;
|
118
|
+
return acc;
|
119
|
+
}, {}), [sortedItemIds]);
|
120
|
+
const sortedAndFilteredItemsToRender = (0, _react.useMemo)(() => selectableItems.filter(filterFn ? filterFn : getDefaultItemFilter(inputValue)).sort((a, b) => itemSortOrderData[a.id] - itemSortOrderData[b.id]), [selectableItems, itemSortOrderData, filterFn, inputValue]);
|
121
|
+
const allItemsToRender = (0, _react.useMemo)(() => [// sorted and filtered selectable items
|
122
|
+
...sortedAndFilteredItemsToRender, // menu item used for creating a token from whatever is in the text input
|
123
|
+
...(addNewItem ? [{ ...addNewItem,
|
124
|
+
leadingVisual: () => /*#__PURE__*/_react.default.createElement(_octiconsReact.PlusIcon, null),
|
125
|
+
onAction: item => {
|
126
|
+
// TODO: make it possible to pass a leadingVisual when using `addNewItem`
|
127
|
+
addNewItem.handleAddItem({ ...item,
|
128
|
+
id: item.id || (0, _uniqueId.uniqueId)(),
|
129
|
+
leadingVisual: undefined
|
130
|
+
});
|
131
|
+
|
132
|
+
if (selectionVariant === 'multiple') {
|
133
|
+
setInputValue('');
|
134
|
+
setAutocompleteSuggestion('');
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}] : [])], [sortedAndFilteredItemsToRender, addNewItem, setAutocompleteSuggestion, selectionVariant, setInputValue]);
|
138
|
+
(0, _useFocusZone.useFocusZone)({
|
139
|
+
containerRef: listContainerRef,
|
140
|
+
focusOutBehavior: 'wrap',
|
141
|
+
focusableElementFilter: element => {
|
142
|
+
return !(element instanceof HTMLInputElement);
|
143
|
+
},
|
144
|
+
activeDescendantFocus: inputRef,
|
145
|
+
onActiveDescendantChanged: (current, _previous, directlyActivated) => {
|
146
|
+
activeDescendantRef.current = current || null;
|
147
|
+
|
148
|
+
if (current) {
|
149
|
+
const selectedItem = selectableItems.find(item => item.id.toString() === current.getAttribute('data-id'));
|
150
|
+
setHighlightedItem(selectedItem);
|
151
|
+
setIsMenuDirectlyActivated(directlyActivated);
|
152
|
+
}
|
153
|
+
|
154
|
+
if (current && customScrollContainerRef && customScrollContainerRef.current && directlyActivated) {
|
155
|
+
(0, _scrollIntoViewingArea.scrollIntoViewingArea)(current, customScrollContainerRef.current);
|
156
|
+
} else if (current && scrollContainerRef.current && directlyActivated) {
|
157
|
+
(0, _scrollIntoViewingArea.scrollIntoViewingArea)(current, scrollContainerRef.current);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}, [loading]);
|
161
|
+
(0, _react.useEffect)(() => {
|
162
|
+
var _highlightedItem$text;
|
163
|
+
|
164
|
+
if (highlightedItem !== null && highlightedItem !== void 0 && (_highlightedItem$text = highlightedItem.text) !== null && _highlightedItem$text !== void 0 && _highlightedItem$text.startsWith(inputValue) && !selectedItemIds.includes(highlightedItem.id)) {
|
165
|
+
setAutocompleteSuggestion(highlightedItem.text);
|
166
|
+
} else {
|
167
|
+
setAutocompleteSuggestion('');
|
168
|
+
}
|
169
|
+
}, [highlightedItem, inputValue, selectedItemIds, setAutocompleteSuggestion]);
|
170
|
+
(0, _react.useEffect)(() => {
|
171
|
+
const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn(itemId => isItemSelected(itemId, selectedItemIds)));
|
172
|
+
const sortResultMatchesState = itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element, index) => element === sortedItemIds[index]);
|
173
|
+
|
174
|
+
if (showMenu === false && !sortResultMatchesState) {
|
175
|
+
setSortedItemIds(itemIdSortResult);
|
176
|
+
}
|
177
|
+
|
178
|
+
onOpenChange && onOpenChange(Boolean(showMenu));
|
179
|
+
}, [showMenu, onOpenChange, selectedItemIds, sortOnCloseFn, sortedItemIds]);
|
180
|
+
(0, _react.useEffect)(() => {
|
181
|
+
if (selectedItemIds.length) {
|
182
|
+
setSelectedItemLength(selectedItemIds.length);
|
183
|
+
}
|
184
|
+
}, [selectedItemIds, setSelectedItemLength]);
|
185
|
+
return /*#__PURE__*/_react.default.createElement(_.Box, {
|
186
|
+
sx: !showMenu ? {
|
187
|
+
// visually hides this label for sighted users
|
188
|
+
position: 'absolute',
|
189
|
+
width: '1px',
|
190
|
+
height: '1px',
|
191
|
+
padding: '0',
|
192
|
+
margin: '-1px',
|
193
|
+
overflow: 'hidden',
|
194
|
+
clip: 'rect(0, 0, 0, 0)',
|
195
|
+
whiteSpace: 'nowrap',
|
196
|
+
borderWidth: '0'
|
197
|
+
} : {}
|
198
|
+
}, loading ? /*#__PURE__*/_react.default.createElement(_.Box, {
|
199
|
+
p: 3,
|
200
|
+
display: "flex",
|
201
|
+
justifyContent: "center"
|
202
|
+
}, /*#__PURE__*/_react.default.createElement(_.Spinner, null)) : /*#__PURE__*/_react.default.createElement("div", {
|
203
|
+
ref: listContainerRef
|
204
|
+
}, allItemsToRender.length ? /*#__PURE__*/_react.default.createElement(_ActionList.ActionList, {
|
205
|
+
selectionVariant: "multiple" // have to typecast to `ItemProps` because we have an extra property
|
206
|
+
// on `items` for Autocomplete: `metadata`
|
207
|
+
,
|
208
|
+
items: allItemsToRender,
|
209
|
+
role: "listbox",
|
210
|
+
id: `${id}-listbox`,
|
211
|
+
"aria-labelledby": ariaLabelledBy
|
212
|
+
}) : /*#__PURE__*/_react.default.createElement(_.Box, {
|
213
|
+
p: 3
|
214
|
+
}, emptyStateText)));
|
215
|
+
}
|
216
|
+
|
217
|
+
AutocompleteMenu.displayName = "AutocompleteMenu";
|
218
|
+
AutocompleteMenu.defaultProps = {
|
219
|
+
emptyStateText: 'No selectable options',
|
220
|
+
selectionVariant: 'single'
|
221
|
+
};
|
222
|
+
AutocompleteMenu.displayName = 'AutocompleteMenu';
|
223
|
+
var _default = AutocompleteMenu;
|
224
|
+
exports.default = _default;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { OverlayProps } from '../Overlay';
|
3
|
+
import { ComponentProps } from '../utils/types';
|
4
|
+
declare type AutocompleteOverlayInternalProps = {
|
5
|
+
/**
|
6
|
+
* The ref of the element that the position of the menu is based on. By default, the menu is positioned based on the text input
|
7
|
+
*/
|
8
|
+
menuAnchorRef?: React.RefObject<HTMLElement>;
|
9
|
+
/**
|
10
|
+
* Props to be spread on the internal `Overlay` component.
|
11
|
+
*/
|
12
|
+
overlayProps?: Partial<OverlayProps>;
|
13
|
+
children?: React.ReactNode;
|
14
|
+
} & Pick<React.AriaAttributes, 'aria-labelledby'>;
|
15
|
+
declare function AutocompleteOverlay({ menuAnchorRef, overlayProps, children }: AutocompleteOverlayInternalProps): JSX.Element | null;
|
16
|
+
declare namespace AutocompleteOverlay {
|
17
|
+
var displayName: string;
|
18
|
+
}
|
19
|
+
export declare type AutocompleteOverlayProps = ComponentProps<typeof AutocompleteOverlay>;
|
20
|
+
export default AutocompleteOverlay;
|
@@ -0,0 +1,80 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
9
|
+
|
10
|
+
var _hooks = require("../hooks");
|
11
|
+
|
12
|
+
var _Overlay = _interopRequireDefault(require("../Overlay"));
|
13
|
+
|
14
|
+
var _AutocompleteContext = require("./AutocompleteContext");
|
15
|
+
|
16
|
+
var _useCombinedRefs = require("../hooks/useCombinedRefs");
|
17
|
+
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
+
|
20
|
+
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); }
|
21
|
+
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
23
|
+
|
24
|
+
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); }
|
25
|
+
|
26
|
+
// TODO: consider making 'aria-labelledby' required
|
27
|
+
function AutocompleteOverlay({
|
28
|
+
menuAnchorRef,
|
29
|
+
overlayProps,
|
30
|
+
children
|
31
|
+
}) {
|
32
|
+
const autocompleteContext = (0, _react.useContext)(_AutocompleteContext.AutocompleteContext);
|
33
|
+
|
34
|
+
if (autocompleteContext === null) {
|
35
|
+
throw new Error('AutocompleteContext returned null values');
|
36
|
+
}
|
37
|
+
|
38
|
+
const {
|
39
|
+
inputRef,
|
40
|
+
scrollContainerRef,
|
41
|
+
selectedItemLength,
|
42
|
+
setShowMenu,
|
43
|
+
showMenu = false
|
44
|
+
} = autocompleteContext;
|
45
|
+
const {
|
46
|
+
floatingElementRef,
|
47
|
+
position
|
48
|
+
} = (0, _hooks.useAnchoredPosition)({
|
49
|
+
side: 'outside-bottom',
|
50
|
+
align: 'start',
|
51
|
+
anchorElementRef: menuAnchorRef ? menuAnchorRef : inputRef
|
52
|
+
}, [showMenu, selectedItemLength]);
|
53
|
+
const combinedOverlayRef = (0, _useCombinedRefs.useCombinedRefs)(scrollContainerRef, floatingElementRef);
|
54
|
+
const closeOptionList = (0, _react.useCallback)(() => {
|
55
|
+
setShowMenu(false);
|
56
|
+
}, [setShowMenu]);
|
57
|
+
|
58
|
+
if (typeof window === 'undefined') {
|
59
|
+
return null;
|
60
|
+
}
|
61
|
+
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_Overlay.default, _extends({
|
63
|
+
returnFocusRef: inputRef,
|
64
|
+
preventFocusOnOpen: true,
|
65
|
+
onClickOutside: closeOptionList,
|
66
|
+
onEscape: closeOptionList,
|
67
|
+
ref: combinedOverlayRef,
|
68
|
+
top: position === null || position === void 0 ? void 0 : position.top,
|
69
|
+
left: position === null || position === void 0 ? void 0 : position.left,
|
70
|
+
visibility: showMenu ? 'visible' : 'hidden',
|
71
|
+
sx: {
|
72
|
+
overflow: 'auto'
|
73
|
+
}
|
74
|
+
}, overlayProps), children);
|
75
|
+
}
|
76
|
+
|
77
|
+
AutocompleteOverlay.displayName = "AutocompleteOverlay";
|
78
|
+
AutocompleteOverlay.displayName = 'AutocompleteOverlay';
|
79
|
+
var _default = AutocompleteOverlay;
|
80
|
+
exports.default = _default;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "default", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function () {
|
9
|
+
return _Autocomplete.default;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
|
13
|
+
var _Autocomplete = _interopRequireDefault(require("./Autocomplete"));
|
14
|
+
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/lib/BaseStyles.js
CHANGED
package/lib/BorderBox.js
CHANGED
@@ -21,7 +21,7 @@ const BorderBox = (0, _styledComponents.default)(_Box.default).withConfig({
|
|
21
21
|
BorderBox.defaultProps = {
|
22
22
|
borderWidth: '1px',
|
23
23
|
borderStyle: 'solid',
|
24
|
-
borderColor: 'border.
|
24
|
+
borderColor: 'border.default',
|
25
25
|
borderRadius: 2
|
26
26
|
};
|
27
27
|
var _default = BorderBox;
|
package/lib/BranchName.js
CHANGED
@@ -16,7 +16,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
16
16
|
const BranchName = _styledComponents.default.a.withConfig({
|
17
17
|
displayName: "BranchName",
|
18
18
|
componentId: "sc-167ouzm-0"
|
19
|
-
})(["display:inline-block;padding:2px 6px;font-size:", ";font-family:", ";color:", ";background-color:", ";border-radius:", ";", ";", ";"], (0, _constants.get)('fontSizes.0'), (0, _constants.get)('fonts.mono'), (0, _constants.get)('colors.fg.
|
19
|
+
})(["display:inline-block;padding:2px 6px;font-size:", ";font-family:", ";color:", ";background-color:", ";border-radius:", ";", ";", ";"], (0, _constants.get)('fontSizes.0'), (0, _constants.get)('fonts.mono'), (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('colors.accent.subtle'), (0, _constants.get)('radii.2'), _constants.COMMON, _sx.default);
|
20
20
|
|
21
21
|
var _default = BranchName;
|
22
22
|
exports.default = _default;
|
package/lib/Breadcrumbs.js
CHANGED
@@ -26,7 +26,7 @@ const SELECTED_CLASS = 'selected';
|
|
26
26
|
const Wrapper = _styledComponents.default.li.withConfig({
|
27
27
|
displayName: "Breadcrumbs__Wrapper",
|
28
28
|
componentId: "hwwoo0-0"
|
29
|
-
})(["display:inline-block;white-space:nowrap;list-style:none;&::after{padding-right:0.5em;padding-left:0.5em;color:", ";font-size:", ";content:'/';}&:first-child{margin-left:0;}&:last-child{&::after{content:none;}}"], (0, _constants.get)('colors.fg.
|
29
|
+
})(["display:inline-block;white-space:nowrap;list-style:none;&::after{padding-right:0.5em;padding-left:0.5em;color:", ";font-size:", ";content:'/';}&:first-child{margin-left:0;}&:last-child{&::after{content:none;}}"], (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('fontSizes.1'));
|
30
30
|
|
31
31
|
const BreadcrumbsBase = _styledComponents.default.nav.withConfig({
|
32
32
|
displayName: "Breadcrumbs__BreadcrumbsBase",
|
package/lib/Button/Button.js
CHANGED
@@ -22,6 +22,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
22
22
|
const Button = (0, _styledComponents.default)(_ButtonBase.default).withConfig({
|
23
23
|
displayName: "Button",
|
24
24
|
componentId: "xjtz72-0"
|
25
|
-
})(["color:", ";background-color:", ";border:1px solid ", ";box-shadow:", ",", "};&:hover{background-color:", ";border-color:", ";}&:focus{border-color:", ";box-shadow:", ";}&:active{background-color:", ";box-shadow:", ";}&:disabled{color:", ";background-color:", ";border-color:", ";}", ";", ";"], (0, _constants.get)('colors.btn.text'), (0, _constants.get)('colors.btn.bg'), (0, _constants.get)('colors.btn.border'), (0, _constants.get)('shadows.btn.shadow'), (0, _constants.get)('shadows.btn.insetShadow'), (0, _constants.get)('colors.btn.hoverBg'), (0, _constants.get)('colors.btn.hoverBorder'), (0, _constants.get)('colors.btn.focusBorder'), (0, _constants.get)('shadows.btn.focusShadow'), (0, _constants.get)('colors.btn.selectedBg'), (0, _constants.get)('shadows.btn.shadowActive'), (0, _constants.get)('colors.fg.
|
25
|
+
})(["color:", ";background-color:", ";border:1px solid ", ";box-shadow:", ",", "};&:hover{background-color:", ";border-color:", ";}&:focus{border-color:", ";box-shadow:", ";}&:active{background-color:", ";box-shadow:", ";}&:disabled{color:", ";background-color:", ";border-color:", ";}", ";", ";"], (0, _constants.get)('colors.btn.text'), (0, _constants.get)('colors.btn.bg'), (0, _constants.get)('colors.btn.border'), (0, _constants.get)('shadows.btn.shadow'), (0, _constants.get)('shadows.btn.insetShadow'), (0, _constants.get)('colors.btn.hoverBg'), (0, _constants.get)('colors.btn.hoverBorder'), (0, _constants.get)('colors.btn.focusBorder'), (0, _constants.get)('shadows.btn.focusShadow'), (0, _constants.get)('colors.btn.selectedBg'), (0, _constants.get)('shadows.btn.shadowActive'), (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('colors.btn.bg'), (0, _constants.get)('colors.btn.border'), _ButtonBase.buttonSystemProps, _sx.default);
|
26
26
|
var _default = Button;
|
27
27
|
exports.default = _default;
|
@@ -26,7 +26,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
26
26
|
const StyledButton = _styledComponents.default.button.withConfig({
|
27
27
|
displayName: "ButtonClose__StyledButton",
|
28
28
|
componentId: "sc-13mzqph-0"
|
29
|
-
})(["border:none;padding:0;background:transparent;outline:none;cursor:pointer;border-radius:", ";color:", ";&:focus{box-shadow:", ";}&:hover{color:", ";}", ";", ";", ";"], (0, _constants.get)('radii.2'), (0, _constants.get)('colors.fg.
|
29
|
+
})(["border:none;padding:0;background:transparent;outline:none;cursor:pointer;border-radius:", ";color:", ";&:focus{box-shadow:", ";}&:hover{color:", ";}", ";", ";", ";"], (0, _constants.get)('radii.2'), (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('shadows.btn.focusShadow'), (0, _constants.get)('colors.accent.fg'), _constants.COMMON, _constants.LAYOUT, _sx.default);
|
30
30
|
|
31
31
|
const ButtonClose = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
32
32
|
return /*#__PURE__*/_react.default.createElement(StyledButton, _extends({
|
@@ -22,6 +22,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
22
22
|
const ButtonInvisible = (0, _styledComponents.default)(_ButtonBase.default).withConfig({
|
23
23
|
displayName: "ButtonInvisible",
|
24
24
|
componentId: "sc-1195tpn-0"
|
25
|
-
})(["color:", ";background-color:transparent;border:0;border-radius:", ";box-shadow:none;&:disabled{color:", ";}&:focus{box-shadow:", ";}", ";", ""], (0, _constants.get)('colors.accent.fg'), (0, _constants.get)('radii.2'), (0, _constants.get)('colors.fg.
|
25
|
+
})(["color:", ";background-color:transparent;border:0;border-radius:", ";box-shadow:none;&:disabled{color:", ";}&:focus{box-shadow:", ";}", ";", ""], (0, _constants.get)('colors.accent.fg'), (0, _constants.get)('radii.2'), (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('shadows.btn.focusShadow'), _ButtonBase.buttonSystemProps, _sx.default);
|
26
26
|
var _default = ButtonInvisible;
|
27
27
|
exports.default = _default;
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
16
16
|
const ButtonTableList = _styledComponents.default.summary.withConfig({
|
17
17
|
displayName: "ButtonTableList",
|
18
18
|
componentId: "sc-1m4q8ia-0"
|
19
|
-
})(["display:inline-block;padding:0;font-size:", ";color:", ";text-decoration:none;white-space:nowrap;cursor:pointer;user-select:none;background-color:transparent;border:0;appearance:none;&:hover{text-decoration:underline;}&:disabled{&,&:hover{color:rgba(", ",0.5);cursor:default;}}&:after{display:inline-block;margin-left:", ";width:0;height:0;vertical-align:-2px;content:'';border:4px solid transparent;border-top-color:currentcolor;}", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.
|
19
|
+
})(["display:inline-block;padding:0;font-size:", ";color:", ";text-decoration:none;white-space:nowrap;cursor:pointer;user-select:none;background-color:transparent;border:0;appearance:none;&:hover{text-decoration:underline;}&:disabled{&,&:hover{color:rgba(", ",0.5);cursor:default;}}&:after{display:inline-block;margin-left:", ";width:0;height:0;vertical-align:-2px;content:'';border:4px solid transparent;border-top-color:currentcolor;}", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('space.1'), _constants.COMMON, _constants.TYPOGRAPHY, _constants.LAYOUT, _sx.default);
|
20
20
|
|
21
21
|
var _default = ButtonTableList;
|
22
22
|
exports.default = _default;
|
package/lib/Caret.js
CHANGED
@@ -119,8 +119,8 @@ function Caret(props) {
|
|
119
119
|
Caret.displayName = "Caret";
|
120
120
|
Caret.locations = ['top', 'top-left', 'top-right', 'right', 'right-top', 'right-bottom', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom'];
|
121
121
|
Caret.defaultProps = {
|
122
|
-
bg: '
|
123
|
-
borderColor: 'border.
|
122
|
+
bg: 'canvas.default',
|
123
|
+
borderColor: 'border.default',
|
124
124
|
borderWidth: 1
|
125
125
|
};
|
126
126
|
var _default = Caret;
|
@@ -61,7 +61,7 @@ ConfirmationHeader.displayName = "ConfirmationHeader";
|
|
61
61
|
const StyledConfirmationBody = (0, _styledComponents.default)(_Box.default).withConfig({
|
62
62
|
displayName: "ConfirmationDialog__StyledConfirmationBody",
|
63
63
|
componentId: "sc-1ub32x2-2"
|
64
|
-
})(["font-size:", ";padding:0 ", " ", " ", ";color:", ";flex-grow:1;"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('space.3'), (0, _constants.get)('space.3'), (0, _constants.get)('space.3'), (0, _constants.get)('colors.fg.
|
64
|
+
})(["font-size:", ";padding:0 ", " ", " ", ";color:", ";flex-grow:1;"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('space.3'), (0, _constants.get)('space.3'), (0, _constants.get)('space.3'), (0, _constants.get)('colors.primer.fg.disabled'));
|
65
65
|
|
66
66
|
const ConfirmationBody = ({
|
67
67
|
children
|
package/lib/Dialog/Dialog.js
CHANGED
@@ -202,7 +202,7 @@ const Title = (0, _styledComponents.default)(_Box.default).withConfig({
|
|
202
202
|
const Subtitle = (0, _styledComponents.default)(_Box.default).withConfig({
|
203
203
|
displayName: "Dialog__Subtitle",
|
204
204
|
componentId: "sc-11pkgky-4"
|
205
|
-
})(["font-size:", ";margin-top:", ";color:", ";"], (0, _constants.get)('fontSizes.0'), (0, _constants.get)('space.1'), (0, _constants.get)('colors.fg.
|
205
|
+
})(["font-size:", ";margin-top:", ";color:", ";"], (0, _constants.get)('fontSizes.0'), (0, _constants.get)('space.1'), (0, _constants.get)('colors.primer.fg.disabled'));
|
206
206
|
const Body = (0, _styledComponents.default)(_Box.default).withConfig({
|
207
207
|
displayName: "Dialog__Body",
|
208
208
|
componentId: "sc-11pkgky-5"
|
@@ -256,7 +256,7 @@ const Buttons = ({
|
|
256
256
|
const DialogCloseButton = (0, _styledComponents.default)(_Button.default).withConfig({
|
257
257
|
displayName: "Dialog__DialogCloseButton",
|
258
258
|
componentId: "sc-11pkgky-7"
|
259
|
-
})(["border-radius:4px;background:transparent;border:0;vertical-align:middle;color:", ";padding:", ";align-self:flex-start;line-height:normal;box-shadow:none;"], (0, _constants.get)('colors.fg.
|
259
|
+
})(["border-radius:4px;background:transparent;border:0;vertical-align:middle;color:", ";padding:", ";align-self:flex-start;line-height:normal;box-shadow:none;"], (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('space.2'));
|
260
260
|
|
261
261
|
const CloseButton = ({
|
262
262
|
onClose
|
package/lib/Dialog.js
CHANGED
@@ -122,7 +122,7 @@ const Dialog = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
122
122
|
}), children)) : null;
|
123
123
|
});
|
124
124
|
DialogHeader.defaultProps = {
|
125
|
-
backgroundColor: '
|
125
|
+
backgroundColor: 'canvas.subtle'
|
126
126
|
};
|
127
127
|
DialogHeader.propTypes = { ..._Box.default.propTypes
|
128
128
|
};
|
package/lib/FilterList.js
CHANGED
@@ -36,7 +36,7 @@ FilterList.displayName = "FilterList";
|
|
36
36
|
const FilterListItemBase = _styledComponents.default.a.withConfig({
|
37
37
|
displayName: "FilterList__FilterListItemBase",
|
38
38
|
componentId: "sc-1l4pxmz-1"
|
39
|
-
})(["position:relative;display:block;padding:", ";margin:", ";overflow:hidden;font-size:", ";color:", ";background-color:", "!important;text-decoration:none;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;border-radius:", ";&:hover{text-decoration:none;background-color:", ";}&:active{color:", ";background-color:", ";}.count{float:right;font-weight:", ";}", ";", ";"], props => props.small ? `${(0, _constants.get)('space.1')(props)} 10px` : `${(0, _constants.get)('space.2')(props)} 11px`, props => props.small ? '0 0 2px' : '0 0 5px 0', (0, _constants.get)('fontSizes.1'), props => props.selected ? (0, _constants.get)('colors.fg.onEmphasis') : (0, _constants.get)('colors.fg.
|
39
|
+
})(["position:relative;display:block;padding:", ";margin:", ";overflow:hidden;font-size:", ";color:", ";background-color:", "!important;text-decoration:none;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;border-radius:", ";&:hover{text-decoration:none;background-color:", ";}&:active{color:", ";background-color:", ";}.count{float:right;font-weight:", ";}", ";", ";"], props => props.small ? `${(0, _constants.get)('space.1')(props)} 10px` : `${(0, _constants.get)('space.2')(props)} 11px`, props => props.small ? '0 0 2px' : '0 0 5px 0', (0, _constants.get)('fontSizes.1'), props => props.selected ? (0, _constants.get)('colors.fg.onEmphasis') : (0, _constants.get)('colors.primer.fg.disabled'), props => props.selected ? (0, _constants.get)('colors.accent.emphasis') : '', (0, _constants.get)('radii.1'), (0, _constants.get)('colors.canvas.subtle'), (0, _constants.get)('colors.fg.onEmphasis'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('fontWeights.bold'), _constants.COMMON, _sx.default);
|
40
40
|
|
41
41
|
function FilterListItem({
|
42
42
|
children,
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { GroupedListProps, ListPropsBase } from '../ActionList/List';
|
3
3
|
import { TextInputProps } from '../TextInput';
|
4
|
-
|
4
|
+
import { SxProp } from '../sx';
|
5
|
+
export interface FilteredActionListProps extends Partial<Omit<GroupedListProps, keyof ListPropsBase>>, ListPropsBase, SxProp {
|
5
6
|
loading?: boolean;
|
6
7
|
placeholderText: string;
|
7
8
|
filterValue?: string;
|
@@ -9,7 +10,7 @@ export interface FilteredActionListProps extends Partial<Omit<GroupedListProps,
|
|
9
10
|
textInputProps?: Partial<Omit<TextInputProps, 'onChange'>>;
|
10
11
|
inputRef?: React.RefObject<HTMLInputElement>;
|
11
12
|
}
|
12
|
-
export declare function FilteredActionList({ loading, placeholderText, filterValue: externalFilterValue, onFilterChange, items, textInputProps, inputRef: providedInputRef, ...listProps }: FilteredActionListProps): JSX.Element;
|
13
|
+
export declare function FilteredActionList({ loading, placeholderText, filterValue: externalFilterValue, onFilterChange, items, textInputProps, inputRef: providedInputRef, sx, ...listProps }: FilteredActionListProps): JSX.Element;
|
13
14
|
export declare namespace FilteredActionList {
|
14
15
|
var displayName: string;
|
15
16
|
}
|
@@ -7,6 +7,8 @@ exports.FilteredActionList = FilteredActionList;
|
|
7
7
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
9
9
|
|
10
|
+
var _ssr = require("@react-aria/ssr");
|
11
|
+
|
10
12
|
var _TextInput = _interopRequireDefault(require("../TextInput"));
|
11
13
|
|
12
14
|
var _Box = _interopRequireDefault(require("../Box"));
|
@@ -27,7 +29,7 @@ var _useProvidedRefOrCreate = require("../hooks/useProvidedRefOrCreate");
|
|
27
29
|
|
28
30
|
var _useScrollFlash = _interopRequireDefault(require("../hooks/useScrollFlash"));
|
29
31
|
|
30
|
-
var
|
32
|
+
var _scrollIntoViewingArea = require("../behaviors/scrollIntoViewingArea");
|
31
33
|
|
32
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
33
35
|
|
@@ -37,34 +39,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
37
39
|
|
38
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); }
|
39
41
|
|
40
|
-
function scrollIntoViewingArea(child, container, margin = 8, behavior = 'smooth') {
|
41
|
-
const {
|
42
|
-
top: childTop,
|
43
|
-
bottom: childBottom
|
44
|
-
} = child.getBoundingClientRect();
|
45
|
-
const {
|
46
|
-
top: containerTop,
|
47
|
-
bottom: containerBottom
|
48
|
-
} = container.getBoundingClientRect();
|
49
|
-
const isChildTopAboveViewingArea = childTop < containerTop + margin;
|
50
|
-
const isChildBottomBelowViewingArea = childBottom > containerBottom - margin;
|
51
|
-
|
52
|
-
if (isChildTopAboveViewingArea) {
|
53
|
-
const scrollHeightToChildTop = childTop - containerTop + container.scrollTop;
|
54
|
-
container.scrollTo({
|
55
|
-
behavior,
|
56
|
-
top: scrollHeightToChildTop - margin
|
57
|
-
});
|
58
|
-
} else if (isChildBottomBelowViewingArea) {
|
59
|
-
const scrollHeightToChildBottom = childBottom - containerBottom + container.scrollTop;
|
60
|
-
container.scrollTo({
|
61
|
-
behavior,
|
62
|
-
top: scrollHeightToChildBottom + margin
|
63
|
-
});
|
64
|
-
} // either completely in view or outside viewing area on both ends, don't scroll
|
65
|
-
|
66
|
-
}
|
67
|
-
|
68
42
|
const StyledHeader = _styledComponents.default.div.withConfig({
|
69
43
|
displayName: "FilteredActionList__StyledHeader",
|
70
44
|
componentId: "yg3jkv-0"
|
@@ -78,6 +52,7 @@ function FilteredActionList({
|
|
78
52
|
items,
|
79
53
|
textInputProps,
|
80
54
|
inputRef: providedInputRef,
|
55
|
+
sx,
|
81
56
|
...listProps
|
82
57
|
}) {
|
83
58
|
const [filterValue, setInternalFilterValue] = (0, _useProvidedStateOrCreate.useProvidedStateOrCreate)(externalFilterValue, undefined, '');
|
@@ -111,7 +86,7 @@ function FilteredActionList({
|
|
111
86
|
activeDescendantRef.current = current;
|
112
87
|
|
113
88
|
if (current && scrollContainerRef.current && directlyActivated) {
|
114
|
-
scrollIntoViewingArea(current, scrollContainerRef.current);
|
89
|
+
(0, _scrollIntoViewingArea.scrollIntoViewingArea)(current, scrollContainerRef.current);
|
115
90
|
}
|
116
91
|
}
|
117
92
|
}, [// List ref isn't set while loading. Need to re-bind focus zone when it changes
|
@@ -119,14 +94,15 @@ function FilteredActionList({
|
|
119
94
|
(0, _react.useEffect)(() => {
|
120
95
|
// if items changed, we want to instantly move active descendant into view
|
121
96
|
if (activeDescendantRef.current && scrollContainerRef.current) {
|
122
|
-
scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, undefined, 'auto');
|
97
|
+
(0, _scrollIntoViewingArea.scrollIntoViewingArea)(activeDescendantRef.current, scrollContainerRef.current, 'vertical', undefined, undefined, 'auto');
|
123
98
|
}
|
124
99
|
}, [items]);
|
125
100
|
(0, _useScrollFlash.default)(scrollContainerRef);
|
126
101
|
return /*#__PURE__*/_react.default.createElement(_Box.default, {
|
127
102
|
display: "flex",
|
128
103
|
flexDirection: "column",
|
129
|
-
overflow: "hidden"
|
104
|
+
overflow: "hidden",
|
105
|
+
sx: sx
|
130
106
|
}, /*#__PURE__*/_react.default.createElement(StyledHeader, null, /*#__PURE__*/_react.default.createElement(_TextInput.default, _extends({
|
131
107
|
ref: inputRef,
|
132
108
|
block: true,
|