@primer/components 0.0.0-20211030175556 → 0.0.0-20211030175634

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/CHANGELOG.md +24 -2
  2. package/dist/browser.esm.js +144 -137
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +128 -121
  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/Button/Button.d.ts +1 -0
  17. package/lib/Button/ButtonClose.d.ts +2 -1
  18. package/lib/Button/ButtonDanger.d.ts +1 -0
  19. package/lib/Button/ButtonInvisible.d.ts +1 -0
  20. package/lib/Button/ButtonOutline.d.ts +1 -0
  21. package/lib/Button/ButtonPrimary.d.ts +1 -0
  22. package/lib/Button/index.js +70 -21
  23. package/lib/Checkbox.d.ts +29 -0
  24. package/lib/Checkbox.js +64 -0
  25. package/lib/CircleOcticon.d.ts +1 -0
  26. package/lib/Dialog.d.ts +3 -2
  27. package/lib/Dropdown.d.ts +4 -0
  28. package/lib/DropdownMenu/DropdownButton.d.ts +2 -1
  29. package/lib/DropdownMenu/index.js +20 -6
  30. package/lib/DropdownStyles.js +26 -18
  31. package/lib/FilterList.d.ts +1 -0
  32. package/lib/FilteredActionList/index.js +12 -4
  33. package/lib/NewButton/index.js +12 -5
  34. package/lib/NewButton/types.js +1 -2
  35. package/lib/Overlay.d.ts +5 -3
  36. package/lib/Pagination/index.js +12 -6
  37. package/lib/Portal/index.js +16 -5
  38. package/lib/Position.d.ts +4 -4
  39. package/lib/SelectMenu/SelectMenu.d.ts +10 -4
  40. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  41. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  42. package/lib/SelectMenu/hooks/useKeyboardNav.js +96 -80
  43. package/lib/SelectMenu/index.js +14 -7
  44. package/lib/SelectPanel/index.js +12 -4
  45. package/lib/TextInputWithTokens.d.ts +1 -0
  46. package/lib/Token/AvatarToken.d.ts +1 -1
  47. package/lib/Token/IssueLabelToken.d.ts +1 -1
  48. package/lib/Token/Token.d.ts +1 -1
  49. package/lib/Token/index.js +30 -11
  50. package/lib/behaviors/anchoredPosition.js +234 -205
  51. package/lib/behaviors/focusTrap.js +157 -121
  52. package/lib/behaviors/focusZone.js +509 -434
  53. package/lib/behaviors/scrollIntoViewingArea.js +35 -18
  54. package/lib/constants.js +43 -39
  55. package/lib/drafts.js +30 -20
  56. package/lib/hooks/index.js +60 -16
  57. package/lib/hooks/useAnchoredPosition.js +40 -32
  58. package/lib/hooks/useCombinedRefs.js +36 -32
  59. package/lib/hooks/useDialog.js +96 -72
  60. package/lib/hooks/useFocusTrap.js +60 -43
  61. package/lib/hooks/useFocusZone.js +50 -54
  62. package/lib/hooks/useOnEscapePress.js +36 -25
  63. package/lib/hooks/useOpenAndCloseFocus.js +34 -22
  64. package/lib/hooks/useProvidedRefOrCreate.js +14 -10
  65. package/lib/hooks/useProvidedStateOrCreate.js +16 -13
  66. package/lib/hooks/useRenderForcingRef.js +17 -13
  67. package/lib/hooks/useResizeObserver.js +18 -15
  68. package/lib/hooks/useSafeTimeout.js +30 -22
  69. package/lib/hooks/useScrollFlash.js +23 -16
  70. package/lib/index.d.ts +2 -0
  71. package/lib/index.js +652 -163
  72. package/lib/polyfills/eventListenerSignal.js +45 -37
  73. package/lib/sx.js +22 -10
  74. package/lib/theme-preval.js +3169 -64
  75. package/lib/theme.js +12 -3
  76. package/lib/utils/iterateFocusableElements.js +85 -63
  77. package/lib/utils/testing.d.ts +2 -1
  78. package/lib/utils/testing.js +29 -0
  79. package/lib/utils/theme.js +47 -33
  80. package/lib/utils/types/AriaRole.js +1 -2
  81. package/lib/utils/types/ComponentProps.js +1 -2
  82. package/lib/utils/types/Flatten.js +1 -2
  83. package/lib/utils/types/KeyPaths.js +1 -2
  84. package/lib/utils/types/MandateProps.js +1 -16
  85. package/lib/utils/types/Merge.js +1 -2
  86. package/lib/utils/types/index.js +69 -16
  87. package/lib/utils/uniqueId.js +8 -5
  88. package/lib/utils/use-force-update.js +14 -8
  89. package/lib/utils/useIsomorphicLayoutEffect.js +11 -8
  90. package/lib/utils/userAgent.js +12 -8
  91. package/lib-esm/ActionList/Item.js +3 -3
  92. package/lib-esm/ActionList2/Item.js +3 -1
  93. package/lib-esm/ActionList2/List.js +1 -2
  94. package/lib-esm/ActionList2/Selection.js +3 -1
  95. package/lib-esm/Autocomplete/Autocomplete.d.ts +1 -0
  96. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +1 -0
  97. package/lib-esm/Button/Button.d.ts +1 -0
  98. package/lib-esm/Button/ButtonClose.d.ts +2 -1
  99. package/lib-esm/Button/ButtonDanger.d.ts +1 -0
  100. package/lib-esm/Button/ButtonInvisible.d.ts +1 -0
  101. package/lib-esm/Button/ButtonOutline.d.ts +1 -0
  102. package/lib-esm/Button/ButtonPrimary.d.ts +1 -0
  103. package/lib-esm/Checkbox.d.ts +29 -0
  104. package/lib-esm/Checkbox.js +44 -0
  105. package/lib-esm/CircleOcticon.d.ts +1 -0
  106. package/lib-esm/Dialog.d.ts +3 -2
  107. package/lib-esm/Dropdown.d.ts +4 -0
  108. package/lib-esm/DropdownMenu/DropdownButton.d.ts +2 -1
  109. package/lib-esm/FilterList.d.ts +1 -0
  110. package/lib-esm/Overlay.d.ts +5 -3
  111. package/lib-esm/Position.d.ts +4 -4
  112. package/lib-esm/SelectMenu/SelectMenu.d.ts +10 -4
  113. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  114. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  115. package/lib-esm/TextInputWithTokens.d.ts +1 -0
  116. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  117. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  118. package/lib-esm/Token/Token.d.ts +1 -1
  119. package/lib-esm/index.d.ts +2 -0
  120. package/lib-esm/index.js +1 -0
  121. package/lib-esm/theme-preval.js +446 -0
  122. package/lib-esm/utils/testing.d.ts +2 -1
  123. package/lib-esm/utils/testing.js +24 -0
  124. package/package.json +4 -5
  125. package/lib/ActionList/Divider.jsx +0 -29
  126. package/lib/ActionList/Group.jsx +0 -23
  127. package/lib/ActionList/Header.jsx +0 -66
  128. package/lib/ActionList/Item.jsx +0 -288
  129. package/lib/ActionList/List.jsx +0 -138
  130. package/lib/ActionList2/Description.jsx +0 -29
  131. package/lib/ActionList2/Divider.jsx +0 -22
  132. package/lib/ActionList2/Group.jsx +0 -54
  133. package/lib/ActionList2/Header.d.ts +0 -26
  134. package/lib/ActionList2/Header.js +0 -55
  135. package/lib/ActionList2/Header.jsx +0 -36
  136. package/lib/ActionList2/Item.jsx +0 -174
  137. package/lib/ActionList2/LinkItem.jsx +0 -28
  138. package/lib/ActionList2/List.jsx +0 -41
  139. package/lib/ActionList2/Selection.jsx +0 -50
  140. package/lib/ActionList2/Visuals.jsx +0 -48
  141. package/lib/ActionMenu.jsx +0 -73
  142. package/lib/AnchoredOverlay/AnchoredOverlay.jsx +0 -100
  143. package/lib/Autocomplete/Autocomplete.jsx +0 -100
  144. package/lib/Autocomplete/AutocompleteContext.jsx +0 -5
  145. package/lib/Autocomplete/AutocompleteInput.jsx +0 -113
  146. package/lib/Autocomplete/AutocompleteMenu.jsx +0 -190
  147. package/lib/Autocomplete/AutocompleteOverlay.jsx +0 -55
  148. package/lib/Avatar.jsx +0 -34
  149. package/lib/AvatarPair.jsx +0 -29
  150. package/lib/AvatarStack.jsx +0 -151
  151. package/lib/BaseStyles.jsx +0 -65
  152. package/lib/BorderBox.jsx +0 -18
  153. package/lib/Box.jsx +0 -10
  154. package/lib/BranchName.jsx +0 -20
  155. package/lib/Breadcrumbs.jsx +0 -71
  156. package/lib/Button/Button.jsx +0 -40
  157. package/lib/Button/ButtonBase.jsx +0 -33
  158. package/lib/Button/ButtonClose.jsx +0 -53
  159. package/lib/Button/ButtonDanger.jsx +0 -43
  160. package/lib/Button/ButtonGroup.jsx +0 -55
  161. package/lib/Button/ButtonInvisible.jsx +0 -32
  162. package/lib/Button/ButtonOutline.jsx +0 -43
  163. package/lib/Button/ButtonPrimary.jsx +0 -42
  164. package/lib/Button/ButtonStyles.jsx +0 -37
  165. package/lib/Button/ButtonTableList.jsx +0 -46
  166. package/lib/Caret.jsx +0 -93
  167. package/lib/CircleBadge.jsx +0 -42
  168. package/lib/CircleOcticon.jsx +0 -21
  169. package/lib/CounterLabel.jsx +0 -43
  170. package/lib/Details.jsx +0 -21
  171. package/lib/Dialog/ConfirmationDialog.jsx +0 -146
  172. package/lib/Dialog/Dialog.jsx +0 -279
  173. package/lib/Dialog.jsx +0 -129
  174. package/lib/Dropdown.jsx +0 -131
  175. package/lib/DropdownMenu/DropdownButton.jsx +0 -14
  176. package/lib/DropdownMenu/DropdownMenu.jsx +0 -70
  177. package/lib/FilterList.jsx +0 -59
  178. package/lib/FilteredActionList/FilteredActionList.jsx +0 -100
  179. package/lib/FilteredSearch.jsx +0 -28
  180. package/lib/Flash.jsx +0 -69
  181. package/lib/Flex.jsx +0 -15
  182. package/lib/FormGroup.jsx +0 -22
  183. package/lib/Grid.jsx +0 -15
  184. package/lib/Header.jsx +0 -83
  185. package/lib/Heading.jsx +0 -21
  186. package/lib/Label.jsx +0 -82
  187. package/lib/LabelGroup.jsx +0 -18
  188. package/lib/Link.jsx +0 -36
  189. package/lib/NewButton/button-counter.jsx +0 -14
  190. package/lib/NewButton/button.jsx +0 -279
  191. package/lib/Overlay.jsx +0 -154
  192. package/lib/Pagehead.jsx +0 -17
  193. package/lib/Pagination/Pagination.jsx +0 -161
  194. package/lib/Pagination/model.jsx +0 -174
  195. package/lib/PointerBox.jsx +0 -25
  196. package/lib/Popover.jsx +0 -202
  197. package/lib/Portal/Portal.jsx +0 -79
  198. package/lib/Position.jsx +0 -46
  199. package/lib/ProgressBar.jsx +0 -39
  200. package/lib/SelectMenu/SelectMenu.jsx +0 -112
  201. package/lib/SelectMenu/SelectMenuContext.jsx +0 -5
  202. package/lib/SelectMenu/SelectMenuDivider.jsx +0 -42
  203. package/lib/SelectMenu/SelectMenuFilter.jsx +0 -58
  204. package/lib/SelectMenu/SelectMenuFooter.jsx +0 -45
  205. package/lib/SelectMenu/SelectMenuHeader.jsx +0 -42
  206. package/lib/SelectMenu/SelectMenuItem.jsx +0 -142
  207. package/lib/SelectMenu/SelectMenuList.jsx +0 -59
  208. package/lib/SelectMenu/SelectMenuLoadingAnimation.jsx +0 -22
  209. package/lib/SelectMenu/SelectMenuModal.jsx +0 -118
  210. package/lib/SelectMenu/SelectMenuTab.jsx +0 -92
  211. package/lib/SelectMenu/SelectMenuTabPanel.jsx +0 -42
  212. package/lib/SelectMenu/SelectMenuTabs.jsx +0 -57
  213. package/lib/SelectPanel/SelectPanel.jsx +0 -105
  214. package/lib/SideNav.jsx +0 -173
  215. package/lib/Spinner.jsx +0 -35
  216. package/lib/StateLabel.jsx +0 -93
  217. package/lib/StyledOcticon.jsx +0 -18
  218. package/lib/SubNav.jsx +0 -101
  219. package/lib/TabNav.jsx +0 -58
  220. package/lib/Text.jsx +0 -14
  221. package/lib/TextInput.jsx +0 -23
  222. package/lib/TextInputWithTokens.jsx +0 -218
  223. package/lib/ThemeProvider.jsx +0 -130
  224. package/lib/Timeline.jsx +0 -123
  225. package/lib/Token/AvatarToken.jsx +0 -54
  226. package/lib/Token/IssueLabelToken.jsx +0 -125
  227. package/lib/Token/Token.jsx +0 -103
  228. package/lib/Token/TokenBase.jsx +0 -88
  229. package/lib/Token/_RemoveTokenButton.jsx +0 -108
  230. package/lib/Token/_TokenTextContainer.jsx +0 -49
  231. package/lib/Tooltip.jsx +0 -246
  232. package/lib/Truncate.jsx +0 -24
  233. package/lib/UnderlineNav.jsx +0 -88
  234. package/lib/_TextInputWrapper.jsx +0 -120
  235. package/lib/_UnstyledTextInput.jsx +0 -22
  236. package/lib/hooks/useDetails.jsx +0 -39
  237. package/lib/hooks/useOnOutsideClick.jsx +0 -61
  238. package/lib/hooks/useOverlay.jsx +0 -15
  239. package/lib/utils/create-slots.jsx +0 -65
  240. package/lib/utils/deprecate.jsx +0 -59
  241. package/lib/utils/isNumeric.jsx +0 -7
  242. package/lib/utils/ssr.jsx +0 -6
  243. package/lib/utils/test-deprecations.jsx +0 -20
  244. package/lib/utils/test-helpers.jsx +0 -8
  245. package/lib/utils/test-matchers.jsx +0 -100
  246. package/lib/utils/testing.jsx +0 -206
  247. package/lib-esm/ActionList2/Header.d.ts +0 -26
  248. package/lib-esm/ActionList2/Header.js +0 -44
