@planningcenter/tapestry-react 2.6.0 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -103,7 +103,9 @@ function Collapse(props) {
103
103
  }
104
104
 
105
105
  if (instantRender) {
106
- handleComplete();
106
+ requestAnimationFrame(function () {
107
+ return handleComplete();
108
+ });
107
109
  }
108
110
 
109
111
  node.addEventListener('transitionend', handleTransitionEnd);
@@ -67,6 +67,10 @@ var Dropdown = /*#__PURE__*/function (_Component) {
67
67
  }
68
68
  });
69
69
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "togglePopover", function (event) {
70
+ _this.setState({
71
+ preventBlur: false
72
+ });
73
+
70
74
  if (_this.state.isPopoverOpen) {
71
75
  _this.closePopover(event);
72
76
  } else {
@@ -91,7 +95,8 @@ var Dropdown = /*#__PURE__*/function (_Component) {
91
95
  }
92
96
  });
93
97
  _this.state = {
94
- isPopoverOpen: props.defaultOpen || props.forceOpen
98
+ isPopoverOpen: props.defaultOpen || props.forceOpen,
99
+ preventBlur: false
95
100
  };
96
101
  _this.id = (0, _utils.generateId)('dropdown');
97
102
  return _this;
@@ -194,7 +199,15 @@ var Dropdown = /*#__PURE__*/function (_Component) {
194
199
  }, _objectSpread2[arrowIconOnly ? 'icon' : 'iconRight'] = {
195
200
  name: isPopoverOpen ? 'general.upCaret' : 'general.downCaret',
196
201
  size: 'sm'
197
- }, _objectSpread2.title = arrowIconOnly ? 'arrow down' : restProps.title, _objectSpread2.tabIndex = 0, _objectSpread2.cursor = 'pointer', _objectSpread2.onBlur = requestBlur, _objectSpread2.onClick = function onClick(event) {
202
+ }, _objectSpread2.title = arrowIconOnly ? 'arrow down' : restProps.title, _objectSpread2.tabIndex = 0, _objectSpread2.cursor = 'pointer', _objectSpread2.onBlur = function onBlur(event) {
203
+ if (_this2.state.preventBlur) {
204
+ _this2.setState({
205
+ preventBlur: false
206
+ });
207
+ } else {
208
+ requestBlur(event);
209
+ }
210
+ }, _objectSpread2.onClick = function onClick(event) {
198
211
  _this2.togglePopover();
199
212
 
200
213
  if (!isPopoverOpen) {
@@ -260,6 +273,10 @@ var Dropdown = /*#__PURE__*/function (_Component) {
260
273
  }
261
274
  });
262
275
  }
276
+ }, _objectSpread2.onMouseDown = function onMouseDown() {
277
+ _this2.setState({
278
+ preventBlur: true
279
+ });
263
280
  }, _objectSpread2), restProps);
264
281
 
265
282
  if ( /*#__PURE__*/_react["default"].isValidElement(triggerElement)) {
@@ -78,7 +78,8 @@ var Input = /*#__PURE__*/function (_Component) {
78
78
  highlightOnInteraction = _this$props.highlightOnInteraction,
79
79
  type = _this$props.type,
80
80
  value = _this$props.value,
81
- restProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, ["backgroundColor", "color", "autoComplete", "autoFocus", "autoWidth", "defaultValue", "disabled", "focus", "hover", "id", "min", "minLength", "max", "maxLength", "name", "onBlur", "onChange", "onFocus", "onKeyDown", "onKeyUp", "placeholder", "placeholderColor", "readOnly", "highlightOnInteraction", "type", "value"]);
81
+ required = _this$props.required,
82
+ restProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, ["backgroundColor", "color", "autoComplete", "autoFocus", "autoWidth", "defaultValue", "disabled", "focus", "hover", "id", "min", "minLength", "max", "maxLength", "name", "onBlur", "onChange", "onFocus", "onKeyDown", "onKeyUp", "placeholder", "placeholderColor", "readOnly", "highlightOnInteraction", "type", "value", "required"]);
82
83
  var ariaLabel = restProps['aria-label'];
83
84
 
