@primer/react 38.0.0-rc.1 → 38.0.0-rc.2

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 (200) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/browser.esm.js +3 -3
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +3 -3
  5. package/dist/browser.umd.js.map +1 -1
  6. package/dist/components.css +660 -23
  7. package/generated/components.json +58 -121
  8. package/lib/AvatarStack/AvatarStack.d.ts +2 -3
  9. package/lib/AvatarStack/AvatarStack.d.ts.map +1 -1
  10. package/lib/AvatarStack/AvatarStack.js +1 -3
  11. package/lib/Banner/Banner.d.ts.map +1 -1
  12. package/lib/Banner/Banner.js +3 -1
  13. package/lib/Blankslate/Blankslate.js +38 -40
  14. package/lib/BranchName/BranchName.d.ts +6 -3
  15. package/lib/BranchName/BranchName.d.ts.map +1 -1
  16. package/lib/BranchName/BranchName.js +1 -3
  17. package/lib/Button/ButtonBase.js +2 -2
  18. package/lib/Checkbox/Checkbox.js +187 -56
  19. package/lib/CircleBadge/CircleBadge.d.ts +4 -0
  20. package/lib/CircleBadge/CircleBadge.d.ts.map +1 -1
  21. package/lib/CircleBadge/CircleBadge.js +4 -0
  22. package/lib/DataTable/useTable.js +63 -82
  23. package/lib/Details/Details.d.ts +2 -3
  24. package/lib/Details/Details.d.ts.map +1 -1
  25. package/lib/Details/Details.js +1 -3
  26. package/lib/FeatureFlags/FeatureFlags.js +10 -12
  27. package/lib/FilteredActionList/useAnnouncements.js +31 -40
  28. package/lib/LabelGroup/LabelGroup.d.ts +1 -2
  29. package/lib/LabelGroup/LabelGroup.d.ts.map +1 -1
  30. package/lib/LabelGroup/LabelGroup.js +13 -16
  31. package/lib/NavList/NavList.js +219 -53
  32. package/lib/PageLayout/PageLayout.js +53 -55
  33. package/lib/PointerBox/PointerBox.d.ts +8 -0
  34. package/lib/PointerBox/PointerBox.d.ts.map +1 -1
  35. package/lib/PointerBox/PointerBox.js +4 -0
  36. package/{lib-esm/ProgressBar/ProgressBar-a0957632.css → lib/ProgressBar/ProgressBar-36f689cb.css} +2 -2
  37. package/lib/ProgressBar/ProgressBar-36f689cb.css.map +1 -0
  38. package/lib/ProgressBar/ProgressBar.d.ts +3 -4
  39. package/lib/ProgressBar/ProgressBar.d.ts.map +1 -1
  40. package/lib/ProgressBar/ProgressBar.module.css.js +1 -1
  41. package/lib/ProgressBar/index.d.ts +2 -2
  42. package/lib/ProgressBar/index.d.ts.map +1 -1
  43. package/lib/Select/Select.d.ts +1 -1
  44. package/lib/Select/Select.d.ts.map +1 -1
  45. package/lib/Select/Select.js +53 -65
  46. package/lib/SelectPanel/{SelectPanel-06900070.css → SelectPanel-e11ce210.css} +2 -2
  47. package/lib/SelectPanel/SelectPanel-e11ce210.css.map +1 -0
  48. package/lib/SelectPanel/SelectPanel.d.ts +1 -1
  49. package/lib/SelectPanel/SelectPanel.d.ts.map +1 -1
  50. package/lib/SelectPanel/SelectPanel.js +2 -9
  51. package/lib/SelectPanel/SelectPanel.module.css.js +2 -2
  52. package/lib/SideNav.d.ts +2 -3
  53. package/lib/SideNav.d.ts.map +1 -1
  54. package/lib/SideNav.js +4 -10
  55. package/lib/StateLabel/StateLabel-50420ff5.css +2 -0
  56. package/lib/StateLabel/StateLabel-50420ff5.css.map +1 -0
  57. package/lib/StateLabel/StateLabel.d.ts +6 -5
  58. package/lib/StateLabel/StateLabel.d.ts.map +1 -1
  59. package/lib/StateLabel/StateLabel.js +54 -126
  60. package/lib/StateLabel/StateLabel.module.css.js +2 -2
  61. package/lib/TextInputWithTokens/TextInputWithTokens.d.ts +6 -0
  62. package/lib/TextInputWithTokens/TextInputWithTokens.d.ts.map +1 -1
  63. package/lib/TextInputWithTokens/TextInputWithTokens.js +343 -331
  64. package/lib/ToggleSwitch/ToggleSwitch-4b23d166.css +2 -0
  65. package/lib/ToggleSwitch/ToggleSwitch-4b23d166.css.map +1 -0
  66. package/lib/ToggleSwitch/ToggleSwitch.d.ts +1 -3
  67. package/lib/ToggleSwitch/ToggleSwitch.d.ts.map +1 -1
  68. package/lib/ToggleSwitch/ToggleSwitch.js +120 -152
  69. package/lib/ToggleSwitch/ToggleSwitch.module.css.js +2 -2
  70. package/lib/Token/IssueLabelToken-0dbbbcdf.css +2 -0
  71. package/lib/Token/IssueLabelToken-0dbbbcdf.css.map +1 -0
  72. package/lib/Token/IssueLabelToken.d.ts.map +1 -1
  73. package/lib/Token/IssueLabelToken.js +7 -65
  74. package/lib/Token/IssueLabelToken.module.css.js +1 -1
  75. package/lib/Token/TokenBase.js +73 -82
  76. package/lib/Token/_RemoveTokenButton.js +106 -26
  77. package/lib/Tooltip/Tooltip.js +15 -17
  78. package/lib/TreeView/TreeView.js +18 -20
  79. package/lib/deprecated/ActionList/List.d.ts.map +1 -1
  80. package/lib/deprecated/ActionList/List.js +115 -138
  81. package/lib/deprecated/ActionMenu.js +19 -21
  82. package/lib/deprecated/index.d.ts +2 -0
  83. package/lib/deprecated/index.d.ts.map +1 -1
  84. package/lib/deprecated/index.js +2 -0
  85. package/lib/hooks/useMenuKeyboardNavigation.js +23 -43
  86. package/lib/hooks/useMnemonics.js +37 -76
  87. package/lib/hooks/useOpenAndCloseFocus.js +7 -14
  88. package/lib/hooks/useOverflow.js +7 -11
  89. package/lib/hooks/useScrollFlash.js +25 -14
  90. package/lib/index.d.ts +4 -3
  91. package/lib/index.d.ts.map +1 -1
  92. package/lib/index.js +10 -10
  93. package/lib/internal/components/BoxWithFallback.js +40 -35
  94. package/lib/internal/components/Caret-e686f04c.css +2 -0
  95. package/lib/internal/components/Caret-e686f04c.css.map +1 -0
  96. package/lib/internal/components/Caret.d.ts +1 -3
  97. package/lib/internal/components/Caret.d.ts.map +1 -1
  98. package/lib/internal/components/Caret.js +14 -48
  99. package/lib/internal/components/Caret.module.css.js +7 -0
  100. package/lib/internal/components/LiveRegion.js +8 -10
  101. package/lib/internal/utils/getGlobalFocusStyles.js +1 -1
  102. package/lib-esm/AvatarStack/AvatarStack.d.ts +2 -3
  103. package/lib-esm/AvatarStack/AvatarStack.js +1 -3
  104. package/lib-esm/Banner/Banner.js +3 -1
  105. package/lib-esm/Blankslate/Blankslate.js +38 -40
  106. package/lib-esm/BranchName/BranchName.d.ts +6 -3
  107. package/lib-esm/BranchName/BranchName.js +1 -3
  108. package/lib-esm/Button/ButtonBase.js +2 -2
  109. package/lib-esm/Checkbox/Checkbox.js +187 -56
  110. package/lib-esm/CircleBadge/CircleBadge.d.ts +4 -0
  111. package/lib-esm/CircleBadge/CircleBadge.js +4 -0
  112. package/lib-esm/DataTable/useTable.js +64 -83
  113. package/lib-esm/Details/Details.d.ts +2 -3
  114. package/lib-esm/Details/Details.js +1 -3
  115. package/lib-esm/FeatureFlags/FeatureFlags.js +10 -12
  116. package/lib-esm/FilteredActionList/useAnnouncements.js +31 -40
  117. package/lib-esm/LabelGroup/LabelGroup.d.ts +1 -2
  118. package/lib-esm/LabelGroup/LabelGroup.js +13 -16
  119. package/lib-esm/NavList/NavList.js +219 -53
  120. package/lib-esm/PageLayout/PageLayout.js +53 -55
  121. package/lib-esm/PointerBox/PointerBox.d.ts +8 -0
  122. package/lib-esm/PointerBox/PointerBox.js +4 -0
  123. package/{lib/ProgressBar/ProgressBar-a0957632.css → lib-esm/ProgressBar/ProgressBar-36f689cb.css} +2 -2
  124. package/lib-esm/ProgressBar/ProgressBar-36f689cb.css.map +1 -0
  125. package/lib-esm/ProgressBar/ProgressBar.d.ts +3 -4
  126. package/lib-esm/ProgressBar/ProgressBar.module.css.js +1 -1
  127. package/lib-esm/ProgressBar/index.d.ts +2 -2
  128. package/lib-esm/Select/Select.d.ts +1 -1
  129. package/lib-esm/Select/Select.js +53 -65
  130. package/lib-esm/SelectPanel/{SelectPanel-06900070.css → SelectPanel-e11ce210.css} +2 -2
  131. package/lib-esm/SelectPanel/SelectPanel-e11ce210.css.map +1 -0
  132. package/lib-esm/SelectPanel/SelectPanel.d.ts +1 -1
  133. package/lib-esm/SelectPanel/SelectPanel.js +2 -9
  134. package/lib-esm/SelectPanel/SelectPanel.module.css.js +2 -2
  135. package/lib-esm/SideNav.d.ts +2 -3
  136. package/lib-esm/SideNav.js +4 -10
  137. package/lib-esm/StateLabel/StateLabel-50420ff5.css +2 -0
  138. package/lib-esm/StateLabel/StateLabel-50420ff5.css.map +1 -0
  139. package/lib-esm/StateLabel/StateLabel.d.ts +6 -5
  140. package/lib-esm/StateLabel/StateLabel.js +55 -123
  141. package/lib-esm/StateLabel/StateLabel.module.css.js +2 -2
  142. package/lib-esm/TextInputWithTokens/TextInputWithTokens.d.ts +6 -0
  143. package/lib-esm/TextInputWithTokens/TextInputWithTokens.js +343 -331
  144. package/lib-esm/ToggleSwitch/ToggleSwitch-4b23d166.css +2 -0
  145. package/lib-esm/ToggleSwitch/ToggleSwitch-4b23d166.css.map +1 -0
  146. package/lib-esm/ToggleSwitch/ToggleSwitch.d.ts +1 -3
  147. package/lib-esm/ToggleSwitch/ToggleSwitch.js +120 -151
  148. package/lib-esm/ToggleSwitch/ToggleSwitch.module.css.js +2 -2
  149. package/lib-esm/Token/IssueLabelToken-0dbbbcdf.css +2 -0
  150. package/lib-esm/Token/IssueLabelToken-0dbbbcdf.css.map +1 -0
  151. package/lib-esm/Token/IssueLabelToken.js +7 -65
  152. package/lib-esm/Token/IssueLabelToken.module.css.js +1 -1
  153. package/lib-esm/Token/TokenBase.js +73 -82
  154. package/lib-esm/Token/_RemoveTokenButton.js +106 -26
  155. package/lib-esm/Tooltip/Tooltip.js +15 -17
  156. package/lib-esm/TreeView/TreeView.js +18 -20
  157. package/lib-esm/deprecated/ActionList/List.js +116 -138
  158. package/lib-esm/deprecated/ActionMenu.js +19 -21
  159. package/lib-esm/deprecated/index.d.ts +2 -0
  160. package/lib-esm/deprecated/index.js +1 -0
  161. package/lib-esm/hooks/useMenuKeyboardNavigation.js +23 -43
  162. package/lib-esm/hooks/useMnemonics.js +37 -76
  163. package/lib-esm/hooks/useOpenAndCloseFocus.js +7 -14
  164. package/lib-esm/hooks/useOverflow.js +7 -11
  165. package/lib-esm/hooks/useScrollFlash.js +25 -14
  166. package/lib-esm/index.d.ts +4 -3
  167. package/lib-esm/index.js +1 -1
  168. package/lib-esm/internal/components/BoxWithFallback.js +40 -35
  169. package/lib-esm/internal/components/Caret-e686f04c.css +2 -0
  170. package/lib-esm/internal/components/Caret-e686f04c.css.map +1 -0
  171. package/lib-esm/internal/components/Caret.d.ts +1 -3
  172. package/lib-esm/internal/components/Caret.js +14 -44
  173. package/lib-esm/internal/components/Caret.module.css.js +5 -0
  174. package/lib-esm/internal/components/LiveRegion.js +8 -10
  175. package/lib-esm/internal/utils/getGlobalFocusStyles.js +1 -1
  176. package/package.json +10 -10
  177. package/lib/CircleOcticon/CircleOcticon.d.ts +0 -16
  178. package/lib/CircleOcticon/CircleOcticon.d.ts.map +0 -1
  179. package/lib/CircleOcticon/CircleOcticon.js +0 -99
  180. package/lib/CircleOcticon/index.d.ts +0 -3
  181. package/lib/CircleOcticon/index.d.ts.map +0 -1
  182. package/lib/ProgressBar/ProgressBar-a0957632.css.map +0 -1
  183. package/lib/SelectPanel/SelectPanel-06900070.css.map +0 -1
  184. package/lib/StateLabel/StateLabel-cd27f475.css +0 -2
  185. package/lib/StateLabel/StateLabel-cd27f475.css.map +0 -1
  186. package/lib/ToggleSwitch/ToggleSwitch-65936b4b.css +0 -4
  187. package/lib/ToggleSwitch/ToggleSwitch-65936b4b.css.map +0 -1
  188. package/lib/Token/IssueLabelToken-99c9b914.css +0 -2
  189. package/lib/Token/IssueLabelToken-99c9b914.css.map +0 -1
  190. package/lib-esm/CircleOcticon/CircleOcticon.d.ts +0 -16
  191. package/lib-esm/CircleOcticon/CircleOcticon.js +0 -97
  192. package/lib-esm/CircleOcticon/index.d.ts +0 -3
  193. package/lib-esm/ProgressBar/ProgressBar-a0957632.css.map +0 -1
  194. package/lib-esm/SelectPanel/SelectPanel-06900070.css.map +0 -1
  195. package/lib-esm/StateLabel/StateLabel-cd27f475.css +0 -2
  196. package/lib-esm/StateLabel/StateLabel-cd27f475.css.map +0 -1
  197. package/lib-esm/ToggleSwitch/ToggleSwitch-65936b4b.css +0 -4
  198. package/lib-esm/ToggleSwitch/ToggleSwitch-65936b4b.css.map +0 -1
  199. package/lib-esm/Token/IssueLabelToken-99c9b914.css +0 -2
  200. package/lib-esm/Token/IssueLabelToken-99c9b914.css.map +0 -1
