@primer/components 0.0.0-202198182351 → 0.0.0-20219819465

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 (80) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/browser.esm.js +295 -294
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +369 -368
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
  7. package/lib/AnchoredOverlay/AnchoredOverlay.js +11 -3
  8. package/lib/Autocomplete/Autocomplete.d.ts +40 -0
  9. package/lib/Autocomplete/Autocomplete.js +68 -0
  10. package/lib/Autocomplete/AutocompleteContext.d.ts +17 -0
  11. package/lib/Autocomplete/AutocompleteContext.js +11 -0
  12. package/lib/Autocomplete/AutocompleteInput.d.ts +9 -0
  13. package/lib/Autocomplete/AutocompleteInput.js +150 -0
  14. package/lib/Autocomplete/AutocompleteMenu.d.ts +71 -0
  15. package/lib/Autocomplete/AutocompleteMenu.js +223 -0
  16. package/lib/Autocomplete/AutocompleteOverlay.d.ts +17 -0
  17. package/lib/Autocomplete/AutocompleteOverlay.js +74 -0
  18. package/lib/Autocomplete/index.d.ts +2 -0
  19. package/lib/Autocomplete/index.js +15 -0
  20. package/lib/FilteredActionList/FilteredActionList.js +5 -31
  21. package/lib/Overlay.d.ts +2 -1
  22. package/lib/Overlay.js +10 -5
  23. package/lib/TextInput.d.ts +4 -12
  24. package/lib/TextInput.js +4 -46
  25. package/lib/TextInputWithTokens.d.ts +323 -0
  26. package/lib/TextInputWithTokens.js +244 -0
  27. package/lib/_TextInputWrapper.d.ts +10 -0
  28. package/lib/_TextInputWrapper.js +51 -0
  29. package/lib/_UnstyledTextInput.d.ts +2 -0
  30. package/lib/_UnstyledTextInput.js +20 -0
  31. package/lib/hooks/useOpenAndCloseFocus.d.ts +2 -1
  32. package/lib/hooks/useOpenAndCloseFocus.js +7 -2
  33. package/lib/hooks/useOverlay.d.ts +2 -1
  34. package/lib/hooks/useOverlay.js +4 -2
  35. package/lib/index.d.ts +3 -0
  36. package/lib/index.js +16 -0
  37. package/lib/utils/scrollIntoViewingArea.d.ts +1 -0
  38. package/lib/utils/scrollIntoViewingArea.js +39 -0
  39. package/lib/utils/types/MandateProps.d.ts +3 -0
  40. package/lib/utils/types/MandateProps.js +1 -0
  41. package/lib/utils/types/index.d.ts +1 -0
  42. package/lib/utils/types/index.js +13 -0
  43. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
  44. package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +11 -3
  45. package/lib-esm/Autocomplete/Autocomplete.d.ts +40 -0
  46. package/lib-esm/Autocomplete/Autocomplete.js +47 -0
  47. package/lib-esm/Autocomplete/AutocompleteContext.d.ts +17 -0
  48. package/lib-esm/Autocomplete/AutocompleteContext.js +2 -0
  49. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +9 -0
  50. package/lib-esm/Autocomplete/AutocompleteInput.js +131 -0
  51. package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +71 -0
  52. package/lib-esm/Autocomplete/AutocompleteMenu.js +204 -0
  53. package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +17 -0
  54. package/lib-esm/Autocomplete/AutocompleteOverlay.js +56 -0
  55. package/lib-esm/Autocomplete/index.d.ts +2 -0
  56. package/lib-esm/Autocomplete/index.js +1 -0
  57. package/lib-esm/FilteredActionList/FilteredActionList.js +3 -31
  58. package/lib-esm/Overlay.d.ts +2 -1
  59. package/lib-esm/Overlay.js +8 -5
  60. package/lib-esm/TextInput.d.ts +4 -12
  61. package/lib-esm/TextInput.js +4 -37
  62. package/lib-esm/TextInputWithTokens.d.ts +323 -0
  63. package/lib-esm/TextInputWithTokens.js +219 -0
  64. package/lib-esm/_TextInputWrapper.d.ts +10 -0
  65. package/lib-esm/_TextInputWrapper.js +31 -0
  66. package/lib-esm/_UnstyledTextInput.d.ts +2 -0
  67. package/lib-esm/_UnstyledTextInput.js +7 -0
  68. package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +2 -1
  69. package/lib-esm/hooks/useOpenAndCloseFocus.js +7 -2
  70. package/lib-esm/hooks/useOverlay.d.ts +2 -1
  71. package/lib-esm/hooks/useOverlay.js +4 -2
  72. package/lib-esm/index.d.ts +3 -0
  73. package/lib-esm/index.js +2 -0
  74. package/lib-esm/utils/scrollIntoViewingArea.d.ts +1 -0
  75. package/lib-esm/utils/scrollIntoViewingArea.js +30 -0
  76. package/lib-esm/utils/types/MandateProps.d.ts +3 -0
  77. package/lib-esm/utils/types/MandateProps.js +1 -0
  78. package/lib-esm/utils/types/index.d.ts +1 -0
  79. package/lib-esm/utils/types/index.js +2 -1
  80. package/package.json +1 -1
