@primer/components 0.0.0-202192231947 → 0.0.0-2021923214017

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 (173) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/codemods/deprecateUtilityComponents.js +1 -1
  3. package/dist/browser.esm.js +880 -770
  4. package/dist/browser.esm.js.map +1 -1
  5. package/dist/browser.umd.js +883 -773
  6. package/dist/browser.umd.js.map +1 -1
  7. package/lib/ActionList/Item.js +4 -4
  8. package/lib/ActionList/List.d.ts +2 -1
  9. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +6 -3
  10. package/lib/AnchoredOverlay/AnchoredOverlay.js +11 -3
  11. package/lib/Autocomplete/Autocomplete.d.ts +306 -0
  12. package/lib/Autocomplete/Autocomplete.js +145 -0
  13. package/lib/Autocomplete/AutocompleteContext.d.ts +17 -0
  14. package/lib/Autocomplete/AutocompleteContext.js +11 -0
  15. package/lib/Autocomplete/AutocompleteInput.d.ts +294 -0
  16. package/lib/Autocomplete/AutocompleteInput.js +157 -0
  17. package/lib/Autocomplete/AutocompleteMenu.d.ts +72 -0
  18. package/lib/Autocomplete/AutocompleteMenu.js +224 -0
  19. package/lib/Autocomplete/AutocompleteOverlay.d.ts +20 -0
  20. package/lib/Autocomplete/AutocompleteOverlay.js +80 -0
  21. package/lib/Autocomplete/index.d.ts +2 -0
  22. package/lib/Autocomplete/index.js +15 -0
  23. package/lib/BaseStyles.js +1 -1
  24. package/lib/BorderBox.js +1 -1
  25. package/lib/Button/Button.js +1 -1
  26. package/lib/Button/ButtonInvisible.js +1 -1
  27. package/lib/Button/ButtonTableList.js +1 -1
  28. package/lib/Caret.js +2 -2
  29. package/lib/DatePicker/DatePicker.js +4 -6
  30. package/lib/DatePicker/DatePickerAnchor.js +7 -2
  31. package/lib/DatePicker/DatePickerOverlay.d.ts +3 -0
  32. package/lib/DatePicker/DatePickerOverlay.js +39 -0
  33. package/lib/DatePicker/Day.js +1 -0
  34. package/lib/DatePicker/useDatePicker.d.ts +7 -2
  35. package/lib/DatePicker/useDatePicker.js +138 -50
  36. package/lib/Dialog.js +1 -1
  37. package/lib/FilteredActionList/FilteredActionList.js +5 -31
  38. package/lib/Flash.js +16 -16
  39. package/lib/Label.js +1 -1
  40. package/lib/Overlay.d.ts +1 -0
  41. package/lib/Overlay.js +3 -1
  42. package/lib/Pagination/Pagination.js +1 -1
  43. package/lib/ProgressBar.js +1 -1
  44. package/lib/SelectMenu/SelectMenu.d.ts +12 -10
  45. package/lib/StateLabel.js +13 -19
  46. package/lib/TextInput.d.ts +5 -13
  47. package/lib/TextInput.js +4 -46
  48. package/lib/TextInputWithTokens.d.ts +325 -0
  49. package/lib/TextInputWithTokens.js +245 -0
  50. package/lib/Token/AvatarToken.d.ts +7 -0
  51. package/lib/Token/AvatarToken.js +64 -0
  52. package/lib/Token/IssueLabelToken.d.ts +14 -0
  53. package/lib/Token/IssueLabelToken.js +144 -0
  54. package/lib/Token/Token.d.ts +15 -0
  55. package/lib/Token/Token.js +94 -0
  56. package/lib/Token/TokenBase.d.ts +31 -0
  57. package/lib/Token/TokenBase.js +108 -0
  58. package/lib/Token/_RemoveTokenButton.d.ts +12 -0
  59. package/lib/Token/_RemoveTokenButton.js +77 -0
  60. package/lib/Token/_TokenTextContainer.d.ts +3 -0
  61. package/lib/Token/_TokenTextContainer.js +17 -0
  62. package/lib/Token/index.d.ts +3 -0
  63. package/lib/Token/index.js +31 -0
  64. package/lib/_TextInputWrapper.d.ts +10 -0
  65. package/lib/_TextInputWrapper.js +51 -0
  66. package/lib/_UnstyledTextInput.d.ts +2 -0
  67. package/lib/_UnstyledTextInput.js +20 -0
  68. package/lib/behaviors/scrollIntoViewingArea.d.ts +1 -0
  69. package/lib/behaviors/scrollIntoViewingArea.js +39 -0
  70. package/lib/hooks/useOpenAndCloseFocus.d.ts +2 -1
  71. package/lib/hooks/useOpenAndCloseFocus.js +7 -2
  72. package/lib/hooks/useOverlay.d.ts +2 -1
  73. package/lib/hooks/useOverlay.js +4 -2
  74. package/lib/index.d.ts +5 -0
  75. package/lib/index.js +36 -0
  76. package/lib/theme-preval.js +372 -3102
  77. package/lib/utils/testing.d.ts +51 -494
  78. package/lib/utils/{types.d.ts → types/AriaRole.d.ts} +0 -13
  79. package/lib/utils/{types.js → types/AriaRole.js} +0 -0
  80. package/lib/utils/types/ComponentProps.d.ts +9 -0
  81. package/lib/utils/types/ComponentProps.js +1 -0
  82. package/lib/utils/types/Flatten.d.ts +4 -0
  83. package/lib/utils/types/Flatten.js +1 -0
  84. package/lib/utils/types/MandateProps.d.ts +3 -0
  85. package/lib/utils/types/MandateProps.js +1 -0
  86. package/lib/utils/types/Merge.d.ts +19 -0
  87. package/lib/utils/types/Merge.js +1 -0
  88. package/lib/utils/types/index.d.ts +5 -0
  89. package/lib/utils/types/index.js +70 -0
  90. package/lib-esm/ActionList/Item.js +4 -4
  91. package/lib-esm/ActionList/List.d.ts +2 -1
  92. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +6 -3
  93. package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +11 -3
  94. package/lib-esm/Autocomplete/Autocomplete.d.ts +306 -0
  95. package/lib-esm/Autocomplete/Autocomplete.js +123 -0
  96. package/lib-esm/Autocomplete/AutocompleteContext.d.ts +17 -0
  97. package/lib-esm/Autocomplete/AutocompleteContext.js +2 -0
  98. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +294 -0
  99. package/lib-esm/Autocomplete/AutocompleteInput.js +138 -0
  100. package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +72 -0
  101. package/lib-esm/Autocomplete/AutocompleteMenu.js +205 -0
  102. package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +20 -0
  103. package/lib-esm/Autocomplete/AutocompleteOverlay.js +62 -0
  104. package/lib-esm/Autocomplete/index.d.ts +2 -0
  105. package/lib-esm/Autocomplete/index.js +1 -0
  106. package/lib-esm/BaseStyles.js +1 -1
  107. package/lib-esm/BorderBox.js +1 -1
  108. package/lib-esm/Button/Button.js +1 -1
  109. package/lib-esm/Button/ButtonInvisible.js +1 -1
  110. package/lib-esm/Button/ButtonTableList.js +1 -1
  111. package/lib-esm/Caret.js +2 -2
  112. package/lib-esm/DatePicker/DatePicker.js +3 -4
  113. package/lib-esm/DatePicker/DatePickerAnchor.js +7 -2
  114. package/lib-esm/DatePicker/DatePickerOverlay.d.ts +3 -0
  115. package/lib-esm/DatePicker/DatePickerOverlay.js +24 -0
  116. package/lib-esm/DatePicker/Day.js +1 -0
  117. package/lib-esm/DatePicker/useDatePicker.d.ts +7 -2
  118. package/lib-esm/DatePicker/useDatePicker.js +138 -50
  119. package/lib-esm/Dialog.js +1 -1
  120. package/lib-esm/FilteredActionList/FilteredActionList.js +3 -31
  121. package/lib-esm/Flash.js +16 -16
  122. package/lib-esm/Label.js +1 -1
  123. package/lib-esm/Overlay.d.ts +1 -0
  124. package/lib-esm/Overlay.js +3 -1
  125. package/lib-esm/Pagination/Pagination.js +1 -1
  126. package/lib-esm/ProgressBar.js +1 -1
  127. package/lib-esm/SelectMenu/SelectMenu.d.ts +12 -10
  128. package/lib-esm/StateLabel.js +13 -19
  129. package/lib-esm/TextInput.d.ts +5 -13
  130. package/lib-esm/TextInput.js +4 -37
  131. package/lib-esm/TextInputWithTokens.d.ts +325 -0
  132. package/lib-esm/TextInputWithTokens.js +220 -0
  133. package/lib-esm/Token/AvatarToken.d.ts +7 -0
  134. package/lib-esm/Token/AvatarToken.js +43 -0
  135. package/lib-esm/Token/IssueLabelToken.d.ts +14 -0
  136. package/lib-esm/Token/IssueLabelToken.js +124 -0
  137. package/lib-esm/Token/Token.d.ts +15 -0
  138. package/lib-esm/Token/Token.js +73 -0
  139. package/lib-esm/Token/TokenBase.d.ts +31 -0
  140. package/lib-esm/Token/TokenBase.js +87 -0
  141. package/lib-esm/Token/_RemoveTokenButton.d.ts +12 -0
  142. package/lib-esm/Token/_RemoveTokenButton.js +60 -0
  143. package/lib-esm/Token/_TokenTextContainer.d.ts +3 -0
  144. package/lib-esm/Token/_TokenTextContainer.js +6 -0
  145. package/lib-esm/Token/index.d.ts +3 -0
  146. package/lib-esm/Token/index.js +3 -0
  147. package/lib-esm/_TextInputWrapper.d.ts +10 -0
  148. package/lib-esm/_TextInputWrapper.js +31 -0
  149. package/lib-esm/_UnstyledTextInput.d.ts +2 -0
  150. package/lib-esm/_UnstyledTextInput.js +7 -0
  151. package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +1 -0
  152. package/lib-esm/behaviors/scrollIntoViewingArea.js +30 -0
  153. package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +2 -1
  154. package/lib-esm/hooks/useOpenAndCloseFocus.js +7 -2
  155. package/lib-esm/hooks/useOverlay.d.ts +2 -1
  156. package/lib-esm/hooks/useOverlay.js +4 -2
  157. package/lib-esm/index.d.ts +5 -0
  158. package/lib-esm/index.js +3 -0
  159. package/lib-esm/theme-preval.js +372 -3102
  160. package/lib-esm/utils/testing.d.ts +51 -494
  161. package/lib-esm/utils/{types.d.ts → types/AriaRole.d.ts} +0 -13
  162. package/lib-esm/utils/{types.js → types/AriaRole.js} +0 -0
  163. package/lib-esm/utils/types/ComponentProps.d.ts +9 -0
  164. package/lib-esm/utils/types/ComponentProps.js +1 -0
  165. package/lib-esm/utils/types/Flatten.d.ts +4 -0
  166. package/lib-esm/utils/types/Flatten.js +1 -0
  167. package/lib-esm/utils/types/MandateProps.d.ts +3 -0
  168. package/lib-esm/utils/types/MandateProps.js +1 -0
  169. package/lib-esm/utils/types/Merge.d.ts +19 -0
  170. package/lib-esm/utils/types/Merge.js +1 -0
  171. package/lib-esm/utils/types/index.d.ts +5 -0
  172. package/lib-esm/utils/types/index.js +5 -0
  173. package/package.json +10 -9