@@ -1,4 +1,3 @@
1
- import { c } from 'react-compiler-runtime';
2
1
  import React from 'react';
3
2
  import { iterateFocusableElements } from '@primer/behaviors/utils';
4
3
  import { useProvidedRefOrCreate } from './useProvidedRefOrCreate.js';
@@ -10,103 +9,65 @@ import { useProvidedRefOrCreate } from './useProvidedRefOrCreate.js';
10
9
  */
11
10
 
12
11
  const useMnemonics = (open, providedRef) => {
13
- const $ = c(9);
14
12
  const containerRef = useProvidedRefOrCreate(providedRef);
15
- let t0;
16
- let t1;
17
- if ($[0] !== containerRef || $[1] !== open) {
18
- t0 = function addAriaKeyshortcuts() {
19
- if (!open || !containerRef.current) {
20
- return;
21
- }
22
- const container = containerRef.current;
23
- const focusableItems = [...iterateFocusableElements(container)];
24
- focusableItems.map(_temp);
25
- };
26
- t1 = [open, containerRef];
27
- $[0] = containerRef;
28
- $[1] = open;
29
- $[2] = t0;
30
- $[3] = t1;
31
- } else {
32
- t0 = $[2];
33
- t1 = $[3];
34
- }
35
- React.useEffect(t0, t1);
36
- let t2;
37
- if ($[4] !== containerRef || $[5] !== open) {
38
- t2 = [open, containerRef];
39
- $[4] = containerRef;
40
- $[5] = open;
41
- $[6] = t2;
42
- } else {
43
- t2 = $[6];
44
- }
13
+ React.useEffect(function addAriaKeyshortcuts() {
14
+ if (!open || !containerRef.current) return;
15
+ const container = containerRef.current;
16
+ const focusableItems = [...iterateFocusableElements(container)];
17
+ focusableItems.map(item => {
18
+ // if item already has aria-keyshortcuts defined by user, skip
19
+ if (item.getAttribute('aria-keyshortcuts')) return;
20
+ const firstLetter = item.textContent.toLowerCase()[0];
21
+ if (firstLetter) item.setAttribute('aria-keyshortcuts', firstLetter);
22
+ });
23
+ }, [open, containerRef]);
45
24
  React.useEffect(function handleKeyDown() {
46
- if (!open || !containerRef.current) {
47
- return;
48
- }
25
+ if (!open || !containerRef.current) return;
49
26
  const container_0 = containerRef.current;
50
27
  const handler = event => {
51
28
  var _elementToFocus;
29
+ // skip if a TextInput has focus
52
30
  const activeElement = document.activeElement;
53
- if (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA") {
54
- return;
55
- }
31
+ if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') return;
32
+
33
+ // skip if used with modifier to preserve shortcuts like ⌘ + F
56
34
  const hasModifier = event.ctrlKey || event.altKey || event.metaKey;
57
- if (hasModifier) {
58
- return;
59
- }
60
- if (!isAlphabetKey(event)) {
61
- return;
62
- }
35
+ if (hasModifier) return;
36
+
37
+ // skip if it's not a alphabet key
38
+ if (!isAlphabetKey(event)) return;
39
+
40
+ // if this is a typeahead event, don't propagate outside of menu
63
41
  event.stopPropagation();
64
42
  const query = event.key.toLowerCase();
65
43
  let elementToFocus;
66
44
  const focusableItems_0 = [...iterateFocusableElements(container_0)];
67
45
  const itemsMatchingKey = focusableItems_0.filter(item_0 => {
68
46
  var _item_0$getAttribute;
69
- const keyshortcuts = (_item_0$getAttribute = item_0.getAttribute("aria-keyshortcuts")) === null || _item_0$getAttribute === void 0 ? void 0 : _item_0$getAttribute.split(" ").map(_temp2);
47
+ const keyshortcuts = (_item_0$getAttribute = item_0.getAttribute('aria-keyshortcuts')) === null || _item_0$getAttribute === void 0 ? void 0 : _item_0$getAttribute.split(' ').map(shortcut => shortcut.toLowerCase());
70
48
  return keyshortcuts && keyshortcuts.includes(query);
71
49
  });
72
50
  const currentActiveIndex = itemsMatchingKey.indexOf(activeElement);
51
+
52
+ // If the last element is already selected, cycle through the list
73
53
  if (currentActiveIndex === itemsMatchingKey.length - 1) {
74
54
  elementToFocus = itemsMatchingKey[0];
75
55
  } else {
76
- elementToFocus = itemsMatchingKey.find((item_1, index) => index > currentActiveIndex);
56
+ elementToFocus = itemsMatchingKey.find((item_1, index) => {
57
+ return index > currentActiveIndex;
58
+ });
77
59
  }
78
60
  (_elementToFocus = elementToFocus) === null || _elementToFocus === void 0 ? void 0 : _elementToFocus.focus();
79
61
  };
80
- container_0.addEventListener("keydown", handler);
81
- return () => container_0.removeEventListener("keydown", handler);
82
- }, t2);
83
- const isAlphabetKey = _temp3;
84
- let t3;
85
- if ($[7] !== containerRef) {
86
- t3 = {
87
- containerRef
88
- };
89
- $[7] = containerRef;
90
- $[8] = t3;
91
- } else {
92
- t3 = $[8];
93
- }
94
- return t3;
62
+ container_0.addEventListener('keydown', handler);
63
+ return () => container_0.removeEventListener('keydown', handler);
64
+ }, [open, containerRef]);
65
+ const isAlphabetKey = event_0 => {
66
+ return event_0.key.length === 1 && /[a-z\d]/i.test(event_0.key);
67
+ };
68
+ return {
69
+ containerRef
70
+ };
95
71
  };
