@primer/components 0.0.0-20211030175556 → 0.0.0-20211030182910

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 (272) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/dist/browser.esm.js +186 -183
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +190 -187
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/Item.js +3 -3
  7. package/lib/ActionList/index.js +23 -12
  8. package/lib/ActionList2/Item.js +3 -1
  9. package/lib/ActionList2/List.js +1 -2
  10. package/lib/ActionList2/Selection.js +3 -1
  11. package/lib/ActionList2/index.js +41 -23
  12. package/lib/AnchoredOverlay/index.js +12 -4
  13. package/lib/Autocomplete/Autocomplete.d.ts +1 -0
  14. package/lib/Autocomplete/AutocompleteInput.d.ts +1 -0
  15. package/lib/Autocomplete/index.js +14 -7
  16. package/lib/Avatar.d.ts +1 -2
  17. package/lib/Avatar.js +1 -1
  18. package/lib/BranchName.d.ts +1 -2
  19. package/lib/BranchName.js +1 -1
  20. package/lib/Button/Button.d.ts +1 -0
  21. package/lib/Button/ButtonClose.d.ts +2 -1
  22. package/lib/Button/ButtonDanger.d.ts +1 -0
  23. package/lib/Button/ButtonInvisible.d.ts +1 -0
  24. package/lib/Button/ButtonOutline.d.ts +1 -0
  25. package/lib/Button/ButtonPrimary.d.ts +1 -0
  26. package/lib/Button/index.js +70 -21
  27. package/lib/Checkbox.d.ts +29 -0
  28. package/lib/Checkbox.js +64 -0
  29. package/lib/CircleOcticon.d.ts +1 -0
  30. package/lib/Details.d.ts +1 -2
  31. package/lib/Details.js +1 -3
  32. package/lib/Dialog.d.ts +3 -2
  33. package/lib/Dropdown.d.ts +6 -66
  34. package/lib/DropdownMenu/DropdownButton.d.ts +2 -1
  35. package/lib/DropdownMenu/index.js +20 -6
  36. package/lib/DropdownStyles.js +26 -18
  37. package/lib/FilterList.d.ts +1 -0
  38. package/lib/FilteredActionList/index.js +12 -4
  39. package/lib/Heading.d.ts +1 -2
  40. package/lib/Heading.js +1 -6
  41. package/lib/NewButton/index.js +12 -5
  42. package/lib/NewButton/types.js +1 -2
  43. package/lib/Overlay.d.ts +5 -3
  44. package/lib/Pagination/index.js +12 -6
  45. package/lib/Portal/index.js +16 -5
  46. package/lib/Position.d.ts +4 -4
  47. package/lib/ProgressBar.d.ts +16 -11
  48. package/lib/ProgressBar.js +6 -10
  49. package/lib/SelectMenu/SelectMenu.d.ts +10 -4
  50. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  51. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  52. package/lib/SelectMenu/hooks/useKeyboardNav.js +96 -80
  53. package/lib/SelectMenu/index.js +14 -7
  54. package/lib/SelectPanel/index.js +12 -4
  55. package/lib/Spinner.d.ts +1 -2
  56. package/lib/Spinner.js +1 -3
  57. package/lib/TextInputWithTokens.d.ts +1 -0
  58. package/lib/Token/AvatarToken.d.ts +1 -1
  59. package/lib/Token/IssueLabelToken.d.ts +1 -1
  60. package/lib/Token/Token.d.ts +1 -1
  61. package/lib/Token/index.js +30 -11
  62. package/lib/behaviors/anchoredPosition.js +234 -205
  63. package/lib/behaviors/focusTrap.js +157 -121
  64. package/lib/behaviors/focusZone.js +509 -434
  65. package/lib/behaviors/scrollIntoViewingArea.js +35 -18
  66. package/lib/constants.js +43 -39
  67. package/lib/drafts.js +30 -20
  68. package/lib/hooks/index.js +60 -16
  69. package/lib/hooks/useAnchoredPosition.js +40 -32
  70. package/lib/hooks/useCombinedRefs.js +36 -32
  71. package/lib/hooks/useDialog.js +96 -72
  72. package/lib/hooks/useFocusTrap.js +60 -43
  73. package/lib/hooks/useFocusZone.js +50 -54
  74. package/lib/hooks/useOnEscapePress.js +36 -25
  75. package/lib/hooks/useOpenAndCloseFocus.js +34 -22
  76. package/lib/hooks/useProvidedRefOrCreate.js +14 -10
  77. package/lib/hooks/useProvidedStateOrCreate.js +16 -13
  78. package/lib/hooks/useRenderForcingRef.js +17 -13
  79. package/lib/hooks/useResizeObserver.js +18 -15
  80. package/lib/hooks/useSafeTimeout.js +30 -22
  81. package/lib/hooks/useScrollFlash.js +23 -16
  82. package/lib/index.d.ts +2 -0
  83. package/lib/index.js +652 -163
  84. package/lib/polyfills/eventListenerSignal.js +45 -37
  85. package/lib/sx.js +22 -10
  86. package/lib/theme-preval.js +3169 -64
  87. package/lib/theme.js +12 -3
  88. package/lib/utils/iterateFocusableElements.js +85 -63
  89. package/lib/utils/testing.d.ts +2 -1
  90. package/lib/utils/testing.js +29 -0
  91. package/lib/utils/theme.js +47 -33
  92. package/lib/utils/types/AriaRole.js +1 -2
  93. package/lib/utils/types/ComponentProps.js +1 -2
  94. package/lib/utils/types/Flatten.js +1 -2
  95. package/lib/utils/types/KeyPaths.js +1 -2
  96. package/lib/utils/types/MandateProps.js +1 -16
  97. package/lib/utils/types/Merge.js +1 -2
  98. package/lib/utils/types/index.js +69 -16
  99. package/lib/utils/uniqueId.js +8 -5
  100. package/lib/utils/use-force-update.js +14 -8
  101. package/lib/utils/useIsomorphicLayoutEffect.js +11 -8
  102. package/lib/utils/userAgent.js +12 -8
  103. package/lib-esm/ActionList/Item.js +3 -3
  104. package/lib-esm/ActionList2/Item.js +3 -1
  105. package/lib-esm/ActionList2/List.js +1 -2
  106. package/lib-esm/ActionList2/Selection.js +3 -1
  107. package/lib-esm/Autocomplete/Autocomplete.d.ts +1 -0
  108. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +1 -0
  109. package/lib-esm/Avatar.d.ts +1 -2
  110. package/lib-esm/Avatar.js +2 -2
  111. package/lib-esm/BranchName.d.ts +1 -2
  112. package/lib-esm/BranchName.js +2 -2
  113. package/lib-esm/Button/Button.d.ts +1 -0
  114. package/lib-esm/Button/ButtonClose.d.ts +2 -1
  115. package/lib-esm/Button/ButtonDanger.d.ts +1 -0
  116. package/lib-esm/Button/ButtonInvisible.d.ts +1 -0
  117. package/lib-esm/Button/ButtonOutline.d.ts +1 -0
  118. package/lib-esm/Button/ButtonPrimary.d.ts +1 -0
  119. package/lib-esm/Checkbox.d.ts +29 -0
  120. package/lib-esm/Checkbox.js +44 -0
  121. package/lib-esm/CircleOcticon.d.ts +1 -0
  122. package/lib-esm/Details.d.ts +1 -2
  123. package/lib-esm/Details.js +1 -2
  124. package/lib-esm/Dialog.d.ts +3 -2
  125. package/lib-esm/Dropdown.d.ts +6 -66
  126. package/lib-esm/DropdownMenu/DropdownButton.d.ts +2 -1
  127. package/lib-esm/FilterList.d.ts +1 -0
  128. package/lib-esm/Heading.d.ts +1 -2
  129. package/lib-esm/Heading.js +2 -6
  130. package/lib-esm/Overlay.d.ts +5 -3
  131. package/lib-esm/Position.d.ts +4 -4
  132. package/lib-esm/ProgressBar.d.ts +16 -11
  133. package/lib-esm/ProgressBar.js +7 -11
  134. package/lib-esm/SelectMenu/SelectMenu.d.ts +10 -4
  135. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  136. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  137. package/lib-esm/Spinner.d.ts +1 -2
  138. package/lib-esm/Spinner.js +1 -2
  139. package/lib-esm/TextInputWithTokens.d.ts +1 -0
  140. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  141. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  142. package/lib-esm/Token/Token.d.ts +1 -1
  143. package/lib-esm/index.d.ts +2 -0
  144. package/lib-esm/index.js +1 -0
  145. package/lib-esm/theme-preval.js +446 -0
  146. package/lib-esm/utils/testing.d.ts +2 -1
  147. package/lib-esm/utils/testing.js +24 -0
  148. package/package.json +4 -5
  149. package/lib/ActionList/Divider.jsx +0 -29
  150. package/lib/ActionList/Group.jsx +0 -23
  151. package/lib/ActionList/Header.jsx +0 -66
  152. package/lib/ActionList/Item.jsx +0 -288
  153. package/lib/ActionList/List.jsx +0 -138
  154. package/lib/ActionList2/Description.jsx +0 -29
  155. package/lib/ActionList2/Divider.jsx +0 -22
  156. package/lib/ActionList2/Group.jsx +0 -54
  157. package/lib/ActionList2/Header.d.ts +0 -26
  158. package/lib/ActionList2/Header.js +0 -55
  159. package/lib/ActionList2/Header.jsx +0 -36
  160. package/lib/ActionList2/Item.jsx +0 -174
  161. package/lib/ActionList2/LinkItem.jsx +0 -28
  162. package/lib/ActionList2/List.jsx +0 -41
  163. package/lib/ActionList2/Selection.jsx +0 -50
  164. package/lib/ActionList2/Visuals.jsx +0 -48
  165. package/lib/ActionMenu.jsx +0 -73
  166. package/lib/AnchoredOverlay/AnchoredOverlay.jsx +0 -100
  167. package/lib/Autocomplete/Autocomplete.jsx +0 -100
  168. package/lib/Autocomplete/AutocompleteContext.jsx +0 -5
  169. package/lib/Autocomplete/AutocompleteInput.jsx +0 -113
  170. package/lib/Autocomplete/AutocompleteMenu.jsx +0 -190
  171. package/lib/Autocomplete/AutocompleteOverlay.jsx +0 -55
  172. package/lib/Avatar.jsx +0 -34
  173. package/lib/AvatarPair.jsx +0 -29
  174. package/lib/AvatarStack.jsx +0 -151
  175. package/lib/BaseStyles.jsx +0 -65
  176. package/lib/BorderBox.jsx +0 -18
  177. package/lib/Box.jsx +0 -10
  178. package/lib/BranchName.jsx +0 -20
  179. package/lib/Breadcrumbs.jsx +0 -71
  180. package/lib/Button/Button.jsx +0 -40
  181. package/lib/Button/ButtonBase.jsx +0 -33
  182. package/lib/Button/ButtonClose.jsx +0 -53
  183. package/lib/Button/ButtonDanger.jsx +0 -43
  184. package/lib/Button/ButtonGroup.jsx +0 -55
  185. package/lib/Button/ButtonInvisible.jsx +0 -32
  186. package/lib/Button/ButtonOutline.jsx +0 -43
  187. package/lib/Button/ButtonPrimary.jsx +0 -42
  188. package/lib/Button/ButtonStyles.jsx +0 -37
  189. package/lib/Button/ButtonTableList.jsx +0 -46
  190. package/lib/Caret.jsx +0 -93
  191. package/lib/CircleBadge.jsx +0 -42
  192. package/lib/CircleOcticon.jsx +0 -21
  193. package/lib/CounterLabel.jsx +0 -43
  194. package/lib/Details.jsx +0 -21
  195. package/lib/Dialog/ConfirmationDialog.jsx +0 -146
  196. package/lib/Dialog/Dialog.jsx +0 -279
  197. package/lib/Dialog.jsx +0 -129
  198. package/lib/Dropdown.jsx +0 -131
  199. package/lib/DropdownMenu/DropdownButton.jsx +0 -14
  200. package/lib/DropdownMenu/DropdownMenu.jsx +0 -70
  201. package/lib/FilterList.jsx +0 -59
  202. package/lib/FilteredActionList/FilteredActionList.jsx +0 -100
  203. package/lib/FilteredSearch.jsx +0 -28
  204. package/lib/Flash.jsx +0 -69
  205. package/lib/Flex.jsx +0 -15
  206. package/lib/FormGroup.jsx +0 -22
  207. package/lib/Grid.jsx +0 -15
  208. package/lib/Header.jsx +0 -83
  209. package/lib/Heading.jsx +0 -21
  210. package/lib/Label.jsx +0 -82
  211. package/lib/LabelGroup.jsx +0 -18
  212. package/lib/Link.jsx +0 -36
  213. package/lib/NewButton/button-counter.jsx +0 -14
  214. package/lib/NewButton/button.jsx +0 -279
  215. package/lib/Overlay.jsx +0 -154
  216. package/lib/Pagehead.jsx +0 -17
  217. package/lib/Pagination/Pagination.jsx +0 -161
  218. package/lib/Pagination/model.jsx +0 -174
  219. package/lib/PointerBox.jsx +0 -25
  220. package/lib/Popover.jsx +0 -202
  221. package/lib/Portal/Portal.jsx +0 -79
  222. package/lib/Position.jsx +0 -46
  223. package/lib/ProgressBar.jsx +0 -39
  224. package/lib/SelectMenu/SelectMenu.jsx +0 -112
  225. package/lib/SelectMenu/SelectMenuContext.jsx +0 -5
  226. package/lib/SelectMenu/SelectMenuDivider.jsx +0 -42
  227. package/lib/SelectMenu/SelectMenuFilter.jsx +0 -58
  228. package/lib/SelectMenu/SelectMenuFooter.jsx +0 -45
  229. package/lib/SelectMenu/SelectMenuHeader.jsx +0 -42
  230. package/lib/SelectMenu/SelectMenuItem.jsx +0 -142
  231. package/lib/SelectMenu/SelectMenuList.jsx +0 -59
  232. package/lib/SelectMenu/SelectMenuLoadingAnimation.jsx +0 -22
  233. package/lib/SelectMenu/SelectMenuModal.jsx +0 -118
  234. package/lib/SelectMenu/SelectMenuTab.jsx +0 -92
  235. package/lib/SelectMenu/SelectMenuTabPanel.jsx +0 -42
  236. package/lib/SelectMenu/SelectMenuTabs.jsx +0 -57
  237. package/lib/SelectPanel/SelectPanel.jsx +0 -105
  238. package/lib/SideNav.jsx +0 -173
  239. package/lib/Spinner.jsx +0 -35
  240. package/lib/StateLabel.jsx +0 -93
  241. package/lib/StyledOcticon.jsx +0 -18
  242. package/lib/SubNav.jsx +0 -101
  243. package/lib/TabNav.jsx +0 -58
  244. package/lib/Text.jsx +0 -14
  245. package/lib/TextInput.jsx +0 -23
  246. package/lib/TextInputWithTokens.jsx +0 -218
  247. package/lib/ThemeProvider.jsx +0 -130
  248. package/lib/Timeline.jsx +0 -123
  249. package/lib/Token/AvatarToken.jsx +0 -54
  250. package/lib/Token/IssueLabelToken.jsx +0 -125
  251. package/lib/Token/Token.jsx +0 -103
  252. package/lib/Token/TokenBase.jsx +0 -88
  253. package/lib/Token/_RemoveTokenButton.jsx +0 -108
  254. package/lib/Token/_TokenTextContainer.jsx +0 -49
  255. package/lib/Tooltip.jsx +0 -246
  256. package/lib/Truncate.jsx +0 -24
  257. package/lib/UnderlineNav.jsx +0 -88
  258. package/lib/_TextInputWrapper.jsx +0 -120
  259. package/lib/_UnstyledTextInput.jsx +0 -22
  260. package/lib/hooks/useDetails.jsx +0 -39
  261. package/lib/hooks/useOnOutsideClick.jsx +0 -61
  262. package/lib/hooks/useOverlay.jsx +0 -15
  263. package/lib/utils/create-slots.jsx +0 -65
  264. package/lib/utils/deprecate.jsx +0 -59
  265. package/lib/utils/isNumeric.jsx +0 -7
  266. package/lib/utils/ssr.jsx +0 -6
  267. package/lib/utils/test-deprecations.jsx +0 -20
  268. package/lib/utils/test-helpers.jsx +0 -8
  269. package/lib/utils/test-matchers.jsx +0 -100
  270. package/lib/utils/testing.jsx +0 -206
  271. package/lib-esm/ActionList2/Header.d.ts +0 -26
  272. package/lib-esm/ActionList2/Header.js +0 -44
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;
@@ -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;
@@ -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, {});
package/lib/Overlay.jsx DELETED
@@ -1,154 +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 useIsomorphicLayoutEffect_1 = __importDefault(require("./utils/useIsomorphicLayoutEffect"));
28
- const constants_1 = require("./constants");
29
- const hooks_1 = require("./hooks");
30
- const Portal_1 = __importDefault(require("./Portal"));
31
- const sx_1 = __importDefault(require("./sx"));
32
- const useCombinedRefs_1 = require("./hooks/useCombinedRefs");
33
- const ThemeProvider_1 = require("./ThemeProvider");
34
- const heightMap = {
35
- xsmall: '192px',
36
- small: '256px',
37
- medium: '320px',
38
- large: '432px',
39
- xlarge: '600px',
40
- auto: 'auto',
41
- initial: 'auto' // Passing 'initial' initially applies 'auto'
42
- };
43
- const widthMap = {
44
- small: '256px',
45
- medium: '320px',
46
- large: '480px',
47
- xlarge: '640px',
48
- xxlarge: '960px',
49
- auto: 'auto'
50
- };
51
- const animationDuration = 200;
52
- function getSlideAnimationStartingVector(anchorSide) {
53
- if (anchorSide?.endsWith('bottom')) {
54
- return { x: 0, y: -1 };
55
- }
56
- else if (anchorSide?.endsWith('top')) {
57
- return { x: 0, y: 1 };
58
- }
59
- else if (anchorSide?.endsWith('right')) {
60
- return { x: -1, y: 0 };
61
- }
62
- else if (anchorSide?.endsWith('left')) {
63
- return { x: 1, y: 0 };
64
- }
65
- return { x: 0, y: 0 };
66
- }
67
- const StyledOverlay = styled_components_1.default.div `
68
- background-color: ${constants_1.get('colors.canvas.overlay')};
69
- box-shadow: ${constants_1.get('shadows.overlay.shadow')};
70
- position: absolute;
71
- min-width: 192px;
72
- max-width: 640px;
73
- height: ${props => heightMap[props.height || 'auto']};
74
- max-height: ${props => props.maxHeight && heightMap[props.maxHeight]};
75
- width: ${props => widthMap[props.width || 'auto']};
76
- border-radius: 12px;
77
- overflow: hidden;
78
- animation: overlay-appear ${animationDuration}ms ${constants_1.get('animation.easeOutCubic')};
79
-
80
- @keyframes overlay-appear {
81
- 0% {
82
- opacity: 0;
83
- }
84
- 100% {
85
- opacity: 1;
86
- }
87
- }
88
- visibility: var(--styled-overlay-visibility);
89
- :focus {
90
- outline: none;
91
- }
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
- useIsomorphicLayoutEffect_1.default(() => {
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
- '--styled-overlay-visibility': visibility
147
- }}/>
148
- </Portal_1.default>);
149
- });
150
- Overlay.defaultProps = {
151
- height: 'auto',
152
- width: 'auto'
153
- };
154
- exports.default = Overlay;
package/lib/Pagehead.jsx DELETED
@@ -1,17 +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 Pagehead = styled_components_1.default.div `
10
- position: relative;
11
- padding-top: ${constants_1.get('space.4')};
12
- padding-bottom: ${constants_1.get('space.4')};
13
- margin-bottom: ${constants_1.get('space.4')};
14
- border-bottom: 1px solid ${constants_1.get('colors.border.default')};
15
- ${sx_1.default};
16
- `;
17
- exports.default = Pagehead;