@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
package/lib/Dropdown.jsx
ADDED
@@ -0,0 +1,131 @@
|
|
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 Button_1 = __importDefault(require("./Button"));
|
9
|
+
const constants_1 = require("./constants");
|
10
|
+
const Details_1 = __importDefault(require("./Details"));
|
11
|
+
const DropdownStyles_1 = __importDefault(require("./DropdownStyles"));
|
12
|
+
const useDetails_1 = __importDefault(require("./hooks/useDetails"));
|
13
|
+
const sx_1 = __importDefault(require("./sx"));
|
14
|
+
const StyledDetails = styled_components_1.default(Details_1.default) `
|
15
|
+
position: relative;
|
16
|
+
display: inline-block;
|
17
|
+
`;
|
18
|
+
const Dropdown = ({ children, className, ...rest }) => {
|
19
|
+
const { getDetailsProps } = useDetails_1.default({ closeOnOutsideClick: true });
|
20
|
+
return (<StyledDetails className={className} {...getDetailsProps()} {...rest}>
|
21
|
+
{children}
|
22
|
+
</StyledDetails>);
|
23
|
+
};
|
24
|
+
const DropdownButton = ({ children, ...rest }) => {
|
25
|
+
return (<Button_1.default as="summary" aria-haspopup="true" {...rest}>
|
26
|
+
{children}
|
27
|
+
<DropdownCaret />
|
28
|
+
</Button_1.default>);
|
29
|
+
};
|
30
|
+
const DropdownCaret = styled_components_1.default.div `
|
31
|
+
border: 4px solid transparent;
|
32
|
+
margin-left: 12px;
|
33
|
+
border-top-color: currentcolor;
|
34
|
+
border-bottom-width: 0;
|
35
|
+
content: '';
|
36
|
+
display: inline-block;
|
37
|
+
height: 0;
|
38
|
+
vertical-align: middle;
|
39
|
+
width: 0;
|
40
|
+
${sx_1.default};
|
41
|
+
`;
|
42
|
+
const DropdownMenu = styled_components_1.default.ul `
|
43
|
+
background-clip: padding-box;
|
44
|
+
background-color: ${constants_1.get('colors.canvas.overlay')};
|
45
|
+
border: 1px solid ${constants_1.get('colors.border.default')};
|
46
|
+
border-radius: ${constants_1.get('radii.2')};
|
47
|
+
box-shadow: ${constants_1.get('shadows.shadow.large')};
|
48
|
+
left: 0;
|
49
|
+
list-style: none;
|
50
|
+
margin-top: 2px;
|
51
|
+
padding: 5px 0 5px 0 !important; //TODO: fix this override on our markdown styles
|
52
|
+
position: absolute;
|
53
|
+
top: 100%;
|
54
|
+
width: 160px;
|
55
|
+
z-index: 100;
|
56
|
+
|
57
|
+
&::before {
|
58
|
+
position: absolute;
|
59
|
+
display: inline-block;
|
60
|
+
content: '';
|
61
|
+
}
|
62
|
+
|
63
|
+
&::after {
|
64
|
+
position: absolute;
|
65
|
+
display: inline-block;
|
66
|
+
content: '';
|
67
|
+
}
|
68
|
+
|
69
|
+
&::before {
|
70
|
+
border: 8px solid transparent;
|
71
|
+
border-bottom-color: ${constants_1.get('colors.canvas.overlay')};
|
72
|
+
}
|
73
|
+
|
74
|
+
&::after {
|
75
|
+
border: 7px solid transparent;
|
76
|
+
border-bottom-color: ${constants_1.get('colors.canvas.overlay')};
|
77
|
+
}
|
78
|
+
|
79
|
+
// stylelint-disable-next-line selector-max-type
|
80
|
+
> ul {
|
81
|
+
list-style: none;
|
82
|
+
}
|
83
|
+
${props => (props.direction ? DropdownStyles_1.default(props.theme, props.direction) : '')};
|
84
|
+
${sx_1.default};
|
85
|
+
`;
|
86
|
+
const DropdownItem = styled_components_1.default.li `
|
87
|
+
display: block;
|
88
|
+
padding: ${constants_1.get('space.1')} 10px ${constants_1.get('space.1')} 15px;
|
89
|
+
overflow: hidden;
|
90
|
+
color: ${constants_1.get('colors.fg.default')};
|
91
|
+
text-overflow: ellipsis;
|
92
|
+
white-space: nowrap;
|
93
|
+
a {
|
94
|
+
color: ${constants_1.get('colors.fg.default')};
|
95
|
+
text-decoration: none;
|
96
|
+
display: block;
|
97
|
+
overflow: hidden;
|
98
|
+
color: ${constants_1.get('colors.fg.default')};
|
99
|
+
text-overflow: ellipsis;
|
100
|
+
white-space: nowrap;
|
101
|
+
}
|
102
|
+
|
103
|
+
&:focus,
|
104
|
+
a:focus {
|
105
|
+
color: ${constants_1.get('colors.fg.onEmphasis')};
|
106
|
+
text-decoration: none;
|
107
|
+
background-color: ${constants_1.get('colors.accent.emphasis')};
|
108
|
+
}
|
109
|
+
|
110
|
+
&:hover,
|
111
|
+
&:hover a {
|
112
|
+
color: ${constants_1.get('colors.fg.onEmphasis')};
|
113
|
+
text-decoration: none;
|
114
|
+
background-color: ${constants_1.get('colors.accent.emphasis')};
|
115
|
+
outline: none;
|
116
|
+
}
|
117
|
+
${sx_1.default};
|
118
|
+
`;
|
119
|
+
DropdownMenu.defaultProps = { direction: 'sw' };
|
120
|
+
DropdownMenu.displayName = 'Dropdown.Menu';
|
121
|
+
DropdownItem.displayName = 'Dropdown.Item';
|
122
|
+
DropdownButton.defaultProps = Button_1.default.defaultProps;
|
123
|
+
DropdownButton.displayName = 'Dropdown.Button';
|
124
|
+
DropdownCaret.displayName = 'Dropdown.Caret';
|
125
|
+
Dropdown.defaultProps = Details_1.default.defaultProps;
|
126
|
+
exports.default = Object.assign(Dropdown, {
|
127
|
+
Caret: DropdownCaret,
|
128
|
+
Menu: DropdownMenu,
|
129
|
+
Item: DropdownItem,
|
130
|
+
Button: DropdownButton
|
131
|
+
});
|
@@ -266,7 +266,6 @@ export declare const DropdownButton: React.ForwardRefExoticComponent<Pick<React.
|
|
266
266
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
267
267
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
268
268
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
269
|
-
css?: import("@emotion/core").InterpolationWithTheme<any>;
|
270
269
|
as?: string | React.ComponentClass<any, any> | React.FunctionComponent<any> | undefined;
|
271
270
|
disabled?: boolean | undefined;
|
272
271
|
autoFocus?: boolean | undefined;
|
@@ -277,4 +276,4 @@ export declare const DropdownButton: React.ForwardRefExoticComponent<Pick<React.
|
|
277
276
|
formTarget?: string | undefined;
|
278
277
|
} & {
|
279
278
|
theme?: any;
|
280
|
-
}>, "color" | "translate" | "hidden" | "children" | "theme" | "value" | "form" | "slot" | "style" | "title" | "variant" | "role" | "sx" | "type" | "name" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "
|
279
|
+
}>, "color" | "translate" | "hidden" | "children" | "theme" | "value" | "form" | "slot" | "style" | "title" | "variant" | "role" | "sx" | "type" | "name" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "as" | "disabled" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget"> & React.RefAttributes<HTMLElement>>;
|
@@ -0,0 +1,14 @@
|
|
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
|
+
exports.DropdownButton = void 0;
|
7
|
+
const react_1 = __importDefault(require("react"));
|
8
|
+
const octicons_react_1 = require("@primer/octicons-react");
|
9
|
+
const Button_1 = __importDefault(require("../Button/Button"));
|
10
|
+
const StyledOcticon_1 = __importDefault(require("../StyledOcticon"));
|
11
|
+
exports.DropdownButton = react_1.default.forwardRef(({ children, ...props }, ref) => (<Button_1.default ref={ref} type="button" {...props}>
|
12
|
+
{children}
|
13
|
+
<StyledOcticon_1.default icon={octicons_react_1.TriangleDownIcon} sx={{ ml: 1 }}/>
|
14
|
+
</Button_1.default>));
|
@@ -0,0 +1,70 @@
|
|
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.DropdownMenu = void 0;
|
23
|
+
const react_1 = __importStar(require("react"));
|
24
|
+
const List_1 = require("../ActionList/List");
|
25
|
+
const DropdownButton_1 = require("./DropdownButton");
|
26
|
+
const AnchoredOverlay_1 = require("../AnchoredOverlay");
|
27
|
+
const useProvidedRefOrCreate_1 = require("../hooks/useProvidedRefOrCreate");
|
28
|
+
const useProvidedStateOrCreate_1 = require("../hooks/useProvidedStateOrCreate");
|
29
|
+
/**
|
30
|
+
* A `DropdownMenu` provides an anchor (button by default) that will open a floating menu of selectable items. The menu can be
|
31
|
+
* opened and navigated using keyboard or mouse. When an item is selected, the menu will close and the `onChange` callback will be called.
|
32
|
+
* If the default anchor button is used, the anchor contents will be updated with the selection.
|
33
|
+
*/
|
34
|
+
function DropdownMenu({ renderAnchor = (props) => <DropdownButton_1.DropdownButton {...props}/>, anchorRef: externalAnchorRef, placeholder, selectedItem, onChange, overlayProps, items, open, onOpenChange, ...listProps }) {
|
35
|
+
const [combinedOpenState, setCombinedOpenState] = useProvidedStateOrCreate_1.useProvidedStateOrCreate(open, onOpenChange, false);
|
36
|
+
const onOpen = react_1.useCallback(() => setCombinedOpenState(true), [setCombinedOpenState]);
|
37
|
+
const onClose = react_1.useCallback(() => setCombinedOpenState(false), [setCombinedOpenState]);
|
38
|
+
const anchorRef = useProvidedRefOrCreate_1.useProvidedRefOrCreate(externalAnchorRef);
|
39
|
+
const renderMenuAnchor = react_1.useMemo(() => {
|
40
|
+
if (renderAnchor === null) {
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
return (props) => renderAnchor({
|
44
|
+
...props,
|
45
|
+
children: selectedItem?.text ?? placeholder
|
46
|
+
});
|
47
|
+
}, [placeholder, renderAnchor, selectedItem?.text]);
|
48
|
+
const itemsToRender = react_1.useMemo(() => {
|
49
|
+
return items.map(item => {
|
50
|
+
return {
|
51
|
+
...item,
|
52
|
+
role: 'option',
|
53
|
+
selected: item === selectedItem,
|
54
|
+
onAction: (itemFromAction, event) => {
|
55
|
+
item.onAction?.(itemFromAction, event);
|
56
|
+
if (event.defaultPrevented) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
onClose();
|
60
|
+
onChange?.(item === selectedItem ? undefined : item);
|
61
|
+
}
|
62
|
+
};
|
63
|
+
});
|
64
|
+
}, [items, onChange, onClose, selectedItem]);
|
65
|
+
return (<AnchoredOverlay_1.AnchoredOverlay renderAnchor={renderMenuAnchor} anchorRef={anchorRef} open={combinedOpenState} onOpen={onOpen} onClose={onClose} overlayProps={overlayProps}>
|
66
|
+
<List_1.List {...listProps} role="listbox" items={itemsToRender}/>
|
67
|
+
</AnchoredOverlay_1.AnchoredOverlay>);
|
68
|
+
}
|
69
|
+
exports.DropdownMenu = DropdownMenu;
|
70
|
+
DropdownMenu.displayName = 'DropdownMenu';
|
@@ -1,21 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
});
|
6
|
-
|
7
|
-
|
8
|
-
get: function () {
|
9
|
-
return _DropdownMenu.DropdownMenu;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
Object.defineProperty(exports, "DropdownButton", {
|
13
|
-
enumerable: true,
|
14
|
-
get: function () {
|
15
|
-
return _DropdownButton.DropdownButton;
|
16
|
-
}
|
17
|
-
});
|
18
|
-
|
19
|
-
var _DropdownMenu = require("./DropdownMenu");
|
20
|
-
|
21
|
-
var _DropdownButton = require("./DropdownButton");
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.DropdownButton = exports.DropdownMenu = void 0;
|
4
|
+
var DropdownMenu_1 = require("./DropdownMenu");
|
5
|
+
Object.defineProperty(exports, "DropdownMenu", { enumerable: true, get: function () { return DropdownMenu_1.DropdownMenu; } });
|
6
|
+
var DropdownButton_1 = require("./DropdownButton");
|
7
|
+
Object.defineProperty(exports, "DropdownButton", { enumerable: true, get: function () { return DropdownButton_1.DropdownButton; } });
|
package/lib/DropdownStyles.js
CHANGED
@@ -1,15 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _constants = require("./constants");
|
9
|
-
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const constants_1 = require("./constants");
|
10
4
|
const getDirectionStyles = (theme, direction) => {
|
11
|
-
|
12
|
-
|
5
|
+
const map = {
|
6
|
+
w: `
|
13
7
|
top: 0;
|
14
8
|
right: 100%;
|
15
9
|
left: auto;
|
@@ -22,7 +16,7 @@ const getDirectionStyles = (theme, direction) => {
|
|
22
16
|
right: -16px;
|
23
17
|
left: auto;
|
24
18
|
border-color: transparent;
|
25
|
-
border-left-color: ${
|
19
|
+
border-left-color: ${constants_1.get('colors.border.default')(theme)};
|
26
20
|
}
|
27
21
|
|
28
22
|
&::after {
|
@@ -30,10 +24,10 @@ const getDirectionStyles = (theme, direction) => {
|
|
30
24
|
right: -14px;
|
31
25
|
left: auto;
|
32
26
|
border-color: transparent;
|
33
|
-
border-left-color: ${
|
27
|
+
border-left-color: ${constants_1.get('colors.border.default')(theme)};
|
34
28
|
}
|
35
29
|
`,
|
36
|
-
|
30
|
+
e: `
|
37
31
|
top: 0;
|
38
32
|
left: 100%;
|
39
33
|
width: auto;
|
@@ -44,17 +38,17 @@ const getDirectionStyles = (theme, direction) => {
|
|
44
38
|
top: 10px;
|
45
39
|
left: -16px;
|
46
40
|
border-color: transparent;
|
47
|
-
border-right-color: ${
|
41
|
+
border-right-color: ${constants_1.get('colors.border.default')(theme)};
|
48
42
|
}
|
49
43
|
|
50
44
|
&::after {
|
51
45
|
top: 11px;
|
52
46
|
left: -14px;
|
53
47
|
border-color: transparent;
|
54
|
-
border-right-color: ${
|
48
|
+
border-right-color: ${constants_1.get('colors.border.default')(theme)};
|
55
49
|
}
|
56
50
|
`,
|
57
|
-
|
51
|
+
ne: `
|
58
52
|
top: auto;
|
59
53
|
bottom: 100%;
|
60
54
|
left: 0;
|
@@ -69,7 +63,7 @@ const getDirectionStyles = (theme, direction) => {
|
|
69
63
|
&::before {
|
70
64
|
bottom: -8px;
|
71
65
|
left: 9px;
|
72
|
-
border-top: 8px solid ${
|
66
|
+
border-top: 8px solid ${constants_1.get('colors.border.default')(theme)};
|
73
67
|
border-bottom: 0;
|
74
68
|
border-left: 8px solid transparent;
|
75
69
|
}
|
@@ -77,13 +71,13 @@ const getDirectionStyles = (theme, direction) => {
|
|
77
71
|
&::after {
|
78
72
|
bottom: -7px;
|
79
73
|
left: 10px;
|
80
|
-
border-top: 7px solid ${
|
74
|
+
border-top: 7px solid ${constants_1.get('colors.border.default')(theme)};
|
81
75
|
border-right: 7px solid transparent;
|
82
76
|
border-bottom: 0;
|
83
77
|
border-left: 7px solid transparent;
|
84
78
|
}
|
85
79
|
`,
|
86
|
-
|
80
|
+
s: `
|
87
81
|
right: 50%;
|
88
82
|
left: auto;
|
89
83
|
transform: translateX(50%);
|
@@ -100,7 +94,7 @@ const getDirectionStyles = (theme, direction) => {
|
|
100
94
|
transform: translateX(50%);
|
101
95
|
}
|
102
96
|
`,
|
103
|
-
|
97
|
+
sw: `
|
104
98
|
right: 0;
|
105
99
|
left: auto;
|
106
100
|
|
@@ -116,7 +110,7 @@ const getDirectionStyles = (theme, direction) => {
|
|
116
110
|
left: auto;
|
117
111
|
}
|
118
112
|
`,
|
119
|
-
|
113
|
+
se: `
|
120
114
|
&::before {
|
121
115
|
top: -16px;
|
122
116
|
left: 9px;
|
@@ -127,9 +121,7 @@ const getDirectionStyles = (theme, direction) => {
|
|
127
121
|
left: 10px;
|
128
122
|
}
|
129
123
|
`
|
130
|
-
|
131
|
-
|
124
|
+
};
|
125
|
+
return map[direction];
|
132
126
|
};
|
133
|
-
|
134
|
-
var _default = getDirectionStyles;
|
135
|
-
exports.default = _default;
|
127
|
+
exports.default = getDirectionStyles;
|
package/lib/FilterList.d.ts
CHANGED
@@ -274,7 +274,6 @@ declare const _default: (({ children, ...rest }: React.PropsWithChildren<{
|
|
274
274
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLUListElement> | undefined;
|
275
275
|
onTransitionEnd?: React.TransitionEventHandler<HTMLUListElement> | undefined;
|
276
276
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLUListElement> | undefined;
|
277
|
-
css?: import("@emotion/core").InterpolationWithTheme<any>;
|
278
277
|
} & {
|
279
278
|
theme?: any;
|
280
279
|
}>) => JSX.Element) & {
|
@@ -0,0 +1,59 @@
|
|
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 FilterListBase = styled_components_1.default.ul `
|
11
|
+
list-style-type: none;
|
12
|
+
margin: 0;
|
13
|
+
padding: 0;
|
14
|
+
${sx_1.default};
|
15
|
+
`;
|
16
|
+
const FilterList = ({ children, ...rest }) => {
|
17
|
+
const items = react_1.default.Children.map(children, child => {
|
18
|
+
return <li>{child}</li>;
|
19
|
+
});
|
20
|
+
return <FilterListBase {...rest}>{items}</FilterListBase>;
|
21
|
+
};
|
22
|
+
const FilterListItemBase = styled_components_1.default.a `
|
23
|
+
position: relative;
|
24
|
+
display: block;
|
25
|
+
padding: ${props => (props.small ? `${constants_1.get('space.1')(props)} 10px` : `${constants_1.get('space.2')(props)} 11px`)};
|
26
|
+
margin: ${props => (props.small ? '0 0 2px' : '0 0 5px 0')};
|
27
|
+
overflow: hidden;
|
28
|
+
font-size: ${constants_1.get('fontSizes.1')};
|
29
|
+
color: ${props => (props.selected ? constants_1.get('colors.fg.onEmphasis') : constants_1.get('colors.fg.muted'))};
|
30
|
+
background-color: ${props => (props.selected ? constants_1.get('colors.accent.emphasis') : '')}!important;
|
31
|
+
text-decoration: none;
|
32
|
+
text-overflow: ellipsis;
|
33
|
+
white-space: nowrap;
|
34
|
+
cursor: pointer;
|
35
|
+
border-radius: ${constants_1.get('radii.1')};
|
36
|
+
&:hover {
|
37
|
+
text-decoration: none;
|
38
|
+
background-color: ${constants_1.get('colors.canvas.subtle')};
|
39
|
+
}
|
40
|
+
&:active {
|
41
|
+
color: ${constants_1.get('colors.fg.onEmphasis')};
|
42
|
+
background-color: ${constants_1.get('colors.accent.emphasis')};
|
43
|
+
}
|
44
|
+
.count {
|
45
|
+
float: right;
|
46
|
+
font-weight: ${constants_1.get('fontWeights.bold')};
|
47
|
+
}
|
48
|
+
${sx_1.default};
|
49
|
+
`;
|
50
|
+
function FilterListItem({ children, count, ...rest }) {
|
51
|
+
return (<FilterListItemBase {...rest}>
|
52
|
+
{count && (<span title="results" className="count">
|
53
|
+
{count}
|
54
|
+
</span>)}
|
55
|
+
{children}
|
56
|
+
</FilterListItemBase>);
|
57
|
+
}
|
58
|
+
FilterListItem.displayName = 'FilterList.Item';
|
59
|
+
exports.default = Object.assign(FilterList, { Item: FilterListItem });
|
@@ -0,0 +1,100 @@
|
|
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
|
+
exports.FilteredActionList = void 0;
|
26
|
+
const react_1 = __importStar(require("react"));
|
27
|
+
const ssr_1 = require("@react-aria/ssr");
|
28
|
+
const TextInput_1 = __importDefault(require("../TextInput"));
|
29
|
+
const Box_1 = __importDefault(require("../Box"));
|
30
|
+
const ActionList_1 = require("../ActionList");
|
31
|
+
const Spinner_1 = __importDefault(require("../Spinner"));
|
32
|
+
const useFocusZone_1 = require("../hooks/useFocusZone");
|
33
|
+
const useProvidedStateOrCreate_1 = require("../hooks/useProvidedStateOrCreate");
|
34
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
35
|
+
const constants_1 = require("../constants");
|
36
|
+
const useProvidedRefOrCreate_1 = require("../hooks/useProvidedRefOrCreate");
|
37
|
+
const useScrollFlash_1 = __importDefault(require("../hooks/useScrollFlash"));
|
38
|
+
const scrollIntoViewingArea_1 = require("../behaviors/scrollIntoViewingArea");
|
39
|
+
const StyledHeader = styled_components_1.default.div `
|
40
|
+
box-shadow: 0 1px 0 ${constants_1.get('colors.border.default')};
|
41
|
+
z-index: 1;
|
42
|
+
`;
|
43
|
+
function FilteredActionList({ loading = false, placeholderText, filterValue: externalFilterValue, onFilterChange, items, textInputProps, inputRef: providedInputRef, sx, ...listProps }) {
|
44
|
+
const [filterValue, setInternalFilterValue] = useProvidedStateOrCreate_1.useProvidedStateOrCreate(externalFilterValue, undefined, '');
|
45
|
+
const onInputChange = react_1.useCallback((e) => {
|
46
|
+
const value = e.target.value;
|
47
|
+
onFilterChange(value, e);
|
48
|
+
setInternalFilterValue(value);
|
49
|
+
}, [onFilterChange, setInternalFilterValue]);
|
50
|
+
const scrollContainerRef = react_1.useRef(null);
|
51
|
+
const listContainerRef = react_1.useRef(null);
|
52
|
+
const inputRef = useProvidedRefOrCreate_1.useProvidedRefOrCreate(providedInputRef);
|
53
|
+
const activeDescendantRef = react_1.useRef();
|
54
|
+
const listId = ssr_1.useSSRSafeId();
|
55
|
+
const onInputKeyPress = react_1.useCallback(event => {
|
56
|
+
if (event.key === 'Enter' && activeDescendantRef.current) {
|
57
|
+
event.preventDefault();
|
58
|
+
event.nativeEvent.stopImmediatePropagation();
|
59
|
+
// Forward Enter key press to active descendant so that item gets activated
|
60
|
+
const activeDescendantEvent = new KeyboardEvent(event.type, event.nativeEvent);
|
61
|
+
activeDescendantRef.current.dispatchEvent(activeDescendantEvent);
|
62
|
+
}
|
63
|
+
}, [activeDescendantRef]);
|
64
|
+
useFocusZone_1.useFocusZone({
|
65
|
+
containerRef: listContainerRef,
|
66
|
+
focusOutBehavior: 'wrap',
|
67
|
+
focusableElementFilter: element => {
|
68
|
+
return !(element instanceof HTMLInputElement);
|
69
|
+
},
|
70
|
+
activeDescendantFocus: inputRef,
|
71
|
+
onActiveDescendantChanged: (current, previous, directlyActivated) => {
|
72
|
+
activeDescendantRef.current = current;
|
73
|
+
if (current && scrollContainerRef.current && directlyActivated) {
|
74
|
+
scrollIntoViewingArea_1.scrollIntoViewingArea(current, scrollContainerRef.current);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}, [
|
78
|
+
// List ref isn't set while loading. Need to re-bind focus zone when it changes
|
79
|
+
loading
|
80
|
+
]);
|
81
|
+
react_1.useEffect(() => {
|
82
|
+
// if items changed, we want to instantly move active descendant into view
|
83
|
+
if (activeDescendantRef.current && scrollContainerRef.current) {
|
84
|
+
scrollIntoViewingArea_1.scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, 'vertical', undefined, undefined, 'auto');
|
85
|
+
}
|
86
|
+
}, [items]);
|
87
|
+
useScrollFlash_1.default(scrollContainerRef);
|
88
|
+
return (<Box_1.default display="flex" flexDirection="column" overflow="hidden" sx={sx}>
|
89
|
+
<StyledHeader>
|
90
|
+
<TextInput_1.default ref={inputRef} block width="auto" color="fg.default" value={filterValue} onChange={onInputChange} onKeyPress={onInputKeyPress} placeholder={placeholderText} aria-label={placeholderText} aria-controls={listId} {...textInputProps}/>
|
91
|
+
</StyledHeader>
|
92
|
+
<Box_1.default ref={scrollContainerRef} overflow="auto">
|
93
|
+
{loading ? (<Box_1.default width="100%" display="flex" flexDirection="row" justifyContent="center" pt={6} pb={7}>
|
94
|
+
<Spinner_1.default />
|
95
|
+
</Box_1.default>) : (<ActionList_1.ActionList ref={listContainerRef} items={items} {...listProps} role="listbox" id={listId}/>)}
|
96
|
+
</Box_1.default>
|
97
|
+
</Box_1.default>);
|
98
|
+
}
|
99
|
+
exports.FilteredActionList = FilteredActionList;
|
100
|
+
FilteredActionList.displayName = 'FilteredActionList';
|
@@ -1,13 +1,5 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
});
|
6
|
-
Object.defineProperty(exports, "FilteredActionList", {
|
7
|
-
enumerable: true,
|
8
|
-
get: function () {
|
9
|
-
return _FilteredActionList.FilteredActionList;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
|
13
|
-
var _FilteredActionList = require("./FilteredActionList");
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FilteredActionList = void 0;
|
4
|
+
var FilteredActionList_1 = require("./FilteredActionList");
|
5
|
+
Object.defineProperty(exports, "FilteredActionList", { enumerable: true, get: function () { return FilteredActionList_1.FilteredActionList; } });
|
@@ -0,0 +1,28 @@
|
|
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 styled_components_1 = __importDefault(require("styled-components"));
|
7
|
+
const constants_1 = require("./constants");
|
8
|
+
const sx_1 = __importDefault(require("./sx"));
|
9
|
+
const FilteredSearch = styled_components_1.default.div `
|
10
|
+
display: flex;
|
11
|
+
align-items: stretch;
|
12
|
+
|
13
|
+
summary {
|
14
|
+
border-radius: 0;
|
15
|
+
border-top-left-radius: ${constants_1.get('radii.2')};
|
16
|
+
border-bottom-left-radius: ${constants_1.get('radii.2')};
|
17
|
+
border-right: 0;
|
18
|
+
}
|
19
|
+
.TextInput-wrapper {
|
20
|
+
border-radius: 0;
|
21
|
+
border-top-right-radius: ${constants_1.get('radii.2')};
|
22
|
+
border-bottom-right-radius: ${constants_1.get('radii.2')};
|
23
|
+
z-index: 1; // Allows the focus outline to show on top of the dropdown.
|
24
|
+
}
|
25
|
+
|
26
|
+
${sx_1.default}
|
27
|
+
`;
|
28
|
+
exports.default = FilteredSearch;
|