@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/Flash.jsx
ADDED
@@ -0,0 +1,69 @@
|
|
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 styled_system_1 = require("styled-system");
|
8
|
+
const constants_1 = require("./constants");
|
9
|
+
const sx_1 = __importDefault(require("./sx"));
|
10
|
+
const variants = styled_system_1.variant({
|
11
|
+
variants: {
|
12
|
+
default: {
|
13
|
+
color: 'fg.default',
|
14
|
+
backgroundColor: 'accent.subtle',
|
15
|
+
borderColor: 'accent.muted',
|
16
|
+
svg: {
|
17
|
+
color: 'accent.fg'
|
18
|
+
}
|
19
|
+
},
|
20
|
+
success: {
|
21
|
+
color: 'fg.default',
|
22
|
+
backgroundColor: 'success.subtle',
|
23
|
+
borderColor: 'success.muted',
|
24
|
+
svg: {
|
25
|
+
color: 'success.fg'
|
26
|
+
}
|
27
|
+
},
|
28
|
+
danger: {
|
29
|
+
color: 'fg.default',
|
30
|
+
backgroundColor: 'danger.subtle',
|
31
|
+
borderColor: 'danger.muted',
|
32
|
+
svg: {
|
33
|
+
color: 'danger.fg'
|
34
|
+
}
|
35
|
+
},
|
36
|
+
warning: {
|
37
|
+
color: 'fg.default',
|
38
|
+
backgroundColor: 'attention.subtle',
|
39
|
+
borderColor: 'attention.muted',
|
40
|
+
svg: {
|
41
|
+
color: 'attention.fg'
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
});
|
46
|
+
const Flash = styled_components_1.default.div `
|
47
|
+
position: relative;
|
48
|
+
color: ${constants_1.get('colors.fg.default')};
|
49
|
+
padding: ${constants_1.get('space.3')};
|
50
|
+
border-style: solid;
|
51
|
+
border-width: ${props => (props.full ? '1px 0px' : '1px')};
|
52
|
+
border-radius: ${props => (props.full ? '0' : constants_1.get('radii.2'))};
|
53
|
+
margin-top: ${props => (props.full ? '-1px' : '0')};
|
54
|
+
|
55
|
+
p:last-child {
|
56
|
+
margin-bottom: 0;
|
57
|
+
}
|
58
|
+
|
59
|
+
svg {
|
60
|
+
margin-right: ${constants_1.get('space.2')};
|
61
|
+
}
|
62
|
+
|
63
|
+
${variants};
|
64
|
+
${sx_1.default};
|
65
|
+
`;
|
66
|
+
Flash.defaultProps = {
|
67
|
+
variant: 'default'
|
68
|
+
};
|
69
|
+
exports.default = Flash;
|
package/lib/Flex.jsx
ADDED
@@ -0,0 +1,15 @@
|
|
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 Box_1 = __importDefault(require("./Box"));
|
8
|
+
/**
|
9
|
+
* @deprecated Use the Box component instead (i.e. <Flex> → <Box display="flex">)
|
10
|
+
*/
|
11
|
+
const Flex = styled_components_1.default(Box_1.default) ``;
|
12
|
+
Flex.defaultProps = {
|
13
|
+
display: 'flex'
|
14
|
+
};
|
15
|
+
exports.default = Flex;
|
@@ -0,0 +1,22 @@
|
|
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 FormGroup = styled_components_1.default.div `
|
10
|
+
margin: ${constants_1.get('space.3')} 0;
|
11
|
+
font-weight: ${constants_1.get('fontWeights.normal')};
|
12
|
+
${sx_1.default};
|
13
|
+
`;
|
14
|
+
const FormGroupLabel = styled_components_1.default.label `
|
15
|
+
display: block;
|
16
|
+
margin: 0 0 ${constants_1.get('space.2')};
|
17
|
+
font-size: ${constants_1.get('fontSizes.1')};
|
18
|
+
font-weight: ${constants_1.get('fontWeights.bold')};
|
19
|
+
${sx_1.default};
|
20
|
+
`;
|
21
|
+
FormGroupLabel.displayName = 'FormGroup.Label';
|
22
|
+
exports.default = Object.assign(FormGroup, { Label: FormGroupLabel });
|
package/lib/Grid.jsx
ADDED
@@ -0,0 +1,15 @@
|
|
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 Box_1 = __importDefault(require("./Box"));
|
8
|
+
/**
|
9
|
+
* @deprecated Use the Box component instead (i.e. <Grid> → <Box display="grid">)
|
10
|
+
*/
|
11
|
+
const Grid = styled_components_1.default(Box_1.default) ``;
|
12
|
+
Grid.defaultProps = {
|
13
|
+
display: 'grid'
|
14
|
+
};
|
15
|
+
exports.default = Grid;
|
package/lib/Header.jsx
ADDED
@@ -0,0 +1,83 @@
|
|
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 styled_components_1 = __importStar(require("styled-components"));
|
26
|
+
const constants_1 = require("./constants");
|
27
|
+
const sx_1 = __importDefault(require("./sx"));
|
28
|
+
const Header = styled_components_1.default.div `
|
29
|
+
z-index: 32;
|
30
|
+
display: flex;
|
31
|
+
padding: ${constants_1.get('space.3')};
|
32
|
+
font-size: ${constants_1.get('fontSizes.1')};
|
33
|
+
line-height: ${constants_1.get('lineHeights.default')};
|
34
|
+
color: ${constants_1.get('colors.header.text')};
|
35
|
+
background-color: ${constants_1.get('colors.header.bg')};
|
36
|
+
align-items: center;
|
37
|
+
flex-wrap: nowrap;
|
38
|
+
|
39
|
+
${sx_1.default};
|
40
|
+
`;
|
41
|
+
const HeaderItem = styled_components_1.default.div `
|
42
|
+
display: flex;
|
43
|
+
margin-right: ${constants_1.get('space.3')};
|
44
|
+
align-self: stretch;
|
45
|
+
align-items: center;
|
46
|
+
flex-wrap: nowrap;
|
47
|
+
|
48
|
+
${({ full }) => full &&
|
49
|
+
styled_components_1.css `
|
50
|
+
flex: auto;
|
51
|
+
`};
|
52
|
+
|
53
|
+
${sx_1.default};
|
54
|
+
`;
|
55
|
+
HeaderItem.displayName = 'Header.Item';
|
56
|
+
const HeaderLink = styled_components_1.default.a.attrs(({ to }) => {
|
57
|
+
const isReactRouter = typeof to === 'string';
|
58
|
+
if (isReactRouter) {
|
59
|
+
// according to their docs, NavLink supports aria-current:
|
60
|
+
// https://reacttraining.com/react-router/web/api/NavLink/aria-current-string
|
61
|
+
return { 'aria-current': 'page' };
|
62
|
+
}
|
63
|
+
else {
|
64
|
+
return {};
|
65
|
+
}
|
66
|
+
}) `
|
67
|
+
font-weight: ${constants_1.get('fontWeights.bold')};
|
68
|
+
color: ${constants_1.get('colors.header.logo')};
|
69
|
+
white-space: nowrap;
|
70
|
+
cursor: pointer;
|
71
|
+
text-decoration: none;
|
72
|
+
display: flex;
|
73
|
+
align-items: center;
|
74
|
+
|
75
|
+
&:hover,
|
76
|
+
&:focus {
|
77
|
+
color: ${constants_1.get('colors.header.text')};
|
78
|
+
}
|
79
|
+
|
80
|
+
${sx_1.default};
|
81
|
+
`;
|
82
|
+
HeaderLink.displayName = 'Header.Link';
|
83
|
+
exports.default = Object.assign(Header, { Link: HeaderLink, Item: HeaderItem });
|
package/lib/Heading.jsx
ADDED
@@ -0,0 +1,21 @@
|
|
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 theme_1 = __importDefault(require("./theme"));
|
10
|
+
const Heading = styled_components_1.default.h2 `
|
11
|
+
font-weight: ${constants_1.get('fontWeights.bold')};
|
12
|
+
font-size: ${constants_1.get('fontSizes.5')};
|
13
|
+
margin: 0;
|
14
|
+
${constants_1.TYPOGRAPHY};
|
15
|
+
${constants_1.COMMON};
|
16
|
+
${sx_1.default};
|
17
|
+
`;
|
18
|
+
Heading.defaultProps = {
|
19
|
+
theme: theme_1.default
|
20
|
+
};
|
21
|
+
exports.default = Heading;
|
package/lib/Label.jsx
ADDED
@@ -0,0 +1,82 @@
|
|
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 styled_components_1 = __importStar(require("styled-components"));
|
26
|
+
const styled_system_1 = require("styled-system");
|
27
|
+
const constants_1 = require("./constants");
|
28
|
+
const sx_1 = __importDefault(require("./sx"));
|
29
|
+
const outlineStyles = styled_components_1.css `
|
30
|
+
margin-top: -1px; // offsets the 1px border
|
31
|
+
margin-bottom: -1px; // offsets the 1px border
|
32
|
+
color: ${constants_1.get('colors.fg.muted')};
|
33
|
+
border: ${constants_1.get('borderWidths.1')} solid ${constants_1.get('colors.border.default')};
|
34
|
+
box-shadow: none;
|
35
|
+
${styled_system_1.borderColor};
|
36
|
+
background-color: transparent;
|
37
|
+
`;
|
38
|
+
const sizeVariant = styled_system_1.variant({
|
39
|
+
variants: {
|
40
|
+
small: {
|
41
|
+
fontSize: 0,
|
42
|
+
lineHeight: '16px',
|
43
|
+
padding: '0px 8px'
|
44
|
+
},
|
45
|
+
medium: {
|
46
|
+
fontSize: 0,
|
47
|
+
lineHeight: '20px',
|
48
|
+
padding: '0 8px'
|
49
|
+
},
|
50
|
+
large: {
|
51
|
+
fontSize: 0,
|
52
|
+
lineHeight: '24px',
|
53
|
+
padding: '0 12px'
|
54
|
+
},
|
55
|
+
// corresponds to StateLabel fontSize/lineHeight/padding
|
56
|
+
xl: {
|
57
|
+
fontSize: 1,
|
58
|
+
lineHeight: '16px',
|
59
|
+
padding: '8px 12px'
|
60
|
+
}
|
61
|
+
}
|
62
|
+
});
|
63
|
+
const Label = styled_components_1.default.span `
|
64
|
+
display: inline-block;
|
65
|
+
font-weight: ${constants_1.get('fontWeights.semibold')};
|
66
|
+
color: ${constants_1.get('colors.fg.onEmphasis')};
|
67
|
+
border-radius: ${constants_1.get('radii.3')};
|
68
|
+
background-color: ${constants_1.get('colors.neutral.emphasis')};
|
69
|
+
|
70
|
+
&:hover {
|
71
|
+
text-decoration: none;
|
72
|
+
}
|
73
|
+
|
74
|
+
${sizeVariant}
|
75
|
+
${props => (props.dropshadow ? 'box-shadow: inset 0 -1px 0 rgba(27, 31, 35, 0.12)' : '')}
|
76
|
+
${props => (props.outline ? outlineStyles : '')} // must be last to override other values
|
77
|
+
${sx_1.default}
|
78
|
+
`;
|
79
|
+
Label.defaultProps = {
|
80
|
+
variant: 'medium'
|
81
|
+
};
|
82
|
+
exports.default = Label;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
7
|
+
const constants_1 = require("./constants");
|
8
|
+
const sx_1 = __importDefault(require("./sx"));
|
9
|
+
const LabelGroup = styled_components_1.default.span `
|
10
|
+
& * {
|
11
|
+
margin-right: ${constants_1.get('space.1')};
|
12
|
+
}
|
13
|
+
& *:last-child {
|
14
|
+
margin-right: 0;
|
15
|
+
}
|
16
|
+
${sx_1.default};
|
17
|
+
`;
|
18
|
+
exports.default = LabelGroup;
|
package/lib/Link.jsx
ADDED
@@ -0,0 +1,36 @@
|
|
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 styled_system_1 = require("styled-system");
|
8
|
+
const constants_1 = require("./constants");
|
9
|
+
const sx_1 = __importDefault(require("./sx"));
|
10
|
+
const hoverColor = styled_system_1.system({
|
11
|
+
hoverColor: {
|
12
|
+
property: 'color',
|
13
|
+
scale: 'colors'
|
14
|
+
}
|
15
|
+
});
|
16
|
+
const Link = styled_components_1.default.a `
|
17
|
+
color: ${props => (props.muted ? constants_1.get('colors.fg.muted')(props) : constants_1.get('colors.accent.fg')(props))};
|
18
|
+
text-decoration: ${props => (props.underline ? 'underline' : 'none')};
|
19
|
+
&:hover {
|
20
|
+
text-decoration: ${props => (props.muted ? 'none' : 'underline')};
|
21
|
+
${props => (props.hoverColor ? hoverColor : props.muted ? `color: ${constants_1.get('colors.accent.fg')(props)}` : '')};
|
22
|
+
}
|
23
|
+
&:is(button) {
|
24
|
+
display: inline-block;
|
25
|
+
padding: 0;
|
26
|
+
font-size: inherit;
|
27
|
+
white-space: nowrap;
|
28
|
+
cursor: pointer;
|
29
|
+
user-select: none;
|
30
|
+
background-color: transparent;
|
31
|
+
border: 0;
|
32
|
+
appearance: none;
|
33
|
+
}
|
34
|
+
${sx_1.default};
|
35
|
+
`;
|
36
|
+
exports.default = Link;
|
@@ -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.Counter = void 0;
|
7
|
+
const react_1 = __importDefault(require("react"));
|
8
|
+
const CounterLabel_1 = __importDefault(require("../CounterLabel"));
|
9
|
+
const Counter = ({ children, sx: sxProp = {}, ...props }) => {
|
10
|
+
return (<CounterLabel_1.default data-component="ButtonCounter" sx={{ ml: 2, ...sxProp }} {...props}>
|
11
|
+
{children}
|
12
|
+
</CounterLabel_1.default>);
|
13
|
+
};
|
14
|
+
exports.Counter = Counter;
|
@@ -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.Button = void 0;
|
26
|
+
const react_1 = __importStar(require("react"));
|
27
|
+
const Box_1 = __importDefault(require("../Box"));
|
28
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
29
|
+
const sx_1 = __importStar(require("../sx"));
|
30
|
+
const ThemeProvider_1 = require("../ThemeProvider");
|
31
|
+
const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
|
32
|
+
const getVariantStyles = (variant = 'default', theme) => {
|
33
|
+
const style = {
|
34
|
+
default: {
|
35
|
+
color: 'btn.text',
|
36
|
+
backgroundColor: 'btn.bg',
|
37
|
+
boxShadow: `${theme?.shadows.btn.shadow}, ${theme?.shadows.btn.insetShadow}`,
|
38
|
+
'&:hover:not([disabled])': {
|
39
|
+
backgroundColor: 'btn.hoverBg'
|
40
|
+
},
|
41
|
+
// focus must come before :active so that the active box shadow overrides
|
42
|
+
'&:focus:not([disabled])': {
|
43
|
+
boxShadow: `${theme?.shadows.btn.focusShadow}`
|
44
|
+
},
|
45
|
+
'&:active:not([disabled])': {
|
46
|
+
backgroundColor: 'btn.selectedBg',
|
47
|
+
boxShadow: `${theme?.shadows.btn.shadowActive}`
|
48
|
+
},
|
49
|
+
'&:disabled': {
|
50
|
+
color: 'primer.fg.disabled',
|
51
|
+
backgroundColor: 'btn.disabledBg'
|
52
|
+
}
|
53
|
+
},
|
54
|
+
primary: {
|
55
|
+
color: 'btn.primary.text',
|
56
|
+
backgroundColor: 'btn.primary.bg',
|
57
|
+
borderColor: 'border.subtle',
|
58
|
+
boxShadow: `${theme?.shadows.btn.primary.shadow}`,
|
59
|
+
'&:hover:not([disabled])': {
|
60
|
+
color: 'btn.primary.hoverText',
|
61
|
+
backgroundColor: 'btn.primary.hoverBg'
|
62
|
+
},
|
63
|
+
// focus must come before :active so that the active box shadow overrides
|
64
|
+
'&:focus:not([disabled])': {
|
65
|
+
boxShadow: `${theme?.shadows.btn.primary.focusShadow}`
|
66
|
+
},
|
67
|
+
'&:active:not([disabled])': {
|
68
|
+
backgroundColor: 'btn.primary.selectedBg',
|
69
|
+
boxShadow: `${theme?.shadows.btn.primary.selectedShadow}`
|
70
|
+
},
|
71
|
+
'&:disabled': {
|
72
|
+
color: 'btn.primary.disabledText',
|
73
|
+
backgroundColor: 'btn.primary.disabledBg'
|
74
|
+
},
|
75
|
+
'[data-component="ButtonCounter"]': {
|
76
|
+
backgroundColor: 'btn.primary.counterBg',
|
77
|
+
color: 'btn.primary.text'
|
78
|
+
}
|
79
|
+
},
|
80
|
+
danger: {
|
81
|
+
color: 'btn.danger.text',
|
82
|
+
backgroundColor: 'btn.bg',
|
83
|
+
boxShadow: `${theme?.shadows.btn.shadow}`,
|
84
|
+
'&:hover:not([disabled])': {
|
85
|
+
color: 'btn.danger.hoverText',
|
86
|
+
backgroundColor: 'btn.danger.hoverBg',
|
87
|
+
borderColor: 'btn.danger.hoverBorder',
|
88
|
+
boxShadow: `${theme?.shadows.btn.danger.hoverShadow}`,
|
89
|
+
'[data-component="ButtonCounter"]': {
|
90
|
+
backgroundColor: 'btn.danger.hoverCounterBg',
|
91
|
+
color: 'btn.danger.hoverText'
|
92
|
+
}
|
93
|
+
},
|
94
|
+
// focus must come before :active so that the active box shadow overrides
|
95
|
+
'&:focus:not([disabled])': {
|
96
|
+
borderColor: 'btn.danger.focusBorder',
|
97
|
+
boxShadow: `${theme?.shadows.btn.danger.focusShadow}`
|
98
|
+
},
|
99
|
+
'&:active:not([disabled])': {
|
100
|
+
color: 'btn.danger.selectedText',
|
101
|
+
backgroundColor: 'btn.danger.selectedBg',
|
102
|
+
boxShadow: `${theme?.shadows.btn.danger.selectedShadow}`,
|
103
|
+
borderColor: 'btn.danger.selectedBorder'
|
104
|
+
},
|
105
|
+
'&:disabled': {
|
106
|
+
color: 'btn.danger.disabledText',
|
107
|
+
backgroundColor: 'btn.danger.disabledBg',
|
108
|
+
borderColor: 'btn.danger.disabledBorder',
|
109
|
+
'[data-component="ButtonCounter"]': {
|
110
|
+
backgroundColor: 'btn.danger.disabledCounterBg'
|
111
|
+
}
|
112
|
+
},
|
113
|
+
'[data-component="ButtonCounter"]': {
|
114
|
+
color: 'btn.danger.text',
|
115
|
+
backgroundColor: 'btn.danger.counterBg'
|
116
|
+
}
|
117
|
+
},
|
118
|
+
invisible: {
|
119
|
+
color: 'accent.fg',
|
120
|
+
backgroundColor: 'transparent',
|
121
|
+
border: '0',
|
122
|
+
boxShadow: 'none',
|
123
|
+
'&:hover:not([disabled])': {
|
124
|
+
backgroundColor: 'btn.hoverBg'
|
125
|
+
},
|
126
|
+
// focus must come before :active so that the active box shadow overrides
|
127
|
+
'&:focus:not([disabled])': {
|
128
|
+
boxShadow: `${theme?.shadows.btn.focusShadow}`
|
129
|
+
},
|
130
|
+
'&:active:not([disabled])': {
|
131
|
+
backgroundColor: 'btn.selectedBg'
|
132
|
+
},
|
133
|
+
'&:disabled': {
|
134
|
+
color: 'primer.fg.disabled'
|
135
|
+
}
|
136
|
+
},
|
137
|
+
outline: {
|
138
|
+
color: 'btn.outline.text',
|
139
|
+
boxShadow: `${theme?.shadows.btn.shadow}`,
|
140
|
+
'&:hover': {
|
141
|
+
color: 'btn.outline.hoverText',
|
142
|
+
backgroundColor: 'btn.outline.hoverBg',
|
143
|
+
borderColor: 'outline.hoverBorder',
|
144
|
+
boxShadow: `${theme?.shadows.btn.outline.hoverShadow}`,
|
145
|
+
'[data-component="ButtonCounter"]': {
|
146
|
+
backgroundColor: 'btn.outline.hoverCounterBg',
|
147
|
+
color: 'btn.outline.hoverText'
|
148
|
+
}
|
149
|
+
},
|
150
|
+
// focus must come before :active so that the active box shadow overrides
|
151
|
+
'&:focus': {
|
152
|
+
borderColor: 'btn.outline.focusBorder',
|
153
|
+
boxShadow: `${theme?.shadows.btn.outline.focusShadow}`
|
154
|
+
},
|
155
|
+
'&:active:not([disabled])': {
|
156
|
+
color: 'btn.outline.selectedText',
|
157
|
+
backgroundColor: 'btn.outline.selectedBg',
|
158
|
+
boxShadow: `${theme?.shadows.btn.outline.selectedShadow}`,
|
159
|
+
borderColor: 'btn.outline.selectedBorder'
|
160
|
+
},
|
161
|
+
'&:disabled': {
|
162
|
+
color: 'btn.outline.disabledText',
|
163
|
+
backgroundColor: 'btn.outline.disabledBg',
|
164
|
+
borderColor: 'btn.border',
|
165
|
+
'[data-component="ButtonCounter"]': {
|
166
|
+
backgroundColor: 'btn.outline.disabledCounterBg'
|
167
|
+
}
|
168
|
+
},
|
169
|
+
'[data-component="ButtonCounter"]': {
|
170
|
+
backgroundColor: 'btn.outline.counterBg',
|
171
|
+
color: 'btn.outline.text'
|
172
|
+
}
|
173
|
+
}
|
174
|
+
};
|
175
|
+
return style[variant];
|
176
|
+
};
|
177
|
+
const getSizeStyles = (size = 'medium', variant = 'default', iconOnly) => {
|
178
|
+
let paddingY, paddingX, fontSize;
|
179
|
+
switch (size) {
|
180
|
+
case 'small':
|
181
|
+
paddingY = 3;
|
182
|
+
paddingX = 12;
|
183
|
+
fontSize = 0;
|
184
|
+
break;
|
185
|
+
case 'large':
|
186
|
+
paddingY = 9;
|
187
|
+
paddingX = 20;
|
188
|
+
fontSize = 2;
|
189
|
+
break;
|
190
|
+
case 'medium':
|
191
|
+
default:
|
192
|
+
paddingY = 5;
|
193
|
+
paddingX = 16;
|
194
|
+
fontSize = 1;
|
195
|
+
}
|
196
|
+
if (iconOnly) {
|
197
|
+
paddingX = paddingY + 2;
|
198
|
+
}
|
199
|
+
if (variant === 'invisible') {
|
200
|
+
paddingY = paddingY + 1;
|
201
|
+
}
|
202
|
+
return {
|
203
|
+
paddingY: `${paddingY}px`,
|
204
|
+
paddingX: `${paddingX}px`,
|
205
|
+
fontSize,
|
206
|
+
'[data-component="ButtonCounter"]': {
|
207
|
+
fontSize
|
208
|
+
}
|
209
|
+
};
|
210
|
+
};
|
211
|
+
const ButtonBase = styled_components_1.default.button(sx_1.default);
|
212
|
+
const Button = react_1.forwardRef(({ children, sx: sxProp = {}, ...props }, forwardedRef) => {
|
213
|
+
const { icon: Icon, leadingIcon: LeadingIcon, trailingIcon: TrailingIcon, variant = 'default', size = 'medium' } = props;
|
214
|
+
const iconOnly = !!Icon;
|
215
|
+
const { theme } = ThemeProvider_1.useTheme();
|
216
|
+
const styles = {
|
217
|
+
borderRadius: '2',
|
218
|
+
border: '1px solid',
|
219
|
+
borderColor: theme?.colors.btn.border,
|
220
|
+
display: 'grid',
|
221
|
+
gridTemplateAreas: '"leadingIcon text trailingIcon"',
|
222
|
+
fontWeight: 'bold',
|
223
|
+
lineHeight: TEXT_ROW_HEIGHT,
|
224
|
+
whiteSpace: 'nowrap',
|
225
|
+
verticalAlign: 'middle',
|
226
|
+
cursor: 'pointer',
|
227
|
+
appearance: 'none',
|
228
|
+
userSelect: 'none',
|
229
|
+
textDecoration: 'none',
|
230
|
+
textAlign: 'center',
|
231
|
+
'& > :not(:last-child)': {
|
232
|
+
mr: '2'
|
233
|
+
},
|
234
|
+
'&:focus': {
|
235
|
+
outline: 'none'
|
236
|
+
},
|
237
|
+
'&:disabled': {
|
238
|
+
cursor: 'default'
|
239
|
+
},
|
240
|
+
'&:disabled svg': {
|
241
|
+
opacity: '0.6'
|
242
|
+
},
|
243
|
+
'[data-component="leadingIcon"]': {
|
244
|
+
gridArea: 'leadingIcon'
|
245
|
+
},
|
246
|
+
'[data-component="text"]': {
|
247
|
+
gridArea: 'text'
|
248
|
+
},
|
249
|
+
'[data-component="trailingIcon"]': {
|
250
|
+
gridArea: 'trailingIcon'
|
251
|
+
}
|
252
|
+
};
|
253
|
+
const iconWrapStyles = {
|
254
|
+
display: 'inline-block'
|
255
|
+
};
|
256
|
+
const sxStyles = sx_1.merge.all([
|
257
|
+
styles,
|
258
|
+
getSizeStyles(size, variant, iconOnly),
|
259
|
+
getVariantStyles(variant, theme),
|
260
|
+
sxProp
|
261
|
+
]);
|
262
|
+
return (<ButtonBase sx={sxStyles} ref={forwardedRef} {...props}>
|
263
|
+
{LeadingIcon && (<Box_1.default as="span" data-component="leadingIcon" sx={iconWrapStyles} aria-hidden={!iconOnly}>
|
264
|
+
<LeadingIcon />
|
265
|
+
</Box_1.default>)}
|
266
|
+
<span data-component="text" hidden={Icon ? true : false}>
|
267
|
+
{children}
|
268
|
+
</span>
|
269
|
+
{Icon && (<Box_1.default data-component="icon-only" as="span" sx={{ display: 'inline-block' }} aria-hidden={!iconOnly}>
|
270
|
+
<Icon />
|
271
|
+
</Box_1.default>)}
|
272
|
+
{TrailingIcon && (<Box_1.default as="span" data-component="trailingIcon" sx={{ ...iconWrapStyles, ml: 2 }} aria-hidden={!iconOnly}>
|
273
|
+
<TrailingIcon />
|
274
|
+
</Box_1.default>)}
|
275
|
+
</ButtonBase>);
|
276
|
+
});
|
277
|
+
exports.Button = Button;
|
278
|
+
Button.displayName = 'Button';
|
279
|
+
Object.assign(Button, {});
|