84
85
  if (ariaLabel) {
@@ -119,7 +120,8 @@ var Input = /*#__PURE__*/function (_Component) {
119
120
  onFocus: onFocus,
120
121
  onBlur: onBlur,
121
122
  onKeyDown: onKeyDown,
122
- onKeyUp: onKeyUp
123
+ onKeyUp: onKeyUp,
124
+ required: required
123
125
  }));
124
126
  };
125
127
 
@@ -60,11 +60,13 @@ function Modal(_ref) {
60
60
  }
61
61
  }, scrimProps), /*#__PURE__*/_react["default"].createElement(_Box["default"], (0, _extends2["default"])({
62
62
  backgroundColor: "surface",
63
+ boxShadow: "0 0 20px rgba(0, 0, 0, 0.15)",
63
64
  innerRef: modalRef,
64
65
  margin: 4,
65
66
  maxWidth: 60,
66
- padding: 2,
67
- radius: 3,
67
+ padding: 4,
68
+ paddingBottom: 3,
69
+ radius: 8,
68
70
  width: "100%"
69
71
  }, themeProps), children));
70
72
  }
@@ -33,6 +33,9 @@ var _utils = require("../utils");
33
33
 
34
34
  var _utils2 = require("./utils");
35
35
 
36
+ var MIN_MINUTE = 0;
37
+ var MAX_MINUTE = 59;
38
+
36
39
  var TimeField = /*#__PURE__*/function (_Component) {
37
40
  (0, _inheritsLoose2["default"])(TimeField, _Component);
38
41
 
@@ -89,9 +92,31 @@ var TimeField = /*#__PURE__*/function (_Component) {
89
92
  });
90
93
  });
91
94
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleHoursKeyDown", function (event) {
95
+ var hour = Number(event.target.value);
96
+ var isTwelveHourClock = _this.props.twelveHourClock;
97
+ var isHourEleven = _utils2.HOURS_TO_NOON - 1;
98
+ var maxHour = isTwelveHourClock ? _utils2.HOURS_TO_NOON : _utils2.HOURS_IN_DAY - 1;
99
+ var minHour = isTwelveHourClock ? 1 : 0;
100
+
92
101
  if (event.key === 'ArrowRight') {
93
102
  _this.inputBox.focus(1);
94
103
  }
104
+
105
+ if (event.key === 'ArrowUp' && isTwelveHourClock && hour === isHourEleven) {
106
+ _this.toggleMeridiem();
107
+ }
108
+
109
+ if (event.key === 'ArrowUp' && hour === maxHour) {
110
+ _this.updateHours(1);
111
+ }
112
+
113
+ if (event.key === 'ArrowDown' && isTwelveHourClock && hour === minHour) {
114
+ _this.toggleMeridiem();
115
+ }
116
+
117
+ if (event.key === 'ArrowDown' && hour === minHour) {
118
+ _this.updateHours(-1);
119
+ }
95
120
  });
96
121
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleMinutesChange", function (minutes) {
97
122
  _this.updateTime({
@@ -99,6 +124,8 @@ var TimeField = /*#__PURE__*/function (_Component) {
99
124
  });
100
125
  });
101
126
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleMinutesKeyDown", function (event) {
127
+ var minute = Number(event.target.value);
128
+
102
129
  if (_this.props.ignoredKeys.includes(event.key)) {
103
130
  return;
104
131
  }
@@ -110,6 +137,14 @@ var TimeField = /*#__PURE__*/function (_Component) {
110
137
  if (event.key === 'ArrowRight') {
111
138
  _this.inputBox.focus(2);
112
139
  }
140
+
141
+ if (event.key === 'ArrowUp' && minute >= MAX_MINUTE) {
142
+ _this.updateMinutes(1);
143
+ }
144
+
145
+ if (event.key === 'ArrowDown' && minute <= MIN_MINUTE) {
146
+ _this.updateMinutes(-1);
147
+ }
113
148
  });