@@ -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
- const classnames_1 = __importDefault(require("classnames"));
7
- const react_1 = __importDefault(require("react"));
8
- const styled_components_1 = __importDefault(require("styled-components"));
9
- const constants_1 = require("./constants");
10
- const sx_1 = __importDefault(require("./sx"));
11
- const ITEM_CLASS = 'UnderlineNav-item';
12
- const SELECTED_CLASS = 'selected';
13
- const UnderlineNavBase = styled_components_1.default.nav `
14
- display: flex;
15
- justify-content: space-between;
16
- border-bottom: 1px solid ${constants_1.get('colors.border.muted')};
17
- &.UnderlineNav--right {
18
- justify-content: flex-end;
19
-
20
- .UnderlineNav-item {
21
- margin-right: 0;
22
- margin-left: ${constants_1.get('space.3')};
23
- }
24
-
25
- .UnderlineNav-actions {
26
- flex: 1 1 auto;
27
- }
28
- }
29
- &.UnderlineNav--full {
30
- display: block;
31
- }
32
-
33
- .UnderlineNav-body {
34
- display: flex;
35
- margin-bottom: -1px;
36
- }
37
-
38
- .UnderlineNav-actions {
39
- align-self: center;
40
- }
41
-
42
- ${sx_1.default};
43
- `;
44
- function UnderlineNav({ actions, className, align, children, full, label, theme, ...rest }) {
45
- const classes = classnames_1.default(className, 'UnderlineNav', align && `UnderlineNav--${align}`, full && 'UnderlineNav--full');
46
- return (<UnderlineNavBase className={classes} aria-label={label} theme={theme} {...rest}>
47
- <div className="UnderlineNav-body">{children}</div>
48
- {actions && <div className="UnderlineNav-actions">{actions}</div>}
49
- </UnderlineNavBase>);
50
- }
51
- const UnderlineNavLink = styled_components_1.default.a.attrs(props => ({
52
- activeClassName: typeof props.to === 'string' ? 'selected' : '',
53
- className: classnames_1.default(ITEM_CLASS, props.selected && SELECTED_CLASS, props.className)
54
- })) `
55
- padding: ${constants_1.get('space.3')} ${constants_1.get('space.2')};
56
- margin-right: ${constants_1.get('space.3')};
57
- font-size: ${constants_1.get('fontSizes.1')};
58
- line-height: ${constants_1.get('lineHeights.default')};
59
- color: ${constants_1.get('colors.fg.default')};
60
- text-align: center;
61
- border-bottom: 2px solid transparent;
62
- text-decoration: none;
63
-
64
- &:hover,
65
- &:focus {
66
- color: ${constants_1.get('colors.fg.default')};
67
- text-decoration: none;
68
- border-bottom-color: ${constants_1.get('colors.neutral.muted')};
69
- transition: 0.2s ease;
70
-
71
- .UnderlineNav-octicon {
72
- color: ${constants_1.get('colors.fg.muted')};
73
- }
74
- }
75
-
76
- &.selected {
77
- color: ${constants_1.get('colors.fg.default')};
78
- border-bottom-color: ${constants_1.get('colors.primer.border.active')};
79
-
80
- .UnderlineNav-octicon {
81
- color: ${constants_1.get('colors.fg.default')};
82
- }
83
- }
84
-
85
- ${sx_1.default};
86
- `;
87
- UnderlineNavLink.displayName = 'UnderlineNav.Link';
88
- exports.default = Object.assign(UnderlineNav, { Link: UnderlineNavLink });
@@ -1,120 +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 sizeVariants = styled_system_1.variant({
30
- variants: {
31
- small: {
32
- minHeight: '28px',
33
- px: 2,
34
- py: '3px',
35
- fontSize: 0,
36
- lineHeight: '20px'
37
- },
38
- large: {
39
- px: 2,
40
- py: '10px',
41
- fontSize: 3
42
- }
43
- }
44
- });
45
- const TextInputWrapper = styled_components_1.default.span `
46
- display: inline-flex;
47
- align-items: stretch;
48
- min-height: 34px;
49
- font-size: ${constants_1.get('fontSizes.1')};
50
- line-height: 20px;
51
- color: ${constants_1.get('colors.fg.default')};
52
- vertical-align: middle;
53
- background-repeat: no-repeat; // Repeat and position set for form states (success, error, etc)
54
- background-position: right 8px center; // For form validation. This keeps images 8px from right and centered vertically.
55
- border: 1px solid ${constants_1.get('colors.border.default')};
56
- border-radius: ${constants_1.get('radii.2')};
57
- outline: none;
58
- box-shadow: ${constants_1.get('shadows.primer.shadow.inset')};
59
- cursor: text;
60
-
61
- ${props => {
62
- if (props.hasIcon) {
63
- return styled_components_1.css `
64
- padding: 0;
65
- `;
66
- }
67
- else {
68
- return styled_components_1.css `
69
- padding: 6px 12px;
70
- `;
71
- }
72
- }}
73
-
74
- .TextInput-icon {
75
- align-self: center;
76
- color: ${constants_1.get('colors.fg.muted')};
77
- margin: 0 ${constants_1.get('space.2')};
78
- flex-shrink: 0;
79
- }
80
-
81
- &:focus-within {
82
- border-color: ${constants_1.get('colors.accent.emphasis')};
83
- box-shadow: ${constants_1.get('shadows.primer.shadow.focus')};
84
- }
85
-
86
- ${props => props.contrast &&
87
- styled_components_1.css `
88
- background-color: ${constants_1.get('colors.canvas.inset')};
89
- `}
90
-
91
- ${props => props.disabled &&
92
- styled_components_1.css `
93
- color: ${constants_1.get('colors.primer.fg.disabled')};
94
- background-color: ${constants_1.get('colors.input.disabledBg')};
95
- border-color: ${constants_1.get('colors.border.default')};
96
- `}
97
-
98
- ${props => props.block &&
99
- styled_components_1.css `
100
- display: block;
101
- width: 100%;
102
- `}
103
-
104
- ${props => props.block &&
105
- props.hasIcon &&
106
- styled_components_1.css `
107
- display: flex;
108
- `}
109
-
110
- // Ensures inputs don't zoom on mobile but are body-font size on desktop
111
- @media (min-width: ${constants_1.get('breakpoints.1')}) {
112
- font-size: ${constants_1.get('fontSizes.1')};
113
- }
114
- ${styled_system_1.width}
115
- ${styled_system_1.minWidth}
116
- ${styled_system_1.maxWidth}
117
- ${sizeVariants}
118
- ${sx_1.default};
119
- `;
120
- exports.default = TextInputWrapper;
@@ -1,22 +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 sx_1 = __importDefault(require("./sx"));
8
- const UnstyledTextInput = styled_components_1.default.input `
9
- border: 0;
10
- font-size: inherit;
11
- font-family: inherit;
12
- background-color: transparent;
13
- -webkit-appearance: none;
14
- color: inherit;
15
- width: 100%;
16
- &:focus {
17
- outline: 0;
18
- }
19
-
20
- ${sx_1.default};
21
- `;
22
- exports.default = UnstyledTextInput;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const react_1 = require("react");
4
- function useDetails({ ref, closeOnOutsideClick, defaultOpen, onClickOutside }) {
5
- const [open, setOpen] = react_1.useState(defaultOpen);
6
- const backupRef = react_1.useRef(null);
7
- const customRef = ref ?? backupRef;
8
- const onClickOutsideInternal = react_1.useCallback((event) => {
9
- const { current } = customRef;
10
- const eventTarget = event.target;
11
- const closest = eventTarget.closest('details');
12
- if (closest !== current) {
13
- onClickOutside && onClickOutside(event);
14
- if (!event.defaultPrevented) {
15
- setOpen(false);
16
- }
17
- }
18
- }, [customRef, setOpen, onClickOutside]);
19
- // handles the overlay behavior - closing the menu when clicking outside of it
20
- react_1.useEffect(() => {
21
- if (open && closeOnOutsideClick) {
22
- document.addEventListener('click', onClickOutsideInternal);
23
- return () => {
24
- document.removeEventListener('click', onClickOutsideInternal);
25
- };
26
- }
27
- }, [open, closeOnOutsideClick, onClickOutsideInternal]);
28
- const handleToggle = (e) => {
29
- if (!e.defaultPrevented) {
30
- const eventTarget = e.target;
31
- setOpen(eventTarget.open);
32
- }
33
- };
34
- const getDetailsProps = () => {
35
- return { onToggle: handleToggle, open, ref: customRef };
36
- };
37
- return { open, setOpen, getDetailsProps };
38
- }
39
- exports.default = useDetails;
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useOnOutsideClick = void 0;
4
- const react_1 = require("react");
5
- // Because events are handled at the document level, we provide a mechanism for early return.
6
- const stopPropagation = true;
7
- /**
8
- * Calls all handlers in reverse order
9
- * @param event The MouseEvent generated by the click event.
10
- */
11
- function handleClick(event) {
12
- if (!event.defaultPrevented) {
13
- for (const handler of Object.values(registry).reverse()) {
14
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
15
- if (handler(event) === stopPropagation || event.defaultPrevented) {
16
- break;
17
- }
18
- }
19
- }
20
- }
21
- const registry = {};
22
- function register(id, handler) {
23
- registry[id] = handler;
24
- }
25
- function deregister(id) {
26
- delete registry[id];
27
- }
28
- // For auto-incrementing unique identifiers for registered handlers.
29
- let handlerId = 0;
30
- const useOnOutsideClick = ({ containerRef, ignoreClickRefs, onClickOutside }) => {
31
- const id = react_1.useMemo(() => handlerId++, []);
32
- const handler = react_1.useCallback(event => {
33
- // don't call click handler if the mouse event was triggered by an auxiliary button (right click/wheel button/etc)
34
- if (event instanceof MouseEvent && event.button > 0) {
35
- return stopPropagation;
36
- }
37
- // don't call handler if the click happened inside of the container
38
- if (containerRef.current?.contains(event.target)) {
39
- return stopPropagation;
40
- }
41
- // don't call handler if click happened on an ignored ref
42
- if (ignoreClickRefs && ignoreClickRefs.some(({ current }) => current?.contains(event.target))) {
43
- return stopPropagation;
44
- }
45
- onClickOutside(event);
46
- }, [containerRef, ignoreClickRefs, onClickOutside]);
47
- react_1.useEffect(() => {
48
- if (Object.keys(registry).length === 0) {
49
- // use capture to ensure we get all events
50
- document.addEventListener('mousedown', handleClick, { capture: true });
51
- }
52
- register(id, handler);
53
- return () => {
54
- deregister(id);
55
- if (Object.keys(registry).length === 0) {
56
- document.removeEventListener('mousedown', handleClick, { capture: true });
57
- }
58
- };
59
- }, [id, handler]);
60
- };
61
- exports.useOnOutsideClick = useOnOutsideClick;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useOverlay = void 0;
4
- const useOnOutsideClick_1 = require("./useOnOutsideClick");
5
- const useOpenAndCloseFocus_1 = require("./useOpenAndCloseFocus");
6
- const useOnEscapePress_1 = require("./useOnEscapePress");
7
- const useProvidedRefOrCreate_1 = require("./useProvidedRefOrCreate");
8
- const useOverlay = ({ overlayRef: _overlayRef, returnFocusRef, initialFocusRef, onEscape, ignoreClickRefs, onClickOutside, preventFocusOnOpen }) => {
9
- const overlayRef = useProvidedRefOrCreate_1.useProvidedRefOrCreate(_overlayRef);
10
- useOpenAndCloseFocus_1.useOpenAndCloseFocus({ containerRef: overlayRef, returnFocusRef, initialFocusRef, preventFocusOnOpen });
11
- useOnOutsideClick_1.useOnOutsideClick({ containerRef: overlayRef, ignoreClickRefs, onClickOutside });
12
- useOnEscapePress_1.useOnEscapePress(onEscape);
13
- return { ref: overlayRef };
14
- };
15
- exports.useOverlay = useOverlay;
@@ -1,65 +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 react_1 = __importDefault(require("react"));
7
- const use_force_update_1 = require("./use-force-update");
8
- /** createSlots is a factory that can create a
9
- * typesafe Slots + Slot pair to use in a component definition
10
- * For example: ActionList.Item uses createSlots to get a Slots wrapper
11
- * + Slot component that is used by LeadingVisual, Description
12
- */
13
- const createSlots = (slotNames) => {
14
- const SlotsContext = react_1.default.createContext({
15
- registerSlot: () => null,
16
- unregisterSlot: () => null,
17
- context: {}
18
- });
19
- /** Slots uses a Double render strategy inspired by [reach-ui/descendants](https://github.com/reach/reach-ui/tree/develop/packages/descendants)
20
- * Slot registers themself with the Slots parent.
21
- * When all the children have mounted = registered themselves in slot,
22
- * we re-render the parent component to render with slots
23
- */
24
- const Slots = ({ context = {}, children }) => {
25
- // initialise slots
26
- const slotsDefinition = {};
27
- slotNames.map(name => (slotsDefinition[name] = null));
28
- const slotsRef = react_1.default.useRef(slotsDefinition);
29
- const rerenderWithSlots = use_force_update_1.useForceUpdate();
30
- const [isMounted, setIsMounted] = react_1.default.useState(false);
31
- // fires after all the effects in children
32
- react_1.default.useEffect(() => {
33
- rerenderWithSlots();
34
- setIsMounted(true);
35
- }, [rerenderWithSlots]);
36
- const registerSlot = react_1.default.useCallback((name, contents) => {
37
- slotsRef.current[name] = contents;
38
- // don't render until the component mounts = all slots are registered
39
- if (isMounted)
40
- rerenderWithSlots();
41
- }, [isMounted, rerenderWithSlots]);
42
- // Slot can be removed from the tree as well,
43
- // we need to unregister them from the slot
44
- const unregisterSlot = react_1.default.useCallback((name) => {
45
- slotsRef.current[name] = null;
46
- rerenderWithSlots();
47
- }, [rerenderWithSlots]);
48
- /**
49
- * Slots uses a render prop API so abstract the
50
- * implementation detail of using a context provider.
51
- */
52
- const slots = slotsRef.current;
53
- return (<SlotsContext.Provider value={{ registerSlot, unregisterSlot, context }}>{children(slots)}</SlotsContext.Provider>);
54
- };
55
- const Slot = ({ name, children }) => {
56
- const { registerSlot, unregisterSlot, context } = react_1.default.useContext(SlotsContext);
57
- react_1.default.useEffect(() => {
58
- registerSlot(name, typeof children === 'function' ? children(context) : children);
59
- return () => unregisterSlot(name);
60
- }, [name, children, registerSlot, unregisterSlot, context]);
61
- return null;
62
- };
63
- return { Slots, Slot };
64
- };
65
- exports.default = createSlots;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Deprecations = exports.useDeprecation = exports.deprecate = void 0;
4
- const react_1 = require("react");
5
- // eslint-disable-next-line @typescript-eslint/no-empty-function
6
- const noop = () => { };
7
- // eslint-disable-next-line import/no-mutable-exports
8
- let deprecate = noop;
9
- exports.deprecate = deprecate;
10
- if (__DEV__) {
11
- exports.deprecate = deprecate = ({ name, message, version }) => {
12
- Deprecations.deprecate({ name, message, version });
13
- };
14
- }
15
- // eslint-disable-next-line import/no-mutable-exports
16
- let useDeprecation = null;
17
- exports.useDeprecation = useDeprecation;
18
- if (__DEV__) {
19
- exports.useDeprecation = useDeprecation = ({ name, message, version }) => {
20
- const ref = react_1.useRef(false);
21
- const logDeprecation = react_1.useCallback(() => {
22
- if (!ref.current) {
23
- ref.current = true;
24
- deprecate({ name, message, version });
25
- }
26
- }, [name, message, version]);
27
- return logDeprecation;
28
- };
29
- }
30
- else {
31
- exports.useDeprecation = useDeprecation = () => {
32
- return noop;
33
- };
34
- }
35
- class Deprecations {
36
- constructor() {
37
- this.deprecations = [];
38
- }
39
- static get() {
40
- if (!Deprecations.instance) {
41
- Deprecations.instance = new Deprecations();
42
- }
43
- return Deprecations.instance;
44
- }
45
- static deprecate({ name, message, version }) {
46
- const msg = `WARNING! ${name} is deprecated and will be removed in version ${version}. ${message}`;
47
- // eslint-disable-next-line no-console
48
- console.warn(msg);
49
- this.get().deprecations.push({ name, message, version });
50
- }
51
- static getDeprecations() {
52
- return this.get().deprecations;
53
- }
54
- static clearDeprecations() {
55
- this.get().deprecations.length = 0;
56
- }
57
- }
58
- exports.Deprecations = Deprecations;
59
- Deprecations.instance = null;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
- function isNumeric(n) {
5
- return !isNaN(parseFloat(n)) && isFinite(n);
6
- }
7
- exports.default = isNumeric;
package/lib/utils/ssr.jsx DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSSRSafeId = exports.SSRProvider = void 0;
4
- var ssr_1 = require("@react-aria/ssr");
5
- Object.defineProperty(exports, "SSRProvider", { enumerable: true, get: function () { return ssr_1.SSRProvider; } });
6
- Object.defineProperty(exports, "useSSRSafeId", { enumerable: true, get: function () { return ssr_1.useSSRSafeId; } });
@@ -1,20 +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 semver_1 = __importDefault(require("semver"));
7
- const deprecate_1 = require("./deprecate");
8
- // eslint-disable-next-line @typescript-eslint/no-var-requires
9
- const ourVersion = require('../../package.json').version;
10
- beforeEach(() => {
11
- deprecate_1.Deprecations.clearDeprecations();
12
- });
13
- afterEach(() => {
14
- const deprecations = deprecate_1.Deprecations.getDeprecations();
15
- for (const dep of deprecations) {
16
- if (semver_1.default.gte(ourVersion, dep.version)) {
17
- throw new Error(`Found a deprecation that should be removed in ${dep.version}`);
18
- }
19
- }
20
- });
@@ -1,8 +0,0 @@
1
- "use strict";
2
- // JSDOM doesn't mock ResizeObserver
3
- global.ResizeObserver = jest.fn().mockImplementation(() => {
4
- return {
5
- observe: jest.fn(),
6
- disconnect: jest.fn()
7
- };
8
- });
@@ -1,100 +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
- require("jest-styled-components");
7
- const serializer_1 = require("jest-styled-components/serializer");
8
- const react_1 = __importDefault(require("react"));
9
- const testing_1 = require("./testing");
10
- expect.addSnapshotSerializer(serializer_1.styleSheetSerializer);
11
- const stringify = (d) => JSON.stringify(d, null, ' ');
12
- expect.extend({
13
- toMatchKeys(obj, values) {
14
- return {
15
- pass: Object.keys(values).every(key => this.equals(obj[key], values[key])),
16
- message: () => `Expected ${stringify(obj)} to have matching keys: ${stringify(values)}`
17
- };
18
- },
19
- toHaveClass(node, klass) {
20
- const classes = testing_1.getClasses(node);
21
- const pass = classes.includes(klass);
22
- return {
23
- pass,
24
- message: () => `expected ${stringify(classes)} to include: ${stringify(klass)}`
25
- };
26
- },
27
- toHaveClasses(node, klasses, only = false) {
28
- const classes = testing_1.getClasses(node);
29
- const pass = only
30
- ? this.equals(classes.sort(), klasses.sort())
31
- : klasses.every((klass) => classes.includes(klass));
32
- return {
33
- pass,
34
- message: () => `expected ${stringify(classes)} to include: ${stringify(klasses)}`
35
- };
36
- },
37
- toImplementSxBehavior(element) {
38
- const mediaKey = '@media (max-width:123px)';
39
- const sxPropValue = {
40
- [mediaKey]: {
41
- color: 'red.5'
42
- }
43
- };
44
- const elem = react_1.default.cloneElement(element, { sx: sxPropValue });
45
- function checkStylesDeep(rendered) {
46
- const className = rendered.props.className;
47
- const styles = testing_1.getComputedStyles(className);
48
- const mediaStyles = styles[mediaKey];
49
- if (mediaStyles && mediaStyles.color) {
50
- return true;
51
- }
52
- else if (rendered.children) {
53
- return rendered.children.some((child) => checkStylesDeep(child));
54
- }
55
- else {
56
- return false;
57
- }
58
- }
59
- return {
60
- pass: checkStylesDeep(testing_1.render(elem)),
61
- message: () => 'sx prop values did not change styles of component nor of any sub-components'
62
- };
63
- },
64
- toSetExports(mod, expectedExports) {
65
- if (!Object.keys(expectedExports).includes('default')) {
66
- return {
67
- pass: false,
68
- message: () => "You must specify the module's default export"
69
- };
70
- }
71
- const seen = new Set();
72
- for (const exp of Object.keys(expectedExports)) {
73
- seen.add(exp);
74
- if (mod[exp] !== expectedExports[exp]) {
75
- if (!mod[exp] && !expectedExports[exp]) {
76
- continue;
77
- }
78
- return {
79
- pass: false,
80
- message: () => `Module exported a different value from key '${exp}' than expected`
81
- };
82
- }
83
- }
84
- for (const exp of Object.keys(mod)) {
85
- if (seen.has(exp)) {
86
- continue;
87
- }
88
- if (mod[exp] !== expectedExports[exp]) {
89
- return {
90
- pass: false,
91
- message: () => `Module exported an unexpected value from key '${exp}'`
92
- };
93
- }
94
- }
95
- return {
96
- pass: true,
97
- message: () => ''
98
- };
99
- }
100
- });