@primer/components 0.0.0-20211030163410 → 0.0.0-20211030175556
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 +2 -28
- package/dist/browser.esm.js +591 -602
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +200 -211
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Divider.jsx +29 -0
- package/lib/ActionList/Group.jsx +23 -0
- package/lib/ActionList/Header.jsx +66 -0
- package/lib/ActionList/Item.js +3 -3
- package/lib/ActionList/Item.jsx +288 -0
- package/lib/ActionList/List.jsx +138 -0
- package/lib/ActionList/index.js +12 -23
- package/lib/ActionList2/Description.jsx +29 -0
- package/lib/ActionList2/Divider.jsx +22 -0
- package/lib/ActionList2/Group.jsx +54 -0
- package/lib/ActionList2/Header.d.ts +26 -0
- package/lib/ActionList2/Header.js +55 -0
- package/lib/ActionList2/Header.jsx +36 -0
- package/lib/ActionList2/Item.js +1 -3
- package/lib/ActionList2/Item.jsx +174 -0
- package/lib/ActionList2/LinkItem.jsx +28 -0
- package/lib/ActionList2/List.js +2 -1
- package/lib/ActionList2/List.jsx +41 -0
- package/lib/ActionList2/Selection.js +1 -3
- package/lib/ActionList2/Selection.jsx +50 -0
- package/lib/ActionList2/Visuals.jsx +48 -0
- package/lib/ActionList2/index.js +23 -41
- package/lib/ActionMenu.jsx +73 -0
- package/lib/AnchoredOverlay/AnchoredOverlay.jsx +100 -0
- package/lib/AnchoredOverlay/index.js +4 -12
- package/lib/Autocomplete/Autocomplete.d.ts +0 -1
- package/lib/Autocomplete/Autocomplete.jsx +100 -0
- package/lib/Autocomplete/AutocompleteContext.jsx +5 -0
- package/lib/Autocomplete/AutocompleteInput.d.ts +0 -1
- package/lib/Autocomplete/AutocompleteInput.jsx +113 -0
- package/lib/Autocomplete/AutocompleteMenu.js +13 -6
- package/lib/Autocomplete/AutocompleteMenu.jsx +190 -0
- package/lib/Autocomplete/AutocompleteOverlay.jsx +55 -0
- package/lib/Autocomplete/index.js +7 -14
- package/lib/Avatar.jsx +34 -0
- package/lib/AvatarPair.jsx +29 -0
- package/lib/AvatarStack.jsx +151 -0
- package/lib/BaseStyles.jsx +65 -0
- package/lib/BorderBox.jsx +18 -0
- package/lib/Box.jsx +10 -0
- package/lib/BranchName.jsx +20 -0
- package/lib/Breadcrumbs.jsx +71 -0
- package/lib/Button/Button.d.ts +0 -1
- package/lib/Button/Button.jsx +40 -0
- package/lib/Button/ButtonBase.jsx +33 -0
- package/lib/Button/ButtonClose.d.ts +1 -2
- package/lib/Button/ButtonClose.jsx +53 -0
- package/lib/Button/ButtonDanger.d.ts +0 -1
- package/lib/Button/ButtonDanger.jsx +43 -0
- package/lib/Button/ButtonGroup.jsx +55 -0
- package/lib/Button/ButtonInvisible.d.ts +0 -1
- package/lib/Button/ButtonInvisible.jsx +32 -0
- package/lib/Button/ButtonOutline.d.ts +0 -1
- package/lib/Button/ButtonOutline.jsx +43 -0
- package/lib/Button/ButtonPrimary.d.ts +0 -1
- package/lib/Button/ButtonPrimary.jsx +42 -0
- package/lib/Button/ButtonStyles.jsx +37 -0
- package/lib/Button/ButtonTableList.jsx +46 -0
- package/lib/Button/index.js +21 -70
- package/lib/Caret.jsx +93 -0
- package/lib/CircleBadge.jsx +42 -0
- package/lib/CircleOcticon.d.ts +0 -1
- package/lib/CircleOcticon.jsx +21 -0
- package/lib/CounterLabel.jsx +43 -0
- package/lib/Details.jsx +21 -0
- package/lib/Dialog/ConfirmationDialog.jsx +146 -0
- package/lib/Dialog/Dialog.jsx +279 -0
- package/lib/Dialog.d.ts +2 -3
- package/lib/Dialog.jsx +129 -0
- package/lib/Dropdown.d.ts +0 -4
- package/lib/Dropdown.jsx +131 -0
- package/lib/DropdownMenu/DropdownButton.d.ts +1 -2
- package/lib/DropdownMenu/DropdownButton.jsx +14 -0
- package/lib/DropdownMenu/DropdownMenu.jsx +70 -0
- package/lib/DropdownMenu/index.js +6 -20
- package/lib/DropdownStyles.js +18 -26
- package/lib/FilterList.d.ts +0 -1
- package/lib/FilterList.jsx +59 -0
- package/lib/FilteredActionList/FilteredActionList.jsx +100 -0
- package/lib/FilteredActionList/index.js +4 -12
- package/lib/FilteredSearch.jsx +28 -0
- package/lib/Flash.jsx +69 -0
- package/lib/Flex.jsx +15 -0
- package/lib/FormGroup.jsx +22 -0
- package/lib/Grid.jsx +15 -0
- package/lib/Header.jsx +83 -0
- package/lib/Heading.jsx +21 -0
- package/lib/Label.jsx +82 -0
- package/lib/LabelGroup.jsx +18 -0
- package/lib/Link.jsx +36 -0
- package/lib/NewButton/button-counter.jsx +14 -0
- package/lib/NewButton/button.jsx +279 -0
- package/lib/NewButton/index.js +5 -12
- package/lib/NewButton/types.js +2 -1
- package/lib/Overlay.d.ts +3 -5
- package/lib/Overlay.jsx +154 -0
- package/lib/Pagehead.jsx +17 -0
- package/lib/Pagination/Pagination.jsx +161 -0
- package/lib/Pagination/index.js +6 -12
- package/lib/Pagination/model.jsx +174 -0
- package/lib/PointerBox.jsx +25 -0
- package/lib/Popover.jsx +202 -0
- package/lib/Portal/Portal.jsx +79 -0
- package/lib/Portal/index.js +5 -16
- package/lib/Position.d.ts +4 -4
- package/lib/Position.jsx +46 -0
- package/lib/ProgressBar.jsx +39 -0
- package/lib/SelectMenu/SelectMenu.d.ts +4 -10
- package/lib/SelectMenu/SelectMenu.jsx +112 -0
- package/lib/SelectMenu/SelectMenuContext.jsx +5 -0
- package/lib/SelectMenu/SelectMenuDivider.jsx +42 -0
- package/lib/SelectMenu/SelectMenuFilter.jsx +58 -0
- package/lib/SelectMenu/SelectMenuFooter.jsx +45 -0
- package/lib/SelectMenu/SelectMenuHeader.jsx +42 -0
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuItem.jsx +142 -0
- package/lib/SelectMenu/SelectMenuList.jsx +59 -0
- package/lib/SelectMenu/SelectMenuLoadingAnimation.jsx +22 -0
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.jsx +118 -0
- package/lib/SelectMenu/SelectMenuTab.jsx +92 -0
- package/lib/SelectMenu/SelectMenuTabPanel.jsx +42 -0
- package/lib/SelectMenu/SelectMenuTabs.jsx +57 -0
- package/lib/SelectMenu/hooks/useKeyboardNav.js +80 -96
- package/lib/SelectMenu/index.js +7 -14
- package/lib/SelectPanel/SelectPanel.jsx +105 -0
- package/lib/SelectPanel/index.js +4 -12
- package/lib/SideNav.jsx +173 -0
- package/lib/Spinner.jsx +35 -0
- package/lib/StateLabel.jsx +93 -0
- package/lib/StyledOcticon.jsx +18 -0
- package/lib/SubNav.jsx +101 -0
- package/lib/TabNav.jsx +58 -0
- package/lib/Text.jsx +14 -0
- package/lib/TextInput.jsx +23 -0
- package/lib/TextInputWithTokens.d.ts +0 -1
- package/lib/TextInputWithTokens.jsx +218 -0
- package/lib/ThemeProvider.jsx +130 -0
- package/lib/Timeline.jsx +123 -0
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/AvatarToken.jsx +54 -0
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.jsx +125 -0
- package/lib/Token/Token.d.ts +1 -1
- package/lib/Token/Token.jsx +103 -0
- package/lib/Token/TokenBase.jsx +88 -0
- package/lib/Token/_RemoveTokenButton.jsx +108 -0
- package/lib/Token/_TokenTextContainer.jsx +49 -0
- package/lib/Token/index.js +11 -30
- package/lib/Tooltip.jsx +246 -0
- package/lib/Truncate.jsx +24 -0
- package/lib/UnderlineNav.jsx +88 -0
- package/lib/_TextInputWrapper.jsx +120 -0
- package/lib/_UnstyledTextInput.jsx +22 -0
- package/lib/behaviors/anchoredPosition.js +205 -234
- package/lib/behaviors/focusTrap.js +121 -157
- package/lib/behaviors/focusZone.js +434 -509
- package/lib/behaviors/scrollIntoViewingArea.js +18 -35
- package/lib/constants.js +39 -43
- package/lib/drafts.js +20 -30
- package/lib/hooks/index.js +16 -60
- package/lib/hooks/useAnchoredPosition.js +32 -40
- package/lib/hooks/useCombinedRefs.js +32 -36
- package/lib/hooks/useDetails.jsx +39 -0
- package/lib/hooks/useDialog.js +72 -96
- package/lib/hooks/useFocusTrap.js +43 -60
- package/lib/hooks/useFocusZone.js +54 -50
- package/lib/hooks/useOnEscapePress.js +25 -36
- package/lib/hooks/useOnOutsideClick.jsx +61 -0
- package/lib/hooks/useOpenAndCloseFocus.js +22 -34
- package/lib/hooks/useOverlay.jsx +15 -0
- package/lib/hooks/useProvidedRefOrCreate.js +10 -14
- package/lib/hooks/useProvidedStateOrCreate.js +13 -16
- package/lib/hooks/useRenderForcingRef.js +13 -17
- package/lib/hooks/useResizeObserver.js +15 -18
- package/lib/hooks/useSafeTimeout.js +22 -30
- package/lib/hooks/useScrollFlash.js +16 -23
- package/lib/index.d.ts +0 -5
- package/lib/index.js +163 -676
- package/lib/polyfills/eventListenerSignal.js +37 -45
- package/lib/sx.js +10 -22
- package/lib/theme-preval.js +64 -3169
- package/lib/theme.js +3 -12
- package/lib/utils/create-slots.jsx +65 -0
- package/lib/utils/deprecate.jsx +59 -0
- package/lib/utils/isNumeric.jsx +7 -0
- package/lib/utils/iterateFocusableElements.js +63 -85
- package/lib/utils/ssr.jsx +6 -0
- package/lib/utils/test-deprecations.jsx +20 -0
- package/lib/utils/test-helpers.jsx +8 -0
- package/lib/utils/test-matchers.jsx +100 -0
- package/lib/utils/testing.d.ts +1 -2
- package/lib/utils/testing.js +0 -29
- package/lib/utils/testing.jsx +206 -0
- package/lib/utils/theme.js +33 -47
- package/lib/utils/types/AriaRole.js +2 -1
- package/lib/utils/types/ComponentProps.js +2 -1
- package/lib/utils/types/Flatten.js +2 -1
- package/lib/utils/types/KeyPaths.js +2 -1
- package/lib/utils/types/MandateProps.js +16 -1
- package/lib/utils/types/Merge.js +2 -1
- package/lib/utils/types/index.js +16 -69
- package/lib/utils/uniqueId.js +5 -8
- package/lib/utils/use-force-update.js +8 -14
- package/lib/utils/useIsomorphicLayoutEffect.js +8 -11
- package/lib/utils/userAgent.js +8 -12
- package/lib-esm/ActionList/Item.js +3 -3
- package/lib-esm/ActionList2/Header.d.ts +26 -0
- package/lib-esm/ActionList2/Header.js +44 -0
- package/lib-esm/ActionList2/Item.js +1 -3
- package/lib-esm/ActionList2/List.js +2 -1
- package/lib-esm/ActionList2/Selection.js +1 -3
- package/lib-esm/Autocomplete/Autocomplete.d.ts +0 -1
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +0 -1
- package/lib-esm/Autocomplete/AutocompleteMenu.js +13 -3
- package/lib-esm/Button/Button.d.ts +0 -1
- package/lib-esm/Button/ButtonClose.d.ts +1 -2
- package/lib-esm/Button/ButtonDanger.d.ts +0 -1
- package/lib-esm/Button/ButtonInvisible.d.ts +0 -1
- package/lib-esm/Button/ButtonOutline.d.ts +0 -1
- package/lib-esm/Button/ButtonPrimary.d.ts +0 -1
- package/lib-esm/CircleOcticon.d.ts +0 -1
- package/lib-esm/Dialog.d.ts +2 -3
- package/lib-esm/Dropdown.d.ts +0 -4
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +1 -2
- package/lib-esm/FilterList.d.ts +0 -1
- package/lib-esm/Overlay.d.ts +3 -5
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/SelectMenu/SelectMenu.d.ts +4 -10
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +0 -1
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/index.d.ts +0 -5
- package/lib-esm/index.js +0 -4
- package/lib-esm/theme-preval.js +0 -446
- package/lib-esm/utils/testing.d.ts +1 -2
- package/lib-esm/utils/testing.js +0 -24
- package/package.json +6 -5
- package/lib/Checkbox.d.ts +0 -29
- package/lib/Checkbox.js +0 -64
- package/lib/CheckboxInputField.d.ts +0 -11
- package/lib/CheckboxInputField.js +0 -74
- package/lib/RadioInputField.d.ts +0 -9
- package/lib/RadioInputField.js +0 -83
- package/lib/TextInputField.d.ts +0 -581
- package/lib/TextInputField.js +0 -66
- package/lib/_InputCaption.d.ts +0 -6
- package/lib/_InputCaption.js +0 -23
- 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 -28
- 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/utils/types/FormValidationStatus.d.ts +0 -1
- package/lib/utils/types/FormValidationStatus.js +0 -1
- package/lib-esm/Checkbox.d.ts +0 -29
- package/lib-esm/Checkbox.js +0 -44
- package/lib-esm/CheckboxInputField.d.ts +0 -11
- package/lib-esm/CheckboxInputField.js +0 -57
- package/lib-esm/RadioInputField.d.ts +0 -9
- package/lib-esm/RadioInputField.js +0 -66
- package/lib-esm/TextInputField.d.ts +0 -581
- package/lib-esm/TextInputField.js +0 -50
- package/lib-esm/_InputCaption.d.ts +0 -6
- package/lib-esm/_InputCaption.js +0 -12
- 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 -16
- 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/utils/types/FormValidationStatus.d.ts +0 -1
- package/lib-esm/utils/types/FormValidationStatus.js +0 -1
@@ -1,101 +1,85 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _react = require("react");
|
9
|
-
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const react_1 = require("react");
|
10
4
|
// adapted from details-menu web component https://github.com/github/details-menu-element
|
11
5
|
function useKeyboardNav(details, open, setOpen) {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
6
|
+
const handleKeyDown = react_1.useCallback(event => {
|
7
|
+
const closeDetails = () => {
|
8
|
+
setOpen(false);
|
9
|
+
const summary = details.current.querySelector('summary');
|
10
|
+
if (summary)
|
11
|
+
summary.focus();
|
12
|
+
};
|
13
|
+
const openDetails = () => {
|
14
|
+
setOpen(true);
|
15
|
+
};
|
16
|
+
const focusItem = next => {
|
17
|
+
const options = Array.from(details.current.querySelectorAll('[role^="menuitem"]:not([hidden]):not([disabled]):not([aria-disabled="true"])'));
|
18
|
+
const selected = document.activeElement;
|
19
|
+
const index = options.indexOf(selected);
|
20
|
+
const found = next ? options[index + 1] : options[index - 1];
|
21
|
+
const def = next ? options[0] : options[options.length - 1];
|
22
|
+
return found || def;
|
23
|
+
};
|
24
|
+
const isMenuItem = el => {
|
25
|
+
const role = el.getAttribute('role');
|
26
|
+
return role === 'menuitem' || role === 'menuitemcheckbox' || role === 'menuitemradio';
|
27
|
+
};
|
28
|
+
if (!(event instanceof KeyboardEvent))
|
29
|
+
return;
|
30
|
+
const isSummaryFocused = event.target instanceof Element && event.target.tagName === 'SUMMARY';
|
31
|
+
switch (event.key) {
|
32
|
+
case 'Escape':
|
33
|
+
if (open) {
|
34
|
+
closeDetails(details);
|
35
|
+
event.preventDefault();
|
36
|
+
event.stopPropagation();
|
37
|
+
}
|
38
|
+
break;
|
39
|
+
case 'ArrowDown':
|
40
|
+
{
|
41
|
+
if (isSummaryFocused && !open) {
|
42
|
+
openDetails(details);
|
43
|
+
}
|
44
|
+
const target = focusItem(true);
|
45
|
+
if (target)
|
46
|
+
target.focus();
|
47
|
+
event.preventDefault();
|
48
|
+
}
|
49
|
+
break;
|
50
|
+
case 'ArrowUp':
|
51
|
+
{
|
52
|
+
if (isSummaryFocused && !open) {
|
53
|
+
openDetails();
|
54
|
+
}
|
55
|
+
const target = focusItem(false);
|
56
|
+
if (target)
|
57
|
+
target.focus();
|
58
|
+
event.preventDefault();
|
59
|
+
}
|
60
|
+
break;
|
61
|
+
case ' ':
|
62
|
+
case 'Enter':
|
63
|
+
{
|
64
|
+
const selected = document.activeElement;
|
65
|
+
if (selected && isMenuItem(selected) && selected.closest('details') === details) {
|
66
|
+
event.preventDefault();
|
67
|
+
event.stopPropagation();
|
68
|
+
selected.click();
|
69
|
+
}
|
70
|
+
}
|
71
|
+
break;
|
72
|
+
default:
|
46
73
|
}
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if (target) target.focus();
|
58
|
-
event.preventDefault();
|
59
|
-
}
|
60
|
-
break;
|
61
|
-
|
62
|
-
case 'ArrowUp':
|
63
|
-
{
|
64
|
-
if (isSummaryFocused && !open) {
|
65
|
-
openDetails();
|
66
|
-
}
|
67
|
-
|
68
|
-
const target = focusItem(false);
|
69
|
-
if (target) target.focus();
|
70
|
-
event.preventDefault();
|
71
|
-
}
|
72
|
-
break;
|
73
|
-
|
74
|
-
case ' ':
|
75
|
-
case 'Enter':
|
76
|
-
{
|
77
|
-
const selected = document.activeElement;
|
78
|
-
|
79
|
-
if (selected && isMenuItem(selected) && selected.closest('details') === details) {
|
80
|
-
event.preventDefault();
|
81
|
-
event.stopPropagation();
|
82
|
-
selected.click();
|
83
|
-
}
|
84
|
-
}
|
85
|
-
break;
|
86
|
-
|
87
|
-
default:
|
88
|
-
}
|
89
|
-
}, [details, open, setOpen]);
|
90
|
-
(0, _react.useEffect)(() => {
|
91
|
-
const current = details.current;
|
92
|
-
if (!current) return;
|
93
|
-
current.addEventListener('keydown', handleKeyDown);
|
94
|
-
return () => {
|
95
|
-
current.removeEventListener('keydown', handleKeyDown);
|
96
|
-
};
|
97
|
-
}, [details, handleKeyDown]);
|
74
|
+
}, [details, open, setOpen]);
|
75
|
+
react_1.useEffect(() => {
|
76
|
+
const current = details.current;
|
77
|
+
if (!current)
|
78
|
+
return;
|
79
|
+
current.addEventListener('keydown', handleKeyDown);
|
80
|
+
return () => {
|
81
|
+
current.removeEventListener('keydown', handleKeyDown);
|
82
|
+
};
|
83
|
+
}, [details, handleKeyDown]);
|
98
84
|
}
|
99
|
-
|
100
|
-
var _default = useKeyboardNav;
|
101
|
-
exports.default = _default;
|
85
|
+
exports.default = useKeyboardNav;
|
package/lib/SelectMenu/index.js
CHANGED
@@ -1,15 +1,8 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
});
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
return _SelectMenu.default;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
|
13
|
-
var _SelectMenu = _interopRequireDefault(require("./SelectMenu"));
|
14
|
-
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.default = void 0;
|
7
|
+
var SelectMenu_1 = require("./SelectMenu");
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(SelectMenu_1).default; } });
|
@@ -0,0 +1,105 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
+
}) : function(o, v) {
|
12
|
+
o["default"] = v;
|
13
|
+
});
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
+
if (mod && mod.__esModule) return mod;
|
16
|
+
var result = {};
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
+
__setModuleDefault(result, mod);
|
19
|
+
return result;
|
20
|
+
};
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
22
|
+
exports.SelectPanel = void 0;
|
23
|
+
const react_1 = __importStar(require("react"));
|
24
|
+
const FilteredActionList_1 = require("../FilteredActionList");
|
25
|
+
const DropdownMenu_1 = require("../DropdownMenu");
|
26
|
+
const AnchoredOverlay_1 = require("../AnchoredOverlay");
|
27
|
+
const useProvidedStateOrCreate_1 = require("../hooks/useProvidedStateOrCreate");
|
28
|
+
const hooks_1 = require("../hooks");
|
29
|
+
function isMultiSelectVariant(selected) {
|
30
|
+
return Array.isArray(selected);
|
31
|
+
}
|
32
|
+
const focusZoneSettings = {
|
33
|
+
// Let FilteredActionList handle focus zone
|
34
|
+
disabled: true
|
35
|
+
};
|
36
|
+
function SelectPanel({ open, onOpenChange, renderAnchor = props => <DropdownMenu_1.DropdownButton {...props}/>, anchorRef: externalAnchorRef, placeholder, selected, onSelectedChange, filterValue: externalFilterValue, onFilterChange: externalOnFilterChange, items, textInputProps, overlayProps, sx, ...listProps }) {
|
37
|
+
const [filterValue, setInternalFilterValue] = useProvidedStateOrCreate_1.useProvidedStateOrCreate(externalFilterValue, undefined, '');
|
38
|
+
const onFilterChange = react_1.useCallback((value, e) => {
|
39
|
+
externalOnFilterChange(value, e);
|
40
|
+
setInternalFilterValue(value);
|
41
|
+
}, [externalOnFilterChange, setInternalFilterValue]);
|
42
|
+
const anchorRef = hooks_1.useProvidedRefOrCreate(externalAnchorRef);
|
43
|
+
const onOpen = react_1.useCallback(gesture => onOpenChange(true, gesture), [onOpenChange]);
|
44
|
+
const onClose = react_1.useCallback((gesture) => {
|
45
|
+
onOpenChange(false, gesture);
|
46
|
+
}, [onOpenChange]);
|
47
|
+
const renderMenuAnchor = react_1.useMemo(() => {
|
48
|
+
if (renderAnchor === null) {
|
49
|
+
return null;
|
50
|
+
}
|
51
|
+
const selectedItems = Array.isArray(selected) ? selected : [...(selected ? [selected] : [])];
|
52
|
+
return (props) => {
|
53
|
+
return renderAnchor({
|
54
|
+
...props,
|
55
|
+
children: selectedItems.length ? selectedItems.map(item => item.text).join(', ') : placeholder
|
56
|
+
});
|
57
|
+
};
|
58
|
+
}, [placeholder, renderAnchor, selected]);
|
59
|
+
const itemsToRender = react_1.useMemo(() => {
|
60
|
+
return items.map(item => {
|
61
|
+
const isItemSelected = isMultiSelectVariant(selected) ? selected.includes(item) : selected === item;
|
62
|
+
return {
|
63
|
+
...item,
|
64
|
+
role: 'option',
|
65
|
+
selected: 'selected' in item && item.selected === undefined ? undefined : isItemSelected,
|
66
|
+
onAction: (itemFromAction, event) => {
|
67
|
+
item.onAction?.(itemFromAction, event);
|
68
|
+
if (event.defaultPrevented) {
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
if (isMultiSelectVariant(selected)) {
|
72
|
+
const otherSelectedItems = selected.filter(selectedItem => selectedItem !== item);
|
73
|
+
const newSelectedItems = selected.includes(item) ? otherSelectedItems : [...otherSelectedItems, item];
|
74
|
+
const multiSelectOnChange = onSelectedChange;
|
75
|
+
multiSelectOnChange(newSelectedItems);
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
// single select
|
79
|
+
const singleSelectOnChange = onSelectedChange;
|
80
|
+
singleSelectOnChange(item === selected ? undefined : item);
|
81
|
+
onClose('selection');
|
82
|
+
}
|
83
|
+
};
|
84
|
+
});
|
85
|
+
}, [onClose, onSelectedChange, items, selected]);
|
86
|
+
const inputRef = react_1.default.useRef(null);
|
87
|
+
const focusTrapSettings = {
|
88
|
+
initialFocusRef: inputRef
|
89
|
+
};
|
90
|
+
const extendedTextInputProps = react_1.useMemo(() => {
|
91
|
+
return {
|
92
|
+
sx: { m: 2 },
|
93
|
+
contrast: true,
|
94
|
+
...textInputProps
|
95
|
+
};
|
96
|
+
}, [textInputProps]);
|
97
|
+
return (<AnchoredOverlay_1.AnchoredOverlay renderAnchor={renderMenuAnchor} anchorRef={anchorRef} open={open} onOpen={onOpen} onClose={onClose} overlayProps={overlayProps} focusTrapSettings={focusTrapSettings} focusZoneSettings={focusZoneSettings}>
|
98
|
+
<FilteredActionList_1.FilteredActionList filterValue={filterValue} onFilterChange={onFilterChange} {...listProps} role="listbox" items={itemsToRender} selectionVariant={isMultiSelectVariant(selected) ? 'multiple' : 'single'} textInputProps={extendedTextInputProps} inputRef={inputRef}
|
99
|
+
// inheriting height and maxHeight ensures that the FilteredActionList is never taller
|
100
|
+
// than the Overlay (which would break scrolling the items)
|
101
|
+
sx={{ ...sx, height: 'inherit', maxHeight: 'inherit' }}/>
|
102
|
+
</AnchoredOverlay_1.AnchoredOverlay>);
|
103
|
+
}
|
104
|
+
exports.SelectPanel = SelectPanel;
|
105
|
+
SelectPanel.displayName = 'SelectPanel';
|
package/lib/SelectPanel/index.js
CHANGED
@@ -1,13 +1,5 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
});
|
6
|
-
Object.defineProperty(exports, "SelectPanel", {
|
7
|
-
enumerable: true,
|
8
|
-
get: function () {
|
9
|
-
return _SelectPanel.SelectPanel;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
|
13
|
-
var _SelectPanel = require("./SelectPanel");
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SelectPanel = void 0;
|
4
|
+
var SelectPanel_1 = require("./SelectPanel");
|
5
|
+
Object.defineProperty(exports, "SelectPanel", { enumerable: true, get: function () { return SelectPanel_1.SelectPanel; } });
|
package/lib/SideNav.jsx
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
+
}) : function(o, v) {
|
12
|
+
o["default"] = v;
|
13
|
+
});
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
+
if (mod && mod.__esModule) return mod;
|
16
|
+
var result = {};
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
+
__setModuleDefault(result, mod);
|
19
|
+
return result;
|
20
|
+
};
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
23
|
+
};
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
25
|
+
const constants_1 = require("./constants");
|
26
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
27
|
+
const Box_1 = __importDefault(require("./Box"));
|
28
|
+
const Link_1 = __importDefault(require("./Link"));
|
29
|
+
const react_1 = __importDefault(require("react"));
|
30
|
+
const classnames_1 = __importDefault(require("classnames"));
|
31
|
+
const sx_1 = __importDefault(require("./sx"));
|
32
|
+
function SideNavBase({ variant, className, bordered, children, 'aria-label': ariaLabel }) {
|
33
|
+
const variantClassName = variant === 'lightweight' ? 'lightweight' : 'normal';
|
34
|
+
const newClassName = classnames_1.default(className, `variant-${variantClassName}`);
|
35
|
+
return (<Box_1.default borderWidth={bordered ? '1px' : 0} borderStyle="solid" borderColor="border.default" borderRadius={2} as="nav" className={newClassName} aria-label={ariaLabel}>
|
36
|
+
{children}
|
37
|
+
</Box_1.default>);
|
38
|
+
}
|
39
|
+
const SideNav = styled_components_1.default(SideNavBase) `
|
40
|
+
background-color: ${constants_1.get('colors.canvas.subtle')};
|
41
|
+
|
42
|
+
${props => props.bordered &&
|
43
|
+
styled_components_1.css `
|
44
|
+
// Remove duplicate borders from nested SideNavs
|
45
|
+
& > & {
|
46
|
+
border-left: 0;
|
47
|
+
border-right: 0;
|
48
|
+
border-bottom: 0;
|
49
|
+
}
|
50
|
+
`}
|
51
|
+
|
52
|
+
${sx_1.default};
|
53
|
+
`;
|
54
|
+
// used for variant normal hover, focus pseudo selectors
|
55
|
+
const CommonAccessibilityVariantNormalStyles = styled_components_1.css `
|
56
|
+
background-color: ${constants_1.get('colors.neutral.subtle')};
|
57
|
+
outline: none;
|
58
|
+
text-decoration: none;
|
59
|
+
`;
|
60
|
+
// used for light weight hover, focus pseudo selectors
|
61
|
+
const CommonAccessibilityVariantLightWeightStyles = styled_components_1.css `
|
62
|
+
color: ${constants_1.get('colors.fg.default')};
|
63
|
+
text-decoration: none;
|
64
|
+
outline: none;
|
65
|
+
`;
|
66
|
+
const SideNavLink = styled_components_1.default(Link_1.default).attrs(props => {
|
67
|
+
const isReactRouter = typeof props.to === 'string';
|
68
|
+
if (isReactRouter || props.selected) {
|
69
|
+
// according to their docs, NavLink supports aria-current:
|
70
|
+
// https://reacttraining.com/react-router/web/api/NavLink/aria-current-string
|
71
|
+
return { 'aria-current': 'page' };
|
72
|
+
}
|
73
|
+
else {
|
74
|
+
return {};
|
75
|
+
}
|
76
|
+
}) `
|
77
|
+
position: relative;
|
78
|
+
display: block;
|
79
|
+
${props => props.variant === 'full' &&
|
80
|
+
styled_components_1.css `
|
81
|
+
display: flex;
|
82
|
+
align-items: center;
|
83
|
+
justify-content: space-between;
|
84
|
+
`}
|
85
|
+
width: 100%;
|
86
|
+
text-align: left;
|
87
|
+
font-size: ${constants_1.get('fontSizes.1')};
|
88
|
+
|
89
|
+
& > ${SideNav} {
|
90
|
+
border-bottom: none;
|
91
|
+
}
|
92
|
+
|
93
|
+
${SideNav}.variant-normal > & {
|
94
|
+
color: ${constants_1.get('colors.fg.default')};
|
95
|
+
padding: ${constants_1.get('space.3')};
|
96
|
+
border: 0;
|
97
|
+
border-top: ${constants_1.get('borderWidths.1')} solid ${constants_1.get('colors.border.muted')};
|
98
|
+
|
99
|
+
&:first-child {
|
100
|
+
border-top: 0;
|
101
|
+
border-top-right-radius: ${constants_1.get('radii.2')};
|
102
|
+
border-top-left-radius: ${constants_1.get('radii.2')};
|
103
|
+
}
|
104
|
+
|
105
|
+
&:last-child {
|
106
|
+
border-bottom-right-radius: ${constants_1.get('radii.2')};
|
107
|
+
border-bottom-left-radius: ${constants_1.get('radii.2')};
|
108
|
+
}
|
109
|
+
|
110
|
+
// Bar on the left
|
111
|
+
&::before {
|
112
|
+
position: absolute;
|
113
|
+
top: 0;
|
114
|
+
bottom: 0;
|
115
|
+
left: 0;
|
116
|
+
z-index: 1;
|
117
|
+
width: 3px;
|
118
|
+
pointer-events: none;
|
119
|
+
content: '';
|
120
|
+
}
|
121
|
+
|
122
|
+
&:hover {
|
123
|
+
${CommonAccessibilityVariantNormalStyles}
|
124
|
+
}
|
125
|
+
|
126
|
+
&:focus {
|
127
|
+
${CommonAccessibilityVariantNormalStyles}
|
128
|
+
box-shadow: ${constants_1.get('shadows.primer.shadow.focus')};
|
129
|
+
z-index: 1;
|
130
|
+
}
|
131
|
+
|
132
|
+
&[aria-current='page'],
|
133
|
+
&[aria-selected='true'] {
|
134
|
+
background-color: ${constants_1.get('colors.sidenav.selectedBg')};
|
135
|
+
|
136
|
+
// Bar on the left
|
137
|
+
&::before {
|
138
|
+
background-color: ${constants_1.get('colors.primer.border.active')};
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
${SideNav}.variant-lightweight > & {
|
144
|
+
padding: ${constants_1.get('space.1')} 0;
|
145
|
+
color: ${constants_1.get('colors.accent.fg')};
|
146
|
+
|
147
|
+
&:hover {
|
148
|
+
${CommonAccessibilityVariantLightWeightStyles}
|
149
|
+
}
|
150
|
+
|
151
|
+
&:focus {
|
152
|
+
${CommonAccessibilityVariantLightWeightStyles}
|
153
|
+
box-shadow: ${constants_1.get('shadows.primer.shadow.focus')};
|
154
|
+
z-index: 1;
|
155
|
+
}
|
156
|
+
|
157
|
+
&[aria-current='page'],
|
158
|
+
&[aria-selected='true'] {
|
159
|
+
color: ${constants_1.get('colors.fg.default')};
|
160
|
+
font-weight: ${constants_1.get('fontWeights.semibold')};
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
${sx_1.default};
|
165
|
+
`;
|
166
|
+
SideNav.defaultProps = {
|
167
|
+
variant: 'normal'
|
168
|
+
};
|
169
|
+
SideNavLink.defaultProps = {
|
170
|
+
variant: 'normal'
|
171
|
+
};
|
172
|
+
SideNavLink.displayName = 'SideNav.Link';
|
173
|
+
exports.default = Object.assign(SideNav, { Link: SideNavLink });
|
package/lib/Spinner.jsx
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const react_1 = __importDefault(require("react"));
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
8
|
+
const constants_1 = require("./constants");
|
9
|
+
const sx_1 = __importDefault(require("./sx"));
|
10
|
+
const sizeMap = {
|
11
|
+
small: '16px',
|
12
|
+
medium: '32px',
|
13
|
+
large: '64px'
|
14
|
+
};
|
15
|
+
function Spinner({ size: sizeKey = 'medium', ...props }) {
|
16
|
+
const size = sizeMap[sizeKey];
|
17
|
+
return (<svg height={size} width={size} viewBox="0 0 16 16" fill="none" {...props}>
|
18
|
+
<circle cx="8" cy="8" r="7" stroke="currentColor" strokeOpacity="0.25" strokeWidth="2" vectorEffect="non-scaling-stroke"/>
|
19
|
+
<path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" strokeWidth="2" strokeLinecap="round" vectorEffect="non-scaling-stroke"/>
|
20
|
+
</svg>);
|
21
|
+
}
|
22
|
+
const StyledSpinner = styled_components_1.default(Spinner) `
|
23
|
+
@keyframes rotate-keyframes {
|
24
|
+
100% {
|
25
|
+
transform: rotate(360deg);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
animation: rotate-keyframes 1s linear infinite;
|
30
|
+
|
31
|
+
${constants_1.COMMON}
|
32
|
+
${sx_1.default}
|
33
|
+
`;
|
34
|
+
StyledSpinner.displayName = 'Spinner';
|
35
|
+
exports.default = StyledSpinner;
|
@@ -0,0 +1,93 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const octicons_react_1 = require("@primer/octicons-react");
|
7
|
+
const react_1 = __importDefault(require("react"));
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
9
|
+
const styled_system_1 = require("styled-system");
|
10
|
+
const constants_1 = require("./constants");
|
11
|
+
const StyledOcticon_1 = __importDefault(require("./StyledOcticon"));
|
12
|
+
const sx_1 = __importDefault(require("./sx"));
|
13
|
+
const octiconMap = {
|
14
|
+
issueOpened: octicons_react_1.IssueOpenedIcon,
|
15
|
+
pullOpened: octicons_react_1.GitPullRequestIcon,
|
16
|
+
issueClosed: octicons_react_1.IssueClosedIcon,
|
17
|
+
pullClosed: octicons_react_1.GitPullRequestIcon,
|
18
|
+
pullMerged: octicons_react_1.GitMergeIcon,
|
19
|
+
draft: octicons_react_1.GitPullRequestIcon,
|
20
|
+
issueDraft: octicons_react_1.IssueDraftIcon
|
21
|
+
};
|
22
|
+
const colorVariants = styled_system_1.variant({
|
23
|
+
prop: 'status',
|
24
|
+
variants: {
|
25
|
+
issueClosed: {
|
26
|
+
backgroundColor: 'danger.emphasis',
|
27
|
+
color: 'fg.onEmphasis'
|
28
|
+
},
|
29
|
+
pullClosed: {
|
30
|
+
backgroundColor: 'danger.emphasis',
|
31
|
+
color: 'fg.onEmphasis'
|
32
|
+
},
|
33
|
+
pullMerged: {
|
34
|
+
backgroundColor: 'done.emphasis',
|
35
|
+
color: 'fg.onEmphasis'
|
36
|
+
},
|
37
|
+
issueOpened: {
|
38
|
+
backgroundColor: 'success.emphasis',
|
39
|
+
color: 'fg.onEmphasis'
|
40
|
+
},
|
41
|
+
pullOpened: {
|
42
|
+
backgroundColor: 'success.emphasis',
|
43
|
+
color: 'fg.onEmphasis'
|
44
|
+
},
|
45
|
+
draft: {
|
46
|
+
backgroundColor: 'neutral.emphasis',
|
47
|
+
color: 'fg.onEmphasis'
|
48
|
+
},
|
49
|
+
issueDraft: {
|
50
|
+
backgroundColor: 'neutral.emphasis',
|
51
|
+
color: 'fg.onEmphasis'
|
52
|
+
}
|
53
|
+
}
|
54
|
+
});
|
55
|
+
const sizeVariants = styled_system_1.variant({
|
56
|
+
prop: 'variant',
|
57
|
+
variants: {
|
58
|
+
small: {
|
59
|
+
paddingX: 2,
|
60
|
+
paddingY: 1,
|
61
|
+
fontSize: 0
|
62
|
+
},
|
63
|
+
normal: {
|
64
|
+
paddingX: '12px',
|
65
|
+
paddingY: 2,
|
66
|
+
fontSize: 1
|
67
|
+
}
|
68
|
+
}
|
69
|
+
});
|
70
|
+
const StateLabelBase = styled_components_1.default.span `
|
71
|
+
display: inline-flex;
|
72
|
+
align-items: center;
|
73
|
+
font-weight: ${constants_1.get('fontWeights.bold')};
|
74
|
+
line-height: 16px;
|
75
|
+
color: ${constants_1.get('colors.canvas.default')};
|
76
|
+
text-align: center;
|
77
|
+
border-radius: ${constants_1.get('radii.3')};
|
78
|
+
${colorVariants};
|
79
|
+
${sizeVariants};
|
80
|
+
${sx_1.default};
|
81
|
+
`;
|
82
|
+
function StateLabel({ children, status, variant: variantProp, ...rest }) {
|
83
|
+
const octiconProps = variantProp === 'small' ? { width: '1em' } : {};
|
84
|
+
return (<StateLabelBase {...rest} variant={variantProp} status={status}>
|
85
|
+
{/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition */}
|
86
|
+
{status && <StyledOcticon_1.default {...octiconProps} icon={octiconMap[status] || octicons_react_1.QuestionIcon} sx={{ mr: 1 }}/>}
|
87
|
+
{children}
|
88
|
+
</StateLabelBase>);
|
89
|
+
}
|
90
|
+
StateLabel.defaultProps = {
|
91
|
+
variant: 'normal'
|
92
|
+
};
|
93
|
+
exports.default = StateLabel;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const react_1 = __importDefault(require("react"));
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
8
|
+
const sx_1 = __importDefault(require("./sx"));
|
9
|
+
function Octicon({ icon: IconComponent, ...rest }) {
|
10
|
+
return <IconComponent {...rest}/>;
|
11
|
+
}
|
12
|
+
const StyledOcticon = styled_components_1.default(Octicon) `
|
13
|
+
${sx_1.default}
|
14
|
+
`;
|
15
|
+
StyledOcticon.defaultProps = {
|
16
|
+
size: 16
|
17
|
+
};
|
18
|
+
exports.default = StyledOcticon;
|