114
149
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleAMPMKeyDown", function (event) {
115
150
  if (_this.props.ignoredKeys.includes(event.key)) {
@@ -200,8 +235,8 @@ var TimeField = /*#__PURE__*/function (_Component) {
200
235
  fontVariantNumeric: "tabular-nums",
201
236
  moveFocusOnMax: true,
202
237
  value: minutes,
203
- min: 0,
204
- max: 59,
238
+ min: MIN_MINUTE,
239
+ max: MAX_MINUTE,
205
240
  pad: 2,
206
241
  grow: 0,
207
242
  width: "2ch",
@@ -204,7 +204,7 @@ it('does not change the meridiem on arrow key if arrow keys are ignored', functi
204
204
 
205
205
  expect(meridiemInput).toHaveValue('PM');
206
206
  });
207
- it('changes the value of hours on arrow up or arrow down', function () {
207
+ it('increment hour on arrow up', function () {
208
208
  var _setup15 = setup({
209
209
  hours: 1,
210
210
  minutes: 42
@@ -217,13 +217,182 @@ it('changes the value of hours on arrow up or arrow down', function () {
217
217
 
218
218
  expect(hourInput).toHaveValue("02");
219
219
  });
220
- it('does not change the value of hours on arrow up or arrow down if ignored', function () {
220
+ it('increment hour if arrow up on minutes exceeds max value', function () {
221
221
  var _setup16 = setup({
222
+ hours: 1,
223
+ minutes: 59
224
+ }),
225
+ hourInput = _setup16.hourInput,
226
+ minuteInput = _setup16.minuteInput;
227
+
228
+ expect(hourInput).toHaveValue("01");
229
+
230
+ _userEvent["default"].type(minuteInput, '{arrowup}');
231
+
232
+ expect(hourInput).toHaveValue("02");
233
+ });
234
+ it('decrement hour on arrow down', function () {
235
+ var _setup17 = setup({
236
+ hours: 2,
237
+ minutes: 42
238
+ }),
239
+ hourInput = _setup17.hourInput;
240
+
241
+ expect(hourInput).toHaveValue("02");
242
+
243
+ _userEvent["default"].type(hourInput, '{arrowdown}');
244
+
245
+ expect(hourInput).toHaveValue("01");
246
+ });
247
+ it('decrement hour if arrow down on minutes exceeds min value', function () {
248
+ var _setup18 = setup({
249
+ hours: 2,
250
+ minutes: 0
251
+ }),
252
+ hourInput = _setup18.hourInput,
253
+ minuteInput = _setup18.minuteInput;
254
+
255
+ expect(hourInput).toHaveValue("02");
256
+
257
+ _userEvent["default"].type(minuteInput, '{arrowdown}');
258
+
259
+ expect(hourInput).toHaveValue("01");
260
+ });
261
+ it('increment minute on arrow up', function () {
262
+ var _setup19 = setup({
263
+ hours: 1,
264
+ minutes: 42
265
+ }),
266
+ minuteInput = _setup19.minuteInput;
267
+
268
+ expect(minuteInput).toHaveValue("42");
269
+
270
+ _userEvent["default"].type(minuteInput, '{arrowup}');
271
+
272
+ expect(minuteInput).toHaveValue("43");
273
+ });
274
+ it('decrement minute on arrow down', function () {
275
+ var _setup20 = setup({
276
+ hours: 2,
277
+ minutes: 43
278
+ }),
279
+ minuteInput = _setup20.minuteInput;
280
+
281
+ expect(minuteInput).toHaveValue("43");
282
+
283
+ _userEvent["default"].type(minuteInput, '{arrowdown}');
284
+
285
+ expect(minuteInput).toHaveValue("42");
286
+ });
287
+ it('set minute to min value if arrow up on minutes exceeds max value', function () {
288
+ var _setup21 = setup({
289
+ hours: 1,
290
+ minutes: 59
291
+ }),
292
+ minuteInput = _setup21.minuteInput;
293
+
294
+ expect(minuteInput).toHaveValue("59");
295
+
296
+ _userEvent["default"].type(minuteInput, '{arrowup}');
297
+
298
+ expect(minuteInput).toHaveValue("00");
299
+ });
300
+ it('set minute to max value if arrow down on minutes exceeds min value', function () {
301
+ var _setup22 = setup({
302
+ hours: 1,
303
+ minutes: 0
304
+ }),
305
+ minuteInput = _setup22.minuteInput;
306
+
307
+ expect(minuteInput).toHaveValue("00");
308
+
309
+ _userEvent["default"].type(minuteInput, '{arrowdown}');
310
+
311
+ expect(minuteInput).toHaveValue("59");
312
+ });
313
+ it('toggle meridiem if arrow up on hour exceeds eleven', function () {
314
+ var _setup23 = setup({
315
+ hours: 11
316
+ }),
317
+ hourInput = _setup23.hourInput,
318
+ meridiemInput = _setup23.meridiemInput;
319
+
320
+ expect(meridiemInput).toHaveValue('AM');
321
+
322
+ _userEvent["default"].type(hourInput, '{arrowup}');
323
+
324
+ expect(meridiemInput).toHaveValue('PM');
325
+ });
326
+ it('toggle meridiem if arrow down on hour exceeds min value', function () {
327
+ var _setup24 = setup({
328
+ hours: 1
329
+ }),
330
+ hourInput = _setup24.hourInput,
331
+ meridiemInput = _setup24.meridiemInput;
332
+
333
+ expect(meridiemInput).toHaveValue('AM');
334
+
335
+ _userEvent["default"].type(hourInput, '{arrowdown}');
336
+
337
+ expect(meridiemInput).toHaveValue('PM');
338
+ });
339
+ it('set 12 hour clock to min value if arrow up on hour exceeds max value', function () {
340
+ var _setup25 = setup({
341
+ hours: 12
342
+ }),
343
+ hourInput = _setup25.hourInput;
344
+
345
+ expect(hourInput).toHaveValue("12");
346
+
347
+ _userEvent["default"].type(hourInput, '{arrowup}');
348
+
349
+ expect(hourInput).toHaveValue("01");
350
+ });
351
+ it('set 24 hour clock to min value if arrow up on hour exceeds max value', function () {
352
+ var _setup26 = setup({
353
+ hours: 23,
354
+ twelveHourClock: false
355
+ }),
356
+ hourInput = _setup26.hourInput;
357
+
358
+ expect(hourInput).toHaveValue("23");
359
+
360
+ _userEvent["default"].type(hourInput, '{arrowup}');
361
+
362
+ expect(hourInput).toHaveValue("00");
363
+ });
364
+ it('set 12 hour clock to max value if arrow down on hour exceeds min value', function () {
365
+ var _setup27 = setup({
366
+ hours: 1
367
+ }),
368
+ hourInput = _setup27.hourInput;
369
+
370
+ expect(hourInput).toHaveValue("01");
371
+
372
+ _userEvent["default"].type(hourInput, '{arrowdown}');
373
+
374
+ expect(hourInput).toHaveValue("12");
375
+ });
376
+ it('set 24 hour clock to max value if arrow down on hour exceeds min value', function () {
377
+ var _setup28 = setup({
378
+ hours: 0,
379
+ twelveHourClock: false
380
+ }),
381
+ hourInput = _setup28.hourInput;
382
+
383
+ expect(hourInput).toHaveValue("00");
384
+
385
+ _userEvent["default"].type(hourInput, '{arrowdown}');
386
+
387
+ expect(hourInput).toHaveValue("23");
388
+ });
389
+ it('does not change the value of hours on arrow up or arrow down if ignored', function () {
390
+ var _setup29 = setup({
222
391
  hours: 1,
223
392
  minutes: 42,
224
393
  ignoredKeys: ['ArrowUp', 'ArrowDown']
225
394
  }),
226
- hourInput = _setup16.hourInput;
395
+ hourInput = _setup29.hourInput;
227
396
 
228
397
  expect(hourInput).toHaveValue("01");
229
398
 
@@ -236,12 +405,12 @@ it('does not change the value of hours on arrow up or arrow down if ignored', fu
236
405
  expect(hourInput).toHaveValue("01");
237
406
  });
238
407
  it('does not change the value of minutes on arrow up or arrow down if ignored', function () {
239
- var _setup17 = setup({
408
+ var _setup30 = setup({
240
409
  hours: 1,
241
410
  minutes: 42,
242
411
  ignoredKeys: ['ArrowUp', 'ArrowDown']
243
412
  }),
244
- minuteInput = _setup17.minuteInput;
413
+ minuteInput = _setup30.minuteInput;
245
414
 
246
415
  expect(minuteInput).toHaveValue("42");
247
416
 
@@ -255,15 +424,15 @@ it('does not change the value of minutes on arrow up or arrow down if ignored',
255
424
  }); // ios
256
425
 
257
426
  it('renders iOS as a single input', function () {
258
- var _setup18 = setup({
427
+ var _setup31 = setup({
259
428
  isIOS: true,
260
429
  hours: 13,
261
430
  minutes: 42
262
431
  }),
263
- container = _setup18.container,
264
- hourInput = _setup18.hourInput,
265
- minuteInput = _setup18.minuteInput,
266
- meridiemInput = _setup18.meridiemInput;
432
+ container = _setup31.container,
433
+ hourInput = _setup31.hourInput,
434
+ minuteInput = _setup31.minuteInput,
435
+ meridiemInput = _setup31.meridiemInput;
267
436
 
268
437
  var singleTimeInput = container.querySelector('[type=time]');
269
438
  expect(singleTimeInput).toHaveValue('13:42');
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
6
+
7
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
+
9
+ var _react = _interopRequireDefault(require("react"));
10
+
11
+ var _react2 = require("@testing-library/react");
12
+
13
+ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
14
+
15
+ require("@testing-library/jest-dom/extend-expect");
16
+
17
+ var _ = require("..");
18
+
19
+ describe('Tooltip', function () {
20
+ test('does not render string when closed', function () {
21
+ var string = 'Test Text';
22
+ (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_.Tooltip, {
23
+ title: string
24
+ }, /*#__PURE__*/_react["default"].createElement(_.Text, null, "Tooltip anchor")));
25
+ expect(_react2.screen.queryByText(string)).toBeNull();
26
+ });
27
+ test('renders string on hover', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
28
+ var string, tooltip;
29
+ return _regenerator["default"].wrap(function _callee$(_context) {
30
+ while (1) {
31
+ switch (_context.prev = _context.next) {
32
+ case 0:
33
+ string = 'Test Text';
34
+ (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_.Tooltip, {
35
+ title: string
36
+ }, /*#__PURE__*/_react["default"].createElement(_.Text, null, "Tooltip anchor")));
37
+
38
+ _userEvent["default"].hover(_react2.screen.getByText('Tooltip anchor'));
39
+
40
+ _context.next = 5;
41
+ return _react2.screen.findByText(string);
42
+
43
+ case 5:
44
+ tooltip = _context.sent;
45
+ expect(tooltip).toBeInTheDocument();
46
+
47
+ case 7:
48
+ case "end":
49
+ return _context.stop();
50
+ }
51
+ }
52
+ }, _callee);
53
+ })));
54
+ test('renders string on focus', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
55
+ var string, tooltip;
56
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
57
+ while (1) {
58
+ switch (_context2.prev = _context2.next) {
59
+ case 0:
60
+ string = 'Test Text';
61
+ (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_.Tooltip, {
62
+ title: string,
63
+ triggerOnFocus: true
64
+ }, /*#__PURE__*/_react["default"].createElement(_.Button, null, "Tooltip anchor")));
65
+
66
+ _userEvent["default"].tab();
67
+
68
+ _context2.next = 5;
69
+ return _react2.screen.findByText(string);
70
+
71
+ case 5:
72
+ tooltip = _context2.sent;
73
+ expect(tooltip).toBeInTheDocument();
74
+
75
+ case 7:
76
+ case "end":
77
+ return _context2.stop();
78
+ }
79
+ }
80
+ }, _callee2);
81
+ })));
82
+ test('removes string after timeout', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
83
+ var string, anchor, tooltip;
84
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
85
+ while (1) {
86
+ switch (_context3.prev = _context3.next) {
87
+ case 0:
88
+ string = 'Test Text';
89
+ (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_.Tooltip, {
90
+ title: string
91
+ }, /*#__PURE__*/_react["default"].createElement(_.Text, null, "Tooltip anchor")));
92
+ anchor = _react2.screen.getByText('Tooltip anchor');
93
+ expect(_react2.screen.queryByText(string)).toBeNull();
94
+
95
+ _userEvent["default"].hover(anchor);
96
+
97
+ _context3.next = 7;
98
+ return _react2.screen.findByText(string);
99
+
100
+ case 7:
101
+ tooltip = _context3.sent;
102
+ expect(tooltip).toBeInTheDocument();
103
+
104
+ _userEvent["default"].unhover(anchor);
105
+
106
+ _context3.next = 12;
107
+ return (0, _react2.waitFor)(function () {
108
+ expect(_react2.screen.queryByText(string)).not.toBeInTheDocument();
109
+ });
110
+
111
+ case 12:
112
+ case "end":
113
+ return _context3.stop();
114
+ }
115
+ }
116
+ }, _callee3);
117
+ })));
118
+ test('stays open when hovering a custom tooltip', function () {
119
+ var CustomTooltip = function CustomTooltip() {
120
+ var _hooks$useHover = _.hooks.useHover(),
121
+ hover = _hooks$useHover.hover,
122
+ hoverProps = _hooks$useHover.hoverProps;
123
+
124
+ return /*#__PURE__*/_react["default"].createElement(_.Tooltip, {
125
+ title: /*#__PURE__*/_react["default"].createElement(_.Link, {
126
+ to: "#"
127
+ }, /*#__PURE__*/_react["default"].createElement(_.StackView, null, /*#__PURE__*/_react["default"].createElement(_.Text, {
128
+ "data-hover": hover
129
+ }, string)))
130
+ }, /*#__PURE__*/_react["default"].createElement(_.Button, hoverProps, "Tooltip anchor"));
131
+ };
132
+
133
+ var string = 'Test Text';
134
+ (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(CustomTooltip, null));
135
+
136
+ var anchor = _react2.screen.getByText('Tooltip anchor');
137
+
138
+ _userEvent["default"].hover(anchor);
139
+
140
+ (0, _react2.act)(function () {
141
+ jest.runAllTimers();
142
+ });
143
+
144
+ var tooltip = _react2.screen.getByText(string);
145
+
146
+ expect(tooltip).toBeInTheDocument();
147
+
148
+ _userEvent["default"].unhover(anchor);
149
+
150
+ _userEvent["default"].hover(tooltip);
151
+
152
+ (0, _react2.act)(function () {
153
+ jest.runAllTimers();
154
+ });
155
+ expect(tooltip).toBeInTheDocument();
156
+
157
+ _userEvent["default"].unhover(tooltip);
158
+
159
+ (0, _react2.act)(function () {
160
+ jest.runAllTimers();
161
+ });
162
+ expect(tooltip).not.toBeInTheDocument();
163
+ });
164
+ test('cleans up pageViewChange listeners', function () {
165
+ window.removeEventListener = jest.fn().mockImplementation(function (event, callback) {});
166
+ document.removeEventListener = jest.fn().mockImplementation(function (event, callback) {});
167
+
168
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_.Tooltip, {
169
+ title: "Test Text"
170
+ }, /*#__PURE__*/_react["default"].createElement(_.Text, null, "Tooltip anchor"))),
171
+ unmount = _render.unmount;
172
+
173
+ unmount();
174
+ expect(window.removeEventListener).toBeCalledWith('focus', expect.any(Function));
175
+ expect(window.removeEventListener).toBeCalledWith('blur', expect.any(Function));
176
+ expect(document.removeEventListener).toBeCalledWith('visibilitychange', expect.any(Function));
177
+ });
178
+ });
@@ -93,7 +93,9 @@ function Collapse(props) {
93
93
  }