@@ -25,35 +25,50 @@ const DatePickerContext = /*#__PURE__*/(0, _react.createContext)(null);
25
25
 
26
26
  const useDatePicker = date => {
27
27
  const value = (0, _react.useContext)(DatePickerContext);
28
+ const [selected, setSelected] = (0, _react.useState)(false);
28
29
 
29
30
  if (!value) {
30
31
  throw new Error('useDatePicker must be used inside a DatePickerProvider');
31
32
  }
32
33
 
33
- let selected = false;
34
- let blocked,
35
- disabled = false;
36
-
37
- if (date) {
38
- if (value.selection) {
39
- if (isMultiSelection(value.selection)) {
40
- selected = !!value.selection.find(d => (0, _dateFns.isEqual)(d, date));
41
- } else if (isRangeSelection(value.selection)) {
42
- if ((0, _dateFns.isEqual)(date, value.selection.from)) {
43
- selected = 'start';
44
- } else if (value.selection.to && (0, _dateFns.isEqual)(date, value.selection.to)) {
45
- selected = 'end';
46
- } else if ((0, _dateFns.isAfter)(date, value.selection.from) && value.selection.to && (0, _dateFns.isBefore)(date, value.selection.to)) {
47
- selected = 'middle';
34
+ (0, _react.useEffect)(() => {
35
+ if (date) {
36
+ if (value.hoverRange) {
37
+ if (isRangeSelection(value.hoverRange)) {
38
+ if ((0, _dateFns.isEqual)(date, value.hoverRange.from)) {
39
+ setSelected('start');
40
+ } else if (value.hoverRange.to && (0, _dateFns.isEqual)(date, value.hoverRange.to)) {
41
+ setSelected('end');
42
+ } else if ((0, _dateFns.isAfter)(date, value.hoverRange.from) && value.hoverRange.to && (0, _dateFns.isBefore)(date, value.hoverRange.to)) {
43
+ setSelected('middle');
44
+ } else {
45
+ setSelected(false);
46
+ }
47
+ }
48
+ } else if (value.selection) {
49
+ if (isMultiSelection(value.selection)) {
50
+ setSelected(!!value.selection.find(d => (0, _dateFns.isEqual)(d, date)));
51
+ } else if (isRangeSelection(value.selection)) {
52
+ if ((0, _dateFns.isEqual)(date, value.selection.from)) {
53
+ setSelected('start');
54
+ } else if (value.selection.to && (0, _dateFns.isEqual)(date, value.selection.to)) {
55
+ setSelected('end');
56
+ } else if ((0, _dateFns.isAfter)(date, value.selection.from) && value.selection.to && (0, _dateFns.isBefore)(date, value.selection.to)) {
57
+ setSelected('middle');
58
+ } else {
59
+ setSelected(false);
60
+ }
48
61
  } else {
49
- selected = false;
62
+ setSelected((0, _dateFns.isEqual)(date, value.selection));
50
63
  }
51
- } else {
52
- selected = (0, _dateFns.isEqual)(date, value.selection);
53
64
  }
54
- } // Determine if date is blocked out
55
-
65
+ }
66
+ }, [date, value.hoverRange, value.selection]);
67
+ let blocked,
68
+ disabled = false;
56
69
 
70
+ if (date) {
71
+ // Determine if date is blocked out
57
72
  if (value.configuration.blockedDates) {
58
73
  blocked = !!value.configuration.blockedDates.find(d => (0, _dateFns.isEqual)(d, date));
59
74
  } // Determine if date is disabled
@@ -79,7 +94,7 @@ function isSingleSelection(selection) {
79
94
  }
80
95
 
81
96
  function isMultiSelection(selection) {
82
- return Array.isArray(selection) && selection.every(d => d instanceof Date);
97
+ return Array.isArray(selection);
83
98
  }
84
99
 
85
100
  function isRangeSelection(selection) {
@@ -90,24 +105,57 @@ function isStringRangeSelection(selection) {
90
105
  return !!selection.from;
91
106
  }
92
107
 
93
- function parseSelection(selection) {
108
+ function parseSelection(selection, variant) {
94
109
  if (!selection) return;
95
110
 
96
- if (Array.isArray(selection)) {
97
- const parsedSelection = [];
111
+ if (variant === 'multi') {
112
+ if (isMultiSelection(selection)) {
113
+ const parsedSelection = [];
98
114
 
99
- for (const d of selection) {
100
- parsedSelection.push(new Date(new Date(d).toDateString()));
101
- }
115
+ for (const d of selection) {
116
+ parsedSelection.push(new Date(new Date(d).toDateString()));
117
+ }
102
118
 
103
- return parsedSelection.sort((a, b) => b.getMilliseconds() - a.getMilliseconds());
104
- } else if (isRangeSelection(selection)) {
105
- return {
106
- from: new Date(new Date(selection.from).toDateString()),
107
- to: selection.to ? new Date(new Date(selection.to).toDateString()) : null
108
- };
119
+ return parsedSelection.sort((a, b) => a.getTime() - b.getTime());
120
+ } else if (selection instanceof Date) {
121
+ return [new Date(new Date(selection).toDateString())];
122
+ } else if (isRangeSelection(selection)) {
123
+ const parsedSelection = [];
124
+ parsedSelection.push(new Date(new Date(selection.from).toDateString()));
125
+
126
+ if (selection.to) {
127
+ parsedSelection.push(new Date(new Date(selection.to).toDateString()));
128
+ }
129
+
130
+ return parsedSelection.sort((a, b) => a.getTime() - b.getTime());
131
+ }
132
+ } else if (variant === 'range') {
133
+ if (isRangeSelection(selection)) {
134
+ return {
135
+ from: new Date(new Date(selection.from).toDateString()),
136
+ to: selection.to ? new Date(new Date(selection.to).toDateString()) : null
137
+ };
138
+ } else if (isMultiSelection(selection)) {
139
+ return {
140
+ from: new Date(new Date(selection[0]).toDateString()),
141
+ to: selection[1] ? new Date(new Date(selection[1]).toDateString()) : null
142
+ };
143
+ } else if (selection instanceof Date) {
144
+ return {
145
+ from: new Date(new Date(selection).toDateString()),
146
+ to: null
147
+ };
148
+ }
109
149
  } else {
110
- return new Date(new Date(selection).toDateString());
150
+ if (selection instanceof Date) {
151
+ return new Date(new Date(selection).toDateString());
152
+ } else if (isMultiSelection(selection)) {
153
+ return new Date(new Date(selection[0]).toDateString());
154
+ } else if (isRangeSelection(selection)) {
155
+ return new Date(new Date(selection.from).toDateString());
156
+ } else {
157
+ return;
158
+ }
111
159
  }
112
160
  }
113
161
 
@@ -128,11 +176,14 @@ const DatePickerProvider = ({
128
176
  value
129
177
  }) => {
130
178
  const [configuration, setConfiguration] = (0, _react.useState)((0, _deepmerge.default)(defaultConfiguration, externalConfig));
131
- const [selection, setSelection] = (0, _react.useState)(parseSelection(value));
179
+ const [previousSelection, setPreviousSelection] = (0, _react.useState)(parseSelection(value, configuration.selection));
180
+ const [selection, setSelection] = (0, _react.useState)(parseSelection(value, configuration.selection));
132
181
  const [hoverRange, setHoverRange] = (0, _react.useState)(null);
133
182
  (0, _react.useEffect)(() => {
134
183
  setConfiguration((0, _deepmerge.default)(defaultConfiguration, externalConfig));
135
- }, [externalConfig]);
184
+ setSelection(parseSelection(selection, configuration.selection)); // Don't want this to run every time selection gets updated
185
+ // eslint-disable-next-line react-hooks/exhaustive-deps
186
+ }, [configuration.selection, externalConfig]);
136
187
  const getFormattedDate = (0, _react.useMemo)(() => {
137
188
  if (!selection) {
138
189
  return configuration.placeholder;
@@ -161,6 +212,10 @@ const DatePickerProvider = ({
161
212
  {
162
213
  if (selection instanceof Date) {
163
214
  return (0, _dateFns.format)(selection, template);
215
+ } else if (Array.isArray(selection)) {
216
+ return (0, _dateFns.format)(selection[0], template);
217
+ } else if (isRangeSelection(selection)) {
218
+ return (0, _dateFns.format)(selection.from, template);
164
219
  } else {
165
220
  return 'Invalid Selection';
166
221
  }
@@ -169,7 +224,13 @@ const DatePickerProvider = ({
169
224
  case 'multi':
170
225
  {
171
226
  if (Array.isArray(selection)) {
172
- return selection.map(d => (0, _dateFns.format)(d, template)).join(', ');
227
+ if (selection.length > 3) return `${selection.length} Selected`;
228
+ const formatted = selection.map(d => (0, _dateFns.format)(d, template)).join(', ');
229
+ return formatted;
230
+ } else if (selection instanceof Date) {
231
+ return [selection].map(d => (0, _dateFns.format)(d, template)).join(', ');
232
+ } else if (isRangeSelection(selection)) {
233
+ return [selection.to, selection.from].map(d => d ? (0, _dateFns.format)(d, template) : '').join(', ');
173
234
  } else {
174
235
  return 'Invalid Selection';
175
236
  }
@@ -179,6 +240,18 @@ const DatePickerProvider = ({
179
240
  {
180
241
  if (isRangeSelection(selection)) {
181
242
  return Object.entries(selection).map(([_, date]) => date ? (0, _dateFns.format)(date, template) : '').join(' - ');
243
+ } else if (selection instanceof Date) {
244
+ return Object.entries({
245
+ from: selection,
246
+ to: null
247
+ }).map(([_, date]) => date ? (0, _dateFns.format)(date, template) : '').join(' - ');
248
+ } else if (Array.isArray(selection)) {
249
+ return Object.entries({
250
+ from: selection[0],
251
+ to: selection[1]
252
+ }) // to date can still be null
253
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
254
+ .map(([_, date]) => date ? (0, _dateFns.format)(date, template) : '').join(' - ');
182
255
  } else {
183
256
  return 'Invalid Selection';
184
257
  }
@@ -190,30 +263,41 @@ const DatePickerProvider = ({
190
263
  }
191
264
  }
192
265
  }, [configuration.dateFormat, configuration.placeholder, configuration.selection, selection]);
266
+ const handleSave = (0, _react.useCallback)(updatedSelection => {
267
+ setPreviousSelection(updatedSelection);
268
+ closePicker === null || closePicker === void 0 ? void 0 : closePicker();
269
+ }, [closePicker]);
193
270
  const selectionHandler = (0, _react.useCallback)(date => {
194
271
  if (configuration.selection === 'multi') {
195
- const selections = selection;
272
+ const selections = [...selection];
196
273
  const existingIndex = selections.findIndex(s => (0, _dateFns.isEqual)(s, date));
197
274
 
198
275
  if (existingIndex > -1) {
199
- setSelection(selections.splice(existingIndex, 1));
276
+ selections.splice(existingIndex, 1);
277
+ setSelection(selections.sort((a, b) => a.getTime() - b.getTime()));
200
278
  } else {
201
- setSelection([...selections, date]);
279
+ setSelection([...selections, date].sort((a, b) => a.getTime() - b.getTime()));
202
280
  }
203
281
  } else if (configuration.selection === 'range') {
204
282
  if (selection && isRangeSelection(selection) && !selection.to) {
205
- setSelection((0, _dateFns.isBefore)(date, selection.from) ? {
283
+ const updatedSelection = (0, _dateFns.isBefore)(date, selection.from) ? {
206
284
  from: date,
207
285
  to: selection.from
208
286
  } : {
209
287
  from: selection.from,
210
288
  to: date
211
- });
289
+ };
290
+ setSelection(updatedSelection);
291
+ setHoverRange(null);
212
292
 
213
293
  if (!configuration.confirmation) {
214
- closePicker === null || closePicker === void 0 ? void 0 : closePicker();
294
+ handleSave(updatedSelection);
215
295
  }
216
296
  } else {
297
+ setHoverRange({
298
+ from: date,
299
+ to: date
300
+ });
217
301
  setSelection({
218
302
  from: date,
219
303
  to: null
@@ -223,14 +307,14 @@ const DatePickerProvider = ({
223
307
  setSelection(date);
224
308
 
225
309
  if (!configuration.confirmation) {
226
- closePicker === null || closePicker === void 0 ? void 0 : closePicker();
310
+ handleSave(date);
227
311
  }
228
312
  }
229
- }, [closePicker, configuration.confirmation, configuration.selection, selection]);
313
+ }, [configuration.confirmation, configuration.selection, handleSave, selection]);
230
314
  const focusHnadler = (0, _react.useCallback)(date => {
231
315
  if (!selection) return;
232
316
 
233
- if (configuration.selection === 'range' && isRangeSelection(selection)) {
317
+ if (configuration.selection === 'range' && isRangeSelection(selection) && hoverRange) {
234
318
  setHoverRange((0, _dateFns.isBefore)(date, selection.from) ? {
235
319
  from: date,
236
320
  to: selection.from
@@ -239,26 +323,30 @@ const DatePickerProvider = ({
239
323
  to: date
240
324
  });
241
325
  }
242
- }, [configuration.selection, selection]);
326
+ }, [configuration.selection, hoverRange, selection]);
243
327
  const blurHnadler = (0, _react.useCallback)(date => {
244
328
  if (!selection || !hoverRange) return;
245
329
 
246
- if (configuration.selection === 'range' && isRangeSelection(selection) && (hoverRange.from === date || hoverRange.to === date)) {
247
- setHoverRange(null);
330
+ if (configuration.selection === 'range' && isRangeSelection(selection) && (hoverRange.from === date || hoverRange.to === date)) {// setHoverRange({from: hoverRange.from, to: hoverRange.from})
248
331
  }
249
332
  }, [configuration.selection, hoverRange, selection]);
333
+ const revertValue = (0, _react.useCallback)(() => {
334
+ setSelection(previousSelection);
335
+ }, [previousSelection]);
250
336
  const datePickerCtx = (0, _react.useMemo)(() => {
251
337
  return {
252
338
  configuration,
253
339
  disabled: false,
254
340
  formattedDate: getFormattedDate,
341
+ hoverRange,
255
342
  onDayBlur: blurHnadler,
256
343
  onDayFocus: focusHnadler,
257
344
  onSelection: selectionHandler,
345
+ revertValue,
258
346
  selectionActive: false,
259
347
  selection
260
348
  };
261
- }, [blurHnadler, configuration, focusHnadler, getFormattedDate, selection, selectionHandler]);
349
+ }, [blurHnadler, configuration, focusHnadler, getFormattedDate, hoverRange, revertValue, selection, selectionHandler]);
262
350
  return /*#__PURE__*/_react.default.createElement(DatePickerContext.Provider, {
263
351
  value: datePickerCtx
264
352
  }, children);
package/lib/Dialog.js CHANGED
@@ -122,7 +122,7 @@ const Dialog = /*#__PURE__*/(0, _react.forwardRef)(({
122
122
  }), children)) : null;
123
123
  });
124
124
  DialogHeader.defaultProps = {
125
- backgroundColor: 'bg.tertiary'
125
+ backgroundColor: 'canvas.subtle'
126
126
  };
127
127
  DialogHeader.propTypes = { ..._Box.default.propTypes
128
128
  };
@@ -7,6 +7,8 @@ exports.FilteredActionList = FilteredActionList;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _ssr = require("@react-aria/ssr");
11
+
10
12
  var _TextInput = _interopRequireDefault(require("../TextInput"));
11
13
 
12
14
  var _Box = _interopRequireDefault(require("../Box"));
@@ -27,7 +29,7 @@ var _useProvidedRefOrCreate = require("../hooks/useProvidedRefOrCreate");
27
29
 
28
30
  var _useScrollFlash = _interopRequireDefault(require("../hooks/useScrollFlash"));
29
31
 
30
- var _ssr = require("@react-aria/ssr");
32
+ var _scrollIntoViewingArea = require("../behaviors/scrollIntoViewingArea");
31
33
 
32
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
35
 
@@ -37,34 +39,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
37
39
 
38
40
  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); }
39
41
 
40
- function scrollIntoViewingArea(child, container, margin = 8, behavior = 'smooth') {
41
- const {
42
- top: childTop,
43
- bottom: childBottom
44
- } = child.getBoundingClientRect();
45
- const {
46
- top: containerTop,
47
- bottom: containerBottom
48
- } = container.getBoundingClientRect();
49
- const isChildTopAboveViewingArea = childTop < containerTop + margin;
50
- const isChildBottomBelowViewingArea = childBottom > containerBottom - margin;
51
-
52
- if (isChildTopAboveViewingArea) {
53
- const scrollHeightToChildTop = childTop - containerTop + container.scrollTop;
54
- container.scrollTo({
55
- behavior,
56
- top: scrollHeightToChildTop - margin
57
- });
58
- } else if (isChildBottomBelowViewingArea) {
59
- const scrollHeightToChildBottom = childBottom - containerBottom + container.scrollTop;
60
- container.scrollTo({
61
- behavior,
62
- top: scrollHeightToChildBottom + margin
63
- });
64
- } // either completely in view or outside viewing area on both ends, don't scroll
65
-
66
- }
67
-
68
42
  const StyledHeader = _styledComponents.default.div.withConfig({
69
43
  displayName: "FilteredActionList__StyledHeader",
70
44
  componentId: "yg3jkv-0"
@@ -112,7 +86,7 @@ function FilteredActionList({
112
86
  activeDescendantRef.current = current;
113
87
 
114
88
  if (current && scrollContainerRef.current && directlyActivated) {
115
- scrollIntoViewingArea(current, scrollContainerRef.current);
89
+ (0, _scrollIntoViewingArea.scrollIntoViewingArea)(current, scrollContainerRef.current);
116
90
  }
117
91
  }
118
92
  }, [// List ref isn't set while loading. Need to re-bind focus zone when it changes
@@ -120,7 +94,7 @@ function FilteredActionList({
120
94
  (0, _react.useEffect)(() => {
121
95
  // if items changed, we want to instantly move active descendant into view
122
96
  if (activeDescendantRef.current && scrollContainerRef.current) {
123
- scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, undefined, 'auto');
97
+ (0, _scrollIntoViewingArea.scrollIntoViewingArea)(activeDescendantRef.current, scrollContainerRef.current, 'vertical', undefined, undefined, 'auto');
124
98
  }
125
99
  }, [items]);
126
100
  (0, _useScrollFlash.default)(scrollContainerRef);
package/lib/Flash.js CHANGED
@@ -18,35 +18,35 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
18
18
  const variants = (0, _styledSystem.variant)({
19
19
  variants: {
20
20
  default: {
21
- color: 'alert.info.text',
22
- backgroundColor: 'alert.info.bg',
23
- borderColor: 'alert.info.border',
21
+ color: 'fg.default',
22
+ backgroundColor: 'accent.subtle',
23
+ borderColor: 'accent.muted',
24
24
  svg: {
25
- color: 'alert.info.icon'
25
+ color: 'accent.fg'
26
26
  }
27
27
  },
28
28
  success: {
29
- color: 'alert.success.text',
30
- backgroundColor: 'alert.success.bg',
31
- borderColor: 'alert.success.border',
29
+ color: 'fg.default',
30
+ backgroundColor: 'success.subtle',
31
+ borderColor: 'success.muted',
32
32
  svg: {
33
- color: 'alert.success.icon'
33
+ color: 'success.fg'
34
34
  }
35
35
  },
36
36
  danger: {
37
- color: 'alert.error.text',
38
- backgroundColor: 'alert.error.bg',
39
- borderColor: 'alert.error.border',
37
+ color: 'fg.default',
38
+ backgroundColor: 'danger.subtle',
39
+ borderColor: 'danger.muted',
40
40
  svg: {
41
- color: 'alert.error.icon'
41
+ color: 'danger.fg'
42
42
  }
43
43
  },
44
44
  warning: {
45
- color: 'alert.warn.text',
46
- backgroundColor: 'alert.warn.bg',
47
- borderColor: 'alert.warn.border',
45
+ color: 'fg.default',
46
+ backgroundColor: 'attention.subtle',
47
+ borderColor: 'attention.muted',
48
48
  svg: {
49
- color: 'alert.warn.icon'
49
+ color: 'attention.fg'
50
50
  }
51
51
  }
52
52
  }
package/lib/Label.js CHANGED
@@ -52,7 +52,7 @@ const Label = _styledComponents.default.span.withConfig({
52
52
  })(["display:inline-block;font-weight:", ";color:", ";border-radius:", ";&:hover{text-decoration:none;}", " ", " ", " ", " ", ""], (0, _constants.get)('fontWeights.semibold'), (0, _constants.get)('colors.fg.onEmphasis'), (0, _constants.get)('radii.3'), sizeVariant, _constants.COMMON, props => props.dropshadow ? 'box-shadow: inset 0 -1px 0 rgba(27, 31, 35, 0.12)' : '', props => props.outline ? outlineStyles : '', _sx.default);
53
53
 
54
54
  Label.defaultProps = {
55
- bg: 'label.primary.border',
55
+ bg: 'neutral.emphasis',
56
56
  variant: 'medium'
57
57
  };
58
58
  var _default = Label;
package/lib/Overlay.d.ts CHANGED
@@ -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,
package/lib/Overlay.js CHANGED
@@ -113,6 +113,7 @@ const Overlay = /*#__PURE__*/_react.default.forwardRef(({
113
113
  left,
114
114
  anchorSide,
115
115
  portalContainerName,
116
+ preventFocusOnOpen,
116
117
  ...rest
117
118
  }, forwardedRef) => {
118
119
  const overlayRef = (0, _react.useRef)(null);
@@ -128,7 +129,8 @@ const Overlay = /*#__PURE__*/_react.default.forwardRef(({
128
129
  onEscape,
129
130
  ignoreClickRefs,
130
131
  onClickOutside,
131
- initialFocusRef
132
+ initialFocusRef,
133
+ preventFocusOnOpen
132
134
  });
133
135
  (0, _react.useEffect)(() => {
134
136
  var _combinedRef$current;
@@ -24,7 +24,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
24
24
  const Page = _styledComponents.default.a.withConfig({
25
25
  displayName: "Pagination__Page",
26
26
  componentId: "b80nss-0"
27
- })(["display:inline-block;min-width:32px;padding:5px 10px;font-style:normal;line-height:20px;color:", ";text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;user-select:none;text-decoration:none;margin-right:", ";&:last-child{margin-right:0;}border:", " solid transparent;border-radius:", ";transition:border-color 0.2s cubic-bezier(0.3,0,0.5,1);&:hover,&:focus{text-decoration:none;border-color:", ";outline:0;transition-duration:0.1s;}&:active{border-color:", ";}&[rel='prev'],&[rel='next']{color:", ";}&[aria-current],&[aria-current]:hover{color:", ";background-color:", ";border-color:transparent;}&[aria-disabled],&[aria-disabled]:hover{color:", ";cursor:default;border-color:transparent;}@supports (clip-path:polygon(50% 0,100% 50%,50% 100%)){&[rel='prev']::before,&[rel='next']::after{display:inline-block;width:16px;height:16px;vertical-align:text-bottom;content:'';background-color:currentColor;}&[rel='prev']::before{margin-right:", ";clip-path:polygon( 9.8px 12.8px,8.7px 12.8px,4.5px 8.5px,4.5px 7.5px,8.7px 3.2px,9.8px 4.3px,6.1px 8px,9.8px 11.7px,9.8px 12.8px );}&[rel='next']::after{margin-left:", ";clip-path:polygon( 6.2px 3.2px,7.3px 3.2px,11.5px 7.5px,11.5px 8.5px,7.3px 12.8px,6.2px 11.7px,9.9px 8px,6.2px 4.3px,6.2px 3.2px );}}", ";"], (0, _constants.get)('colors.fg.default'), (0, _constants.get)('space.1'), (0, _constants.get)('borderWidths.1'), (0, _constants.get)('radii.2'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('colors.border.muted'), (0, _constants.get)('colors.accent.fg'), (0, _constants.get)('colors.fg.onEmphasis'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('space.1'), (0, _constants.get)('space.1'), _constants.COMMON);
27
+ })(["display:inline-block;min-width:32px;padding:5px 10px;font-style:normal;line-height:20px;color:", ";text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;user-select:none;text-decoration:none;margin-right:", ";&:last-child{margin-right:0;}border:", " solid transparent;border-radius:", ";transition:border-color 0.2s cubic-bezier(0.3,0,0.5,1);&:hover,&:focus{text-decoration:none;border-color:", ";outline:0;transition-duration:0.1s;}&:active{border-color:", ";}&[rel='prev'],&[rel='next']{color:", ";}&[aria-current],&[aria-current]:hover{color:", ";background-color:", ";border-color:transparent;}&[aria-disabled],&[aria-disabled]:hover{color:", ";cursor:default;border-color:transparent;}@supports (clip-path:polygon(50% 0,100% 50%,50% 100%)){&[rel='prev']::before,&[rel='next']::after{display:inline-block;width:16px;height:16px;vertical-align:text-bottom;content:'';background-color:currentColor;}&[rel='prev']::before{margin-right:", ";clip-path:polygon( 9.8px 12.8px,8.7px 12.8px,4.5px 8.5px,4.5px 7.5px,8.7px 3.2px,9.8px 4.3px,6.1px 8px,9.8px 11.7px,9.8px 12.8px );}&[rel='next']::after{margin-left:", ";clip-path:polygon( 6.2px 3.2px,7.3px 3.2px,11.5px 7.5px,11.5px 8.5px,7.3px 12.8px,6.2px 11.7px,9.9px 8px,6.2px 4.3px,6.2px 3.2px );}}", ";"], (0, _constants.get)('colors.fg.default'), (0, _constants.get)('space.1'), (0, _constants.get)('borderWidths.1'), (0, _constants.get)('radii.2'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('colors.border.muted'), (0, _constants.get)('colors.accent.fg'), (0, _constants.get)('colors.fg.onEmphasis'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('space.1'), (0, _constants.get)('space.1'), _constants.COMMON);
28
28
 
29
29
  function usePaginationPages({
30
30
  theme,
@@ -52,7 +52,7 @@ function ProgressBar({
52
52
 
53
53
  ProgressBar.displayName = "ProgressBar";
54
54
  ProgressBar.defaultProps = {
55
- bg: 'bg.successInverse',
55
+ bg: 'success.emphasis',
56
56
  barSize: 'default'
57
57
  };
58
58
  var _default = ProgressBar;
@@ -32,7 +32,17 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
32
32
  Divider: import("styled-components").StyledComponent<"div", any, SystemCommonProps & SxProp, never>;
33
33
  Filter: React.ForwardRefExoticComponent<Pick<{
34
34
  value?: string | undefined;
35
- } & Pick<{
35
+ } & Pick<Omit<Pick<({
36
+ [x: string]: any;
37
+ [x: number]: any;
38
+ } & {
39
+ theme?: any;
40
+ } & ({} | {
41
+ children?: React.ReactNode;
42
+ })) & {
43
+ as?: string | React.ComponentType<any> | undefined;
44
+ forwardedAs?: string | React.ComponentType<any> | undefined;
45
+ }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
36
46
  className?: string | undefined;
37
47
  icon?: React.ComponentType<{
38
48
  className?: string | undefined;
@@ -307,15 +317,7 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
307
317
  contrast?: boolean | undefined;
308
318
  } & {
309
319
  theme?: any;
310
- }, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "sx" | "disabled" | "variant" | "contrast"> & Omit<Pick<{
311
- [x: string]: any;
312
- [x: number]: any;
313
- } & {
314
- theme?: any;
315
- } & {
316
- as?: string | React.ComponentType<any> | undefined;
317
- forwardedAs?: string | React.ComponentType<any> | undefined;
318
- }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
320
+ }, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "sx" | "disabled" | "variant" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
319
321
  Footer: import("styled-components").StyledComponent<"footer", any, SystemCommonProps & SxProp, never>;
320
322
  Item: React.ForwardRefExoticComponent<Pick<{
321
323
  as?: React.ElementType<any> | undefined;
package/lib/StateLabel.js CHANGED
@@ -35,34 +35,28 @@ const colorVariants = (0, _styledSystem.variant)({
35
35
  prop: 'status',
36
36
  variants: {
37
37
  issueClosed: {
38
- backgroundColor: 'prState.closed.bg',
39
- color: 'prState.closed.text',
40
- borderColor: 'prState.closed.border'
38
+ backgroundColor: 'danger.emphasis',
39
+ color: 'fg.onEmphasis'
41
40
  },
42
41
  pullClosed: {
43
- backgroundColor: 'prState.closed.bg',
44
- color: 'prState.closed.text',
45
- borderColor: 'prState.closed.border'
42
+ backgroundColor: 'danger.emphasis',
43
+ color: 'fg.onEmphasis'
46
44
  },
47
45
  pullMerged: {
48
- backgroundColor: 'prState.merged.bg',
49
- color: 'prState.merged.text',
50
- borderColor: 'prState.merged.border'
46
+ backgroundColor: 'done.emphasis',
47
+ color: 'fg.onEmphasis'
51
48
  },
52
49
  issueOpened: {
53
- backgroundColor: 'prState.open.bg',
54
- color: 'prState.open.text',
55
- borderColor: 'prState.open.border'
50
+ backgroundColor: 'success.emphasis',
51
+ color: 'fg.onEmphasis'
56
52
  },
57
53
  pullOpened: {
58
- backgroundColor: 'prState.open.bg',
59
- color: 'prState.open.text',
60
- borderColor: 'prState.open.border'
54
+ backgroundColor: 'success.emphasis',
55
+ color: 'fg.onEmphasis'
61
56
  },
62
57
  draft: {
63
- backgroundColor: 'prState.draft.bg',
64
- color: 'prState.draft.text',
65
- borderColor: 'prState.draft.border'
58
+ backgroundColor: 'neutral.emphasis',
59
+ color: 'fg.onEmphasis'
66
60
  }
67
61
  }
68
62
  });
@@ -85,7 +79,7 @@ const sizeVariants = (0, _styledSystem.variant)({
85
79
  const StateLabelBase = _styledComponents.default.span.withConfig({
86
80
  displayName: "StateLabel__StateLabelBase",
87
81
  componentId: "k4pd9e-0"
88
- })(["display:inline-flex;align-items:center;font-weight:", ";line-height:16px;color:", ";text-align:center;border-radius:", ";border-width:1px;border-style:solid;", ";", ";", ";", ";"], (0, _constants.get)('fontWeights.bold'), (0, _constants.get)('colors.canvas.default'), (0, _constants.get)('radii.3'), colorVariants, sizeVariants, _constants.COMMON, _sx.default);
82
+ })(["display:inline-flex;align-items:center;font-weight:", ";line-height:16px;color:", ";text-align:center;border-radius:", ";", ";", ";", ";", ";"], (0, _constants.get)('fontWeights.bold'), (0, _constants.get)('colors.canvas.default'), (0, _constants.get)('radii.3'), colorVariants, sizeVariants, _constants.COMMON, _sx.default);
89
83
 
90
84
  function StateLabel({
91
85
  children,
@@ -1,22 +1,14 @@
1
1
  import React from 'react';
2
- import { MaxWidthProps, MinWidthProps, WidthProps } from 'styled-system';
3
- import { SxProp } from './sx';
4
- import { ComponentProps } 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>;
2
+ import { ComponentProps, Merge } from './utils/types';
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 = NonPassthroughProps & Omit<React.ComponentPropsWithoutRef<typeof Input>, keyof 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;