@primer/components 0.0.0-20211030175556 → 0.0.0-20211030175634
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 +24 -2
- package/dist/browser.esm.js +144 -137
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +128 -121
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.js +3 -3
- package/lib/ActionList/index.js +23 -12
- package/lib/ActionList2/Item.js +3 -1
- package/lib/ActionList2/List.js +1 -2
- package/lib/ActionList2/Selection.js +3 -1
- package/lib/ActionList2/index.js +41 -23
- package/lib/AnchoredOverlay/index.js +12 -4
- package/lib/Autocomplete/Autocomplete.d.ts +1 -0
- package/lib/Autocomplete/AutocompleteInput.d.ts +1 -0
- package/lib/Autocomplete/index.js +14 -7
- package/lib/Button/Button.d.ts +1 -0
- package/lib/Button/ButtonClose.d.ts +2 -1
- package/lib/Button/ButtonDanger.d.ts +1 -0
- package/lib/Button/ButtonInvisible.d.ts +1 -0
- package/lib/Button/ButtonOutline.d.ts +1 -0
- package/lib/Button/ButtonPrimary.d.ts +1 -0
- package/lib/Button/index.js +70 -21
- package/lib/Checkbox.d.ts +29 -0
- package/lib/Checkbox.js +64 -0
- package/lib/CircleOcticon.d.ts +1 -0
- package/lib/Dialog.d.ts +3 -2
- package/lib/Dropdown.d.ts +4 -0
- package/lib/DropdownMenu/DropdownButton.d.ts +2 -1
- package/lib/DropdownMenu/index.js +20 -6
- package/lib/DropdownStyles.js +26 -18
- package/lib/FilterList.d.ts +1 -0
- package/lib/FilteredActionList/index.js +12 -4
- package/lib/NewButton/index.js +12 -5
- package/lib/NewButton/types.js +1 -2
- package/lib/Overlay.d.ts +5 -3
- package/lib/Pagination/index.js +12 -6
- package/lib/Portal/index.js +16 -5
- package/lib/Position.d.ts +4 -4
- package/lib/SelectMenu/SelectMenu.d.ts +10 -4
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/SelectMenu/hooks/useKeyboardNav.js +96 -80
- package/lib/SelectMenu/index.js +14 -7
- package/lib/SelectPanel/index.js +12 -4
- package/lib/TextInputWithTokens.d.ts +1 -0
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/Token/index.js +30 -11
- package/lib/behaviors/anchoredPosition.js +234 -205
- package/lib/behaviors/focusTrap.js +157 -121
- package/lib/behaviors/focusZone.js +509 -434
- package/lib/behaviors/scrollIntoViewingArea.js +35 -18
- package/lib/constants.js +43 -39
- package/lib/drafts.js +30 -20
- package/lib/hooks/index.js +60 -16
- package/lib/hooks/useAnchoredPosition.js +40 -32
- package/lib/hooks/useCombinedRefs.js +36 -32
- package/lib/hooks/useDialog.js +96 -72
- package/lib/hooks/useFocusTrap.js +60 -43
- package/lib/hooks/useFocusZone.js +50 -54
- package/lib/hooks/useOnEscapePress.js +36 -25
- package/lib/hooks/useOpenAndCloseFocus.js +34 -22
- package/lib/hooks/useProvidedRefOrCreate.js +14 -10
- package/lib/hooks/useProvidedStateOrCreate.js +16 -13
- package/lib/hooks/useRenderForcingRef.js +17 -13
- package/lib/hooks/useResizeObserver.js +18 -15
- package/lib/hooks/useSafeTimeout.js +30 -22
- package/lib/hooks/useScrollFlash.js +23 -16
- package/lib/index.d.ts +2 -0
- package/lib/index.js +652 -163
- package/lib/polyfills/eventListenerSignal.js +45 -37
- package/lib/sx.js +22 -10
- package/lib/theme-preval.js +3169 -64
- package/lib/theme.js +12 -3
- package/lib/utils/iterateFocusableElements.js +85 -63
- package/lib/utils/testing.d.ts +2 -1
- package/lib/utils/testing.js +29 -0
- package/lib/utils/theme.js +47 -33
- package/lib/utils/types/AriaRole.js +1 -2
- package/lib/utils/types/ComponentProps.js +1 -2
- package/lib/utils/types/Flatten.js +1 -2
- package/lib/utils/types/KeyPaths.js +1 -2
- package/lib/utils/types/MandateProps.js +1 -16
- package/lib/utils/types/Merge.js +1 -2
- package/lib/utils/types/index.js +69 -16
- package/lib/utils/uniqueId.js +8 -5
- package/lib/utils/use-force-update.js +14 -8
- package/lib/utils/useIsomorphicLayoutEffect.js +11 -8
- package/lib/utils/userAgent.js +12 -8
- package/lib-esm/ActionList/Item.js +3 -3
- package/lib-esm/ActionList2/Item.js +3 -1
- package/lib-esm/ActionList2/List.js +1 -2
- package/lib-esm/ActionList2/Selection.js +3 -1
- package/lib-esm/Autocomplete/Autocomplete.d.ts +1 -0
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +1 -0
- package/lib-esm/Button/Button.d.ts +1 -0
- package/lib-esm/Button/ButtonClose.d.ts +2 -1
- package/lib-esm/Button/ButtonDanger.d.ts +1 -0
- package/lib-esm/Button/ButtonInvisible.d.ts +1 -0
- package/lib-esm/Button/ButtonOutline.d.ts +1 -0
- package/lib-esm/Button/ButtonPrimary.d.ts +1 -0
- package/lib-esm/Checkbox.d.ts +29 -0
- package/lib-esm/Checkbox.js +44 -0
- package/lib-esm/CircleOcticon.d.ts +1 -0
- package/lib-esm/Dialog.d.ts +3 -2
- package/lib-esm/Dropdown.d.ts +4 -0
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +2 -1
- package/lib-esm/FilterList.d.ts +1 -0
- package/lib-esm/Overlay.d.ts +5 -3
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/SelectMenu/SelectMenu.d.ts +10 -4
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +1 -0
- 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 +2 -0
- package/lib-esm/index.js +1 -0
- package/lib-esm/theme-preval.js +446 -0
- package/lib-esm/utils/testing.d.ts +2 -1
- package/lib-esm/utils/testing.js +24 -0
- package/package.json +4 -5
- package/lib/ActionList/Divider.jsx +0 -29
- package/lib/ActionList/Group.jsx +0 -23
- package/lib/ActionList/Header.jsx +0 -66
- package/lib/ActionList/Item.jsx +0 -288
- package/lib/ActionList/List.jsx +0 -138
- package/lib/ActionList2/Description.jsx +0 -29
- package/lib/ActionList2/Divider.jsx +0 -22
- package/lib/ActionList2/Group.jsx +0 -54
- package/lib/ActionList2/Header.d.ts +0 -26
- package/lib/ActionList2/Header.js +0 -55
- package/lib/ActionList2/Header.jsx +0 -36
- package/lib/ActionList2/Item.jsx +0 -174
- package/lib/ActionList2/LinkItem.jsx +0 -28
- package/lib/ActionList2/List.jsx +0 -41
- package/lib/ActionList2/Selection.jsx +0 -50
- package/lib/ActionList2/Visuals.jsx +0 -48
- package/lib/ActionMenu.jsx +0 -73
- package/lib/AnchoredOverlay/AnchoredOverlay.jsx +0 -100
- package/lib/Autocomplete/Autocomplete.jsx +0 -100
- package/lib/Autocomplete/AutocompleteContext.jsx +0 -5
- package/lib/Autocomplete/AutocompleteInput.jsx +0 -113
- package/lib/Autocomplete/AutocompleteMenu.jsx +0 -190
- package/lib/Autocomplete/AutocompleteOverlay.jsx +0 -55
- package/lib/Avatar.jsx +0 -34
- package/lib/AvatarPair.jsx +0 -29
- package/lib/AvatarStack.jsx +0 -151
- package/lib/BaseStyles.jsx +0 -65
- package/lib/BorderBox.jsx +0 -18
- package/lib/Box.jsx +0 -10
- package/lib/BranchName.jsx +0 -20
- package/lib/Breadcrumbs.jsx +0 -71
- package/lib/Button/Button.jsx +0 -40
- package/lib/Button/ButtonBase.jsx +0 -33
- package/lib/Button/ButtonClose.jsx +0 -53
- package/lib/Button/ButtonDanger.jsx +0 -43
- package/lib/Button/ButtonGroup.jsx +0 -55
- package/lib/Button/ButtonInvisible.jsx +0 -32
- package/lib/Button/ButtonOutline.jsx +0 -43
- package/lib/Button/ButtonPrimary.jsx +0 -42
- package/lib/Button/ButtonStyles.jsx +0 -37
- package/lib/Button/ButtonTableList.jsx +0 -46
- package/lib/Caret.jsx +0 -93
- package/lib/CircleBadge.jsx +0 -42
- package/lib/CircleOcticon.jsx +0 -21
- package/lib/CounterLabel.jsx +0 -43
- package/lib/Details.jsx +0 -21
- package/lib/Dialog/ConfirmationDialog.jsx +0 -146
- package/lib/Dialog/Dialog.jsx +0 -279
- package/lib/Dialog.jsx +0 -129
- package/lib/Dropdown.jsx +0 -131
- package/lib/DropdownMenu/DropdownButton.jsx +0 -14
- package/lib/DropdownMenu/DropdownMenu.jsx +0 -70
- package/lib/FilterList.jsx +0 -59
- package/lib/FilteredActionList/FilteredActionList.jsx +0 -100
- package/lib/FilteredSearch.jsx +0 -28
- package/lib/Flash.jsx +0 -69
- package/lib/Flex.jsx +0 -15
- package/lib/FormGroup.jsx +0 -22
- package/lib/Grid.jsx +0 -15
- package/lib/Header.jsx +0 -83
- package/lib/Heading.jsx +0 -21
- package/lib/Label.jsx +0 -82
- package/lib/LabelGroup.jsx +0 -18
- package/lib/Link.jsx +0 -36
- package/lib/NewButton/button-counter.jsx +0 -14
- package/lib/NewButton/button.jsx +0 -279
- package/lib/Overlay.jsx +0 -154
- package/lib/Pagehead.jsx +0 -17
- package/lib/Pagination/Pagination.jsx +0 -161
- package/lib/Pagination/model.jsx +0 -174
- package/lib/PointerBox.jsx +0 -25
- package/lib/Popover.jsx +0 -202
- package/lib/Portal/Portal.jsx +0 -79
- package/lib/Position.jsx +0 -46
- package/lib/ProgressBar.jsx +0 -39
- package/lib/SelectMenu/SelectMenu.jsx +0 -112
- package/lib/SelectMenu/SelectMenuContext.jsx +0 -5
- package/lib/SelectMenu/SelectMenuDivider.jsx +0 -42
- package/lib/SelectMenu/SelectMenuFilter.jsx +0 -58
- package/lib/SelectMenu/SelectMenuFooter.jsx +0 -45
- package/lib/SelectMenu/SelectMenuHeader.jsx +0 -42
- package/lib/SelectMenu/SelectMenuItem.jsx +0 -142
- package/lib/SelectMenu/SelectMenuList.jsx +0 -59
- package/lib/SelectMenu/SelectMenuLoadingAnimation.jsx +0 -22
- package/lib/SelectMenu/SelectMenuModal.jsx +0 -118
- package/lib/SelectMenu/SelectMenuTab.jsx +0 -92
- package/lib/SelectMenu/SelectMenuTabPanel.jsx +0 -42
- package/lib/SelectMenu/SelectMenuTabs.jsx +0 -57
- package/lib/SelectPanel/SelectPanel.jsx +0 -105
- package/lib/SideNav.jsx +0 -173
- package/lib/Spinner.jsx +0 -35
- package/lib/StateLabel.jsx +0 -93
- package/lib/StyledOcticon.jsx +0 -18
- package/lib/SubNav.jsx +0 -101
- package/lib/TabNav.jsx +0 -58
- package/lib/Text.jsx +0 -14
- package/lib/TextInput.jsx +0 -23
- package/lib/TextInputWithTokens.jsx +0 -218
- package/lib/ThemeProvider.jsx +0 -130
- package/lib/Timeline.jsx +0 -123
- package/lib/Token/AvatarToken.jsx +0 -54
- package/lib/Token/IssueLabelToken.jsx +0 -125
- package/lib/Token/Token.jsx +0 -103
- package/lib/Token/TokenBase.jsx +0 -88
- package/lib/Token/_RemoveTokenButton.jsx +0 -108
- package/lib/Token/_TokenTextContainer.jsx +0 -49
- package/lib/Tooltip.jsx +0 -246
- package/lib/Truncate.jsx +0 -24
- package/lib/UnderlineNav.jsx +0 -88
- package/lib/_TextInputWrapper.jsx +0 -120
- package/lib/_UnstyledTextInput.jsx +0 -22
- package/lib/hooks/useDetails.jsx +0 -39
- package/lib/hooks/useOnOutsideClick.jsx +0 -61
- package/lib/hooks/useOverlay.jsx +0 -15
- package/lib/utils/create-slots.jsx +0 -65
- package/lib/utils/deprecate.jsx +0 -59
- package/lib/utils/isNumeric.jsx +0 -7
- package/lib/utils/ssr.jsx +0 -6
- package/lib/utils/test-deprecations.jsx +0 -20
- package/lib/utils/test-helpers.jsx +0 -8
- package/lib/utils/test-matchers.jsx +0 -100
- package/lib/utils/testing.jsx +0 -206
- package/lib-esm/ActionList2/Header.d.ts +0 -26
- package/lib-esm/ActionList2/Header.js +0 -44
package/lib/Header.jsx
DELETED
@@ -1,83 +0,0 @@
|
|
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
DELETED
@@ -1,21 +0,0 @@
|
|
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
DELETED
@@ -1,82 +0,0 @@
|
|
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;
|
package/lib/LabelGroup.jsx
DELETED
@@ -1,18 +0,0 @@
|
|
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
DELETED
@@ -1,36 +0,0 @@
|
|
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;
|
@@ -1,14 +0,0 @@
|
|
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;
|
package/lib/NewButton/button.jsx
DELETED
@@ -1,279 +0,0 @@
|
|
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, {});
|