94
94
 
95
95
  if (instantRender) {
96
- handleComplete();
96
+ requestAnimationFrame(function () {
97
+ return handleComplete();
98
+ });
97
99
  }
98
100
 
99
101
  node.addEventListener('transitionend', handleTransitionEnd);
@@ -49,6 +49,10 @@ var Dropdown = /*#__PURE__*/function (_Component) {
49
49
  });
50
50
 
51
51
  _defineProperty(_assertThisInitialized(_this), "togglePopover", function (event) {
52
+ _this.setState({
53
+ preventBlur: false
54
+ });
55
+
52
56
  if (_this.state.isPopoverOpen) {
53
57
  _this.closePopover(event);
54
58
  } else {
@@ -75,7 +79,8 @@ var Dropdown = /*#__PURE__*/function (_Component) {
75
79
  });
76
80
 
77
81
  _this.state = {
78
- isPopoverOpen: props.defaultOpen || props.forceOpen
82
+ isPopoverOpen: props.defaultOpen || props.forceOpen,
83
+ preventBlur: false
79
84
  };
80
85
  _this.id = generateId('dropdown');
81
86
  return _this;
@@ -179,7 +184,15 @@ var Dropdown = /*#__PURE__*/function (_Component) {
179
184
  }, _objectSpread2[arrowIconOnly ? 'icon' : 'iconRight'] = {
180
185
  name: isPopoverOpen ? 'general.upCaret' : 'general.downCaret',
181
186
  size: 'sm'
182
- }, _objectSpread2.title = arrowIconOnly ? 'arrow down' : restProps.title, _objectSpread2.tabIndex = 0, _objectSpread2.cursor = 'pointer', _objectSpread2.onBlur = requestBlur, _objectSpread2.onClick = function onClick(event) {
187
+ }, _objectSpread2.title = arrowIconOnly ? 'arrow down' : restProps.title, _objectSpread2.tabIndex = 0, _objectSpread2.cursor = 'pointer', _objectSpread2.onBlur = function onBlur(event) {
188
+ if (_this2.state.preventBlur) {
189
+ _this2.setState({
190
+ preventBlur: false
191
+ });
192
+ } else {
193
+ requestBlur(event);
194
+ }
195
+ }, _objectSpread2.onClick = function onClick(event) {
183
196
  _this2.togglePopover();
184
197
 
185
198
  if (!isPopoverOpen) {
@@ -245,6 +258,10 @@ var Dropdown = /*#__PURE__*/function (_Component) {
245
258
  }
246
259
  });
247
260
  }
261
+ }, _objectSpread2.onMouseDown = function onMouseDown() {
262
+ _this2.setState({
263
+ preventBlur: true
264
+ });
248
265
  }, _objectSpread2), restProps);
