@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
@@ -0,0 +1,146 @@
|
|
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.useConfirm = exports.ConfirmationDialog = void 0;
|
26
|
+
const react_1 = __importStar(require("react"));
|
27
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
28
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
29
|
+
const Box_1 = __importDefault(require("../Box"));
|
30
|
+
const ThemeProvider_1 = require("../ThemeProvider");
|
31
|
+
const focusZone_1 = require("../behaviors/focusZone");
|
32
|
+
const constants_1 = require("../constants");
|
33
|
+
const Dialog_1 = require("../Dialog/Dialog");
|
34
|
+
const useFocusZone_1 = require("../hooks/useFocusZone");
|
35
|
+
const StyledConfirmationHeader = styled_components_1.default.header `
|
36
|
+
padding: ${constants_1.get('space.2')};
|
37
|
+
display: flex;
|
38
|
+
flex-direction: row;
|
39
|
+
`;
|
40
|
+
const StyledTitle = styled_components_1.default(Box_1.default) `
|
41
|
+
font-size: ${constants_1.get('fontSizes.3')};
|
42
|
+
font-weight: ${constants_1.get('fontWeights.bold')};
|
43
|
+
padding: 6px ${constants_1.get('space.2')};
|
44
|
+
flex-grow: 1;
|
45
|
+
`;
|
46
|
+
const ConfirmationHeader = ({ title, onClose, dialogLabelId }) => {
|
47
|
+
const onCloseClick = react_1.useCallback(() => {
|
48
|
+
onClose('close-button');
|
49
|
+
}, [onClose]);
|
50
|
+
return (<StyledConfirmationHeader>
|
51
|
+
<StyledTitle id={dialogLabelId}>{title}</StyledTitle>
|
52
|
+
<Dialog_1.Dialog.CloseButton onClose={onCloseClick}/>
|
53
|
+
</StyledConfirmationHeader>);
|
54
|
+
};
|
55
|
+
const StyledConfirmationBody = styled_components_1.default(Box_1.default) `
|
56
|
+
font-size: ${constants_1.get('fontSizes.1')};
|
57
|
+
padding: 0 ${constants_1.get('space.3')} ${constants_1.get('space.3')} ${constants_1.get('space.3')};
|
58
|
+
color: ${constants_1.get('colors.fg.muted')};
|
59
|
+
flex-grow: 1;
|
60
|
+
`;
|
61
|
+
const ConfirmationBody = ({ children }) => {
|
62
|
+
return <StyledConfirmationBody>{children}</StyledConfirmationBody>;
|
63
|
+
};
|
64
|
+
const StyledConfirmationFooter = styled_components_1.default(Box_1.default) `
|
65
|
+
display: grid;
|
66
|
+
grid-auto-flow: column;
|
67
|
+
grid-auto-columns: max-content;
|
68
|
+
grid-gap: ${constants_1.get('space.2')};
|
69
|
+
align-items: end;
|
70
|
+
justify-content: end;
|
71
|
+
padding: ${constants_1.get('space.1')} ${constants_1.get('space.3')} ${constants_1.get('space.3')};
|
72
|
+
`;
|
73
|
+
const ConfirmationFooter = ({ footerButtons }) => {
|
74
|
+
const { containerRef: footerRef } = useFocusZone_1.useFocusZone({
|
75
|
+
bindKeys: focusZone_1.FocusKeys.ArrowHorizontal | focusZone_1.FocusKeys.Tab,
|
76
|
+
focusInStrategy: 'closest'
|
77
|
+
});
|
78
|
+
// Must have exactly 2 buttons!
|
79
|
+
return (<StyledConfirmationFooter ref={footerRef}>
|
80
|
+
<Dialog_1.Dialog.Buttons buttons={footerButtons ?? []}/>
|
81
|
+
</StyledConfirmationFooter>);
|
82
|
+
};
|
83
|
+
/**
|
84
|
+
* A ConfirmationDialog is a special kind of dialog with more rigid behavior. It
|
85
|
+
* is used to confirm a user action. ConfirmationDialogs always have exactly
|
86
|
+
* two buttons: one to cancel the action and one to confirm it. No custom
|
87
|
+
* rendering capabilities are provided for ConfirmationDialog.
|
88
|
+
*/
|
89
|
+
const ConfirmationDialog = props => {
|
90
|
+
const { onClose, title, cancelButtonContent = 'Cancel', confirmButtonContent = 'OK', confirmButtonType = 'normal', children } = props;
|
91
|
+
const onCancelButtonClick = react_1.useCallback(() => {
|
92
|
+
onClose('cancel');
|
93
|
+
}, [onClose]);
|
94
|
+
const onConfirmButtonClick = react_1.useCallback(() => {
|
95
|
+
onClose('confirm');
|
96
|
+
}, [onClose]);
|
97
|
+
const cancelButton = {
|
98
|
+
content: cancelButtonContent,
|
99
|
+
onClick: onCancelButtonClick
|
100
|
+
};
|
101
|
+
const confirmButton = {
|
102
|
+
content: confirmButtonContent,
|
103
|
+
buttonType: confirmButtonType,
|
104
|
+
onClick: onConfirmButtonClick,
|
105
|
+
autoFocus: true
|
106
|
+
};
|
107
|
+
const footerButtons = [cancelButton, confirmButton];
|
108
|
+
return (<Dialog_1.Dialog onClose={onClose} title={title} footerButtons={footerButtons} role="alertdialog" width="medium" renderHeader={ConfirmationHeader} renderBody={ConfirmationBody} renderFooter={ConfirmationFooter}>
|
109
|
+
{children}
|
110
|
+
</Dialog_1.Dialog>);
|
111
|
+
};
|
112
|
+
exports.ConfirmationDialog = ConfirmationDialog;
|
113
|
+
async function confirm(themeProps, options) {
|
114
|
+
const { content, ...confirmationDialogProps } = options;
|
115
|
+
return new Promise(resolve => {
|
116
|
+
const hostElement = document.createElement('div');
|
117
|
+
const onClose = gesture => {
|
118
|
+
react_dom_1.default.unmountComponentAtNode(hostElement);
|
119
|
+
if (gesture === 'confirm') {
|
120
|
+
resolve(true);
|
121
|
+
}
|
122
|
+
else {
|
123
|
+
resolve(false);
|
124
|
+
}
|
125
|
+
};
|
126
|
+
react_dom_1.default.render(<ThemeProvider_1.ThemeProvider {...themeProps}>
|
127
|
+
<exports.ConfirmationDialog {...confirmationDialogProps} onClose={onClose}>
|
128
|
+
{content}
|
129
|
+
</exports.ConfirmationDialog>
|
130
|
+
</ThemeProvider_1.ThemeProvider>, hostElement);
|
131
|
+
});
|
132
|
+
}
|
133
|
+
/**
|
134
|
+
* This hook takes no parameters and returns an `async` function, `confirm`. When `confirm`
|
135
|
+
* is called, it shows the confirmation dialog. When the dialog is dismissed, a promise is
|
136
|
+
* resolved with `true` or `false` depending on whether or not the confirm button was used.
|
137
|
+
*/
|
138
|
+
function useConfirm() {
|
139
|
+
const { theme, colorMode, dayScheme, nightScheme } = ThemeProvider_1.useTheme();
|
140
|
+
const result = react_1.useCallback((options) => {
|
141
|
+
const themeProps = { theme, colorMode, dayScheme, nightScheme };
|
142
|
+
return confirm(themeProps, options);
|
143
|
+
}, [theme, colorMode, dayScheme, nightScheme]);
|
144
|
+
return result;
|
145
|
+
}
|
146
|
+
exports.useConfirm = useConfirm;
|
@@ -0,0 +1,279 @@
|
|
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.Dialog = void 0;
|
26
|
+
const react_1 = __importStar(require("react"));
|
27
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
28
|
+
const Button_1 = __importStar(require("../Button"));
|
29
|
+
const Box_1 = __importDefault(require("../Box"));
|
30
|
+
const constants_1 = require("../constants");
|
31
|
+
const hooks_1 = require("../hooks");
|
32
|
+
const useFocusTrap_1 = require("../hooks/useFocusTrap");
|
33
|
+
const sx_1 = __importDefault(require("../sx"));
|
34
|
+
const StyledOcticon_1 = __importDefault(require("../StyledOcticon"));
|
35
|
+
const octicons_react_1 = require("@primer/octicons-react");
|
36
|
+
const useFocusZone_1 = require("../hooks/useFocusZone");
|
37
|
+
const focusZone_1 = require("../behaviors/focusZone");
|
38
|
+
const Portal_1 = __importDefault(require("../Portal"));
|
39
|
+
const useCombinedRefs_1 = require("../hooks/useCombinedRefs");
|
40
|
+
const ssr_1 = require("@react-aria/ssr");
|
41
|
+
const ANIMATION_DURATION = '200ms';
|
42
|
+
const Backdrop = styled_components_1.default('div') `
|
43
|
+
position: fixed;
|
44
|
+
top: 0;
|
45
|
+
left: 0;
|
46
|
+
bottom: 0;
|
47
|
+
right: 0;
|
48
|
+
display: flex;
|
49
|
+
align-items: center;
|
50
|
+
justify-content: center;
|
51
|
+
background-color: rgba(0, 0, 0, 0.4);
|
52
|
+
animation: dialog-backdrop-appear ${ANIMATION_DURATION} ${constants_1.get('animation.easeOutCubic')};
|
53
|
+
|
54
|
+
@keyframes dialog-backdrop-appear {
|
55
|
+
0% {
|
56
|
+
opacity: 0;
|
57
|
+
}
|
58
|
+
100% {
|
59
|
+
opacity: 1;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
`;
|
63
|
+
const heightMap = {
|
64
|
+
small: '480px',
|
65
|
+
large: '640px',
|
66
|
+
auto: 'auto'
|
67
|
+
};
|
68
|
+
const widthMap = {
|
69
|
+
small: '296px',
|
70
|
+
medium: '320px',
|
71
|
+
large: '480px',
|
72
|
+
xlarge: '640px'
|
73
|
+
};
|
74
|
+
const StyledDialog = styled_components_1.default.div `
|
75
|
+
display: flex;
|
76
|
+
flex-direction: column;
|
77
|
+
background-color: ${constants_1.get('colors.canvas.overlay')};
|
78
|
+
box-shadow: ${constants_1.get('shadows.overlay.shadow')};
|
79
|
+
min-width: 296px;
|
80
|
+
max-width: calc(100vw - 64px);
|
81
|
+
max-height: calc(100vh - 64px);
|
82
|
+
width: ${props => widthMap[props.width ?? 'xlarge']};
|
83
|
+
height: ${props => heightMap[props.height ?? 'auto']};
|
84
|
+
border-radius: 12px;
|
85
|
+
opacity: 1;
|
86
|
+
animation: overlay--dialog-appear ${ANIMATION_DURATION} ${constants_1.get('animation.easeOutCubic')};
|
87
|
+
|
88
|
+
@keyframes overlay--dialog-appear {
|
89
|
+
0% {
|
90
|
+
opacity: 0;
|
91
|
+
transform: scale(0.5);
|
92
|
+
}
|
93
|
+
100% {
|
94
|
+
opacity: 1;
|
95
|
+
transform: scale(1);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
${sx_1.default};
|
100
|
+
`;
|
101
|
+
const DefaultHeader = ({ dialogLabelId, title, subtitle, dialogDescriptionId, onClose }) => {
|
102
|
+
const onCloseClick = react_1.useCallback(() => {
|
103
|
+
onClose('close-button');
|
104
|
+
}, [onClose]);
|
105
|
+
return (<exports.Dialog.Header>
|
106
|
+
<Box_1.default display="flex">
|
107
|
+
<Box_1.default display="flex" px={2} py="6px" flexDirection="column" flexGrow={1}>
|
108
|
+
<exports.Dialog.Title id={dialogLabelId}>{title ?? 'Dialog'}</exports.Dialog.Title>
|
109
|
+
{subtitle && <exports.Dialog.Subtitle id={dialogDescriptionId}>{subtitle}</exports.Dialog.Subtitle>}
|
110
|
+
</Box_1.default>
|
111
|
+
<exports.Dialog.CloseButton onClose={onCloseClick}/>
|
112
|
+
</Box_1.default>
|
113
|
+
</exports.Dialog.Header>);
|
114
|
+
};
|
115
|
+
const DefaultBody = ({ children }) => {
|
116
|
+
return <exports.Dialog.Body>{children}</exports.Dialog.Body>;
|
117
|
+
};
|
118
|
+
const DefaultFooter = ({ footerButtons }) => {
|
119
|
+
const { containerRef: footerRef } = useFocusZone_1.useFocusZone({
|
120
|
+
bindKeys: focusZone_1.FocusKeys.ArrowHorizontal | focusZone_1.FocusKeys.Tab,
|
121
|
+
focusInStrategy: 'closest'
|
122
|
+
});
|
123
|
+
return footerButtons ? (<exports.Dialog.Footer ref={footerRef}>
|
124
|
+
<exports.Dialog.Buttons buttons={footerButtons}/>
|
125
|
+
</exports.Dialog.Footer>) : null;
|
126
|
+
};
|
127
|
+
const _Dialog = react_1.default.forwardRef((props, forwardedRef) => {
|
128
|
+
const { title = 'Dialog', subtitle = '', renderHeader, renderBody, renderFooter, onClose, role = 'dialog', width = 'xlarge', height = 'auto', footerButtons = [] } = props;
|
129
|
+
const dialogLabelId = ssr_1.useSSRSafeId();
|
130
|
+
const dialogDescriptionId = ssr_1.useSSRSafeId();
|
131
|
+
const autoFocusedFooterButtonRef = react_1.useRef(null);
|
132
|
+
for (const footerButton of footerButtons) {
|
133
|
+
if (footerButton.autoFocus) {
|
134
|
+
footerButton.ref = autoFocusedFooterButtonRef;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
const defaultedProps = { ...props, title, subtitle, role, dialogLabelId, dialogDescriptionId };
|
138
|
+
const dialogRef = react_1.useRef(null);
|
139
|
+
const combinedRef = useCombinedRefs_1.useCombinedRefs(dialogRef, forwardedRef);
|
140
|
+
const backdropRef = react_1.useRef(null);
|
141
|
+
useFocusTrap_1.useFocusTrap({ containerRef: dialogRef, restoreFocusOnCleanUp: true, initialFocusRef: autoFocusedFooterButtonRef });
|
142
|
+
hooks_1.useOnEscapePress((event) => {
|
143
|
+
onClose('escape');
|
144
|
+
event.preventDefault();
|
145
|
+
}, [onClose]);
|
146
|
+
const header = (renderHeader ?? DefaultHeader)(defaultedProps);
|
147
|
+
const body = (renderBody ?? DefaultBody)(defaultedProps);
|
148
|
+
const footer = (renderFooter ?? DefaultFooter)(defaultedProps);
|
149
|
+
return (<>
|
150
|
+
<Portal_1.default>
|
151
|
+
<Backdrop ref={backdropRef}>
|
152
|
+
<StyledDialog width={width} height={height} ref={combinedRef} role={role} aria-labelledby={dialogLabelId} aria-describedby={dialogDescriptionId}>
|
153
|
+
{header}
|
154
|
+
{body}
|
155
|
+
{footer}
|
156
|
+
</StyledDialog>
|
157
|
+
</Backdrop>
|
158
|
+
</Portal_1.default>
|
159
|
+
</>);
|
160
|
+
});
|
161
|
+
_Dialog.displayName = 'Dialog';
|
162
|
+
const Header = styled_components_1.default.div.attrs({ as: 'header' }) `
|
163
|
+
box-shadow: 0 1px 0 ${constants_1.get('colors.border.default')};
|
164
|
+
padding: ${constants_1.get('space.2')};
|
165
|
+
z-index: 1;
|
166
|
+
flex-shrink: 0;
|
167
|
+
`;
|
168
|
+
const Title = styled_components_1.default.div `
|
169
|
+
font-size: ${constants_1.get('fontSizes.1')};
|
170
|
+
font-weight: ${constants_1.get('fontWeights.bold')};
|
171
|
+
|
172
|
+
${sx_1.default};
|
173
|
+
`;
|
174
|
+
const Subtitle = styled_components_1.default.div `
|
175
|
+
font-size: ${constants_1.get('fontSizes.0')};
|
176
|
+
margin-top: ${constants_1.get('space.1')};
|
177
|
+
color: ${constants_1.get('colors.fg.muted')};
|
178
|
+
|
179
|
+
${sx_1.default};
|
180
|
+
`;
|
181
|
+
const Body = styled_components_1.default.div `
|
182
|
+
flex-grow: 1;
|
183
|
+
overflow: auto;
|
184
|
+
padding: ${constants_1.get('space.3')};
|
185
|
+
|
186
|
+
${sx_1.default};
|
187
|
+
`;
|
188
|
+
const Footer = styled_components_1.default.div.attrs({ as: 'footer' }) `
|
189
|
+
box-shadow: 0 -1px 0 ${constants_1.get('colors.border.default')};
|
190
|
+
padding: ${constants_1.get('space.3')};
|
191
|
+
display: flex;
|
192
|
+
flex-flow: wrap;
|
193
|
+
justify-content: flex-end;
|
194
|
+
z-index: 1;
|
195
|
+
flex-shrink: 0;
|
196
|
+
|
197
|
+
button {
|
198
|
+
margin-left: ${constants_1.get('space.1')};
|
199
|
+
&:first-child {
|
200
|
+
margin-left: 0;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
${sx_1.default};
|
205
|
+
`;
|
206
|
+
const buttonTypes = {
|
207
|
+
normal: Button_1.default,
|
208
|
+
primary: Button_1.ButtonPrimary,
|
209
|
+
danger: Button_1.ButtonDanger
|
210
|
+
};
|
211
|
+
const Buttons = ({ buttons }) => {
|
212
|
+
const autoFocusRef = hooks_1.useProvidedRefOrCreate(buttons.find(button => button.autoFocus)?.ref);
|
213
|
+
let autoFocusCount = 0;
|
214
|
+
const [hasRendered, setHasRendered] = react_1.useState(0);
|
215
|
+
react_1.useEffect(() => {
|
216
|
+
// hack to work around dialogs originating from other focus traps.
|
217
|
+
if (hasRendered === 1) {
|
218
|
+
autoFocusRef.current?.focus();
|
219
|
+
}
|
220
|
+
else {
|
221
|
+
setHasRendered(hasRendered + 1);
|
222
|
+
}
|
223
|
+
}, [autoFocusRef, hasRendered]);
|
224
|
+
return (<>
|
225
|
+
{buttons.map((dialogButtonProps, index) => {
|
226
|
+
const { content, buttonType = 'normal', autoFocus = false, ...buttonProps } = dialogButtonProps;
|
227
|
+
const ButtonElement = buttonTypes[buttonType];
|
228
|
+
return (<ButtonElement key={index} {...buttonProps} variant={buttonType} ref={autoFocus && autoFocusCount === 0 ? (autoFocusCount++, autoFocusRef) : null}>
|
229
|
+
{content}
|
230
|
+
</ButtonElement>);
|
231
|
+
})}
|
232
|
+
</>);
|
233
|
+
};
|
234
|
+
const DialogCloseButton = styled_components_1.default(Button_1.default) `
|
235
|
+
border-radius: 4px;
|
236
|
+
background: transparent;
|
237
|
+
border: 0;
|
238
|
+
vertical-align: middle;
|
239
|
+
color: ${constants_1.get('colors.fg.muted')};
|
240
|
+
padding: ${constants_1.get('space.2')};
|
241
|
+
align-self: flex-start;
|
242
|
+
line-height: normal;
|
243
|
+
box-shadow: none;
|
244
|
+
`;
|
245
|
+
const CloseButton = ({ onClose }) => {
|
246
|
+
return (<DialogCloseButton aria-label="Close" onClick={onClose}>
|
247
|
+
<StyledOcticon_1.default icon={octicons_react_1.XIcon}/>
|
248
|
+
</DialogCloseButton>);
|
249
|
+
};
|
250
|
+
/**
|
251
|
+
* A dialog is a type of overlay that can be used for confirming actions, asking
|
252
|
+
* for disambiguation, and presenting small forms. They generally allow the user
|
253
|
+
* to focus on a quick task without having to navigate to a different page.
|
254
|
+
*
|
255
|
+
* Dialogs appear in the page after a direct user interaction. Don't show dialogs
|
256
|
+
* on page load or as system alerts.
|
257
|
+
*
|
258
|
+
* Dialogs appear centered in the page, with a visible backdrop that dims the rest
|
259
|
+
* of the window for focus.
|
260
|
+
*
|
261
|
+
* All dialogs have a title and a close button.
|
262
|
+
*
|
263
|
+
* Dialogs are modal. Dialogs can be dismissed by clicking on the close button,
|
264
|
+
* pressing the escape key, or by interacting with another button in the dialog.
|
265
|
+
* To avoid losing information and missing important messages, clicking outside
|
266
|
+
* of the dialog will not close it.
|
267
|
+
*
|
268
|
+
* The sub components provided (e.g. Header, Title, etc.) are available for custom
|
269
|
+
* renderers only. They are not intended to be used otherwise.
|
270
|
+
*/
|
271
|
+
exports.Dialog = Object.assign(_Dialog, {
|
272
|
+
Header,
|
273
|
+
Title,
|
274
|
+
Subtitle,
|
275
|
+
Body,
|
276
|
+
Footer,
|
277
|
+
Buttons,
|
278
|
+
CloseButton
|
279
|
+
});
|
package/lib/Dialog.d.ts
CHANGED
@@ -385,7 +385,6 @@ declare namespace DialogHeader {
|
|
385
385
|
onAnimationIterationCapture?: React.Validator<React.AnimationEventHandler<HTMLDivElement> | null | undefined> | undefined;
|
386
386
|
onTransitionEnd?: React.Validator<React.TransitionEventHandler<HTMLDivElement> | null | undefined> | undefined;
|
387
387
|
onTransitionEndCapture?: React.Validator<React.TransitionEventHandler<HTMLDivElement> | null | undefined> | undefined;
|
388
|
-
css?: React.Validator<import("@emotion/core").InterpolationWithTheme<any>> | undefined;
|
389
388
|
borderX?: React.Validator<import("styled-system").ResponsiveValue<import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined> | undefined;
|
390
389
|
borderY?: React.Validator<import("styled-system").ResponsiveValue<import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined> | undefined;
|
391
390
|
theme?: React.Validator<any> | undefined;
|
@@ -398,9 +397,9 @@ declare type InternalDialogProps = {
|
|
398
397
|
initialFocusRef?: React.RefObject<HTMLElement>;
|
399
398
|
returnFocusRef?: React.RefObject<HTMLElement>;
|
400
399
|
} & ComponentProps<typeof DialogBase>;
|
401
|
-
declare const Dialog: React.ForwardRefExoticComponent<Pick<InternalDialogProps, "color" | "translate" | "hidden" | "children" | "theme" | "slot" | "style" | "title" | "role" | "sx" | "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" | "
|
400
|
+
declare const Dialog: React.ForwardRefExoticComponent<Pick<InternalDialogProps, "color" | "translate" | "hidden" | "children" | "theme" | "slot" | "style" | "title" | "role" | "sx" | "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" | "initialFocusRef" | "returnFocusRef" | "isOpen" | "onDismiss" | "narrow" | "wide"> & React.RefAttributes<HTMLDivElement>>;
|
402
401
|
export declare type DialogProps = ComponentProps<typeof Dialog>;
|
403
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<InternalDialogProps, "color" | "translate" | "hidden" | "children" | "theme" | "slot" | "style" | "title" | "role" | "sx" | "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" | "
|
402
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<InternalDialogProps, "color" | "translate" | "hidden" | "children" | "theme" | "slot" | "style" | "title" | "role" | "sx" | "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" | "initialFocusRef" | "returnFocusRef" | "isOpen" | "onDismiss" | "narrow" | "wide"> & React.RefAttributes<HTMLDivElement>> & {
|
404
403
|
Header: typeof DialogHeader;
|
405
404
|
};
|
406
405
|
export default _default;
|
package/lib/Dialog.jsx
ADDED
@@ -0,0 +1,129 @@
|
|
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 react_1 = __importStar(require("react"));
|
26
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
27
|
+
const ButtonClose_1 = __importDefault(require("./Button/ButtonClose"));
|
28
|
+
const constants_1 = require("./constants");
|
29
|
+
const Box_1 = __importDefault(require("./Box"));
|
30
|
+
const useDialog_1 = __importDefault(require("./hooks/useDialog"));
|
31
|
+
const sx_1 = __importDefault(require("./sx"));
|
32
|
+
const Text_1 = __importDefault(require("./Text"));
|
33
|
+
const useCombinedRefs_1 = require("./hooks/useCombinedRefs");
|
34
|
+
const noop = () => null;
|
35
|
+
const DialogBase = styled_components_1.default.div `
|
36
|
+
box-shadow: ${constants_1.get('shadows.shadow.large')};
|
37
|
+
border-radius: ${constants_1.get('radii.2')};
|
38
|
+
position: fixed;
|
39
|
+
top: 0;
|
40
|
+
left: 50%;
|
41
|
+
transform: translateX(-50%);
|
42
|
+
max-height: 80vh;
|
43
|
+
z-index: 999;
|
44
|
+
margin: 10vh auto;
|
45
|
+
background-color: ${constants_1.get('colors.canvas.default')};
|
46
|
+
width: ${props => (props.narrow ? '320px' : props.wide ? '640px' : '440px')};
|
47
|
+
outline: none;
|
48
|
+
|
49
|
+
@media screen and (max-width: 750px) {
|
50
|
+
width: 100vw;
|
51
|
+
margin: 0;
|
52
|
+
border-radius: 0;
|
53
|
+
height: 100vh;
|
54
|
+
}
|
55
|
+
|
56
|
+
${sx_1.default};
|
57
|
+
`;
|
58
|
+
const DialogHeaderBase = styled_components_1.default(Box_1.default) `
|
59
|
+
border-radius: ${constants_1.get('radii.2')} ${constants_1.get('radii.2')} 0px 0px;
|
60
|
+
border-bottom: 1px solid ${constants_1.get('colors.border.default')};
|
61
|
+
display: flex;
|
62
|
+
|
63
|
+
@media screen and (max-width: 750px) {
|
64
|
+
border-radius: 0px;
|
65
|
+
}
|
66
|
+
|
67
|
+
${sx_1.default};
|
68
|
+
`;
|
69
|
+
function DialogHeader({ theme, children, backgroundColor = 'gray.1', ...rest }) {
|
70
|
+
if (react_1.default.Children.toArray(children).every(ch => typeof ch === 'string')) {
|
71
|
+
children = (<Text_1.default theme={theme} color="fg.default" fontSize={1} fontWeight="bold" fontFamily="sans-serif">
|
72
|
+
{children}
|
73
|
+
</Text_1.default>);
|
74
|
+
}
|
75
|
+
return (<DialogHeaderBase theme={theme} p={3} backgroundColor={backgroundColor} {...rest}>
|
76
|
+
{children}
|
77
|
+
</DialogHeaderBase>);
|
78
|
+
}
|
79
|
+
const Overlay = styled_components_1.default.span `
|
80
|
+
&:before {
|
81
|
+
position: fixed;
|
82
|
+
top: 0;
|
83
|
+
right: 0;
|
84
|
+
bottom: 0;
|
85
|
+
left: 0;
|
86
|
+
display: block;
|
87
|
+
cursor: default;
|
88
|
+
content: ' ';
|
89
|
+
background: transparent;
|
90
|
+
z-index: 99;
|
91
|
+
background: ${constants_1.get('colors.primer.canvas.backdrop')};
|
92
|
+
}
|
93
|
+
`;
|
94
|
+
const Dialog = react_1.forwardRef(({ children, onDismiss = noop, isOpen, initialFocusRef, returnFocusRef, ...props }, forwardedRef) => {
|
95
|
+
const overlayRef = react_1.useRef(null);
|
96
|
+
const modalRef = useCombinedRefs_1.useCombinedRefs(forwardedRef);
|
97
|
+
const closeButtonRef = react_1.useRef(null);
|
98
|
+
const onCloseClick = () => {
|
99
|
+
onDismiss();
|
100
|
+
if (returnFocusRef && returnFocusRef.current) {
|
101
|
+
returnFocusRef.current.focus();
|
102
|
+
}
|
103
|
+
};
|
104
|
+
const { getDialogProps } = useDialog_1.default({
|
105
|
+
modalRef,
|
106
|
+
onDismiss: onCloseClick,
|
107
|
+
isOpen,
|
108
|
+
initialFocusRef,
|
109
|
+
closeButtonRef,
|
110
|
+
returnFocusRef,
|
111
|
+
overlayRef
|
112
|
+
});
|
113
|
+
return isOpen ? (<>
|
114
|
+
<Overlay ref={overlayRef}/>
|
115
|
+
<DialogBase tabIndex={-1} ref={modalRef} role="dialog" aria-modal="true" {...props} {...getDialogProps()}>
|
116
|
+
<ButtonClose_1.default ref={closeButtonRef} onClick={onCloseClick} sx={{ position: 'absolute', top: '16px', right: '16px' }}/>
|
117
|
+
{children}
|
118
|
+
</DialogBase>
|
119
|
+
</>) : null;
|
120
|
+
});
|
121
|
+
DialogHeader.defaultProps = {
|
122
|
+
backgroundColor: 'canvas.subtle'
|
123
|
+
};
|
124
|
+
DialogHeader.propTypes = {
|
125
|
+
...Box_1.default.propTypes
|
126
|
+
};
|
127
|
+
DialogHeader.displayName = 'Dialog.Header';
|
128
|
+
Dialog.displayName = 'Dialog';
|
129
|
+
exports.default = Object.assign(Dialog, { Header: DialogHeader });
|
package/lib/Dropdown.d.ts
CHANGED
@@ -307,7 +307,6 @@ declare const _default: {
|
|
307
307
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLElement> | undefined;
|
308
308
|
onTransitionEnd?: React.TransitionEventHandler<HTMLElement> | undefined;
|
309
309
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLElement> | undefined;
|
310
|
-
css?: import("@emotion/core").InterpolationWithTheme<any>;
|
311
310
|
onToggle?: React.ReactEventHandler<HTMLElement> | undefined;
|
312
311
|
} & {
|
313
312
|
theme?: any;
|
@@ -605,7 +604,6 @@ declare const _default: {
|
|
605
604
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLElement> | undefined;
|
606
605
|
onTransitionEnd?: React.TransitionEventHandler<HTMLElement> | undefined;
|
607
606
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLElement> | undefined;
|
608
|
-
css?: import("@emotion/core").InterpolationWithTheme<any>;
|
609
607
|
onToggle?: React.ReactEventHandler<HTMLElement> | undefined;
|
610
608
|
} & {
|
611
609
|
theme?: any;
|
@@ -882,7 +880,6 @@ declare const _default: {
|
|
882
880
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
883
881
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
884
882
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
885
|
-
css?: import("@emotion/core").InterpolationWithTheme<any>;
|
886
883
|
as?: string | React.ComponentClass<any, any> | React.FunctionComponent<any> | undefined;
|
887
884
|
disabled?: boolean | undefined;
|
888
885
|
autoFocus?: boolean | undefined;
|
@@ -1159,7 +1156,6 @@ declare const _default: {
|
|
1159
1156
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
1160
1157
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
1161
1158
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
1162
|
-
css?: import("@emotion/core").InterpolationWithTheme<any>;
|
1163
1159
|
as?: string | React.ComponentClass<any, any> | React.FunctionComponent<any> | undefined;
|
1164
1160
|
disabled?: boolean | undefined;
|
1165
1161
|
autoFocus?: boolean | undefined;
|