96
- function _temp(item) {
97
- if (item.getAttribute("aria-keyshortcuts")) {
98
- return;
99
- }
100
- const firstLetter = item.textContent.toLowerCase()[0];
101
- if (firstLetter) {
102
- item.setAttribute("aria-keyshortcuts", firstLetter);
103
- }
104
- }
105
- function _temp2(shortcut) {
106
- return shortcut.toLowerCase();
107
- }
108
- function _temp3(event_0) {
109
- return event_0.key.length === 1 && /[a-z\d]/i.test(event_0.key);
110
- }
111
72
 
112
73
  export { useMnemonics };
@@ -3,7 +3,7 @@ import { useEffect } from 'react';
3
3
  import { iterateFocusableElements } from '@primer/behaviors/utils';
4
4
 
5
5
  function useOpenAndCloseFocus(t0) {
6
- const $ = c(10);
6
+ const $ = c(6);
7
7
  const {
8
8
  initialFocusRef,
9
9
  returnFocusRef,
@@ -11,7 +11,8 @@ function useOpenAndCloseFocus(t0) {
11
11
  preventFocusOnOpen
12
12
  } = t0;
13
13
  let t1;
14
- if ($[0] !== containerRef || $[1] !== initialFocusRef || $[2] !== preventFocusOnOpen || $[3] !== returnFocusRef.current) {
14
+ let t2;
15
+ if ($[0] !== containerRef || $[1] !== initialFocusRef || $[2] !== preventFocusOnOpen || $[3] !== returnFocusRef) {
15
16
  t1 = () => {
16
17
  if (!preventFocusOnOpen) {
17
18
  if (initialFocusRef && initialFocusRef.current) {
@@ -28,24 +29,16 @@ function useOpenAndCloseFocus(t0) {
28
29
  returnFocusRefCurrent === null || returnFocusRefCurrent === void 0 ? void 0 : returnFocusRefCurrent.focus();
29
30
  };
30
31
  };
32
+ t2 = [initialFocusRef, returnFocusRef, containerRef, preventFocusOnOpen];
31
33
  $[0] = containerRef;
32
34
  $[1] = initialFocusRef;
33
35
  $[2] = preventFocusOnOpen;
34
- $[3] = returnFocusRef.current;
36
+ $[3] = returnFocusRef;
35
37
  $[4] = t1;
38
+ $[5] = t2;
36
39
  } else {
37
40
  t1 = $[4];
38
- }
39
- let t2;
40
- if ($[5] !== containerRef || $[6] !== initialFocusRef || $[7] !== preventFocusOnOpen || $[8] !== returnFocusRef) {
41
- t2 = [initialFocusRef, returnFocusRef, containerRef, preventFocusOnOpen];
42
- $[5] = containerRef;
43
- $[6] = initialFocusRef;
44
- $[7] = preventFocusOnOpen;
45
- $[8] = returnFocusRef;
46
- $[9] = t2;
47
- } else {
48
- t2 = $[9];
41
+ t2 = $[5];
49
42
  }
50
43
  useEffect(t1, t2);
51
44
  }
@@ -2,10 +2,11 @@ import { c } from 'react-compiler-runtime';
2
2
  import { useState, useEffect } from 'react';
3
3
 
4
4
  function useOverflow(ref) {
5
- const $ = c(4);
5
+ const $ = c(3);
6
6
  const [hasOverflow, setHasOverflow] = useState(false);
7
7
  let t0;
8
- if ($[0] !== ref.current) {
8
+ let t1;
9
+ if ($[0] !== ref) {
9
10
  t0 = () => {
10
11
  if (ref.current === null) {
11
12
  return;
@@ -23,18 +24,13 @@ function useOverflow(ref) {
23
24
  observer.disconnect();
24
25
  };
25
26
  };
26
- $[0] = ref.current;
27
+ t1 = [ref];
28
+ $[0] = ref;
27
29
  $[1] = t0;
30
+ $[2] = t1;
28
31
  } else {
29
32
  t0 = $[1];
30
- }
31
- let t1;
32
- if ($[2] !== ref) {
33
- t1 = [ref];
34
- $[2] = ref;
35
- $[3] = t1;
36
- } else {
37
- t1 = $[3];
33
+ t1 = $[2];
38
34
  }
39
35
  useEffect(t0, t1);
40
36
  return hasOverflow;
@@ -1,3 +1,4 @@
1
+ import { c } from 'react-compiler-runtime';
1
2
  import { useEffect } from 'react';
2
3
 
3
4
  /**
@@ -5,20 +6,30 @@ import { useEffect } from 'react';
5
6
  * @param scrollContainerRef The ref of the scrollable content
6
7
  */
7
8
  function useScrollFlash(scrollContainerRef) {
8
- // https://adxlv.computer/projects/flash-scrollers/
9
- useEffect(() => {
10
- const scrollContainer = scrollContainerRef.current;
11
- if (!scrollContainer) {
12
- return;
13
- }
14
- const currentScroll = scrollContainer.scrollTop;
15
- const maxScroll = scrollContainer.scrollHeight;
16
- const altScroll = currentScroll < Math.min(1, maxScroll) ? currentScroll + 1 : currentScroll - 1;
17
-
18
- // eslint-disable-next-line react-compiler/react-compiler
19
- scrollContainer.scrollTop = altScroll;
20
- scrollContainer.scrollTop = currentScroll;
21
- }, [scrollContainerRef]);
9
+ const $ = c(3);
10
+ let t0;
11
+ let t1;
12
+ if ($[0] !== scrollContainerRef) {
13
+ t0 = () => {
14
+ const scrollContainer = scrollContainerRef.current;
15
+ if (!scrollContainer) {
16
+ return;
17
+ }
18
+ const currentScroll = scrollContainer.scrollTop;
19
+ const maxScroll = scrollContainer.scrollHeight;
20
+ const altScroll = currentScroll < Math.min(1, maxScroll) ? currentScroll + 1 : currentScroll - 1;
21
+ scrollContainer.scrollTop = altScroll;
22
+ scrollContainer.scrollTop = currentScroll;
23
+ };
24
+ t1 = [scrollContainerRef];
25
+ $[0] = scrollContainerRef;
26
+ $[1] = t0;
27
+ $[2] = t1;
28
+ } else {
29
+ t0 = $[1];
30
+ t1 = $[2];
31
+ }
32
+ useEffect(t0, t1);
22
33
  }
23
34
 
24
35
  export { useScrollFlash as default };
@@ -43,6 +43,8 @@ export { default as Avatar } from './Avatar';
43
43
  export type { AvatarProps } from './Avatar';
44
44
  export { default as AvatarStack } from './AvatarStack';
45
45
  export type { AvatarStackProps } from './AvatarStack';
46
+ export { Banner } from './Banner';
47
+ export type { BannerProps } from './Banner';
46
48
  export { default as BranchName } from './BranchName';
47
49
  export type { BranchNameProps } from './BranchName';
48
50
  export { default as Breadcrumbs, Breadcrumb } from './Breadcrumbs';
@@ -50,8 +52,6 @@ export type { BreadcrumbsProps, BreadcrumbsItemProps, BreadcrumbProps, Breadcrum
50
52
  export { default as ButtonGroup } from './ButtonGroup';
51
53
  export type { ButtonGroupProps } from './ButtonGroup';
52
54
  export type { CircleBadgeProps, CircleBadgeIconProps } from './CircleBadge';
53
- export { default as CircleOcticon } from './CircleOcticon';
54
- export type { CircleOcticonProps } from './CircleOcticon';
55
55
  export { default as CheckboxGroup } from './CheckboxGroup';
56
56
  export { default as CircleBadge } from './CircleBadge';
57
57
  export { default as CounterLabel } from './CounterLabel';
@@ -89,7 +89,7 @@ export type { PopoverProps, PopoverContentProps } from './Popover';
89
89
  export { default as Portal, registerPortalRoot } from './Portal';
90
90
  export type { PortalProps } from './Portal';
91
91
  export { ProgressBar } from './ProgressBar';
92
- export type { ProgressBarProps } from './ProgressBar';
92
+ export type { ProgressBarProps, ProgressBarItemProps } from './ProgressBar';
93
93
  export { default as RadioGroup } from './RadioGroup';
94
94
  export type { RelativeTimeProps } from './RelativeTime';
95
95
  export { default as RelativeTime } from './RelativeTime';
@@ -107,6 +107,7 @@ export type { StateLabelProps } from './StateLabel';
107
107
  export { default as SubNav } from './SubNav';
108
108
  export type { SubNavProps, SubNavLinkProps, SubNavLinksProps } from './SubNav';
109
109
  export { default as ToggleSwitch } from './ToggleSwitch';
110
+ export type { ToggleSwitchProps } from './ToggleSwitch';
110
111
  export { default as TextInput } from './TextInput';
111
112
  export type { TextInputProps } from './TextInput';
112
113
  export { default as TextInputWithTokens } from './TextInputWithTokens';
package/lib-esm/index.js CHANGED
@@ -19,6 +19,7 @@ export { default as useIsomorphicLayoutEffect } from './utils/useIsomorphicLayou
19
19
  export { useProvidedRefOrCreate } from './hooks/useProvidedRefOrCreate.js';
20
20
  export { createComponent } from './utils/create-component.js';
21
21
  export { ActionList } from './ActionList/index.js';
22
+ export { Banner } from './Banner/index.js';
22
23
  export { Dialog } from './Dialog/Dialog.js';
23
24
  export { default as Label } from './Label/Label.js';
24
25
  export { default as Pagination } from './Pagination/Pagination.js';
@@ -34,7 +35,6 @@ export { default as Radio } from './Radio/Radio.js';
34
35
  export { default as Avatar } from './Avatar/Avatar.js';
35
36
  export { default as AvatarStack } from './AvatarStack/AvatarStack.js';
36
37
  export { default as ButtonGroup } from './ButtonGroup/ButtonGroup.js';
37
- export { default as CircleOcticon } from './CircleOcticon/CircleOcticon.js';
38
38
  export { default as CounterLabel } from './CounterLabel/CounterLabel.js';
39
39
  export { default as Details } from './Details/Details.js';
40
40
  export { default as Flash } from './Flash/Flash.js';
@@ -6,60 +6,65 @@ import { jsx } from 'react/jsx-runtime';
6
6
  import Box from '../../Box/Box.js';
7
7
 
8
8
  const BoxWithFallback = /*#__PURE__*/React.forwardRef(function BoxWithFallback(t0, ref) {
9
- const $ = c(13);
9
+ const $ = c(14);
10
+ let BaseComponent;
10
11
  let rest;
12
+ let sx;
11
13
  let t1;
12
- let t2;
13
14
  if ($[0] !== t0) {
14
- ({
15
- as: t1,
16
- sx: t2,
17
- ...rest
18
- } = t0);
15
+ const {
16
+ as: t2,
17
+ sx: t3,
18
+ ...t4
19
+ } = t0;
20
+ rest = t4;
21
+ BaseComponent = t2 === undefined ? "div" : t2;
22
+ sx = t3 === undefined ? defaultSxProp : t3;
23
+ t1 = sx !== defaultSxProp || includesSystemProps(rest);
19
24
  $[0] = t0;
20
- $[1] = rest;
21
- $[2] = t1;
22
- $[3] = t2;
25
+ $[1] = BaseComponent;
26
+ $[2] = rest;
27
+ $[3] = sx;
28
+ $[4] = t1;
23
29
  } else {
24
- rest = $[1];
25
- t1 = $[2];
26
- t2 = $[3];
30
+ BaseComponent = $[1];
31
+ rest = $[2];
32
+ sx = $[3];
33
+ t1 = $[4];
27
34
  }
28
- const BaseComponent = t1 === undefined ? "div" : t1;
29
- const sx = t2 === undefined ? defaultSxProp : t2;
30
- if (sx !== defaultSxProp || includesSystemProps(rest)) {
31
- let t3;
32
- if ($[4] !== BaseComponent || $[5] !== ref || $[6] !== rest || $[7] !== sx) {
33
- t3 = /*#__PURE__*/jsx(Box, {
35
+ if (t1) {
36
+ let t2;
37
+ if ($[5] !== BaseComponent || $[6] !== ref || $[7] !== rest || $[8] !== sx) {
38
+ t2 = /*#__PURE__*/jsx(Box, {
34
39
  ...rest,
35
40
  ref: ref,
36
41
  as: BaseComponent,
37
42
  sx: sx
38
43
  });
39
- $[4] = BaseComponent;
40
- $[5] = ref;
41
- $[6] = rest;
42
- $[7] = sx;
43
- $[8] = t3;
44
+ $[5] = BaseComponent;
45
+ $[6] = ref;
46
+ $[7] = rest;
47
+ $[8] = sx;
48
+ $[9] = t2;
44
49
  } else {
45
- t3 = $[8];
50
+ t2 = $[9];
46
51
  }
47
- return t3;
52
+ return t2;
48
53
  }
49
- let t3;
50
- if ($[9] !== BaseComponent || $[10] !== ref || $[11] !== rest) {
51
- t3 = /*#__PURE__*/jsx(BaseComponent, {
54
+ let t2;
55
+ if ($[10] !== BaseComponent || $[11] !== ref || $[12] !== rest) {
56
+ t2 = /*#__PURE__*/jsx(BaseComponent, {
52
57
  ...rest,
53
58
  ref: ref
54
59
  });
55
- $[9] = BaseComponent;
56
- $[10] = ref;
57
- $[11] = rest;
58
- $[12] = t3;
60
+ $[10] = BaseComponent;
61
+ $[11] = ref;
62
+ $[12] = rest;
63
+ $[13] = t2;
59
64
  } else {
60
- t3 = $[12];
65
+ t2 = $[13];
61
66
  }
62
- return t3;
67
+ return t2;
63
68
  });
64
69
 
65
70
  export { BoxWithFallback };
@@ -0,0 +1,2 @@
1
+ .prc-components-Caret-PNu-B{pointer-events:none;position:absolute}.prc-components-CaretTriangle-Iu0GY{fill:var(--caret-bg,var(--bgColor-default,var(--color-canvas-default)))}.prc-components-CaretBorder-o3vP2{fill:none;stroke:var(--caret-border-color,var(--borderColor-default,var(--color-border-default)));stroke-width:var(--caret-border-width,var(--borderWidth-thin,.0625rem))}
2
+ /*# sourceMappingURL=Caret-e686f04c.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/internal/components/Caret.module.css"],"names":[],"mappings":"AAAA,4BACE,mBAAoB,CACpB,iBACF,CAEA,oCAEE,uEACF,CAEA,kCACE,SAAU,CAEV,uFAA6D,CAC7D,uEACF","file":"Caret-e686f04c.css","sourcesContent":[".Caret {\n pointer-events: none;\n position: absolute;\n}\n\n.CaretTriangle {\n /* stylelint-disable-next-line primer/colors */\n fill: var(--caret-bg, var(--bgColor-default));\n}\n\n.CaretBorder {\n fill: none;\n /* stylelint-disable-next-line primer/colors */\n stroke: var(--caret-border-color, var(--borderColor-default));\n stroke-width: var(--caret-border-width, var(--borderWidth-thin));\n}\n"]}
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import type { Theme } from '../../ThemeProvider';
1
+ import type React from 'react';
3
2
  type Location = 'top' | 'top-left' | 'top-right' | 'right' | 'right-top' | 'right-bottom' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-top' | 'left-bottom';
4
3
  export type CaretProps = {
5
4
  bg?: string;
@@ -7,7 +6,6 @@ export type CaretProps = {
7
6
  borderWidth?: string | number;
8
7
  size?: number;
9
8
  location?: Location;
10
- theme?: Theme;
11
9
  };
12
10
  declare function Caret(props: CaretProps): React.JSX.Element;
13
11
  declare namespace Caret {
@@ -1,6 +1,4 @@
1
- import React from 'react';
2
- import { ThemeContext } from 'styled-components';
3
- import { style } from 'styled-system';
1
+ import classes from './Caret.module.css.js';
4
2
  import { jsx, jsxs } from 'react/jsx-runtime';
5
3
 
6
4
  const oppositeEdge = {
@@ -27,39 +25,11 @@ function getPosition(edge, align, spacing) {
27
25
  [align || perp]: align ? spacing : '50%'
28
26
  };
29
27
  }
30
- const getBg = style({
31
- prop: 'bg',
32
- key: 'colors'
33
- });
34
- const getBorderColor = style({
35
- prop: 'borderColor',
36
- key: 'colors'
37
- });
38
- const getBorderWidth = style({
39
- prop: 'borderWidth',
40
- key: 'borderWidths',
41
- scale: [0, 1]
42
- });
43
28
  function Caret(props) {
44
- var _props$theme;
45
- const theme = React.useContext(ThemeContext);
46
- const propsWithTheme = {
47
- ...props,
48
- bg: props.bg || 'canvas.default',
49
- borderColor: props.borderColor || 'border.default',
50
- borderWidth: props.borderWidth || 1,
51
- theme: (_props$theme = props.theme) !== null && _props$theme !== void 0 ? _props$theme : theme
52
- };
53
- const {
54
- bg
55
- } = getBg(propsWithTheme);
56
- const {
57
- borderColor
58
- } = getBorderColor(propsWithTheme);
59
- const {
60
- borderWidth
61
- } = getBorderWidth(propsWithTheme);
62
29
  const {
30
+ bg,
31
+ borderColor,
32
+ borderWidth,
63
33
  size = 8,
64
34
  location = 'bottom'
65
35
  } = props;
@@ -83,30 +53,30 @@ function Caret(props) {
83
53
  left: `translate(${[size * 2, size]}) rotate(90)`
84
54
  }[edge];
85
55
  return /*#__PURE__*/jsx("svg", {
56
+ className: classes.Caret,
86
57
  width: size * 2,
87
58
  height: size * 2,
88
59
  style: {
89
- pointerEvents: 'none',
90
- position: 'absolute',
91
60
  ...getPosition(edge, align, size),
92
61
  // if align is set (top|right|bottom|left),
93
62
  // then we don't need an offset margin
94
- [`margin${perp}`]: align ? null : -size
63
+ [`margin${perp}`]: align ? null : -size,
64
+ ...{
65
+ '--caret-bg': bg,
66
+ '--caret-border-color': borderColor,
67
+ '--caret-border-width': borderWidth
68
+ }
95
69
  },
96
70
  role: "presentation",
97
71
  children: /*#__PURE__*/jsxs("g", {
72
+ className: classes.CaretGroup,
98
73
  transform: transform,
99
74
  children: [/*#__PURE__*/jsx("path", {
100
75
  d: triangle,
101
- fill: theme === null || theme === void 0 ? void 0 : theme.colors.canvas.default
102
- }), /*#__PURE__*/jsx("path", {
103
- d: triangle,
104
- fill: bg
76
+ className: classes.CaretTriangle
105
77
  }), /*#__PURE__*/jsx("path", {
106
78
  d: line,
107
- fill: "none",
108
- stroke: borderColor,
109
- strokeWidth: borderWidth
79
+ className: classes.CaretBorder
110
80
  })]
111
81
  })
112
82
  });
@@ -0,0 +1,5 @@
1
+ import './Caret-e686f04c.css';
2
+
3
+ var classes = {"Caret":"prc-components-Caret-PNu-B","CaretTriangle":"prc-components-CaretTriangle-Iu0GY","CaretBorder":"prc-components-CaretBorder-o3vP2"};
4
+
5
+ export { classes as default };
@@ -18,32 +18,30 @@ function LiveRegion(t0) {
18
18
  } = t0;
19
19
  const [message, setMessage] = React.useState("");
20
20
  let t1;
21
- let t2;
22
21
  if ($[0] !== message) {
23
- t2 = {
22
+ t1 = {
24
23
  announce: setMessage,
25
24
  message
26
25
  };
27
26
  $[0] = message;
28
- $[1] = t2;
27
+ $[1] = t1;
29
28
  } else {
30
- t2 = $[1];
29
+ t1 = $[1];
31
30
  }
32
- t1 = t2;
33
31
  const value = t1;
34
- let t3;
32
+ let t2;
35
33
  if ($[2] !== children || $[3] !== value) {
36
- t3 = /*#__PURE__*/jsx(LiveRegionContext.Provider, {
34
+ t2 = /*#__PURE__*/jsx(LiveRegionContext.Provider, {
37
35
  value: value,
38
36
  children: children
39
37
  });
40
38
  $[2] = children;
41
39
  $[3] = value;
42
- $[4] = t3;
40
+ $[4] = t2;
43
41
  } else {
44
- t3 = $[4];
42
+ t2 = $[4];
45
43
  }
46
- return t3;
44
+ return t2;
47
45
  }
48
46
  function LiveRegionOutlet() {
49
47
  const $ = c(2);
@@ -2,6 +2,6 @@ import { css } from 'styled-components';
2
2
  import { get } from '../../constants.js';
3
3
 
4
4
  const globalFocusStyle = css(["box-shadow:none;outline:2px solid ", ";"], get('colors.accent.fg'));
5
- const getGlobalFocusStyles = outlineOffset => css(["&:focus:not(:disabled){", ";outline-offset:", ";&:not(:focus-visible){outline:solid 1px transparent;}}&:focus-visible:not(:disabled){", ";outline-offset:", ";}"], globalFocusStyle, typeof outlineOffset === 'undefined' ? '2px' : outlineOffset, globalFocusStyle, typeof outlineOffset === 'undefined' ? '2px' : outlineOffset);
5
+ const getGlobalFocusStyles = outlineOffset => css(["&:focus:not(:disabled){", ";outline-offset:", ";&:not(:focus-visible){outline:solid 1px transparent;}}&:focus-visible:not(:disabled){", ";outline-offset:", ";}"], globalFocusStyle, outlineOffset, globalFocusStyle, outlineOffset);
6
6
 
7
7
  export { getGlobalFocusStyles as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/react",
3
- "version": "38.0.0-rc.1",
3
+ "version": "38.0.0-rc.2",
4
4
  "description": "An implementation of GitHub's Primer Design System using React",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -112,8 +112,8 @@
112
112
  "devDependencies": {
113
113
  "@actions/core": "1.11.1",
114
114
  "@babel/cli": "7.28.3",
115
- "@babel/core": "7.28.3",
116
- "@babel/parser": "7.28.3",
115
+ "@babel/core": "7.28.4",
116
+ "@babel/parser": "7.28.4",
117
117
  "@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
118
118
  "@babel/plugin-proposal-optional-chaining": "7.21.0",
119
119
  "@babel/plugin-transform-modules-commonjs": "7.27.1",
@@ -129,11 +129,11 @@
129
129
  "@rollup/plugin-terser": "0.4.4",
130
130
  "@rollup/plugin-typescript": "12.1.4",
131
131
  "@rollup/plugin-virtual": "3.0.2",
132
- "@storybook/addon-a11y": "^9.1.2",
133
- "@storybook/addon-docs": "^9.1.2",
134
- "@storybook/addon-links": "^9.1.2",
132
+ "@storybook/addon-a11y": "^9.1.5",
133
+ "@storybook/addon-docs": "^9.1.5",
134
+ "@storybook/addon-links": "^9.1.5",
135
135
  "@storybook/icons": "^1.4.0",
136
- "@storybook/react-vite": "^9.1.2",
136
+ "@storybook/react-vite": "^9.1.5",
137
137
  "@testing-library/dom": "^10.4.0",
138
138
  "@testing-library/jest-dom": "^6.4.5",
139
139
  "@testing-library/react": "^16.3.0",
@@ -158,7 +158,7 @@
158
158
  "babel-plugin-dev-expression": "0.2.3",
159
159
  "babel-plugin-macros": "3.1.0",
160
160
  "babel-plugin-open-source": "1.3.4",
161
- "babel-plugin-react-compiler": "^19.1.0-rc.2",
161
+ "babel-plugin-react-compiler": "^19.1.0-rc.3",
162
162
  "babel-plugin-styled-components": "2.1.4",
163
163
  "babel-plugin-transform-replace-expressions": "0.2.0",
164
164
  "babel-polyfill": "6.26.0",
@@ -188,11 +188,11 @@
188
188
  "react-test-renderer": "18.3.1",
189
189
  "recast": "0.23.7",
190
190
  "rimraf": "5.0.5",
191
- "rollup": "4.48.0",
191
+ "rollup": "4.50.1",
192
192
  "rollup-plugin-import-css": "^0.0.0",
193
193
  "rollup-plugin-postcss": "4.0.2",
194
194
  "rollup-plugin-visualizer": "6.0.3",
195
- "storybook": "^9.1.2",
195
+ "storybook": "^9.1.5",
196
196
  "styled-components": "5.3.11",
197
197
  "terser": "5.36.0",
198
198
  "ts-toolbelt": "9.6.0",