249
266
 
250
267
  if ( /*#__PURE__*/React.isValidElement(triggerElement)) {
@@ -64,7 +64,8 @@ var Input = /*#__PURE__*/function (_Component) {
64
64
  highlightOnInteraction = _this$props.highlightOnInteraction,
65
65
  type = _this$props.type,
66
66
  value = _this$props.value,
67
- restProps = _objectWithoutPropertiesLoose(_this$props, ["backgroundColor", "color", "autoComplete", "autoFocus", "autoWidth", "defaultValue", "disabled", "focus", "hover", "id", "min", "minLength", "max", "maxLength", "name", "onBlur", "onChange", "onFocus", "onKeyDown", "onKeyUp", "placeholder", "placeholderColor", "readOnly", "highlightOnInteraction", "type", "value"]);
67
+ required = _this$props.required,
68
+ restProps = _objectWithoutPropertiesLoose(_this$props, ["backgroundColor", "color", "autoComplete", "autoFocus", "autoWidth", "defaultValue", "disabled", "focus", "hover", "id", "min", "minLength", "max", "maxLength", "name", "onBlur", "onChange", "onFocus", "onKeyDown", "onKeyUp", "placeholder", "placeholderColor", "readOnly", "highlightOnInteraction", "type", "value", "required"]);
68
69
 
69
70
  var ariaLabel = restProps['aria-label'];
70
71
 
@@ -106,7 +107,8 @@ var Input = /*#__PURE__*/function (_Component) {
106
107
  onFocus: onFocus,
107
108
  onBlur: onBlur,
108
109
  onKeyDown: onKeyDown,
109
- onKeyUp: onKeyUp
110
+ onKeyUp: onKeyUp,
111
+ required: required
110
112
  }));
111
113
  };
112
114
 
@@ -44,11 +44,13 @@ function Modal(_ref) {
44
44
  }
45
45
  }, scrimProps), /*#__PURE__*/React.createElement(Box, _extends({
46
46
  backgroundColor: "surface",
47
+ boxShadow: "0 0 20px rgba(0, 0, 0, 0.15)",
47
48
  innerRef: modalRef,
48
49
  margin: 4,
49
50
  maxWidth: 60,
50
- padding: 2,
51
- radius: 3,
51
+ padding: 4,
52
+ paddingBottom: 3,
53
+ radius: 8,
52
54
  width: "100%"
53
55
  }, themeProps), children));
54
56
  }