@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/Timeline.jsx DELETED
@@ -1,123 +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 classnames_1 = __importDefault(require("classnames"));
26
- const react_1 = __importDefault(require("react"));
27
- const styled_components_1 = __importStar(require("styled-components"));
28
- const _1 = require(".");
29
- const constants_1 = require("./constants");
30
- const sx_1 = __importDefault(require("./sx"));
31
- const Timeline = styled_components_1.default.div `
32
- display: flex;
33
- flex-direction: column;
34
- ${props => props.clipSidebar &&
35
- styled_components_1.css `
36
- .Timeline-Item:first-child {
37
- padding-top: 0;
38
- }
39
-
40
- .Timeline-Item:last-child {
41
- padding-bottom: 0;
42
- }
43
- `}
44
-
45
- ${sx_1.default};
46
- `;
47
- const TimelineItem = styled_components_1.default.div.attrs(props => ({
48
- className: classnames_1.default('Timeline-Item', props.className)
49
- })) `
50
- display: flex;
51
- position: relative;
52
- padding: ${constants_1.get('space.3')} 0;
53
- margin-left: ${constants_1.get('space.3')};
54
-
55
- &::before {
56
- position: absolute;
57
- top: 0;
58
- bottom: 0;
59
- left: 0;
60
- display: block;
61
- width: 2px;
62
- content: '';
63
- background-color: ${constants_1.get('colors.border.muted')};
64
- }
65
-
66
- ${props => props.condensed &&
67
- styled_components_1.css `
68
- padding-top: ${constants_1.get('space.1')};
69
- padding-bottom: 0;
70
- &:last-child {
71
- padding-bottom: ${constants_1.get('space.3')};
72
- }
73
-
74
- .TimelineItem-Badge {
75
- height: 16px;
76
- margin-top: ${constants_1.get('space.2')};
77
- margin-bottom: ${constants_1.get('space.2')};
78
- color: ${constants_1.get('colors.fg.muted')};
79
- background-color: ${constants_1.get('colors.canvas.default')};
80
- border: 0;
81
- }
82
- `}
83
-
84
- ${sx_1.default};
85
- `;
86
- const TimelineBadge = (props) => {
87
- return (<_1.Box position="relative" zIndex={1}>
88
- <_1.Box display="flex" className="TimelineItem-Badge" flexShrink={0} borderRadius="50%" borderWidth="2px" borderStyle="solid" borderColor="canvas.default" overflow="hidden" color="fg.muted" bg="timeline.badgeBg" width="32px" height="32px" mr={2} ml="-15px" alignItems="center" justifyContent="center" sx={props.sx}>
89
- {props.children}
90
- </_1.Box>
91
- </_1.Box>);
92
- };
93
- const TimelineBody = styled_components_1.default.div `
94
- min-width: 0;
95
- max-width: 100%;
96
- margin-top: ${constants_1.get('space.1')};
97
- color: ${constants_1.get('colors.fg.muted')};
98
- flex: auto;
99
- font-size: ${constants_1.get('fontSizes.1')};
100
- ${sx_1.default};
101
- `;
102
- const TimelineBreak = styled_components_1.default.div `
103
- position: relative
104
- z-index: 1;
105
- height: 24px;
106
- margin: 0;
107
- margin-bottom: -${constants_1.get('space.3')};
108
- margin-left: 0;
109
- background-color: ${constants_1.get('colors.canvas.default')};
110
- border: 0;
111
- border-top: ${constants_1.get('space.1')} solid ${constants_1.get('colors.border.default')};
112
- ${sx_1.default};
113
- `;
114
- TimelineItem.displayName = 'Timeline.Item';
115
- TimelineBadge.displayName = 'Timeline.Badge';
116
- TimelineBody.displayName = 'Timeline.Body';
117
- TimelineBreak.displayName = 'Timeline.Break';
118
- exports.default = Object.assign(Timeline, {
119
- Item: TimelineItem,
120
- Badge: TimelineBadge,
121
- Body: TimelineBody,
122
- Break: TimelineBreak
123
- });
@@ -1,54 +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 react_1 = __importStar(require("react"));
26
- const styled_components_1 = __importDefault(require("styled-components"));
27
- const constants_1 = require("../constants");
28
- const TokenBase_1 = require("./TokenBase");
29
- const Token_1 = __importDefault(require("./Token"));
30
- const __1 = require("..");
31
- const AvatarContainer = styled_components_1.default.span `
32
- // 'space.1' is used because to match space from the left of the token to the left of the avatar
33
- // '* 2' is done to account for the top and bottom
34
- --spacing: calc(${constants_1.get('space.1')} * 2);
35
-
36
- display: block;
37
- height: ${props => `calc(${TokenBase_1.tokenSizes[props.avatarSize]} - var(--spacing))`};
38
- width: ${props => `calc(${TokenBase_1.tokenSizes[props.avatarSize]} - var(--spacing))`};
39
- `;
40
- const AvatarToken = react_1.forwardRef(({ avatarSrc, id, size, ...rest }, forwardedRef) => {
41
- return (<Token_1.default leadingVisual={() => (<AvatarContainer avatarSize={size || TokenBase_1.defaultTokenSize}>
42
- <__1.Avatar src={avatarSrc} size={parseInt(TokenBase_1.tokenSizes[size || TokenBase_1.defaultTokenSize], 10)} sx={{
43
- width: '100%',
44
- height: '100%'
45
- }}/>
46
- </AvatarContainer>)} size={size} id={id?.toString()} sx={{
47
- paddingLeft: constants_1.get('space.1')
48
- }} {...rest} ref={forwardedRef}/>);
49
- });
50
- AvatarToken.defaultProps = {
51
- size: TokenBase_1.defaultTokenSize
52
- };
53
- AvatarToken.displayName = 'AvatarToken';
54
- exports.default = AvatarToken;
@@ -1,125 +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 react_1 = __importStar(require("react"));
26
- const TokenBase_1 = __importStar(require("./TokenBase"));
27
- const _RemoveTokenButton_1 = __importDefault(require("./_RemoveTokenButton"));
28
- const color2k_1 = require("color2k");
29
- const ThemeProvider_1 = require("../ThemeProvider");
30
- const _TokenTextContainer_1 = __importDefault(require("./_TokenTextContainer"));
31
- const tokenBorderWidthPx = 1;
32
- const lightModeStyles = {
33
- '--lightness-threshold': '0.453',
34
- '--border-threshold': '0.96',
35
- '--border-alpha': 'max(0, min(calc((var(--perceived-lightness) - var(--border-threshold)) * 100), 1))',
36
- background: 'rgb(var(--label-r), var(--label-g), var(--label-b))',
37
- color: 'hsl(0, 0%, calc(var(--lightness-switch) * 100%))',
38
- borderWidth: tokenBorderWidthPx,
39
- borderStyle: 'solid',
40
- borderColor: 'hsla(var(--label-h),calc(var(--label-s) * 1%),calc((var(--label-l) - 25) * 1%),var(--border-alpha))'
41
- };
42
- const darkModeStyles = {
43
- '--lightness-threshold': '0.6',
44
- '--background-alpha': '0.18',
45
- '--border-alpha': '0.3',
46
- '--lighten-by': 'calc(((var(--lightness-threshold) - var(--perceived-lightness)) * 100) * var(--lightness-switch))',
47
- borderWidth: tokenBorderWidthPx,
48
- borderStyle: 'solid',
49
- background: 'rgba(var(--label-r), var(--label-g), var(--label-b), var(--background-alpha))',
50
- color: 'hsl(var(--label-h), calc(var(--label-s) * 1%), calc((var(--label-l) + var(--lighten-by)) * 1%))',
51
- borderColor: 'hsla(var(--label-h), calc(var(--label-s) * 1%),calc((var(--label-l) + var(--lighten-by)) * 1%),var(--border-alpha))'
52
- };
53
- const IssueLabelToken = react_1.forwardRef((props, forwardedRef) => {
54
- const { as, fillColor = '#999', onRemove, id, isSelected, text, size, hideRemoveButton, href, onClick, ...rest } = props;
55
- const interactiveTokenProps = {
56
- as,
57
- href,
58
- onClick
59
- };
60
- const { colorScheme } = ThemeProvider_1.useTheme();
61
- const hasMultipleActionTargets = TokenBase_1.isTokenInteractive(props) && Boolean(onRemove) && !hideRemoveButton;
62
- const onRemoveClick = e => {
63
- e.stopPropagation();
64
- onRemove && onRemove();
65
- };
66
- const labelStyles = react_1.useMemo(() => {
67
- const [r, g, b] = color2k_1.parseToRgba(fillColor);
68
- const [h, s, l] = color2k_1.parseToHsla(fillColor);
69
- // label hack taken from https://github.com/github/github/blob/master/app/assets/stylesheets/hacks/hx_primer-labels.scss#L43-L108
70
- // this logic should eventually live in primer/components. Also worthy of note is that the dotcom hack code will be moving to primer/css soon.
71
- return {
72
- '--label-r': String(r),
73
- '--label-g': String(g),
74
- '--label-b': String(b),
75
- '--label-h': String(Math.round(h)),
76
- '--label-s': String(Math.round(s * 100)),
77
- '--label-l': String(Math.round(l * 100)),
78
- '--perceived-lightness': 'calc(((var(--label-r) * 0.2126) + (var(--label-g) * 0.7152) + (var(--label-b) * 0.0722)) / 255)',
79
- '--lightness-switch': 'max(0, min(calc((var(--perceived-lightness) - var(--lightness-threshold)) * -1000), 1))',
80
- paddingRight: hideRemoveButton || !onRemove ? undefined : 0,
81
- position: 'relative',
82
- ...(colorScheme === 'light' ? lightModeStyles : darkModeStyles),
83
- ...(isSelected
84
- ? {
85
- background: colorScheme === 'light'
86
- ? 'hsl(var(--label-h), calc(var(--label-s) * 1%), calc((var(--label-l) - 5) * 1%))'
87
- : darkModeStyles.background,
88
- ':focus': {
89
- outline: 'none'
90
- },
91
- ':after': {
92
- content: '""',
93
- position: 'absolute',
94
- zIndex: 1,
95
- top: `-${tokenBorderWidthPx * 2}px`,
96
- right: `-${tokenBorderWidthPx * 2}px`,
97
- bottom: `-${tokenBorderWidthPx * 2}px`,
98
- left: `-${tokenBorderWidthPx * 2}px`,
99
- display: 'block',
100
- pointerEvents: 'none',
101
- boxShadow: `0 0 0 ${tokenBorderWidthPx * 2}px ${colorScheme === 'light'
102
- ? 'rgb(var(--label-r), var(--label-g), var(--label-b))'
103
- : 'hsl(var(--label-h), calc(var(--label-s) * 1%), calc((var(--label-l) + var(--lighten-by)) * 1%))'}`,
104
- borderRadius: '999px'
105
- }
106
- }
107
- : {})
108
- };
109
- }, [colorScheme, fillColor, isSelected, hideRemoveButton, onRemove]);
110
- return (<TokenBase_1.default onRemove={onRemove} id={id?.toString()} isSelected={isSelected} text={text} size={size} sx={labelStyles} {...(!hasMultipleActionTargets ? interactiveTokenProps : {})} {...rest} ref={forwardedRef}>
111
- <_TokenTextContainer_1.default {...(hasMultipleActionTargets ? interactiveTokenProps : {})}>{text}</_TokenTextContainer_1.default>
112
- {!hideRemoveButton && onRemove ? (<_RemoveTokenButton_1.default borderOffset={tokenBorderWidthPx} onClick={onRemoveClick} size={size} aria-hidden={hasMultipleActionTargets ? 'true' : 'false'} isParentInteractive={TokenBase_1.isTokenInteractive(props)} sx={hasMultipleActionTargets
113
- ? {
114
- position: 'relative',
115
- zIndex: '1'
116
- }
117
- : {}}/>) : null}
118
- </TokenBase_1.default>);
119
- });
120
- IssueLabelToken.defaultProps = {
121
- fillColor: '#999',
122
- size: TokenBase_1.defaultTokenSize
123
- };
124
- IssueLabelToken.displayName = 'IssueLabelToken';
125
- exports.default = IssueLabelToken;
@@ -1,103 +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 react_1 = __importStar(require("react"));
26
- const styled_components_1 = __importStar(require("styled-components"));
27
- const constants_1 = require("../constants");
28
- const sx_1 = __importDefault(require("../sx"));
29
- const TokenBase_1 = __importStar(require("./TokenBase"));
30
- const _RemoveTokenButton_1 = __importDefault(require("./_RemoveTokenButton"));
31
- const _TokenTextContainer_1 = __importDefault(require("./_TokenTextContainer"));
32
- const tokenBorderWidthPx = 1;
33
- const DefaultTokenStyled = styled_components_1.default(TokenBase_1.default) `
34
- background-color: ${constants_1.get('colors.neutral.subtle')};
35
- border-color: ${props => (props.isSelected ? constants_1.get('colors.fg.default') : constants_1.get('colors.border.subtle'))};
36
- border-style: solid;
37
- border-width: ${tokenBorderWidthPx}px;
38
- color: ${props => (props.isSelected ? constants_1.get('colors.fg.default') : constants_1.get('colors.fg.muted'))};
39
- max-width: 100%;
40
- padding-right: ${props => (!props.hideRemoveButton ? 0 : undefined)};
41
- position: relative;
42
- ${sx_1.default}
43
-
44
- ${props => {
45
- if (props.isTokenInteractive) {
46
- return styled_components_1.css `
47
- &:hover {
48
- background-color: ${constants_1.get('colors.neutral.muted')};
49
- box-shadow: ${constants_1.get('colors.shadow.medium')};
50
- color: ${constants_1.get('colors.fg.default')};
51
- }
52
- `;
53
- }
54
- }}
55
- `;
56
- const LeadingVisualContainer = styled_components_1.default('span') `
57
- flex-shrink: 0;
58
- line-height: 0;
59
-
60
- ${props => {
61
- switch (props.size) {
62
- case 'large':
63
- case 'extralarge':
64
- return styled_components_1.css `
65
- margin-right: ${constants_1.get('space.2')};
66
- `;
67
- default:
68
- return styled_components_1.css `
69
- margin-right: ${constants_1.get('space.1')};
70
- `;
71
- }
72
- }}
73
- `;
74
- const Token = react_1.forwardRef((props, forwardedRef) => {
75
- const { as, onRemove, id, leadingVisual: LeadingVisual, text, size, hideRemoveButton, href, onClick, ...rest } = props;
76
- const hasMultipleActionTargets = TokenBase_1.isTokenInteractive(props) && Boolean(onRemove) && !hideRemoveButton;
77
- const onRemoveClick = e => {
78
- e.stopPropagation();
79
- onRemove && onRemove();
80
- };
81
- const interactiveTokenProps = {
82
- as,
83
- href,
84
- onClick
85
- };
86
- return (<DefaultTokenStyled onRemove={onRemove} hideRemoveButton={hideRemoveButton || !onRemove} id={id?.toString()} text={text} size={size} isTokenInteractive={TokenBase_1.isTokenInteractive(props)} {...(!hasMultipleActionTargets ? interactiveTokenProps : {})} {...rest} ref={forwardedRef}>
87
- {LeadingVisual ? (<LeadingVisualContainer size={size}>
88
- <LeadingVisual />
89
- </LeadingVisualContainer>) : null}
90
- <_TokenTextContainer_1.default {...(hasMultipleActionTargets ? interactiveTokenProps : {})}>{text}</_TokenTextContainer_1.default>
91
- {!hideRemoveButton && onRemove ? (<_RemoveTokenButton_1.default borderOffset={tokenBorderWidthPx} onClick={onRemoveClick} size={size} isParentInteractive={TokenBase_1.isTokenInteractive(props)} aria-hidden={hasMultipleActionTargets ? 'true' : 'false'} sx={hasMultipleActionTargets
92
- ? {
93
- position: 'relative',
94
- zIndex: '1'
95
- }
96
- : {}}/>) : null}
97
- </DefaultTokenStyled>);
98
- });
99
- Token.displayName = 'Token';
100
- Token.defaultProps = {
101
- size: TokenBase_1.defaultTokenSize
102
- };
103
- exports.default = Token;
@@ -1,88 +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.isTokenInteractive = exports.defaultTokenSize = exports.tokenSizes = void 0;
7
- const styled_components_1 = __importDefault(require("styled-components"));
8
- const styled_system_1 = require("styled-system");
9
- const constants_1 = require("../constants");
10
- const sx_1 = __importDefault(require("../sx"));
11
- exports.tokenSizes = {
12
- small: '16px',
13
- medium: '20px',
14
- large: '24px',
15
- extralarge: '32px'
16
- };
17
- exports.defaultTokenSize = 'medium';
18
- const isTokenInteractive = ({ as = 'span', onClick, onFocus, tabIndex = -1 }) => Boolean(onFocus || onClick || tabIndex > -1 || ['a', 'button'].includes(as));
19
- exports.isTokenInteractive = isTokenInteractive;
20
- const variants = styled_system_1.variant({
21
- prop: 'size',
22
- variants: {
23
- small: {
24
- fontSize: 0,
25
- height: exports.tokenSizes.small,
26
- // without setting lineHeight to match height, the "x" appears vertically mis-aligned
27
- lineHeight: exports.tokenSizes.small,
28
- paddingLeft: 1,
29
- paddingRight: 1,
30
- // need to explicitly set padding top and bottom to "0" to override default `<button>` element styles
31
- // without setting these, the "x" appears vertically mis-aligned
32
- paddingTop: 0,
33
- paddingBottom: 0
34
- },
35
- medium: {
36
- fontSize: 0,
37
- height: exports.tokenSizes.medium,
38
- lineHeight: exports.tokenSizes.medium,
39
- paddingLeft: 2,
40
- paddingRight: 2,
41
- paddingTop: 0,
42
- paddingBottom: 0
43
- },
44
- large: {
45
- fontSize: 0,
46
- height: exports.tokenSizes.large,
47
- lineHeight: exports.tokenSizes.large,
48
- paddingLeft: 2,
49
- paddingRight: 2,
50
- paddingTop: 0,
51
- paddingBottom: 0
52
- },
53
- extralarge: {
54
- fontSize: 1,
55
- height: exports.tokenSizes.extralarge,
56
- lineHeight: exports.tokenSizes.extralarge,
57
- paddingLeft: 3,
58
- paddingRight: 3,
59
- paddingTop: 0,
60
- paddingBottom: 0
61
- }
62
- }
63
- });
64
- const TokenBase = styled_components_1.default.span.attrs(({ text, onRemove, onKeyDown }) => ({
65
- onKeyDown: (event) => {
66
- onKeyDown && onKeyDown(event);
67
- if ((event.key === 'Backspace' || event.key === 'Delete') && onRemove) {
68
- onRemove();
69
- }
70
- },
71
- 'aria-label': onRemove ? `${text}, press backspace or delete to remove` : undefined
72
- })) `
73
- align-items: center;
74
- border-radius: 999px;
75
- cursor: ${props => (exports.isTokenInteractive(props) ? 'pointer' : 'auto')};
76
- display: inline-flex;
77
- font-weight: ${constants_1.get('fontWeights.bold')};
78
- font-family: inherit;
79
- text-decoration: none;
80
- white-space: nowrap;
81
- ${variants}
82
- ${sx_1.default}
83
- `;
84
- TokenBase.defaultProps = {
85
- as: 'span',
86
- size: exports.defaultTokenSize
87
- };
88
- exports.default = TokenBase;
@@ -1,108 +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 react_1 = __importDefault(require("react"));
26
- const octicons_react_1 = require("@primer/octicons-react");
27
- const styled_components_1 = __importStar(require("styled-components"));
28
- const styled_system_1 = require("styled-system");
29
- const constants_1 = require("../constants");
30
- const sx_1 = __importDefault(require("../sx"));
31
- const TokenBase_1 = require("./TokenBase");
32
- const variants = styled_system_1.variant({
33
- prop: 'size',
34
- variants: {
35
- small: {
36
- height: TokenBase_1.tokenSizes.small,
37
- width: TokenBase_1.tokenSizes.small
38
- },
39
- medium: {
40
- height: TokenBase_1.tokenSizes.medium,
41
- width: TokenBase_1.tokenSizes.medium
42
- },
43
- large: {
44
- height: TokenBase_1.tokenSizes.large,
45
- width: TokenBase_1.tokenSizes.large
46
- },
47
- extralarge: {
48
- height: TokenBase_1.tokenSizes.extralarge,
49
- width: TokenBase_1.tokenSizes.extralarge
50
- }
51
- }
52
- });
53
- const getTokenButtonIconSize = (size) => parseInt(TokenBase_1.tokenSizes[size || TokenBase_1.defaultTokenSize], 10) * 0.75;
54
- const StyledTokenButton = styled_components_1.default.span `
55
- background-color: transparent;
56
- font-family: inherit;
57
- color: currentColor;
58
- cursor: pointer;
59
- display: inline-flex;
60
- justify-content: center;
61
- align-items: center;
62
- user-select: none;
63
- appearance: none;
64
- text-decoration: none;
65
- padding: 0;
66
- transform: ${props => `translate(${props.borderOffset}px, -${props.borderOffset}px)`};
67
- align-self: baseline;
68
- border: 0;
69
- border-radius: 999px;
70
-
71
- ${props => {
72
- switch (props.size) {
73
- case 'large':
74
- case 'extralarge':
75
- return styled_components_1.css `
76
- margin-left: ${constants_1.get('space.2')};
77
- `;
78
- default:
79
- return styled_components_1.css `
80
- margin-left: ${constants_1.get('space.1')};
81
- `;
82
- }
83
- }}
84
-
85
- &:hover,
86
- &:focus {
87
- // TODO: choose a better functional color variable for this
88
- background-color: ${constants_1.get('colors.neutral.muted')};
89
- }
90
-
91
- &:active {
92
- // TODO: choose a better functional color variable for this
93
- background-color: ${constants_1.get('colors.neutral.subtle')};
94
- }
95
-
96
- ${variants}
97
- ${sx_1.default}
98
- `;
99
- const RemoveTokenButton = ({ 'aria-label': ariaLabel, isParentInteractive, size, ...rest }) => {
100
- delete rest.children;
101
- return (<StyledTokenButton as={isParentInteractive ? 'span' : 'button'} tabIndex={isParentInteractive ? -1 : undefined} aria-label={!isParentInteractive ? 'Remove token' : ariaLabel} size={size} {...rest}>
102
- <octicons_react_1.XIcon size={getTokenButtonIconSize(size)}/>
103
- </StyledTokenButton>);
104
- };
105
- RemoveTokenButton.defaultProps = {
106
- size: TokenBase_1.defaultTokenSize
107
- };
108
- exports.default = RemoveTokenButton;
@@ -1,49 +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 TokenTextContainer = styled_components_1.default('span') `
8
- flex-grow: 1;
9
- min-width: 0;
10
- overflow: hidden;
11
- text-overflow: ellipsis;
12
- white-space: nowrap;
13
-
14
- // reset button styles, make the cursor a pointer, and add line-height
15
- background: transparent;
16
- border: none;
17
- color: inherit;
18
- font: inherit;
19
- margin: 0;
20
- overflow: visible;
21
- padding: 0;
22
- width: auto;
23
- -webkit-font-smoothing: inherit;
24
- -moz-osx-font-smoothing: inherit;
25
- -webkit-appearance: none;
26
- line-height: 1;
27
-
28
- // reset anchor styles
29
- color: currentColor;
30
- text-decoration: none;
31
-
32
- // Position psuedo-element above text content, but below the
33
- // remove button.
34
- // This ensures the <a> or <button> receives the click no
35
- // matter where on the token the user clicks.
36
- &:is(a, button, [tabIndex='0']) {
37
- cursor: pointer;
38
-
39
- &:after {
40
- content: '';
41
- position: absolute;
42
- left: 0;
43
- top: 0;
44
- right: 0;
45
- bottom: 0;
46
- }
47
- }
48
- `;
49
- exports.default = TokenTextContainer;