@@ -0,0 +1,204 @@
1
+ import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { ActionList } from '../ActionList';
3
+ import { useFocusZone } from '../hooks/useFocusZone';
4
+ import { Box, Spinner } from '../';
5
+ import { AutocompleteContext } from './AutocompleteContext';
6
+ import { PlusIcon } from '@primer/octicons-react';
7
+ import { uniqueId } from '../utils/uniqueId';
8
+ import { scrollIntoViewingArea } from '../utils/scrollIntoViewingArea';
9
+
10
+ const getDefaultSortFn = isItemSelectedFn => (itemIdA, itemIdB) => isItemSelectedFn(itemIdA) === isItemSelectedFn(itemIdB) ? 0 : isItemSelectedFn(itemIdA) ? -1 : 1;
11
+
12
+ function getDefaultItemFilter(filterValue) {
13
+ return function (item, _i) {
14
+ var _item$text;
15
+
16
+ return Boolean((_item$text = item.text) === null || _item$text === void 0 ? void 0 : _item$text.toLowerCase().startsWith(filterValue.toLowerCase()));
17
+ };
18
+ }
19
+
20
+ function getDefaultOnSelectionChange(setInputValueFn) {
21
+ return function (itemOrItems) {
22
+ const {
23
+ text = ''
24
+ } = Array.isArray(itemOrItems) ? itemOrItems.slice(-1)[0] : itemOrItems;
25
+ setInputValueFn && setInputValueFn(text);
26
+ };
27
+ }
28
+
29
+ const isItemSelected = (itemId, selectedItemIds) => selectedItemIds.includes(itemId);
30
+
31
+ function getItemById(itemId, items) {
32
+ return items.find(item => item.id === itemId);
33
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+
35
+
36
+ function AutocompleteMenu(props) {
37
+ const {
38
+ activeDescendantRef,
39
+ id,
40
+ inputRef,
41
+ inputValue = '',
42
+ scrollContainerRef,
43
+ setAutocompleteSuggestion,
44
+ setShowMenu,
45
+ setInputValue,
46
+ setIsMenuDirectlyActivated,
47
+ setSelectedItemLength,
48
+ showMenu
49
+ } = useContext(AutocompleteContext);
50
+ const {
51
+ items,
52
+ selectedItemIds,
53
+ sortOnCloseFn,
54
+ emptyStateText,
55
+ addNewItem,
56
+ loading,
57
+ selectionVariant,
58
+ filterFn = getDefaultItemFilter(inputValue),
59
+ 'aria-labelledby': ariaLabelledBy,
60
+ onOpenChange,
61
+ onSelectedChange = getDefaultOnSelectionChange(setInputValue),
62
+ customScrollContainerRef
63
+ } = props;
64
+ const listContainerRef = useRef(null);
65
+ const [highlightedItem, setHighlightedItem] = useState();
66
+ const [sortedItemIds, setSortedItemIds] = useState(items.map(({
67
+ id: itemId
68
+ }) => itemId));
69
+ const selectableItems = useMemo(() => items.map(selectableItem => {
70
+ return { ...selectableItem,
71
+ role: 'option',
72
+ id: selectableItem.id,
73
+ selected: selectionVariant === 'multiple' ? selectedItemIds.includes(selectableItem.id) : undefined,
74
+ onAction: item => {
75
+ const otherSelectedItemIds = selectedItemIds.filter(selectedItemId => selectedItemId !== item.id);
76
+ const newSelectedItemIds = selectedItemIds.includes(item.id) ? otherSelectedItemIds : [...otherSelectedItemIds, item.id];
77
+ onSelectedChange && onSelectedChange(newSelectedItemIds.map(newSelectedItemId => getItemById(newSelectedItemId, items)));
78
+
79
+ if (selectionVariant === 'multiple') {
80
+ setInputValue && setInputValue('');
81
+ setAutocompleteSuggestion && setAutocompleteSuggestion('');
82
+ } else {
83
+ var _inputRef$current;
84
+
85
+ setShowMenu && setShowMenu(false);
86
+ inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.setSelectionRange(inputRef.current.value.length, inputRef.current.value.length);
87
+ }
88
+ }
89
+ };
90
+ }), [items, selectedItemIds, inputRef, onSelectedChange, selectionVariant, setAutocompleteSuggestion, setInputValue, setShowMenu]);
91
+ const itemSortOrderData = useMemo(() => sortedItemIds.reduce((acc, curr, i) => {
92
+ acc[curr] = i;
93
+ return acc;
94
+ }, {}), [sortedItemIds]);
95
+ const sortedAndFilteredItemsToRender = useMemo(() => selectableItems.filter(filterFn).sort((a, b) => itemSortOrderData[a.id] - itemSortOrderData[b.id]), [selectableItems, itemSortOrderData, filterFn]);
96
+ const allItemsToRender = useMemo(() => [// sorted and filtered selectable items
97
+ ...sortedAndFilteredItemsToRender, // menu item used for creating a token from whatever is in the text input
98
+ ...(addNewItem ? [{ ...addNewItem,
99
+ leadingVisual: () => /*#__PURE__*/React.createElement(PlusIcon, null),
100
+ onAction: item => {
101
+ // TODO: make it possible to pass a leadingVisual when using `addNewItem`
102
+ addNewItem.handleAddItem({ ...item,
103
+ id: item.id || uniqueId(),
104
+ leadingVisual: undefined
105
+ });
106
+
107
+ if (selectionVariant === 'multiple') {
108
+ setInputValue && setInputValue('');
109
+ setAutocompleteSuggestion && setAutocompleteSuggestion('');
110
+ }
111
+ }
112
+ }] : [])], [sortedAndFilteredItemsToRender, addNewItem, setAutocompleteSuggestion, selectionVariant, setInputValue]);
113
+ useFocusZone({
114
+ containerRef: listContainerRef,
115
+ focusOutBehavior: 'wrap',
116
+ focusableElementFilter: element => {
117
+ return !(element instanceof HTMLInputElement);
118
+ },
119
+ activeDescendantFocus: inputRef,
120
+ onActiveDescendantChanged: (current, _previous, directlyActivated) => {
121
+ if (activeDescendantRef) {
122
+ activeDescendantRef.current = current || null;
123
+ }
124
+
125
+ if (current) {
126
+ const selectedItem = selectableItems.find(item => item.id.toString() === current.getAttribute('data-id'));
127
+ setHighlightedItem(selectedItem);
128
+ setIsMenuDirectlyActivated && setIsMenuDirectlyActivated(directlyActivated);
129
+ }
130
+
131
+ if (current && customScrollContainerRef && customScrollContainerRef.current && directlyActivated) {
132
+ scrollIntoViewingArea(current, customScrollContainerRef.current);
133
+ } else if (current && scrollContainerRef && scrollContainerRef.current && directlyActivated) {
134
+ scrollIntoViewingArea(current, scrollContainerRef.current);
135
+ }
136
+ }
137
+ }, [loading]);
138
+ useEffect(() => {
139
+ var _highlightedItem$text;
140
+
141
+ if (!setAutocompleteSuggestion) {
142
+ return;
143
+ }
144
+
145
+ if (highlightedItem !== null && highlightedItem !== void 0 && (_highlightedItem$text = highlightedItem.text) !== null && _highlightedItem$text !== void 0 && _highlightedItem$text.startsWith(inputValue) && !selectedItemIds.includes(highlightedItem.id)) {
146
+ setAutocompleteSuggestion(highlightedItem.text);
147
+ } else {
148
+ setAutocompleteSuggestion('');
149
+ }
150
+ }, [highlightedItem, inputValue, selectedItemIds, setAutocompleteSuggestion]);
151
+ useEffect(() => {
152
+ const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn(itemId => isItemSelected(itemId, selectedItemIds)));
153
+ const sortResultMatchesState = itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element, index) => element === sortedItemIds[index]);
154
+
155
+ if (showMenu === false && !sortResultMatchesState) {
156
+ setSortedItemIds(itemIdSortResult);
157
+ }
158
+
159
+ onOpenChange && onOpenChange(Boolean(showMenu));
160
+ }, [showMenu, onOpenChange, selectedItemIds, sortOnCloseFn, sortedItemIds]);
161
+ useEffect(() => {
162
+ if (selectedItemIds.length) {
163
+ setSelectedItemLength && setSelectedItemLength(selectedItemIds.length);
164
+ }
165
+ }, [selectedItemIds, setSelectedItemLength]);
166
+ return /*#__PURE__*/React.createElement(Box, {
167
+ sx: !showMenu ? {
168
+ // visually hides this label for sighted users
169
+ position: 'absolute',
170
+ width: '1px',
171
+ height: '1px',
172
+ padding: '0',
173
+ margin: '-1px',
174
+ overflow: 'hidden',
175
+ clip: 'rect(0, 0, 0, 0)',
176
+ whiteSpace: 'nowrap',
177
+ borderWidth: '0'
178
+ } : {}
179
+ }, loading ? /*#__PURE__*/React.createElement(Box, {
180
+ p: 3,
181
+ display: "flex",
182
+ justifyContent: "center"
183
+ }, /*#__PURE__*/React.createElement(Spinner, null)) : /*#__PURE__*/React.createElement("div", {
184
+ ref: listContainerRef
185
+ }, allItemsToRender.length ? /*#__PURE__*/React.createElement(ActionList, {
186
+ selectionVariant: "multiple" // have to typecast to `ItemProps` because we have an extra property
187
+ // on `items` for Autocomplete: `metadata`
188
+ ,
189
+ items: allItemsToRender,
190
+ role: "listbox",
191
+ id: `${id}-listbox`,
192
+ "aria-labelledby": ariaLabelledBy
193
+ }) : /*#__PURE__*/React.createElement(Box, {
194
+ p: 3
195
+ }, emptyStateText)));
196
+ }
197
+
198
+ AutocompleteMenu.displayName = "AutocompleteMenu";
199
+ AutocompleteMenu.defaultProps = {
200
+ emptyStateText: 'No selectable options',
201
+ selectionVariant: 'single'
202
+ };
203
+ AutocompleteMenu.displayName = 'AutocompleteMenu';
204
+ export default AutocompleteMenu;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { OverlayProps } from '../Overlay';
3
+ import { ComponentProps } from '../utils/types';
4
+ declare type AutocompleteOverlayInternalProps = {
5
+ /**
6
+ * The ref of the element that the position of the menu is based on. By default, the menu is positioned based on the text input
7
+ */
8
+ menuAnchorRef?: React.RefObject<HTMLElement>;
9
+ /**
10
+ * Props to be spread on the internal `Overlay` component.
11
+ */
12
+ overlayProps?: Partial<OverlayProps>;
13
+ children?: React.ReactNode;
14
+ } & Pick<React.AriaAttributes, 'aria-labelledby'>;
15
+ declare const AutocompleteOverlay: React.FC<AutocompleteOverlayInternalProps>;
16
+ export declare type AutocompleteOverlayProps = ComponentProps<typeof AutocompleteOverlay>;
17
+ export default AutocompleteOverlay;
@@ -0,0 +1,56 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React, { useCallback, useContext } from 'react';
4
+ import { useAnchoredPosition } from '../hooks';
5
+ import Overlay from '../Overlay';
6
+ import { AutocompleteContext } from './AutocompleteContext';
7
+ import { useCombinedRefs } from '../hooks/useCombinedRefs';
8
+
9
+ // TODO: consider making 'aria-labelledby' required
10
+ const AutocompleteOverlay = ({
11
+ menuAnchorRef,
12
+ overlayProps,
13
+ children
14
+ }) => {
15
+ const {
16
+ inputRef,
17
+ scrollContainerRef,
18
+ selectedItemLength,
19
+ setShowMenu,
20
+ showMenu = false
21
+ } = useContext(AutocompleteContext);
22
+ const {
23
+ floatingElementRef,
24
+ position
25
+ } = useAnchoredPosition({
26
+ side: 'outside-bottom',
27
+ align: 'start',
28
+ anchorElementRef: menuAnchorRef ? menuAnchorRef : inputRef
29
+ }, [showMenu, selectedItemLength]);
30
+ const combinedOverlayRef = useCombinedRefs(scrollContainerRef, floatingElementRef);
31
+ const closeOptionList = useCallback(() => {
32
+ setShowMenu && setShowMenu(false);
33
+ }, [setShowMenu]);
34
+
35
+ if (typeof window === 'undefined') {
36
+ return null;
37
+ }
38
+
39
+ return /*#__PURE__*/React.createElement(Overlay, _extends({
40
+ returnFocusRef: inputRef,
41
+ preventFocusOnOpen: true,
42
+ onClickOutside: closeOptionList,
43
+ onEscape: closeOptionList,
44
+ ref: combinedOverlayRef,
45
+ top: position === null || position === void 0 ? void 0 : position.top,
46
+ left: position === null || position === void 0 ? void 0 : position.left,
47
+ visibility: showMenu ? 'visible' : 'hidden',
48
+ sx: {
49
+ overflow: 'auto'
50
+ }
51
+ }, overlayProps), children);
52
+ };
53
+
54
+ AutocompleteOverlay.displayName = "AutocompleteOverlay";
55
+ AutocompleteOverlay.displayName = 'AutocompleteOverlay';
56
+ export default AutocompleteOverlay;
@@ -0,0 +1,2 @@
1
+ export { default } from './Autocomplete';
2
+ export type { AutocompleteMenuProps, AutocompleteInputProps, AutocompleteOverlayProps } from './Autocomplete';
@@ -0,0 +1 @@
1
+ export { default } from './Autocomplete';
@@ -1,6 +1,7 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
3
  import React, { useCallback, useEffect, useRef } from 'react';
