@primer/components 0.0.0-2021821193917 → 0.0.0-2021823142332

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/dist/browser.esm.js +665 -619
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +432 -386
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/Divider.js +1 -1
  7. package/lib/ActionList/Header.js +2 -2
  8. package/lib/ActionList/Item.js +13 -13
  9. package/lib/ActionList/List.js +1 -1
  10. package/lib/AnchoredOverlay/AnchoredOverlay.js +2 -2
  11. package/lib/Avatar.d.ts +4 -0
  12. package/lib/AvatarPair.js +1 -1
  13. package/lib/AvatarStack.js +1 -1
  14. package/lib/BranchName.js +1 -1
  15. package/lib/Breadcrumb.js +2 -2
  16. package/lib/Button/Button.d.ts +0 -1
  17. package/lib/Button/Button.js +1 -1
  18. package/lib/Button/ButtonClose.d.ts +1 -2
  19. package/lib/Button/ButtonClose.js +1 -1
  20. package/lib/Button/ButtonDanger.d.ts +0 -1
  21. package/lib/Button/ButtonInvisible.d.ts +0 -1
  22. package/lib/Button/ButtonInvisible.js +1 -1
  23. package/lib/Button/ButtonOutline.d.ts +0 -1
  24. package/lib/Button/ButtonPrimary.d.ts +0 -1
  25. package/lib/Button/ButtonTableList.js +1 -1
  26. package/lib/CircleBadge.js +1 -1
  27. package/lib/CircleOcticon.d.ts +0 -1
  28. package/lib/CircleOcticon.js +1 -1
  29. package/lib/CounterLabel.js +2 -2
  30. package/lib/Dialog/ConfirmationDialog.js +1 -1
  31. package/lib/Dialog/Dialog.js +9 -9
  32. package/lib/Dialog.d.ts +2 -3
  33. package/lib/Dialog.js +4 -4
  34. package/lib/Dropdown.d.ts +0 -4
  35. package/lib/Dropdown.js +2 -2
  36. package/lib/DropdownMenu/DropdownButton.d.ts +1 -2
  37. package/lib/DropdownStyles.js +6 -6
  38. package/lib/FilterList.d.ts +0 -1
  39. package/lib/FilterList.js +1 -1
  40. package/lib/FilteredActionList/FilteredActionList.js +5 -5
  41. package/lib/Flash.js +1 -1
  42. package/lib/Label.js +2 -2
  43. package/lib/Link.js +1 -1
  44. package/lib/Overlay.d.ts +1 -2
  45. package/lib/Overlay.js +6 -11
  46. package/lib/Pagehead.js +1 -1
  47. package/lib/Pagination/Pagination.js +1 -1
  48. package/lib/Popover.js +1 -1
  49. package/lib/Position.d.ts +4 -4
  50. package/lib/ProgressBar.js +1 -1
  51. package/lib/SelectMenu/SelectMenu.d.ts +15 -337
  52. package/lib/SelectMenu/SelectMenuDivider.js +1 -1
  53. package/lib/SelectMenu/SelectMenuFilter.d.ts +1 -1
  54. package/lib/SelectMenu/SelectMenuFilter.js +1 -1
  55. package/lib/SelectMenu/SelectMenuFooter.js +1 -1
  56. package/lib/SelectMenu/SelectMenuHeader.js +2 -2
  57. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  58. package/lib/SelectMenu/SelectMenuItem.js +1 -1
  59. package/lib/SelectMenu/SelectMenuList.js +1 -1
  60. package/lib/SelectMenu/SelectMenuLoadingAnimation.js +1 -1
  61. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  62. package/lib/SelectMenu/SelectMenuModal.js +2 -2
  63. package/lib/SelectMenu/SelectMenuTab.js +1 -1
  64. package/lib/SelectMenu/SelectMenuTabPanel.js +1 -1
  65. package/lib/SelectPanel/SelectPanel.js +3 -2
  66. package/lib/SideNav.js +5 -5
  67. package/lib/StateLabel.js +1 -1
  68. package/lib/SubNav.js +1 -1
  69. package/lib/TabNav.js +2 -2
  70. package/lib/TextInput.d.ts +6 -6
  71. package/lib/TextInput.js +21 -16
  72. package/lib/Timeline.d.ts +0 -1
  73. package/lib/Timeline.js +16 -19
  74. package/lib/Tooltip.js +1 -1
  75. package/lib/UnderlineNav.js +2 -2
  76. package/lib/hooks/useOverlay.d.ts +1 -2
  77. package/lib/hooks/useOverlay.js +6 -11
  78. package/lib/index.d.ts +1 -0
  79. package/lib/index.js +14 -0
  80. package/lib/theme-preval.d.ts +12 -6
  81. package/lib/theme-preval.js +940 -0
  82. package/lib/utils/ssr.d.ts +1 -0
  83. package/lib/utils/ssr.js +19 -0
  84. package/lib/utils/testing.d.ts +1854 -0
  85. package/lib/utils/uniqueId.js +1 -0
  86. package/lib-esm/ActionList/Divider.js +1 -1
  87. package/lib-esm/ActionList/Header.js +2 -2
  88. package/lib-esm/ActionList/Item.js +14 -14
  89. package/lib-esm/ActionList/List.js +1 -1
  90. package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +3 -3
  91. package/lib-esm/Avatar.d.ts +4 -0
  92. package/lib-esm/AvatarPair.js +1 -1
  93. package/lib-esm/AvatarStack.js +1 -1
  94. package/lib-esm/BranchName.js +1 -1
  95. package/lib-esm/Breadcrumb.js +2 -2
  96. package/lib-esm/Button/Button.d.ts +0 -1
  97. package/lib-esm/Button/Button.js +1 -1
  98. package/lib-esm/Button/ButtonClose.d.ts +1 -2
  99. package/lib-esm/Button/ButtonClose.js +1 -1
  100. package/lib-esm/Button/ButtonDanger.d.ts +0 -1
  101. package/lib-esm/Button/ButtonInvisible.d.ts +0 -1
  102. package/lib-esm/Button/ButtonInvisible.js +1 -1
  103. package/lib-esm/Button/ButtonOutline.d.ts +0 -1
  104. package/lib-esm/Button/ButtonPrimary.d.ts +0 -1
  105. package/lib-esm/Button/ButtonTableList.js +1 -1
  106. package/lib-esm/CircleBadge.js +1 -1
  107. package/lib-esm/CircleOcticon.d.ts +0 -1
  108. package/lib-esm/CircleOcticon.js +1 -1
  109. package/lib-esm/CounterLabel.js +2 -2
  110. package/lib-esm/Dialog/ConfirmationDialog.js +1 -1
  111. package/lib-esm/Dialog/Dialog.js +8 -8
  112. package/lib-esm/Dialog.d.ts +2 -3
  113. package/lib-esm/Dialog.js +4 -4
  114. package/lib-esm/Dropdown.d.ts +0 -4
  115. package/lib-esm/Dropdown.js +2 -2
  116. package/lib-esm/DropdownMenu/DropdownButton.d.ts +1 -2
  117. package/lib-esm/DropdownStyles.js +6 -6
  118. package/lib-esm/FilterList.d.ts +0 -1
  119. package/lib-esm/FilterList.js +1 -1
  120. package/lib-esm/FilteredActionList/FilteredActionList.js +5 -5
  121. package/lib-esm/Flash.js +1 -1
  122. package/lib-esm/Label.js +2 -2
  123. package/lib-esm/Link.js +1 -1
  124. package/lib-esm/Overlay.d.ts +1 -2
  125. package/lib-esm/Overlay.js +6 -9
  126. package/lib-esm/Pagehead.js +1 -1
  127. package/lib-esm/Pagination/Pagination.js +1 -1
  128. package/lib-esm/Popover.js +1 -1
  129. package/lib-esm/Position.d.ts +4 -4
  130. package/lib-esm/ProgressBar.js +1 -1
  131. package/lib-esm/SelectMenu/SelectMenu.d.ts +15 -337
  132. package/lib-esm/SelectMenu/SelectMenuDivider.js +1 -1
  133. package/lib-esm/SelectMenu/SelectMenuFilter.d.ts +1 -1
  134. package/lib-esm/SelectMenu/SelectMenuFilter.js +1 -1
  135. package/lib-esm/SelectMenu/SelectMenuFooter.js +1 -1
  136. package/lib-esm/SelectMenu/SelectMenuHeader.js +2 -2
  137. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  138. package/lib-esm/SelectMenu/SelectMenuItem.js +1 -1
  139. package/lib-esm/SelectMenu/SelectMenuList.js +1 -1
  140. package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.js +1 -1
  141. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  142. package/lib-esm/SelectMenu/SelectMenuModal.js +2 -2
  143. package/lib-esm/SelectMenu/SelectMenuTab.js +1 -1
  144. package/lib-esm/SelectMenu/SelectMenuTabPanel.js +1 -1
  145. package/lib-esm/SelectPanel/SelectPanel.js +3 -2
  146. package/lib-esm/SideNav.js +5 -5
  147. package/lib-esm/StateLabel.js +1 -1
  148. package/lib-esm/SubNav.js +1 -1
  149. package/lib-esm/TabNav.js +2 -2
  150. package/lib-esm/TextInput.d.ts +6 -6
  151. package/lib-esm/TextInput.js +22 -16
  152. package/lib-esm/Timeline.d.ts +0 -1
  153. package/lib-esm/Timeline.js +12 -17
  154. package/lib-esm/Tooltip.js +1 -1
  155. package/lib-esm/UnderlineNav.js +2 -2
  156. package/lib-esm/hooks/useOverlay.d.ts +1 -2
  157. package/lib-esm/hooks/useOverlay.js +6 -11
  158. package/lib-esm/index.d.ts +1 -0
  159. package/lib-esm/index.js +2 -1
  160. package/lib-esm/theme-preval.d.ts +12 -6
  161. package/lib-esm/theme-preval.js +940 -0
  162. package/lib-esm/utils/ssr.d.ts +1 -0
  163. package/lib-esm/utils/ssr.js +1 -0
  164. package/lib-esm/utils/testing.d.ts +1854 -0
  165. package/lib-esm/utils/uniqueId.js +1 -0
  166. package/package.json +9 -9
  167. package/lib/Autocomplete/Autocomplete.d.ts +0 -36
  168. package/lib/Autocomplete/Autocomplete.js +0 -55
  169. package/lib/Autocomplete/AutocompleteContext.d.ts +0 -13
  170. package/lib/Autocomplete/AutocompleteContext.js +0 -14
  171. package/lib/Autocomplete/AutocompleteInput.d.ts +0 -9
  172. package/lib/Autocomplete/AutocompleteInput.js +0 -128
  173. package/lib/Autocomplete/AutocompleteMenu.d.ts +0 -54
  174. package/lib/Autocomplete/AutocompleteMenu.js +0 -268
  175. package/lib/Autocomplete/index.d.ts +0 -2
  176. package/lib/Autocomplete/index.js +0 -15
  177. package/lib/Badge/Badge.d.ts +0 -8
  178. package/lib/Badge/Badge.js +0 -59
  179. package/lib/Badge/BadgeState.d.ts +0 -13
  180. package/lib/Badge/BadgeState.js +0 -51
  181. package/lib/Badge/_badgeStyleUtils.d.ts +0 -3
  182. package/lib/Badge/_badgeStyleUtils.js +0 -39
  183. package/lib/TextInputTokens.d.ts +0 -32
  184. package/lib/TextInputTokens.js +0 -241
  185. package/lib/TextInputWithTokens.d.ts +0 -41
  186. package/lib/TextInputWithTokens.js +0 -396
  187. package/lib/Token/Token.d.ts +0 -7
  188. package/lib/Token/Token.js +0 -69
  189. package/lib/Token/TokenBase.d.ts +0 -16
  190. package/lib/Token/TokenBase.js +0 -76
  191. package/lib/Token/TokenLabel.d.ts +0 -10
  192. package/lib/Token/TokenLabel.js +0 -115
  193. package/lib/Token/TokenProfile.d.ts +0 -7
  194. package/lib/Token/TokenProfile.js +0 -45
  195. package/lib/Token/_AddTokenButton.d.ts +0 -3
  196. package/lib/Token/_AddTokenButton.js +0 -42
  197. package/lib/Token/_RemoveTokenButton.d.ts +0 -3
  198. package/lib/Token/_RemoveTokenButton.js +0 -42
  199. package/lib/Token/_tokenButtonUtils.d.ts +0 -8
  200. package/lib/Token/_tokenButtonUtils.js +0 -42
  201. package/lib-esm/Autocomplete/Autocomplete.d.ts +0 -36
  202. package/lib-esm/Autocomplete/Autocomplete.js +0 -36
  203. package/lib-esm/Autocomplete/AutocompleteContext.d.ts +0 -13
  204. package/lib-esm/Autocomplete/AutocompleteContext.js +0 -5
  205. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +0 -9
  206. package/lib-esm/Autocomplete/AutocompleteInput.js +0 -109
  207. package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +0 -54
  208. package/lib-esm/Autocomplete/AutocompleteMenu.js +0 -244
  209. package/lib-esm/Autocomplete/index.d.ts +0 -2
  210. package/lib-esm/Autocomplete/index.js +0 -1
  211. package/lib-esm/Badge/Badge.d.ts +0 -8
  212. package/lib-esm/Badge/Badge.js +0 -44
  213. package/lib-esm/Badge/BadgeState.d.ts +0 -13
  214. package/lib-esm/Badge/BadgeState.js +0 -40
  215. package/lib-esm/Badge/_badgeStyleUtils.d.ts +0 -3
  216. package/lib-esm/Badge/_badgeStyleUtils.js +0 -29
  217. package/lib-esm/TextInputTokens.d.ts +0 -32
  218. package/lib-esm/TextInputTokens.js +0 -211
  219. package/lib-esm/TextInputWithTokens.d.ts +0 -41
  220. package/lib-esm/TextInputWithTokens.js +0 -361
  221. package/lib-esm/Token/Token.d.ts +0 -7
  222. package/lib-esm/Token/Token.js +0 -49
  223. package/lib-esm/Token/TokenBase.d.ts +0 -16
  224. package/lib-esm/Token/TokenBase.js +0 -56
  225. package/lib-esm/Token/TokenLabel.d.ts +0 -10
  226. package/lib-esm/Token/TokenLabel.js +0 -99
  227. package/lib-esm/Token/TokenProfile.d.ts +0 -7
  228. package/lib-esm/Token/TokenProfile.js +0 -28
  229. package/lib-esm/Token/_AddTokenButton.d.ts +0 -3
  230. package/lib-esm/Token/_AddTokenButton.js +0 -27
  231. package/lib-esm/Token/_RemoveTokenButton.d.ts +0 -3
  232. package/lib-esm/Token/_RemoveTokenButton.js +0 -27
  233. package/lib-esm/Token/_tokenButtonUtils.d.ts +0 -8
  234. package/lib-esm/Token/_tokenButtonUtils.js +0 -26
