@primer/components 0.0.0-2021109221452 → 0.0.0-2021109223232

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.
Files changed (175) hide show
  1. package/CHANGELOG.md +5 -3
  2. package/dist/browser.esm.js +178 -178
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +179 -179
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/index.js +23 -12
  7. package/lib/AnchoredOverlay/index.js +12 -4
  8. package/lib/Autocomplete/index.js +14 -7
  9. package/lib/Button/index.js +70 -21
  10. package/lib/DropdownMenu/index.js +20 -6
  11. package/lib/DropdownStyles.js +26 -18
  12. package/lib/FilteredActionList/index.js +12 -4
  13. package/lib/Overlay.js +3 -1
  14. package/lib/Pagination/index.js +12 -6
  15. package/lib/Portal/Portal.js +3 -2
  16. package/lib/Portal/index.js +16 -5
  17. package/lib/SelectMenu/hooks/useKeyboardNav.js +96 -80
  18. package/lib/SelectMenu/index.js +14 -7
  19. package/lib/SelectPanel/index.js +12 -4
  20. package/lib/Token/index.js +30 -11
  21. package/lib/behaviors/anchoredPosition.js +234 -205
  22. package/lib/behaviors/focusTrap.js +157 -121
  23. package/lib/behaviors/focusZone.js +509 -434
  24. package/lib/behaviors/scrollIntoViewingArea.js +35 -18
  25. package/lib/constants.js +43 -39
  26. package/lib/hooks/index.js +60 -16
  27. package/lib/hooks/useAnchoredPosition.js +40 -31
  28. package/lib/hooks/useCombinedRefs.d.ts +2 -2
  29. package/lib/hooks/useCombinedRefs.js +35 -46
  30. package/lib/hooks/useDialog.js +96 -72
  31. package/lib/hooks/useFocusTrap.js +60 -43
  32. package/lib/hooks/useFocusZone.js +50 -54
  33. package/lib/hooks/useOnEscapePress.js +36 -25
  34. package/lib/hooks/useOpenAndCloseFocus.js +34 -22
  35. package/lib/hooks/useProvidedRefOrCreate.js +14 -10
  36. package/lib/hooks/useProvidedStateOrCreate.js +16 -13
  37. package/lib/hooks/useRenderForcingRef.js +17 -13
  38. package/lib/hooks/useResizeObserver.js +18 -15
  39. package/lib/hooks/useSafeTimeout.js +30 -22
  40. package/lib/hooks/useScrollFlash.js +23 -16
  41. package/lib/index.js +636 -161
  42. package/lib/polyfills/eventListenerSignal.js +45 -37
  43. package/lib/sx.js +14 -7
  44. package/lib/theme-preval.js +2945 -64
  45. package/lib/theme.js +12 -3
  46. package/lib/utils/iterateFocusableElements.js +85 -63
  47. package/lib/utils/theme.js +47 -33
  48. package/lib/utils/types/AriaRole.js +1 -2
  49. package/lib/utils/types/ComponentProps.js +1 -2
  50. package/lib/utils/types/Flatten.js +1 -2
  51. package/lib/utils/types/KeyPaths.js +1 -2
  52. package/lib/utils/types/MandateProps.js +1 -16
  53. package/lib/utils/types/Merge.js +1 -2
  54. package/lib/utils/types/index.js +69 -16
  55. package/lib/utils/uniqueId.js +8 -5
  56. package/lib/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  57. package/lib/utils/useIsomorphicLayoutEffect.js +12 -0
  58. package/lib/utils/userAgent.js +12 -8
  59. package/lib-esm/Overlay.js +2 -1
  60. package/lib-esm/Portal/Portal.js +2 -1
  61. package/lib-esm/hooks/useAnchoredPosition.js +2 -1
  62. package/lib-esm/hooks/useCombinedRefs.d.ts +2 -2
  63. package/lib-esm/hooks/useCombinedRefs.js +3 -2
  64. package/lib-esm/hooks/useResizeObserver.js +2 -2
  65. package/lib-esm/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  66. package/lib-esm/utils/useIsomorphicLayoutEffect.js +3 -0
  67. package/package.json +2 -3
  68. package/lib/ActionList/Divider.jsx +0 -29
  69. package/lib/ActionList/Group.jsx +0 -23
  70. package/lib/ActionList/Header.jsx +0 -66
  71. package/lib/ActionList/Item.jsx +0 -301
  72. package/lib/ActionList/List.jsx +0 -138
  73. package/lib/ActionMenu.jsx +0 -73
  74. package/lib/AnchoredOverlay/AnchoredOverlay.jsx +0 -100
  75. package/lib/Autocomplete/Autocomplete.jsx +0 -100
  76. package/lib/Autocomplete/AutocompleteContext.jsx +0 -5
  77. package/lib/Autocomplete/AutocompleteInput.jsx +0 -113
  78. package/lib/Autocomplete/AutocompleteMenu.jsx +0 -190
  79. package/lib/Autocomplete/AutocompleteOverlay.jsx +0 -55
  80. package/lib/Avatar.jsx +0 -34
  81. package/lib/AvatarPair.jsx +0 -29
  82. package/lib/AvatarStack.jsx +0 -151
  83. package/lib/BaseStyles.jsx +0 -65
  84. package/lib/BorderBox.jsx +0 -18
  85. package/lib/Box.jsx +0 -10
  86. package/lib/BranchName.jsx +0 -20
  87. package/lib/Breadcrumbs.jsx +0 -74
  88. package/lib/Button/Button.jsx +0 -60
  89. package/lib/Button/ButtonBase.jsx +0 -36
  90. package/lib/Button/ButtonClose.jsx +0 -55
  91. package/lib/Button/ButtonDanger.jsx +0 -63
  92. package/lib/Button/ButtonGroup.jsx +0 -55
  93. package/lib/Button/ButtonInvisible.jsx +0 -52
  94. package/lib/Button/ButtonOutline.jsx +0 -63
  95. package/lib/Button/ButtonPrimary.jsx +0 -62
  96. package/lib/Button/ButtonStyles.jsx +0 -37
  97. package/lib/Button/ButtonTableList.jsx +0 -49
  98. package/lib/Caret.jsx +0 -93
  99. package/lib/CircleBadge.jsx +0 -43
  100. package/lib/CircleOcticon.jsx +0 -21
  101. package/lib/CounterLabel.jsx +0 -44
  102. package/lib/Details.jsx +0 -21
  103. package/lib/Dialog/ConfirmationDialog.jsx +0 -146
  104. package/lib/Dialog/Dialog.jsx +0 -273
  105. package/lib/Dialog.jsx +0 -131
  106. package/lib/Dropdown.jsx +0 -134
  107. package/lib/DropdownMenu/DropdownButton.jsx +0 -14
  108. package/lib/DropdownMenu/DropdownMenu.jsx +0 -70
  109. package/lib/FilterList.jsx +0 -63
  110. package/lib/FilteredActionList/FilteredActionList.jsx +0 -100
  111. package/lib/FilteredSearch.jsx +0 -29
  112. package/lib/Flash.jsx +0 -70
  113. package/lib/Flex.jsx +0 -15
  114. package/lib/FormGroup.jsx +0 -25
  115. package/lib/Grid.jsx +0 -15
  116. package/lib/Header.jsx +0 -90
  117. package/lib/Heading.jsx +0 -21
  118. package/lib/Label.jsx +0 -84
  119. package/lib/LabelGroup.jsx +0 -19
  120. package/lib/Link.jsx +0 -38
  121. package/lib/Overlay.jsx +0 -155
  122. package/lib/Pagehead.jsx +0 -18
  123. package/lib/Pagination/Pagination.jsx +0 -163
  124. package/lib/Pagination/model.jsx +0 -174
  125. package/lib/PointerBox.jsx +0 -25
  126. package/lib/Popover.jsx +0 -210
  127. package/lib/Portal/Portal.jsx +0 -78
  128. package/lib/Position.jsx +0 -46
  129. package/lib/ProgressBar.jsx +0 -39
  130. package/lib/SelectMenu/SelectMenu.jsx +0 -114
  131. package/lib/SelectMenu/SelectMenuContext.jsx +0 -5
  132. package/lib/SelectMenu/SelectMenuDivider.jsx +0 -43
  133. package/lib/SelectMenu/SelectMenuFilter.jsx +0 -59
  134. package/lib/SelectMenu/SelectMenuFooter.jsx +0 -46
  135. package/lib/SelectMenu/SelectMenuHeader.jsx +0 -44
  136. package/lib/SelectMenu/SelectMenuItem.jsx +0 -143
  137. package/lib/SelectMenu/SelectMenuList.jsx +0 -60
  138. package/lib/SelectMenu/SelectMenuLoadingAnimation.jsx +0 -21
  139. package/lib/SelectMenu/SelectMenuModal.jsx +0 -119
  140. package/lib/SelectMenu/SelectMenuTab.jsx +0 -93
  141. package/lib/SelectMenu/SelectMenuTabPanel.jsx +0 -43
  142. package/lib/SelectMenu/SelectMenuTabs.jsx +0 -58
  143. package/lib/SelectPanel/SelectPanel.jsx +0 -105
  144. package/lib/SideNav.jsx +0 -177
  145. package/lib/Spinner.jsx +0 -35
  146. package/lib/StateLabel.jsx +0 -89
  147. package/lib/StyledOcticon.jsx +0 -20
  148. package/lib/SubNav.jsx +0 -104
  149. package/lib/TabNav.jsx +0 -60
  150. package/lib/Text.jsx +0 -14
  151. package/lib/TextInput.jsx +0 -23
  152. package/lib/TextInputWithTokens.jsx +0 -218
  153. package/lib/ThemeProvider.jsx +0 -130
  154. package/lib/Timeline.jsx +0 -124
  155. package/lib/Token/AvatarToken.jsx +0 -54
  156. package/lib/Token/IssueLabelToken.jsx +0 -125
  157. package/lib/Token/Token.jsx +0 -103
  158. package/lib/Token/TokenBase.jsx +0 -88
  159. package/lib/Token/_RemoveTokenButton.jsx +0 -108
  160. package/lib/Token/_TokenTextContainer.jsx +0 -49
  161. package/lib/Tooltip.jsx +0 -246
  162. package/lib/Truncate.jsx +0 -27
  163. package/lib/UnderlineNav.jsx +0 -90
  164. package/lib/_TextInputWrapper.jsx +0 -114
  165. package/lib/_UnstyledTextInput.jsx +0 -22
  166. package/lib/hooks/useDetails.jsx +0 -39
  167. package/lib/hooks/useOnOutsideClick.jsx +0 -61
  168. package/lib/hooks/useOverlay.jsx +0 -15
  169. package/lib/utils/deprecate.jsx +0 -59
  170. package/lib/utils/isNumeric.jsx +0 -7
  171. package/lib/utils/ssr.jsx +0 -6
  172. package/lib/utils/test-deprecations.jsx +0 -20
  173. package/lib/utils/test-helpers.jsx +0 -8
  174. package/lib/utils/test-matchers.jsx +0 -100
  175. package/lib/utils/testing.jsx +0 -206