4
+ import { useSSRSafeId } from '@react-aria/ssr';
4
5
  import TextInput from '../TextInput';
5
6
  import Box from '../Box';
6
7
  import { ActionList } from '../ActionList';
@@ -11,36 +12,7 @@ import styled from 'styled-components';
11
12
  import { get } from '../constants';
12
13
  import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate';
13
14
  import useScrollFlash from '../hooks/useScrollFlash';
14
- import { useSSRSafeId } from '@react-aria/ssr';
15
-
16
- function scrollIntoViewingArea(child, container, margin = 8, behavior = 'smooth') {
17
- const {
18
- top: childTop,
19
- bottom: childBottom
20
- } = child.getBoundingClientRect();
21
- const {
22
- top: containerTop,
23
- bottom: containerBottom
24
- } = container.getBoundingClientRect();
25
- const isChildTopAboveViewingArea = childTop < containerTop + margin;
26
- const isChildBottomBelowViewingArea = childBottom > containerBottom - margin;
27
-
28
- if (isChildTopAboveViewingArea) {
29
- const scrollHeightToChildTop = childTop - containerTop + container.scrollTop;
30
- container.scrollTo({
31
- behavior,
32
- top: scrollHeightToChildTop - margin
33
- });
34
- } else if (isChildBottomBelowViewingArea) {
35
- const scrollHeightToChildBottom = childBottom - containerBottom + container.scrollTop;
36
- container.scrollTo({
37
- behavior,
38
- top: scrollHeightToChildBottom + margin
39
- });
40
- } // either completely in view or outside viewing area on both ends, don't scroll
41
-
42
- }
43
-
15
+ import { scrollIntoViewingArea } from '../utils/scrollIntoViewingArea';
44
16
  const StyledHeader = styled.div.withConfig({
45
17
  displayName: "FilteredActionList__StyledHeader",
46
18
  componentId: "yg3jkv-0"
@@ -95,7 +67,7 @@ export function FilteredActionList({
95
67
  useEffect(() => {
96
68
  // if items changed, we want to instantly move active descendant into view
97
69
  if (activeDescendantRef.current && scrollContainerRef.current) {
98
- scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, undefined, 'auto');
70
+ scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, 'vertical', undefined, undefined, 'auto');
99
71
  }
100
72
  }, [items]);
101
73
  useScrollFlash(scrollContainerRef);
@@ -4,7 +4,7 @@ import { ComponentProps } from './utils/types';
4
4
  import { TouchOrMouseEvent } from './hooks';
5
5
  import { SxProp } from './sx';
6
6
  import { AnchorSide } from './behaviors/anchoredPosition';
7
- declare type StyledOverlayProps = {
7
+ export declare type StyledOverlayProps = {
8
8
  width?: keyof typeof widthMap;
9
9
  height?: keyof typeof heightMap;
10
10
  maxHeight?: keyof Omit<typeof heightMap, 'auto' | 'initial'>;
@@ -40,6 +40,7 @@ export declare type OverlayProps = {
40
40
  top: number;
41
41
  left: number;
42
42
  portalContainerName?: string;
43
+ preventFocusOnOpen?: boolean;
43
44
  } & Omit<ComponentProps<typeof StyledOverlay>, 'visibility' | keyof SystemPositionProps>;
44
45
  /**
45
46
  * An `Overlay` is a flexible floating surface, used to display transient content such as menus,
@@ -92,6 +92,7 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
92
92
  left,
93
93
  anchorSide,
94
94
  portalContainerName,
95
+ preventFocusOnOpen,
95
96
  ...rest
96
97
  }, forwardedRef) => {
97
98
  const overlayRef = useRef(null);
@@ -107,7 +108,8 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
107
108
  onEscape,
108
109
  ignoreClickRefs,
109
110
  onClickOutside,
110
- initialFocusRef
111
+ initialFocusRef,
112
+ preventFocusOnOpen
111
113
  });
112
114
  useEffect(() => {
113
115
  var _combinedRef$current;
@@ -136,9 +138,7 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
136
138
  easing: slideAnimationEasing
137
139
  });
138
140
  }, [anchorSide, slideAnimationDistance, slideAnimationEasing, visibility]);
139
- return /*#__PURE__*/React.createElement(Portal, {
140
- containerName: portalContainerName
141
- }, /*#__PURE__*/React.createElement(StyledOverlay, _extends({
141
+ const styledOverlay = /*#__PURE__*/React.createElement(StyledOverlay, _extends({
142
142
  height: height,
143
143
  role: role
144
144
  }, rest, {
@@ -149,7 +149,10 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
149
149
  ...rest.style,
150
150
  '--styled-overlay-visibility': visibility
151
151
  }
152
- })));
152
+ }));
153
+ return /*#__PURE__*/React.createElement(Portal, {
154
+ containerName: portalContainerName
155
+ }, styledOverlay);
153
156
  });
154
157
  Overlay.defaultProps = {
155
158
  height: 'auto',
@@ -1,22 +1,14 @@
1
1
  import React from 'react';
2
- import { MaxWidthProps, MinWidthProps, WidthProps } from 'styled-system';
3
- import { SxProp } from './sx';
4
2
  import { ComponentProps, Merge } from './utils/types';
5
- declare const Input: import("styled-components").StyledComponent<"input", any, {}, never>;
6
- declare const Wrapper: import("styled-components").StyledComponent<"span", any, {
7
- disabled?: boolean | undefined;
8
- hasIcon?: boolean | undefined;
9
- block?: boolean | undefined;
10
- contrast?: boolean | undefined;
11
- variant?: "large" | "small" | undefined;
12
- } & WidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Width<import("styled-system").TLengthStyledSystem>> & MinWidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.MinWidth<import("styled-system").TLengthStyledSystem>> & MaxWidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>> & SxProp, never>;
3
+ import UnstyledTextInput from './_UnstyledTextInput';
4
+ import TextInputWrapper from './_TextInputWrapper';
13
5
  declare type NonPassthroughProps = {
14
6
  className?: string;
15
7
  icon?: React.ComponentType<{
16
8
  className?: string;
17
9
  }>;
18
- } & Pick<ComponentProps<typeof Wrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'theme' | 'width' | 'maxWidth' | 'minWidth' | 'variant'>;
19
- declare type TextInputInternalProps = Merge<React.ComponentPropsWithoutRef<typeof Input>, NonPassthroughProps>;
10
+ } & Pick<ComponentProps<typeof TextInputWrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'theme' | 'width' | 'maxWidth' | 'minWidth' | 'variant'>;
11
+ declare type TextInputInternalProps = Merge<React.ComponentPropsWithoutRef<typeof UnstyledTextInput>, NonPassthroughProps>;
20
12
  declare const TextInput: React.ForwardRefExoticComponent<Pick<TextInputInternalProps, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
21
13
  export declare type TextInputProps = ComponentProps<typeof TextInput>;
22
14
  export default TextInput;
@@ -2,41 +2,8 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import classnames from 'classnames';
4
4
  import React from 'react';
5
- import styled, { css } from 'styled-components';
6
- import { maxWidth, minWidth, variant, width } from 'styled-system';
7
- import { get } from './constants';
8
- import sx from './sx';
9
- const sizeVariants = variant({
10
- variants: {
11
- small: {
12
- minHeight: '28px',
13
- px: 2,
14
- py: '3px',
15
- fontSize: 0,
16
- lineHeight: '20px'
17
- },
18
- large: {
19
- px: 2,
20
- py: '10px',
21
- fontSize: 3
22
- }
23
- }
24
- });
25
- const Input = styled.input.withConfig({
26
- displayName: "TextInput__Input",
27
- componentId: "sc-1apmpmt-0"
28
- })(["border:0;font-size:inherit;font-family:inherit;background-color:transparent;-webkit-appearance:none;color:inherit;width:100%;&:focus{outline:0;}"]);
29
- const Wrapper = styled.span.withConfig({
30
- displayName: "TextInput__Wrapper",
31
- componentId: "sc-1apmpmt-1"
32
- })(["display:inline-flex;align-items:stretch;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], get('fontSizes.1'), get('colors.fg.default'), get('colors.border.default'), get('radii.2'), get('shadows.primer.shadow.inset'), props => {
33
- if (props.hasIcon) {
34
- return css(["padding:0;"]);
35
- } else {
36
- return css(["padding:6px 12px;"]);
37
- }
38
- }, get('colors.fg.muted'), get('space.2'), get('colors.accent.emphasis'), get('shadows.primer.shadow.focus'), props => props.contrast && css(["background-color:", ";"], get('colors.canvas.inset')), props => props.disabled && css(["color:", ";background-color:", ";border-color:", ";"], get('colors.fg.muted'), get('colors.input.disabledBg'), get('colors.border.default')), props => props.block && css(["display:block;width:100%;"]), get('breakpoints.1'), get('fontSizes.1'), width, minWidth, maxWidth, sizeVariants, sx); // Props that are not passed through to Input:
39
-
5
+ import UnstyledTextInput from './_UnstyledTextInput';
6
+ import TextInputWrapper from './_TextInputWrapper';
40
7
  // using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
41
8
  const TextInput = /*#__PURE__*/React.forwardRef(({
42
9
  icon: IconComponent,
@@ -54,7 +21,7 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
54
21
  }, ref) => {
55
22
  // this class is necessary to style FilterSearch, plz no touchy!
56
23
  const wrapperClasses = classnames(className, 'TextInput-wrapper');
57
- return /*#__PURE__*/React.createElement(Wrapper, {
24
+ return /*#__PURE__*/React.createElement(TextInputWrapper, {
58
25
  block: block,
59
26
  className: wrapperClasses,
60
27
  contrast: contrast,
@@ -68,7 +35,7 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
68
35
  variant: variantProp
69
36
  }, IconComponent && /*#__PURE__*/React.createElement(IconComponent, {
70
37
  className: "TextInput-icon"
71
- }), /*#__PURE__*/React.createElement(Input, _extends({
38
+ }), /*#__PURE__*/React.createElement(UnstyledTextInput, _extends({
72
39
  ref: ref,
73
40
  disabled: disabled
74
41
  }, inputProps)));