@@ -1,244 +0,0 @@
1
- import React, { useContext, useEffect, useRef, useState } from 'react';
2
- import { ActionList } from '../ActionList';
3
- import { useAnchoredPosition } from '../hooks';
4
- import { useFocusZone } from '../hooks/useFocusZone';
5
- import Overlay from '../Overlay';
6
- import { Box, Spinner } from '../';
7
- import { registerPortalRoot } from '../Portal';
8
- import { AutocompleteContext } from './AutocompleteContext';
9
- import { useCombinedRefs } from '../hooks/useCombinedRefs';
10
- const DROPDOWN_PORTAL_CONTAINER_NAME = '__listcontainerportal__';
11
-
12
- const getDefaultSortFn = isItemSelectedFn => (itemIdA, itemIdB) => isItemSelectedFn(itemIdA) === isItemSelectedFn(itemIdB) ? 0 : isItemSelectedFn(itemIdA) ? -1 : 1;
13
-
14
- function scrollIntoViewingArea(child, container, margin = 8, behavior = 'smooth') {
15
- const {
16
- top: childTop,
17
- bottom: childBottom
18
- } = child.getBoundingClientRect();
19
- const {
20
- top: containerTop,
21
- bottom: containerBottom
22
- } = container.getBoundingClientRect();
23
- const isChildTopAboveViewingArea = childTop < containerTop + margin;
24
- const isChildBottomBelowViewingArea = childBottom > containerBottom - margin;
25
-
26
- if (isChildTopAboveViewingArea) {
27
- const scrollHeightToChildTop = childTop - containerTop + container.scrollTop;
28
- container.scrollTo({
29
- behavior,
30
- top: scrollHeightToChildTop - margin
31
- });
32
- } else if (isChildBottomBelowViewingArea) {
33
- const scrollHeightToChildBottom = childBottom - containerBottom + container.scrollTop;
34
- container.scrollTo({
35
- behavior,
36
- top: scrollHeightToChildBottom + margin
37
- });
38
- } // either completely in view or outside viewing area on both ends, don't scroll
39
-
40
- }
41
-
42
- const defaultItemFilter = filterValue => (item, _i) => {
43
- var _item$text;
44
-
45
- return Boolean(item === null || item === void 0 ? void 0 : (_item$text = item.text) === null || _item$text === void 0 ? void 0 : _item$text.toLowerCase().startsWith(filterValue.toLowerCase()));
46
- }; // TODO:
47
- // insteaad of using `forwardRef`, just use a regular Functional Component
48
- // get rid of unused props
49
-
50
-
51
- const AutocompleteMenu = /*#__PURE__*/React.forwardRef(({
52
- items,
53
- selectedItemIds,
54
- selectedSortFn,
55
- onItemSelect,
56
- onItemDeselect,
57
- emptyStateText,
58
- addNewItem,
59
- loading,
60
- selectionVariant,
61
- filterFn: externalFilterFn,
62
- width,
63
- height,
64
- maxHeight
65
- }, ref) => {
66
- const {
67
- activeDescendantRef,
68
- inputRef,
69
- inputValue = '',
70
- setAutocompleteSuggestion,
71
- setShowMenu,
72
- setInputValue,
73
- setIsMenuDirectlyActivated,
74
- showMenu
75
- } = useContext(AutocompleteContext);
76
- const filterFn = externalFilterFn ? externalFilterFn : defaultItemFilter(inputValue);
77
- const listContainerRef = useRef(null);
78
- const scrollContainerRef = useRef(null);
79
- const [highlightedItem, setHighlightedItem] = useState(); // TODO: clean up this mess by making id required on ItemProps
80
-
81
- const [sortedItemIds, setSortedItemIds] = useState(items.map(({
82
- id
83
- }) => id || id === 0 ? id : ''));
84
- const {
85
- floatingElementRef,
86
- position
87
- } = useAnchoredPosition({
88
- side: 'outside-bottom',
89
- align: 'start',
90
- anchorElementRef: inputRef
91
- }, [showMenu, selectedItemIds]);
92
- const combinedOverlayRef = useCombinedRefs(scrollContainerRef, floatingElementRef);
93
-
94
- const closeOptionList = () => {
95
- if (setShowMenu) {
96
- setShowMenu(false);
97
- }
98
- };
99
-
100
- const isItemSelected = itemId => {
101
- var _items$find;
102
-
103
- return ((_items$find = items.find(selectableItem => selectableItem.id === itemId)) === null || _items$find === void 0 ? void 0 : _items$find.selected) || selectedItemIds.includes(itemId);
104
- };
105
-
106
- const itemsToRender = [// selectable tokens
107
- ...items.map(selectableItem => {
108
- return { ...selectableItem,
109
- //TODO: just make `id` required
110
- selected: selectionVariant === 'multiple' ? isItemSelected(selectableItem.id) : undefined,
111
- onAction: (item, e) => {
112
- // TODO: clean up all of these `if/else` statements
113
- if (item.selected) {
114
- // TODO: make `onItemDeselect` optional
115
- if (onItemDeselect) {
116
- onItemDeselect(item, e);
117
- }
118
- } else {
119
- // TODO: make `onItemSelect` optional
120
- if (onItemSelect) {
121
- onItemSelect(item, e);
122
- }
123
-
124
- if (selectionVariant === 'multiple') {
125
- if (setInputValue) {
126
- setInputValue('');
127
- }
128
-
129
- if (setAutocompleteSuggestion) {
130
- setAutocompleteSuggestion('');
131
- }
132
- }
133
- }
134
-
135
- if (selectionVariant === 'single') {
136
- if (setShowMenu) {
137
- setShowMenu(false);
138
- }
139
-
140
- if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
141
- inputRef.current.setSelectionRange(inputRef.current.value.length, inputRef.current.value.length);
142
- }
143
- }
144
- }
145
- };
146
- }), // menu item used for creating a token from whatever is in the text input
147
- ...(addNewItem ? [{ ...addNewItem,
148
- onAction: onItemSelect ? (_item, e) => {
149
- onItemSelect({
150
- text: inputValue,
151
- id: `randomlyGeneratedId-${inputValue}`
152
- }, e);
153
- } : undefined
154
- }] : [])];
155
- useFocusZone({
156
- containerRef: listContainerRef,
157
- focusOutBehavior: 'wrap',
158
- focusableElementFilter: element => {
159
- return !(element instanceof HTMLInputElement);
160
- },
161
- activeDescendantFocus: inputRef,
162
- onActiveDescendantChanged: (current, _previous, directlyActivated) => {
163
- if (activeDescendantRef) {
164
- activeDescendantRef.current = current || null;
165
- }
166
-
167
- if (current) {
168
- const selectedItem = itemsToRender.find(item => {
169
- var _item$id;
170
-
171
- return ((_item$id = item.id) === null || _item$id === void 0 ? void 0 : _item$id.toString()) === (current === null || current === void 0 ? void 0 : current.dataset.id);
172
- });
173
- setHighlightedItem({ ...selectedItem,
174
- isDirectlyActivated: directlyActivated
175
- });
176
-
177
- if (setIsMenuDirectlyActivated) {
178
- setIsMenuDirectlyActivated(directlyActivated);
179
- }
180
- }
181
-
182
- if (current && scrollContainerRef.current && directlyActivated) {
183
- scrollIntoViewingArea(current, scrollContainerRef.current);
184
- }
185
- }
186
- });
187
- useEffect(() => {
188
- var _highlightedItem$text;
189
-
190
- if (!setAutocompleteSuggestion) {
191
- return;
192
- }
193
-
194
- if (highlightedItem !== null && highlightedItem !== void 0 && (_highlightedItem$text = highlightedItem.text) !== null && _highlightedItem$text !== void 0 && _highlightedItem$text.startsWith(inputValue || '')) {
195
- setAutocompleteSuggestion(highlightedItem.text);
196
- } else {
197
- setAutocompleteSuggestion('');
198
- }
199
- }, [highlightedItem, inputValue]);
200
- useEffect(() => {
201
- setSortedItemIds([...sortedItemIds].sort(selectedSortFn ? selectedSortFn : getDefaultSortFn(isItemSelected)));
202
- }, [showMenu]);
203
-
204
- if (listContainerRef.current) {
205
- registerPortalRoot(listContainerRef.current, DROPDOWN_PORTAL_CONTAINER_NAME);
206
- }
207
-
208
- const itemSortOrderData = sortedItemIds.reduce((acc, curr, i) => {
209
- acc[curr] = i;
210
- return acc;
211
- }, {});
212
- const sortedAndFilteredItemsToRender = [...(filterFn ? itemsToRender.filter(filterFn) : itemsToRender)].sort((a, b) => itemSortOrderData[a.id] - itemSortOrderData[b.id]);
213
- return /*#__PURE__*/React.createElement("div", {
214
- ref: listContainerRef
215
- }, showMenu && emptyStateText ? /*#__PURE__*/React.createElement(Overlay, {
216
- returnFocusRef: inputRef,
217
- portalContainerName: DROPDOWN_PORTAL_CONTAINER_NAME,
218
- preventFocusOnOpen: true,
219
- onClickOutside: closeOptionList,
220
- onEscape: closeOptionList,
221
- ref: combinedOverlayRef,
222
- top: position === null || position === void 0 ? void 0 : position.top,
223
- left: position === null || position === void 0 ? void 0 : position.left,
224
- width: width,
225
- height: height,
226
- maxHeight: maxHeight
227
- }, loading ? /*#__PURE__*/React.createElement(Box, {
228
- p: 3,
229
- display: "flex",
230
- justifyContent: "center"
231
- }, /*#__PURE__*/React.createElement(Spinner, null)) : /*#__PURE__*/React.createElement(React.Fragment, null, sortedAndFilteredItemsToRender.length ? /*#__PURE__*/React.createElement(ActionList, {
232
- selectionVariant: "multiple",
233
- items: sortedAndFilteredItemsToRender,
234
- role: "listbox"
235
- }) : /*#__PURE__*/React.createElement(Box, {
236
- p: 3
237
- }, emptyStateText))) : null);
238
- });
239
- AutocompleteMenu.defaultProps = {
240
- emptyStateText: 'No selectable options',
241
- selectionVariant: 'single'
242
- };
243
- AutocompleteMenu.displayName = 'AutocompleteMenu';
244
- export default AutocompleteMenu;
@@ -1,2 +0,0 @@
1
- export { default } from './Autocomplete';
2
- export type { AutocompleteMenuProps, AutocompleteInputProps, } from './Autocomplete';
@@ -1 +0,0 @@
1
- export { default } from './Autocomplete';
@@ -1,8 +0,0 @@
1
- import { BadgeSizeKeys } from './_badgeStyleUtils';
2
- declare type BadgeColorOptions = 'default' | 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'danger';
3
- interface Props {
4
- color?: BadgeColorOptions;
5
- variant?: BadgeSizeKeys;
6
- }
7
- declare const Badge: import("styled-components").StyledComponent<"span", any, Props, never>;
8
- export default Badge;
@@ -1,44 +0,0 @@
1
- import styled from 'styled-components';
2
- import { get } from '../constants';
3
- import { badgeVariants } from './_badgeStyleUtils';
4
- const badgeColorMap = {
5
- default: {
6
- borderColor: get('colors.border.default')
7
- },
8
- primary: {
9
- borderColor: get('colors.fg.default')
10
- },
11
- secondary: {
12
- borderColor: get('colors.border.muted'),
13
- textColor: get('colors.fg.muted')
14
- },
15
- info: {
16
- borderColor: get('colors.accent.fg'),
17
- textColor: get('colors.accent.fg')
18
- },
19
- success: {
20
- borderColor: get('colors.success.fg'),
21
- textColor: get('colors.success.emphasis')
22
- },
23
- warning: {
24
- borderColor: get('colors.attention.fg'),
25
- textColor: get('colors.attention.emphasis')
26
- },
27
- danger: {
28
- borderColor: get('colors.danger.fg'),
29
- textColor: get('colors.danger.emphasis')
30
- }
31
- };
32
- const Badge = styled.span.withConfig({
33
- displayName: "Badge",
34
- componentId: "sc-15t9m5z-0"
35
- })(["align-items:center;background-color:transparent;border-width:1px;border-radius:999px;border-style:solid;border-color:", ";color:", ";display:inline-flex;font-weight:", ";line-height:1;white-space:nowrap;", ";"], ({
36
- color = 'default'
37
- }) => badgeColorMap[color].borderColor, ({
38
- color = 'default'
39
- }) => badgeColorMap[color].textColor, get('fontWeights.bold'), badgeVariants);
40
- Badge.defaultProps = {
41
- variant: 'sm',
42
- color: 'default'
43
- };
44
- export default Badge;
@@ -1,13 +0,0 @@
1
- /// <reference types="react" />
2
- import { IconProps } from '@primer/octicons-react';
3
- import { BadgeSizeKeys } from './_badgeStyleUtils';
4
- declare type BadgeStateColorOptions = 'default' | 'open' | 'merged' | 'closed';
5
- interface Props {
6
- color?: BadgeStateColorOptions;
7
- icon?: React.ComponentType<{
8
- size?: IconProps['size'];
9
- }>;
10
- variant?: BadgeSizeKeys;
11
- }
12
- declare const BadgeState: React.FC<Props>;
13
- export default BadgeState;
@@ -1,40 +0,0 @@
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 styled from 'styled-components';
4
- import { get } from '../constants';
5
- import { badgeVariants } from './_badgeStyleUtils'; // TODO: consider making these a little less specific by using:
6
- // 'default' | 'success' | 'done' | 'danger'
7
-
8
- const badgeStateColorMap = {
9
- default: get('colors.neutral.emphasis'),
10
- open: get('colors.success.emphasis'),
11
- merged: get('colors.done.emphasis'),
12
- closed: get('colors.danger.emphasis')
13
- }; // const badgeStateIconSizeMap: Record<BadgeSizeKeys, number> = {
14
- // 'sm':
15
- // };
16
-
17
- const StyledBadgeState = styled.span.withConfig({
18
- displayName: "BadgeState__StyledBadgeState",
19
- componentId: "sc-5hwzjt-0"
20
- })(["align-items:center;background-color:", ";border-radius:999px;color:", ";display:inline-flex;font-weight:", ";gap:", ";line-height:1;white-space:nowrap;", ";"], ({
21
- color = 'default'
22
- }) => badgeStateColorMap[color], get('colors.fg.onEmphasis'), get('fontWeights.bold'), get('space.1'), badgeVariants);
23
-
24
- const BadgeState = ({
25
- children,
26
- icon: IconComponent,
27
- variant,
28
- ...rest
29
- }) => /*#__PURE__*/React.createElement(StyledBadgeState, _extends({
30
- variant: variant
31
- }, rest), IconComponent ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconComponent, {
32
- size: variant === 'sm' ? 12 : 'small'
33
- }), children) : children);
34
-
35
- BadgeState.displayName = "BadgeState";
36
- BadgeState.defaultProps = {
37
- variant: 'lg',
38
- color: 'default'
39
- };
40
- export default BadgeState;
@@ -1,3 +0,0 @@
1
- export declare type BadgeSizeKeys = 'sm' | 'md' | 'lg';
2
- export declare const badgeSizes: Record<BadgeSizeKeys, number>;
3
- export declare const badgeVariants: (...args: any[]) => any;
@@ -1,29 +0,0 @@
1
- import { variant } from 'styled-system';
2
- // TODO: consider moving to Primitives
3
- export const badgeSizes = {
4
- sm: 20,
5
- md: 24,
6
- lg: 32
7
- };
8
- export const badgeVariants = variant({
9
- variants: {
10
- sm: {
11
- fontSize: 0,
12
- height: `${badgeSizes.sm}px`,
13
- paddingLeft: 2,
14
- paddingRight: 2
15
- },
16
- md: {
17
- fontSize: 0,
18
- height: `${badgeSizes.md}px`,
19
- paddingLeft: 2,
20
- paddingRight: 2
21
- },
22
- lg: {
23
- fontSize: 1,
24
- height: `${badgeSizes.lg}px`,
25
- paddingLeft: 3,
26
- paddingRight: 3
27
- }
28
- }
29
- });
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import { MaxWidthProps, MinWidthProps, WidthProps } from 'styled-system';
3
- import { SystemCommonProps } from './constants';
4
- import { SxProp } from './sx';
5
- import { ComponentProps } from './utils/types';
6
- import Token from './Token/Token';
7
- declare const Input: import("styled-components").StyledComponent<"input", any, {}, never>;
8
- declare const Wrapper: import("styled-components").StyledComponent<"span", any, {
9
- disabled?: boolean | undefined;
10
- hasIcon?: boolean | undefined;
11
- block?: boolean | undefined;
12
- contrast?: boolean | undefined;
13
- variant?: "large" | "small" | undefined;
14
- maxHeight?: React.CSSProperties['maxHeight'];
15
- } & SystemCommonProps & 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>;
16
- interface Token {
17
- text?: string;
18
- id: string | number;
19
- }
20
- declare type TextInputWithTokensInternalProps = {
21
- as?: any;
22
- icon?: React.ComponentType<{
23
- className?: string;
24
- }>;
25
- tokens: Token[];
26
- onTokenRemove: (tokenId: string | number) => void;
27
- tokenComponent?: React.FunctionComponent<any>;
28
- maxHeight?: React.CSSProperties['maxHeight'];
29
- } & ComponentProps<typeof Wrapper> & ComponentProps<typeof Input>;
30
- declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<TextInputWithTokensInternalProps, "backgroundColor" | "color" | "display" | "height" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minWidth" | "opacity" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "translate" | "width" | "margin" | "padding" | "hidden" | "children" | "theme" | "value" | "form" | "p" | "slot" | "style" | "title" | "pattern" | "list" | "type" | "name" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "css" | "block" | "bg" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "step" | "size" | "icon" | "sx" | "max" | "min" | "crossOrigin" | "alt" | "src" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "autoComplete" | "accept" | "capture" | "checked" | "enterKeyHint" | "maxLength" | "minLength" | "multiple" | "readOnly" | "required" | "as" | "variant" | "hasIcon" | "contrast" | "tokens" | "onTokenRemove" | "tokenComponent"> & React.RefAttributes<HTMLInputElement>>;
31
- export declare type TextInputWithTokensProps = ComponentProps<typeof TextInputWithTokens>;
32
- export default TextInputWithTokens;
@@ -1,211 +0,0 @@
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, { useRef, useState } from 'react';
4
- import { omit, pick } from '@styled-system/props';
5
- import classnames from 'classnames';
6
- import styled, { css } from 'styled-components';
7
- import { maxWidth, minWidth, variant, width } from 'styled-system';
8
- import { FocusKeys } from './behaviors/focusZone';
9
- import { COMMON, get } from './constants';
10
- import { useCombinedRefs } from './hooks/useCombinedRefs';
11
- import { useFocusZone } from './hooks/useFocusZone';
12
- import sx from './sx';
13
- import Token from './Token/Token';
14
- const sizeVariants = variant({
15
- variants: {
16
- small: {
17
- minHeight: '28px',
18
- px: 2,
19
- py: '3px',
20
- fontSize: 0,
21
- lineHeight: '20px'
22
- },
23
- large: {
24
- px: 2,
25
- py: '10px',
26
- fontSize: 3
27
- }
28
- }
29
- });
30
- const Input = styled.input.withConfig({
31
- displayName: "TextInputTokens__Input",
32
- componentId: "sc-1k54xiz-0"
33
- })(["border:0;font-size:inherit;font-family:inherit;background-color:transparent;-webkit-appearance:none;color:inherit;height:100%;width:100%;padding:0;&:focus{outline:0;}"]);
34
- const InputWrapper = styled.div.withConfig({
35
- displayName: "TextInputTokens__InputWrapper",
36
- componentId: "sc-1k54xiz-1"
37
- })(["position:relative;order:1;flex-grow:1;&:after{pointer-events:none;display:flex;align-items:center;position:absolute;left:0;top:1px;width:100%;height:100%;display:flex;align-items:center;color:rgba(0,0,0,0.5);}"]);
38
- const Wrapper = styled.span.withConfig({
39
- displayName: "TextInputTokens__Wrapper",
40
- componentId: "sc-1k54xiz-2"
41
- })(["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:", ";flex-wrap:wrap;gap:0.25rem;", " ", " .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.text.primary'), get('colors.border.primary'), get('radii.2'), get('shadows.shadow.inset'), props => {
42
- if (props.hasIcon) {
43
- return css(["padding:0;"]);
44
- } else {
45
- return css(["padding:6px 12px;"]);
46
- }
47
- }, props => {
48
- if (props.maxHeight) {
49
- return css(["max-height:", ";overflow:auto;"], props.maxHeight);
50
- }
51
- }, get('colors.icon.tertiary'), get('space.2'), get('colors.state.focus.border'), get('shadows.state.focus.shadow'), props => props.contrast && css(["background-color:", ";"], get('colors.input.contrastBg')), props => props.disabled && css(["color:", ";background-color:", ";border-color:", ";"], get('colors.text.secondary'), get('colors.input.disabledBg'), get('colors.input.disabledBorder')), props => props.block && css(["display:block;width:100%;"]), get('breakpoints.1'), get('fontSizes.1'), COMMON, width, minWidth, maxWidth, sizeVariants, sx);
52
- // using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
53
- const TextInputWithTokens = /*#__PURE__*/React.forwardRef(({
54
- icon: IconComponent,
55
- contrast,
56
- className,
57
- block,
58
- disabled,
59
- theme,
60
- sx: sxProp,
61
- tokens,
62
- onTokenRemove,
63
- tokenComponent: TokenComponent,
64
- ...rest
65
- }, ref) => {
66
- const localInputRef = useRef(null);
67
- const combinedInputRef = useCombinedRefs(localInputRef, ref); // this class is necessary to style FilterSearch, plz no touchy!
68
-
69
- const wrapperClasses = classnames(className, 'TextInput-wrapper');
70
- const wrapperProps = pick(rest);
71
- const {
72
- onFocus,
73
- onKeyDown,
74
- ...inputPropsRest
75
- } = omit(rest);
76
- const [selectedTokenIdx, setSelectedTokenIdx] = useState();
77
- const {
78
- containerRef
79
- } = useFocusZone({
80
- focusOutBehavior: 'wrap',
81
- bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
82
- focusableElementFilter: element => {
83
- return !(element instanceof HTMLButtonElement);
84
- },
85
- getNextFocusable: (direction, from, event) => {
86
- var _containerRef$current;
87
-
88
- if (!selectedTokenIdx && selectedTokenIdx !== 0) {
89
- return undefined;
90
- }
91
-
92
- let nextIndex = selectedTokenIdx + 1;
93
-
94
- if (direction === 'next') {
95
- console.log('direction is next');
96
- nextIndex += 1;
97
- }
98
-
99
- if (direction === 'previous') {
100
- console.log('direction is previous');
101
- nextIndex -= 1;
102
- }
103
-
104
- if (nextIndex > tokens.length || nextIndex < 1) {
105
- return combinedInputRef.current || undefined;
106
- }
107
-
108
- return containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.children[nextIndex];
109
- }
110
- }, [selectedTokenIdx]);
111
-
112
- const handleTokenRemove = tokenId => {
113
- onTokenRemove(tokenId);
114
- };
115
-
116
- const handleTokenFocus = tokenIdx => () => {
117
- setSelectedTokenIdx(tokenIdx);
118
- };
119
-
120
- const handleTokenBlur = () => {
121
- setSelectedTokenIdx(undefined);
122
- };
123
-
124
- const handleTokenKeyUp = tokenId => e => {
125
- if (e.key === 'Backspace') {
126
- handleTokenRemove(tokenId);
127
- }
128
-
129
- if (e.key === 'Escape') {
130
- var _combinedInputRef$cur;
131
-
132
- combinedInputRef === null || combinedInputRef === void 0 ? void 0 : (_combinedInputRef$cur = combinedInputRef.current) === null || _combinedInputRef$cur === void 0 ? void 0 : _combinedInputRef$cur.focus();
133
- }
134
- };
135
-
136
- const handleInputFocus = e => {
137
- if (onFocus) {
138
- onFocus(e);
139
- }
140
-
141
- setSelectedTokenIdx(undefined);
142
- };
143
-
144
- const handleInputKeyDown = e => {
145
- var _combinedInputRef$cur2;
146
-
147
- if (onKeyDown) {
148
- onKeyDown(e);
149
- }
150
-
151
- if ((_combinedInputRef$cur2 = combinedInputRef.current) !== null && _combinedInputRef$cur2 !== void 0 && _combinedInputRef$cur2.value) {
152
- return;
153
- }
154
-
155
- const lastToken = tokens[tokens.length - 1];
156
-
157
- if (e.key === 'Backspace') {
158
- handleTokenRemove(lastToken.id);
159
-
160
- if (combinedInputRef.current) {
161
- // TODO: eliminate the first hack by making changes to the Autocomplete component
162
- // HACKS:
163
- // 1. Directly setting `combinedInputRef.current.value` instead of updating state because the autocomplete highlight behavior doesn't work correctly if we update the value with a setState action in onChange
164
- // 2. Adding an extra space so that when I backspace, it doesn't delete the last letter
165
- combinedInputRef.current.value = `${lastToken.text} `;
166
- } // HACK: for some reason we need to wait a tick for `.select()` to work
167
-
168
-
169
- setTimeout(() => {
170
- var _combinedInputRef$cur3;
171
-
172
- combinedInputRef === null || combinedInputRef === void 0 ? void 0 : (_combinedInputRef$cur3 = combinedInputRef.current) === null || _combinedInputRef$cur3 === void 0 ? void 0 : _combinedInputRef$cur3.select();
173
- }, 1);
174
- }
175
- };
176
-
177
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Wrapper, _extends({
178
- className: wrapperClasses,
179
- hasIcon: !!IconComponent,
180
- block: block,
181
- theme: theme,
182
- disabled: disabled,
183
- contrast: contrast,
184
- sx: sxProp,
185
- ref: containerRef
186
- }, wrapperProps), /*#__PURE__*/React.createElement(InputWrapper, null, /*#__PURE__*/React.createElement(Input, _extends({
187
- ref: combinedInputRef,
188
- disabled: disabled,
189
- onFocus: handleInputFocus,
190
- onKeyDown: handleInputKeyDown,
191
- type: "text"
192
- }, inputPropsRest))), tokens !== null && tokens !== void 0 && tokens.length && TokenComponent ? tokens.map((token, i) => /*#__PURE__*/React.createElement(TokenComponent, {
193
- onFocus: handleTokenFocus(i),
194
- onBlur: handleTokenBlur,
195
- onKeyUp: handleTokenKeyUp(token.id),
196
- text: token.text || '' // TODO: just make token.text required
197
- ,
198
- isSelected: selectedTokenIdx === i,
199
- handleRemove: () => {
200
- handleTokenRemove(token.id);
201
- },
202
- variant: "xl",
203
- fillColor: token.labelColor ? token.labelColor : undefined,
204
- tabIndex: 0
205
- })) : null));
206
- });
207
- TextInputWithTokens.defaultProps = {
208
- tokenComponent: Token
209
- };
210
- TextInputWithTokens.displayName = 'TextInputWithTokens';
211
- export default TextInputWithTokens;