@@ -1,100 +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.FilteredActionList = void 0;
26
- const react_1 = __importStar(require("react"));
27
- const ssr_1 = require("@react-aria/ssr");
28
- const TextInput_1 = __importDefault(require("../TextInput"));
29
- const Box_1 = __importDefault(require("../Box"));
30
- const ActionList_1 = require("../ActionList");
31
- const Spinner_1 = __importDefault(require("../Spinner"));
32
- const useFocusZone_1 = require("../hooks/useFocusZone");
33
- const useProvidedStateOrCreate_1 = require("../hooks/useProvidedStateOrCreate");
34
- const styled_components_1 = __importDefault(require("styled-components"));
35
- const constants_1 = require("../constants");
36
- const useProvidedRefOrCreate_1 = require("../hooks/useProvidedRefOrCreate");
37
- const useScrollFlash_1 = __importDefault(require("../hooks/useScrollFlash"));
38
- const scrollIntoViewingArea_1 = require("../behaviors/scrollIntoViewingArea");
39
- const StyledHeader = styled_components_1.default.div `
40
- box-shadow: 0 1px 0 ${constants_1.get('colors.border.default')};
41
- z-index: 1;
42
- `;
43
- function FilteredActionList({ loading = false, placeholderText, filterValue: externalFilterValue, onFilterChange, items, textInputProps, inputRef: providedInputRef, sx, ...listProps }) {
44
- const [filterValue, setInternalFilterValue] = useProvidedStateOrCreate_1.useProvidedStateOrCreate(externalFilterValue, undefined, '');
45
- const onInputChange = react_1.useCallback((e) => {
46
- const value = e.target.value;
47
- onFilterChange(value, e);
48
- setInternalFilterValue(value);
49
- }, [onFilterChange, setInternalFilterValue]);
50
- const scrollContainerRef = react_1.useRef(null);
51
- const listContainerRef = react_1.useRef(null);
52
- const inputRef = useProvidedRefOrCreate_1.useProvidedRefOrCreate(providedInputRef);
53
- const activeDescendantRef = react_1.useRef();
54
- const listId = ssr_1.useSSRSafeId();
55
- const onInputKeyPress = react_1.useCallback(event => {
56
- if (event.key === 'Enter' && activeDescendantRef.current) {
57
- event.preventDefault();
58
- event.nativeEvent.stopImmediatePropagation();
59
- // Forward Enter key press to active descendant so that item gets activated
60
- const activeDescendantEvent = new KeyboardEvent(event.type, event.nativeEvent);
61
- activeDescendantRef.current.dispatchEvent(activeDescendantEvent);
62
- }
63
- }, [activeDescendantRef]);
64
- useFocusZone_1.useFocusZone({
65
- containerRef: listContainerRef,
66
- focusOutBehavior: 'wrap',
67
- focusableElementFilter: element => {
68
- return !(element instanceof HTMLInputElement);
69
- },
70
- activeDescendantFocus: inputRef,
71
- onActiveDescendantChanged: (current, previous, directlyActivated) => {
72
- activeDescendantRef.current = current;
73
- if (current && scrollContainerRef.current && directlyActivated) {
74
- scrollIntoViewingArea_1.scrollIntoViewingArea(current, scrollContainerRef.current);
75
- }
76
- }
77
- }, [
78
- // List ref isn't set while loading. Need to re-bind focus zone when it changes
79
- loading
80
- ]);
81
- react_1.useEffect(() => {
82
- // if items changed, we want to instantly move active descendant into view
83
- if (activeDescendantRef.current && scrollContainerRef.current) {
84
- scrollIntoViewingArea_1.scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, 'vertical', undefined, undefined, 'auto');
85
- }
86
- }, [items]);
87
- useScrollFlash_1.default(scrollContainerRef);
88
- return (<Box_1.default display="flex" flexDirection="column" overflow="hidden" sx={sx}>
89
- <StyledHeader>
90
- <TextInput_1.default ref={inputRef} block width="auto" color="fg.default" value={filterValue} onChange={onInputChange} onKeyPress={onInputKeyPress} placeholder={placeholderText} aria-label={placeholderText} aria-controls={listId} {...textInputProps}/>
91
- </StyledHeader>
92
- <Box_1.default ref={scrollContainerRef} overflow="auto">
93
- {loading ? (<Box_1.default width="100%" display="flex" flexDirection="row" justifyContent="center" pt={6} pb={7}>
94
- <Spinner_1.default />
95
- </Box_1.default>) : (<ActionList_1.ActionList ref={listContainerRef} items={items} {...listProps} role="listbox" id={listId}/>)}
96
- </Box_1.default>
97
- </Box_1.default>);
98
- }
99
- exports.FilteredActionList = FilteredActionList;
100
- FilteredActionList.displayName = 'FilteredActionList';
@@ -1,29 +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 FilteredSearch = styled_components_1.default.div `
10
- ${constants_1.COMMON};
11
- display: flex;
12
- align-items: stretch;
13
-
14
- summary {
15
- border-radius: 0;
16
- border-top-left-radius: ${constants_1.get('radii.2')};
17
- border-bottom-left-radius: ${constants_1.get('radii.2')};
18
- border-right: 0;
19
- }
20
- .TextInput-wrapper {
21
- border-radius: 0;
22
- border-top-right-radius: ${constants_1.get('radii.2')};
23
- border-bottom-right-radius: ${constants_1.get('radii.2')};
24
- z-index: 1; // Allows the focus outline to show on top of the dropdown.
25
- }
26
-
27
- ${sx_1.default}
28
- `;
29
- exports.default = FilteredSearch;
package/lib/Flash.jsx DELETED
@@ -1,70 +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 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
- ${constants_1.COMMON};
64
- ${variants};
65
- ${sx_1.default};
66
- `;
67
- Flash.defaultProps = {
68
- variant: 'default'
69
- };
70
- exports.default = Flash;
package/lib/Flex.jsx DELETED
@@ -1,15 +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 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;
package/lib/FormGroup.jsx DELETED
@@ -1,25 +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 FormGroup = styled_components_1.default.div `
10
- margin: ${constants_1.get('space.3')} 0;
11
- font-weight: ${constants_1.get('fontWeights.normal')};
12
- ${constants_1.COMMON};
13
- ${sx_1.default};
14
- `;
15
- const FormGroupLabel = styled_components_1.default.label `
16
- display: block;
17
- margin: 0 0 ${constants_1.get('space.2')};
18
- font-size: ${constants_1.get('fontSizes.1')};
19
- font-weight: ${constants_1.get('fontWeights.bold')};
20
- ${constants_1.TYPOGRAPHY};
21
- ${constants_1.COMMON};
22
- ${sx_1.default};
23
- `;
24
- FormGroupLabel.displayName = 'FormGroup.Label';
25
- exports.default = Object.assign(FormGroup, { Label: FormGroupLabel });
package/lib/Grid.jsx DELETED
@@ -1,15 +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 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 DELETED
@@ -1,90 +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
- ${constants_1.COMMON}
40
- ${constants_1.BORDER}
41
- ${sx_1.default};
42
- `;
43
- const HeaderItem = styled_components_1.default.div `
44
- display: flex;
45
- margin-right: ${constants_1.get('space.3')};
46
- align-self: stretch;
47
- align-items: center;
48
- flex-wrap: nowrap;
49
-
50
- ${({ full }) => full &&
51
- styled_components_1.css `
52
- flex: auto;
53
- `};
54
-
55
- ${constants_1.COMMON};
56
- ${constants_1.BORDER};
57
- ${sx_1.default};
58
- `;
59
- HeaderItem.displayName = 'Header.Item';
60
- const HeaderLink = styled_components_1.default.a.attrs(({ to }) => {
61
- const isReactRouter = typeof to === 'string';
62
- if (isReactRouter) {
63
- // according to their docs, NavLink supports aria-current:
64
- // https://reacttraining.com/react-router/web/api/NavLink/aria-current-string
65
- return { 'aria-current': 'page' };
66
- }
67
- else {
68
- return {};
69
- }
70
- }) `
71
- font-weight: ${constants_1.get('fontWeights.bold')};
72
- color: ${constants_1.get('colors.header.logo')};
73
- white-space: nowrap;
74
- cursor: pointer;
75
- text-decoration: none;
76
- display: flex;
77
- align-items: center;
78
-
79
- &:hover,
80
- &:focus {
81
- color: ${constants_1.get('colors.header.text')};
82
- }
83
-
84
- ${constants_1.COMMON};
85
- ${constants_1.BORDER};
86
- ${constants_1.TYPOGRAPHY};
87
- ${sx_1.default};
88
- `;
89
- HeaderLink.displayName = 'Header.Link';
90
- 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,84 +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
- ${constants_1.COMMON};
37
- background-color: transparent;
38
- `;
39
- const sizeVariant = styled_system_1.variant({
40
- variants: {
41
- small: {
42
- fontSize: 0,
43
- lineHeight: '16px',
44
- padding: '0px 8px'
45
- },
46
- medium: {
47
- fontSize: 0,
48
- lineHeight: '20px',
49
- padding: '0 8px'
50
- },
51
- large: {
52
- fontSize: 0,
53
- lineHeight: '24px',
54
- padding: '0 12px'
55
- },
56
- // corresponds to StateLabel fontSize/lineHeight/padding
57
- xl: {
58
- fontSize: 1,
59
- lineHeight: '16px',
60
- padding: '8px 12px'
61
- }
62
- }
63
- });
64
- const Label = styled_components_1.default.span `
65
- display: inline-block;
66
- font-weight: ${constants_1.get('fontWeights.semibold')};
67
- color: ${constants_1.get('colors.fg.onEmphasis')};
68
- border-radius: ${constants_1.get('radii.3')};
69
-
70
- &:hover {
71
- text-decoration: none;
72
- }
73
-
74
- ${sizeVariant}
75
- ${constants_1.COMMON}
76
- ${props => (props.dropshadow ? 'box-shadow: inset 0 -1px 0 rgba(27, 31, 35, 0.12)' : '')}
77
- ${props => (props.outline ? outlineStyles : '')} // must be last to override other values
78
- ${sx_1.default}
79
- `;
80
- Label.defaultProps = {
81
- bg: 'neutral.emphasis',
82
- variant: 'medium'
83
- };
84
- exports.default = Label;
@@ -1,19 +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
- ${constants_1.COMMON}
11
- & * {
12
- margin-right: ${constants_1.get('space.1')};
13
- }
14
- & *:last-child {
15
- margin-right: 0;
16
- }
17
- ${sx_1.default};
18
- `;
19
- exports.default = LabelGroup;
package/lib/Link.jsx DELETED
@@ -1,38 +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
- ${constants_1.TYPOGRAPHY};
35
- ${constants_1.COMMON};
36
- ${sx_1.default};
37
- `;
38
- exports.default = Link;
package/lib/Overlay.jsx DELETED
@@ -1,155 +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 = __importDefault(require("styled-components"));
26
- const react_1 = __importStar(require("react"));
27
- const constants_1 = require("./constants");
28
- const hooks_1 = require("./hooks");
29
- const Portal_1 = __importDefault(require("./Portal"));
30
- const sx_1 = __importDefault(require("./sx"));
31
- const useCombinedRefs_1 = require("./hooks/useCombinedRefs");
32
- const ThemeProvider_1 = require("./ThemeProvider");
33
- const heightMap = {
34
- xsmall: '192px',
35
- small: '256px',
36
- medium: '320px',
37
- large: '432px',
38
- xlarge: '600px',
39
- auto: 'auto',
40
- initial: 'auto' // Passing 'initial' initially applies 'auto'
41
- };
42
- const widthMap = {
43
- small: '256px',
44
- medium: '320px',
45
- large: '480px',
46
- xlarge: '640px',
47
- xxlarge: '960px',
48
- auto: 'auto'
49
- };
50
- const animationDuration = 200;
51
- function getSlideAnimationStartingVector(anchorSide) {
52
- if (anchorSide?.endsWith('bottom')) {
53
- return { x: 0, y: -1 };
54
- }
55
- else if (anchorSide?.endsWith('top')) {
56
- return { x: 0, y: 1 };
57
- }
58
- else if (anchorSide?.endsWith('right')) {
59
- return { x: -1, y: 0 };
60
- }
61
- else if (anchorSide?.endsWith('left')) {
62
- return { x: 1, y: 0 };
63
- }
64
- return { x: 0, y: 0 };
65
- }
66
- const StyledOverlay = styled_components_1.default.div `
67
- background-color: ${constants_1.get('colors.canvas.overlay')};
68
- box-shadow: ${constants_1.get('shadows.overlay.shadow')};
69
- position: absolute;
70
- min-width: 192px;
71
- max-width: 640px;
72
- height: ${props => heightMap[props.height || 'auto']};
73
- max-height: ${props => props.maxHeight && heightMap[props.maxHeight]};
74
- width: ${props => widthMap[props.width || 'auto']};
75
- border-radius: 12px;
76
- overflow: hidden;
77
- animation: overlay-appear ${animationDuration}ms ${constants_1.get('animation.easeOutCubic')};
78
-
79
- @keyframes overlay-appear {
80
- 0% {
81
- opacity: 0;
82
- }
83
- 100% {
84
- opacity: 1;
85
- }
86
- }
87
- visibility: var(--styled-overlay-visibility);
88
- :focus {
89
- outline: none;
90
- }
91
- ${constants_1.COMMON};
92
- ${sx_1.default};
93
- `;
94
- /**
95
- * An `Overlay` is a flexible floating surface, used to display transient content such as menus,
96
- * selection options, dialogs, and more. Overlays use shadows to express elevation. The `Overlay`
97
- * component handles all behaviors needed by overlay UIs as well as the common styles that all overlays * should have.
98
- * @param ignoreClickRefs Optional. An array of ref objects to ignore clicks on in the `onOutsideClick` behavior. This is often used to ignore clicking on the element that toggles the open/closed state for the `Overlay` to prevent the `Overlay` from being toggled twice.
99
- * @param initialFocusRef Optional. Ref for the element to focus when the `Overlay` is opened. If nothing is provided, the first focusable element in the `Overlay` body is focused.
100
- * @param returnFocusRef Required. Ref for the element to focus when the `Overlay` is closed.
101
- * @param onClickOutside Required. Function to call when clicking outside of the `Overlay`. Typically this function removes the Overlay.
102
- * @param onEscape Required. Function to call when user presses `Escape`. Typically this function removes the Overlay.
103
- * @param width Sets the width of the `Overlay`, pick from our set list of widths, or pass `auto` to automatically set the width based on the content of the `Overlay`. `small` corresponds to `256px`, `medium` corresponds to `320px`, `large` corresponds to `480px`, `xlarge` corresponds to `640px`, `xxlarge` corresponds to `960px`.
104
- * @param height Sets the height of the `Overlay`, pick from our set list of heights, or pass `auto` to automatically set the height based on the content of the `Overlay`, or pass `initial` to set the height based on the initial content of the `Overlay` (i.e. ignoring content changes). `xsmall` corresponds to `192px`, `small` corresponds to `256px`, `medium` corresponds to `320px`, `large` corresponds to `432px`, `xlarge` corresponds to `600px`.
105
- * @param maxHeight Sets the maximum height of the `Overlay`, pick from our set list of heights. `xsmall` corresponds to `192px`, `small` corresponds to `256px`, `medium` corresponds to `320px`, `large` corresponds to `432px`, `xlarge` corresponds to `600px`.
106
- * @param anchorSide If provided, the Overlay will slide into position from the side of the anchor with a brief animation
107
- * @param top Optional. Vertical position of the overlay, relative to its closest positioned ancestor (often its `Portal`).
108
- * @param left Optional. Horizontal position of the overlay, relative to its closest positioned ancestor (often its `Portal`).
109
- * @param portalContainerName Optional. The name of the portal container to render the Overlay into.
110
- */
111
- const Overlay = react_1.default.forwardRef(({ onClickOutside, role = 'none', initialFocusRef, returnFocusRef, ignoreClickRefs, onEscape, visibility = 'visible', height, top, left, anchorSide, portalContainerName, preventFocusOnOpen, ...rest }, forwardedRef) => {
112
- const overlayRef = react_1.useRef(null);
113
- const combinedRef = useCombinedRefs_1.useCombinedRefs(overlayRef, forwardedRef);
114
- const { theme } = ThemeProvider_1.useTheme();
115
- const slideAnimationDistance = parseInt(constants_1.get('space.2')(theme).replace('px', ''));
116
- const slideAnimationEasing = constants_1.get('animation.easeOutCubic')(theme);
117
- hooks_1.useOverlay({
118
- overlayRef,
119
- returnFocusRef,
120
- onEscape,
121
- ignoreClickRefs,
122
- onClickOutside,
123
- initialFocusRef,
124
- preventFocusOnOpen
125
- });
126
- react_1.useEffect(() => {
127
- if (height === 'initial' && combinedRef.current?.clientHeight) {
128
- combinedRef.current.style.height = `${combinedRef.current.clientHeight}px`;
129
- }
130
- }, [height, combinedRef]);
131
- react_1.useLayoutEffect(() => {
132
- const { x, y } = getSlideAnimationStartingVector(anchorSide);
133
- if ((!x && !y) || !overlayRef.current?.animate || visibility === 'hidden') {
134
- return;
135
- }
136
- // JS animation is required because Safari does not allow css animations to start paused and then run
137
- overlayRef.current.animate({ transform: [`translate(${slideAnimationDistance * x}px, ${slideAnimationDistance * y}px)`, `translate(0, 0)`] }, {
138
- duration: animationDuration,
139
- easing: slideAnimationEasing
140
- });
141
- }, [anchorSide, slideAnimationDistance, slideAnimationEasing, visibility]);
142
- return (<Portal_1.default containerName={portalContainerName}>
143
- <StyledOverlay height={height} role={role} {...rest} ref={combinedRef} style={{
144
- top: `${top || 0}px`,
145
- left: `${left || 0}px`,
146
- ...rest.style,
147
- '--styled-overlay-visibility': visibility
148
- }}/>
149
- </Portal_1.default>);
150
- });
151
- Overlay.defaultProps = {
152
- height: 'auto',
153
- width: 'auto'
154
- };
155
- exports.default = Overlay;