@planningcenter/tapestry-react 2.6.0-rc.9 → 2.6.1
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.
- package/dist/cjs/Button/Button.js +8 -1
- package/dist/cjs/Button/Button.test.js +51 -8
- package/dist/cjs/Collapse/Collapse.js +3 -1
- package/dist/cjs/DataTable/components/BodyRow.js +2 -2
- package/dist/cjs/DataTable/hooks/useCollapsibleRows.js +2 -2
- package/dist/cjs/Dropdown/Dropdown.js +23 -4
- package/dist/cjs/Dropdown/Dropdown.test.js +3 -3
- package/dist/cjs/Dropdown/Link.js +2 -4
- package/dist/cjs/Input/InputLabel.js +40 -63
- package/dist/cjs/Modal/Modal.js +18 -8
- package/dist/cjs/Modal/Modal.test.js +2 -2
- package/dist/cjs/Popover/Popover.js +10 -2
- package/dist/cjs/Scrim/Scrim.js +16 -4
- package/dist/cjs/Table/Table.js +5 -3
- package/dist/cjs/ThemeProvider/ThemeProvider.js +2 -2
- package/dist/cjs/TimeField/TimeField.js +38 -3
- package/dist/cjs/TimeField/TimeField.test.js +179 -10
- package/dist/cjs/Tooltip/Tooltip.js +27 -23
- package/dist/cjs/Tooltip/Tooltip.test.js +178 -0
- package/dist/cjs/system/utils.js +2 -2
- package/dist/cjs/utils.js +3 -3
- package/dist/esm/Button/Button.js +8 -1
- package/dist/esm/Button/Button.test.js +67 -9
- package/dist/esm/Collapse/Collapse.js +3 -1
- package/dist/esm/DataTable/components/BodyRow.js +2 -2
- package/dist/esm/DataTable/hooks/useCollapsibleRows.js +1 -1
- package/dist/esm/Dropdown/Dropdown.js +24 -5
- package/dist/esm/Dropdown/Dropdown.test.js +1 -1
- package/dist/esm/Dropdown/Link.js +1 -2
- package/dist/esm/Input/InputLabel.js +40 -63
- package/dist/esm/Modal/Modal.js +16 -8
- package/dist/esm/Modal/Modal.test.js +1 -1
- package/dist/esm/Popover/Popover.js +8 -2
- package/dist/esm/Scrim/Scrim.js +15 -4
- package/dist/esm/Table/Table.js +2 -1
- package/dist/esm/ThemeProvider/ThemeProvider.js +1 -1
- package/dist/esm/TimeField/TimeField.js +37 -3
- package/dist/esm/TimeField/TimeField.test.js +153 -10
- package/dist/esm/Tooltip/Tooltip.js +29 -24
- package/dist/esm/Tooltip/Tooltip.test.js +160 -0
- package/dist/esm/system/utils.js +1 -1
- package/dist/esm/utils.js +1 -1
- package/dist/types/Button/Button.d.ts +4 -0
- package/dist/types/ThemeProvider/ThemeProvider.d.ts +3 -3
- package/dist/types/Tooltip/Tooltip.test.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +4 -4
- package/src/Button/Button.test.tsx +30 -0
- package/src/Button/Button.tsx +14 -1
- package/src/Collapse/Collapse.js +1 -1
- package/src/DataTable/DataTable.js +1 -1
- package/src/DataTable/components/BodyRow.js +1 -1
- package/src/DataTable/hooks/useCollapsibleRows.js +1 -1
- package/src/Dropdown/Dropdown.js +19 -5
- package/src/Dropdown/Dropdown.mdx +3 -3
- package/src/Dropdown/Dropdown.test.tsx +1 -1
- package/src/Dropdown/Link.js +1 -7
- package/src/Input/InputLabel.js +39 -36
- package/src/Input/InputLabel.mdx +1 -0
- package/src/Modal/Modal.js +16 -6
- package/src/Modal/Modal.mdx +2 -1
- package/src/Modal/Modal.test.tsx +1 -1
- package/src/Popover/Popover.mdx +1 -0
- package/src/Popover/Popover.tsx +8 -2
- package/src/Scrim/Scrim.mdx +1 -0
- package/src/Scrim/Scrim.tsx +11 -6
- package/src/Sidebar/Sidebar.mdx +0 -1
- package/src/Table/Table.js +2 -1
- package/src/ThemeProvider/ThemeProvider.tsx +7 -6
- package/src/TimeField/TimeField.js +36 -3
- package/src/TimeField/TimeField.test.tsx +105 -1
- package/src/Tooltip/Tooltip.js +19 -21
- package/src/Tooltip/Tooltip.test.tsx +136 -0
- package/src/index.d.ts +1 -1
- package/src/system/utils.js +1 -1
- package/src/utils.js +1 -1
|
@@ -182,7 +182,7 @@ it('does not change the meridiem on arrow key if arrow keys are ignored', functi
|
|
|
182
182
|
userEvent.type(meridiemInput, '{arrowup}');
|
|
183
183
|
expect(meridiemInput).toHaveValue('PM');
|
|
184
184
|
});
|
|
185
|
-
it('
|
|
185
|
+
it('increment hour on arrow up', function () {
|
|
186
186
|
var _setup15 = setup({
|
|
187
187
|
hours: 1,
|
|
188
188
|
minutes: 42
|
|
@@ -193,13 +193,156 @@ it('changes the value of hours on arrow up or arrow down', function () {
|
|
|
193
193
|
userEvent.type(hourInput, '{arrowup}');
|
|
194
194
|
expect(hourInput).toHaveValue("02");
|
|
195
195
|
});
|
|
196
|
-
it('
|
|
196
|
+
it('increment hour if arrow up on minutes exceeds max value', function () {
|
|
197
197
|
var _setup16 = setup({
|
|
198
|
+
hours: 1,
|
|
199
|
+
minutes: 59
|
|
200
|
+
}),
|
|
201
|
+
hourInput = _setup16.hourInput,
|
|
202
|
+
minuteInput = _setup16.minuteInput;
|
|
203
|
+
|
|
204
|
+
expect(hourInput).toHaveValue("01");
|
|
205
|
+
userEvent.type(minuteInput, '{arrowup}');
|
|
206
|
+
expect(hourInput).toHaveValue("02");
|
|
207
|
+
});
|
|
208
|
+
it('decrement hour on arrow down', function () {
|
|
209
|
+
var _setup17 = setup({
|
|
210
|
+
hours: 2,
|
|
211
|
+
minutes: 42
|
|
212
|
+
}),
|
|
213
|
+
hourInput = _setup17.hourInput;
|
|
214
|
+
|
|
215
|
+
expect(hourInput).toHaveValue("02");
|
|
216
|
+
userEvent.type(hourInput, '{arrowdown}');
|
|
217
|
+
expect(hourInput).toHaveValue("01");
|
|
218
|
+
});
|
|
219
|
+
it('decrement hour if arrow down on minutes exceeds min value', function () {
|
|
220
|
+
var _setup18 = setup({
|
|
221
|
+
hours: 2,
|
|
222
|
+
minutes: 0
|
|
223
|
+
}),
|
|
224
|
+
hourInput = _setup18.hourInput,
|
|
225
|
+
minuteInput = _setup18.minuteInput;
|
|
226
|
+
|
|
227
|
+
expect(hourInput).toHaveValue("02");
|
|
228
|
+
userEvent.type(minuteInput, '{arrowdown}');
|
|
229
|
+
expect(hourInput).toHaveValue("01");
|
|
230
|
+
});
|
|
231
|
+
it('increment minute on arrow up', function () {
|
|
232
|
+
var _setup19 = setup({
|
|
233
|
+
hours: 1,
|
|
234
|
+
minutes: 42
|
|
235
|
+
}),
|
|
236
|
+
minuteInput = _setup19.minuteInput;
|
|
237
|
+
|
|
238
|
+
expect(minuteInput).toHaveValue("42");
|
|
239
|
+
userEvent.type(minuteInput, '{arrowup}');
|
|
240
|
+
expect(minuteInput).toHaveValue("43");
|
|
241
|
+
});
|
|
242
|
+
it('decrement minute on arrow down', function () {
|
|
243
|
+
var _setup20 = setup({
|
|
244
|
+
hours: 2,
|
|
245
|
+
minutes: 43
|
|
246
|
+
}),
|
|
247
|
+
minuteInput = _setup20.minuteInput;
|
|
248
|
+
|
|
249
|
+
expect(minuteInput).toHaveValue("43");
|
|
250
|
+
userEvent.type(minuteInput, '{arrowdown}');
|
|
251
|
+
expect(minuteInput).toHaveValue("42");
|
|
252
|
+
});
|
|
253
|
+
it('set minute to min value if arrow up on minutes exceeds max value', function () {
|
|
254
|
+
var _setup21 = setup({
|
|
255
|
+
hours: 1,
|
|
256
|
+
minutes: 59
|
|
257
|
+
}),
|
|
258
|
+
minuteInput = _setup21.minuteInput;
|
|
259
|
+
|
|
260
|
+
expect(minuteInput).toHaveValue("59");
|
|
261
|
+
userEvent.type(minuteInput, '{arrowup}');
|
|
262
|
+
expect(minuteInput).toHaveValue("00");
|
|
263
|
+
});
|
|
264
|
+
it('set minute to max value if arrow down on minutes exceeds min value', function () {
|
|
265
|
+
var _setup22 = setup({
|
|
266
|
+
hours: 1,
|
|
267
|
+
minutes: 0
|
|
268
|
+
}),
|
|
269
|
+
minuteInput = _setup22.minuteInput;
|
|
270
|
+
|
|
271
|
+
expect(minuteInput).toHaveValue("00");
|
|
272
|
+
userEvent.type(minuteInput, '{arrowdown}');
|
|
273
|
+
expect(minuteInput).toHaveValue("59");
|
|
274
|
+
});
|
|
275
|
+
it('toggle meridiem if arrow up on hour exceeds eleven', function () {
|
|
276
|
+
var _setup23 = setup({
|
|
277
|
+
hours: 11
|
|
278
|
+
}),
|
|
279
|
+
hourInput = _setup23.hourInput,
|
|
280
|
+
meridiemInput = _setup23.meridiemInput;
|
|
281
|
+
|
|
282
|
+
expect(meridiemInput).toHaveValue('AM');
|
|
283
|
+
userEvent.type(hourInput, '{arrowup}');
|
|
284
|
+
expect(meridiemInput).toHaveValue('PM');
|
|
285
|
+
});
|
|
286
|
+
it('toggle meridiem if arrow down on hour exceeds min value', function () {
|
|
287
|
+
var _setup24 = setup({
|
|
288
|
+
hours: 1
|
|
289
|
+
}),
|
|
290
|
+
hourInput = _setup24.hourInput,
|
|
291
|
+
meridiemInput = _setup24.meridiemInput;
|
|
292
|
+
|
|
293
|
+
expect(meridiemInput).toHaveValue('AM');
|
|
294
|
+
userEvent.type(hourInput, '{arrowdown}');
|
|
295
|
+
expect(meridiemInput).toHaveValue('PM');
|
|
296
|
+
});
|
|
297
|
+
it('set 12 hour clock to min value if arrow up on hour exceeds max value', function () {
|
|
298
|
+
var _setup25 = setup({
|
|
299
|
+
hours: 12
|
|
300
|
+
}),
|
|
301
|
+
hourInput = _setup25.hourInput;
|
|
302
|
+
|
|
303
|
+
expect(hourInput).toHaveValue("12");
|
|
304
|
+
userEvent.type(hourInput, '{arrowup}');
|
|
305
|
+
expect(hourInput).toHaveValue("01");
|
|
306
|
+
});
|
|
307
|
+
it('set 24 hour clock to min value if arrow up on hour exceeds max value', function () {
|
|
308
|
+
var _setup26 = setup({
|
|
309
|
+
hours: 23,
|
|
310
|
+
twelveHourClock: false
|
|
311
|
+
}),
|
|
312
|
+
hourInput = _setup26.hourInput;
|
|
313
|
+
|
|
314
|
+
expect(hourInput).toHaveValue("23");
|
|
315
|
+
userEvent.type(hourInput, '{arrowup}');
|
|
316
|
+
expect(hourInput).toHaveValue("00");
|
|
317
|
+
});
|
|
318
|
+
it('set 12 hour clock to max value if arrow down on hour exceeds min value', function () {
|
|
319
|
+
var _setup27 = setup({
|
|
320
|
+
hours: 1
|
|
321
|
+
}),
|
|
322
|
+
hourInput = _setup27.hourInput;
|
|
323
|
+
|
|
324
|
+
expect(hourInput).toHaveValue("01");
|
|
325
|
+
userEvent.type(hourInput, '{arrowdown}');
|
|
326
|
+
expect(hourInput).toHaveValue("12");
|
|
327
|
+
});
|
|
328
|
+
it('set 24 hour clock to max value if arrow down on hour exceeds min value', function () {
|
|
329
|
+
var _setup28 = setup({
|
|
330
|
+
hours: 0,
|
|
331
|
+
twelveHourClock: false
|
|
332
|
+
}),
|
|
333
|
+
hourInput = _setup28.hourInput;
|
|
334
|
+
|
|
335
|
+
expect(hourInput).toHaveValue("00");
|
|
336
|
+
userEvent.type(hourInput, '{arrowdown}');
|
|
337
|
+
expect(hourInput).toHaveValue("23");
|
|
338
|
+
});
|
|
339
|
+
it('does not change the value of hours on arrow up or arrow down if ignored', function () {
|
|
340
|
+
var _setup29 = setup({
|
|
198
341
|
hours: 1,
|
|
199
342
|
minutes: 42,
|
|
200
343
|
ignoredKeys: ['ArrowUp', 'ArrowDown']
|
|
201
344
|
}),
|
|
202
|
-
hourInput =
|
|
345
|
+
hourInput = _setup29.hourInput;
|
|
203
346
|
|
|
204
347
|
expect(hourInput).toHaveValue("01");
|
|
205
348
|
userEvent.type(hourInput, '{arrowup}');
|
|
@@ -208,12 +351,12 @@ it('does not change the value of hours on arrow up or arrow down if ignored', fu
|
|
|
208
351
|
expect(hourInput).toHaveValue("01");
|
|
209
352
|
});
|
|
210
353
|
it('does not change the value of minutes on arrow up or arrow down if ignored', function () {
|
|
211
|
-
var
|
|
354
|
+
var _setup30 = setup({
|
|
212
355
|
hours: 1,
|
|
213
356
|
minutes: 42,
|
|
214
357
|
ignoredKeys: ['ArrowUp', 'ArrowDown']
|
|
215
358
|
}),
|
|
216
|
-
minuteInput =
|
|
359
|
+
minuteInput = _setup30.minuteInput;
|
|
217
360
|
|
|
218
361
|
expect(minuteInput).toHaveValue("42");
|
|
219
362
|
userEvent.type(minuteInput, '{arrowup}');
|
|
@@ -223,15 +366,15 @@ it('does not change the value of minutes on arrow up or arrow down if ignored',
|
|
|
223
366
|
}); // ios
|
|
224
367
|
|
|
225
368
|
it('renders iOS as a single input', function () {
|
|
226
|
-
var
|
|
369
|
+
var _setup31 = setup({
|
|
227
370
|
isIOS: true,
|
|
228
371
|
hours: 13,
|
|
229
372
|
minutes: 42
|
|
230
373
|
}),
|
|
231
|
-
container =
|
|
232
|
-
hourInput =
|
|
233
|
-
minuteInput =
|
|
234
|
-
meridiemInput =
|
|
374
|
+
container = _setup31.container,
|
|
375
|
+
hourInput = _setup31.hourInput,
|
|
376
|
+
minuteInput = _setup31.minuteInput,
|
|
377
|
+
meridiemInput = _setup31.meridiemInput;
|
|
235
378
|
|
|
236
379
|
var singleTimeInput = container.querySelector('[type=time]');
|
|
237
380
|
expect(singleTimeInput).toHaveValue('13:42');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import React, { Children, cloneElement, forwardRef, useRef, useState,
|
|
3
|
+
import React, { Children, cloneElement, forwardRef, useRef, useState, useImperativeHandle, useEffect } from 'react';
|
|
4
4
|
import mitt from 'mitt';
|
|
5
5
|
import Popover from '../Popover';
|
|
6
6
|
import { composeEvents, pageViewChange } from '../utils';
|
|
@@ -41,23 +41,22 @@ function Tooltip(props, ref) {
|
|
|
41
41
|
triggerOnHover = _useThemeProps$trigge2 === void 0 ? true : _useThemeProps$trigge2,
|
|
42
42
|
childProps = _objectWithoutPropertiesLoose(_useThemeProps, ["children", "openDelay", "closeDelay", "defaultOpen", "keepInView", "placement", "popoverProps", "renderTo", "title", "triggerOnFocus", "triggerOnHover"]);
|
|
43
43
|
|
|
44
|
-
var isPageInView = true;
|
|
45
|
-
var
|
|
46
|
-
var isMouseDown = false;
|
|
44
|
+
var isPageInView = useRef(true);
|
|
45
|
+
var isMouseDown = useRef(false);
|
|
47
46
|
var openTimeoutId = useRef(null);
|
|
48
|
-
var closeTimeoutId = useRef(null);
|
|
49
|
-
|
|
50
|
-
var cleanupPageViewChange = useCallback(pageViewChange(function (inView) {
|
|
51
|
-
return setTimeout(function () {
|
|
52
|
-
return isPageInView = inView;
|
|
53
|
-
});
|
|
54
|
-
}));
|
|
47
|
+
var closeTimeoutId = useRef(null);
|
|
55
48
|
|
|
56
49
|
var _useState = useState(defaultOpen),
|
|
57
50
|
isPopoverOpen = _useState[0],
|
|
58
51
|
setIsPopoverOpen = _useState[1];
|
|
59
52
|
|
|
60
53
|
useEffect(function () {
|
|
54
|
+
// prevents tooltips showing when focused and navigating back to a page after leaving
|
|
55
|
+
var cleanupPageViewChange = pageViewChange(function (inView) {
|
|
56
|
+
return setTimeout(function () {
|
|
57
|
+
return isPageInView.current = inView;
|
|
58
|
+
});
|
|
59
|
+
});
|
|
61
60
|
emitter.on('CLOSE_OPEN_TOOLTIPS', close);
|
|
62
61
|
return function () {
|
|
63
62
|
emitter.off('CLOSE_OPEN_TOOLTIPS', close);
|
|
@@ -100,7 +99,8 @@ function Tooltip(props, ref) {
|
|
|
100
99
|
close();
|
|
101
100
|
}
|
|
102
101
|
}, [triggerOnHover]);
|
|
103
|
-
|
|
102
|
+
|
|
103
|
+
var createOpenTimeout = function createOpenTimeout() {
|
|
104
104
|
clearGlobalTimeout();
|
|
105
105
|
|
|
106
106
|
if (openTimeoutId.current === null) {
|
|
@@ -114,8 +114,9 @@ function Tooltip(props, ref) {
|
|
|
114
114
|
}, instantDelay ? 0 : openDelay);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
var createCloseTimeout = function createCloseTimeout() {
|
|
119
120
|
startGlobalTimeout();
|
|
120
121
|
|
|
121
122
|
if (closeTimeoutId.current === null) {
|
|
@@ -125,19 +126,23 @@ function Tooltip(props, ref) {
|
|
|
125
126
|
return close();
|
|
126
127
|
}, closeDelay);
|
|
127
128
|
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
var handleFocus = function handleFocus() {
|
|
132
|
+
if (isPageInView.current && !isMouseDown.current) {
|
|
131
133
|
open();
|
|
132
134
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
var handleMouseDown = function handleMouseDown() {
|
|
138
|
+
isMouseDown.current = true;
|
|
136
139
|
close();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
var handleMouseUp = function handleMouseUp() {
|
|
143
|
+
isMouseDown.current = false;
|
|
144
|
+
};
|
|
145
|
+
|
|
141
146
|
var child = Children.only(children);
|
|
142
147
|
var _child$props = child.props,
|
|
143
148
|
onFocus = _child$props.onFocus,
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { act, render, screen, waitFor } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
6
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
+
import { Button, Link, StackView, Text, Tooltip, hooks } from '..';
|
|
8
|
+
|
|
9
|
+
var _ref = /*#__PURE__*/React.createElement(Text, null, "Tooltip anchor");
|
|
10
|
+
|
|
11
|
+
var _ref3 = /*#__PURE__*/React.createElement(Text, null, "Tooltip anchor");
|
|
12
|
+
|
|
13
|
+
var _ref5 = /*#__PURE__*/React.createElement(Button, null, "Tooltip anchor");
|
|
14
|
+
|
|
15
|
+
var _ref7 = /*#__PURE__*/React.createElement(Text, null, "Tooltip anchor");
|
|
16
|
+
|
|
17
|
+
var _ref8 = /*#__PURE__*/React.createElement(Tooltip, {
|
|
18
|
+
title: "Test Text"
|
|
19
|
+
}, /*#__PURE__*/React.createElement(Text, null, "Tooltip anchor"));
|
|
20
|
+
|
|
21
|
+
describe('Tooltip', function () {
|
|
22
|
+
test('does not render string when closed', function () {
|
|
23
|
+
var string = 'Test Text';
|
|
24
|
+
render( /*#__PURE__*/React.createElement(Tooltip, {
|
|
25
|
+
title: string
|
|
26
|
+
}, _ref));
|
|
27
|
+
expect(screen.queryByText(string)).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
test('renders string on hover', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
30
|
+
var string, tooltip;
|
|
31
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
32
|
+
while (1) {
|
|
33
|
+
switch (_context.prev = _context.next) {
|
|
34
|
+
case 0:
|
|
35
|
+
string = 'Test Text';
|
|
36
|
+
render( /*#__PURE__*/React.createElement(Tooltip, {
|
|
37
|
+
title: string
|
|
38
|
+
}, _ref3));
|
|
39
|
+
userEvent.hover(screen.getByText('Tooltip anchor'));
|
|
40
|
+
_context.next = 5;
|
|
41
|
+
return 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__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
55
|
+
var string, tooltip;
|
|
56
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
57
|
+
while (1) {
|
|
58
|
+
switch (_context2.prev = _context2.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
string = 'Test Text';
|
|
61
|
+
render( /*#__PURE__*/React.createElement(Tooltip, {
|
|
62
|
+
title: string,
|
|
63
|
+
triggerOnFocus: true
|
|
64
|
+
}, _ref5));
|
|
65
|
+
userEvent.tab();
|
|
66
|
+
_context2.next = 5;
|
|
67
|
+
return screen.findByText(string);
|
|
68
|
+
|
|
69
|
+
case 5:
|
|
70
|
+
tooltip = _context2.sent;
|
|
71
|
+
expect(tooltip).toBeInTheDocument();
|
|
72
|
+
|
|
73
|
+
case 7:
|
|
74
|
+
case "end":
|
|
75
|
+
return _context2.stop();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}, _callee2);
|
|
79
|
+
})));
|
|
80
|
+
test('removes string after timeout', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
81
|
+
var string, anchor, tooltip;
|
|
82
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
83
|
+
while (1) {
|
|
84
|
+
switch (_context3.prev = _context3.next) {
|
|
85
|
+
case 0:
|
|
86
|
+
string = 'Test Text';
|
|
87
|
+
render( /*#__PURE__*/React.createElement(Tooltip, {
|
|
88
|
+
title: string
|
|
89
|
+
}, _ref7));
|
|
90
|
+
anchor = screen.getByText('Tooltip anchor');
|
|
91
|
+
expect(screen.queryByText(string)).toBeNull();
|
|
92
|
+
userEvent.hover(anchor);
|
|
93
|
+
_context3.next = 7;
|
|
94
|
+
return screen.findByText(string);
|
|
95
|
+
|
|
96
|
+
case 7:
|
|
97
|
+
tooltip = _context3.sent;
|
|
98
|
+
expect(tooltip).toBeInTheDocument();
|
|
99
|
+
userEvent.unhover(anchor);
|
|
100
|
+
_context3.next = 12;
|
|
101
|
+
return waitFor(function () {
|
|
102
|
+
expect(screen.queryByText(string)).not.toBeInTheDocument();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
case 12:
|
|
106
|
+
case "end":
|
|
107
|
+
return _context3.stop();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, _callee3);
|
|
111
|
+
})));
|
|
112
|
+
test('stays open when hovering a custom tooltip', function () {
|
|
113
|
+
var CustomTooltip = function CustomTooltip() {
|
|
114
|
+
var _hooks$useHover = hooks.useHover(),
|
|
115
|
+
hover = _hooks$useHover.hover,
|
|
116
|
+
hoverProps = _hooks$useHover.hoverProps;
|
|
117
|
+
|
|
118
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
119
|
+
title: /*#__PURE__*/React.createElement(Link, {
|
|
120
|
+
to: "#"
|
|
121
|
+
}, /*#__PURE__*/React.createElement(StackView, null, /*#__PURE__*/React.createElement(Text, {
|
|
122
|
+
"data-hover": hover
|
|
123
|
+
}, string)))
|
|
124
|
+
}, /*#__PURE__*/React.createElement(Button, hoverProps, "Tooltip anchor"));
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var string = 'Test Text';
|
|
128
|
+
render( /*#__PURE__*/React.createElement(CustomTooltip, null));
|
|
129
|
+
var anchor = screen.getByText('Tooltip anchor');
|
|
130
|
+
userEvent.hover(anchor);
|
|
131
|
+
act(function () {
|
|
132
|
+
jest.runAllTimers();
|
|
133
|
+
});
|
|
134
|
+
var tooltip = screen.getByText(string);
|
|
135
|
+
expect(tooltip).toBeInTheDocument();
|
|
136
|
+
userEvent.unhover(anchor);
|
|
137
|
+
userEvent.hover(tooltip);
|
|
138
|
+
act(function () {
|
|
139
|
+
jest.runAllTimers();
|
|
140
|
+
});
|
|
141
|
+
expect(tooltip).toBeInTheDocument();
|
|
142
|
+
userEvent.unhover(tooltip);
|
|
143
|
+
act(function () {
|
|
144
|
+
jest.runAllTimers();
|
|
145
|
+
});
|
|
146
|
+
expect(tooltip).not.toBeInTheDocument();
|
|
147
|
+
});
|
|
148
|
+
test('cleans up pageViewChange listeners', function () {
|
|
149
|
+
window.removeEventListener = jest.fn().mockImplementation(function (event, callback) {});
|
|
150
|
+
document.removeEventListener = jest.fn().mockImplementation(function (event, callback) {});
|
|
151
|
+
|
|
152
|
+
var _render = render(_ref8),
|
|
153
|
+
unmount = _render.unmount;
|
|
154
|
+
|
|
155
|
+
unmount();
|
|
156
|
+
expect(window.removeEventListener).toBeCalledWith('focus', expect.any(Function));
|
|
157
|
+
expect(window.removeEventListener).toBeCalledWith('blur', expect.any(Function));
|
|
158
|
+
expect(document.removeEventListener).toBeCalledWith('visibilitychange', expect.any(Function));
|
|
159
|
+
});
|
|
160
|
+
});
|
package/dist/esm/system/utils.js
CHANGED
|
@@ -7,7 +7,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
7
7
|
import { useContext, useCallback } from 'react';
|
|
8
8
|
import { ThemeContext } from '@emotion/react';
|
|
9
9
|
import { darken, getLuminance, lighten, parseToRgb } from 'polished';
|
|
10
|
-
import
|
|
10
|
+
import get from 'lodash/get';
|
|
11
11
|
import { getColor } from './colors';
|
|
12
12
|
import defaultTheme from './default-theme';
|
|
13
13
|
export var spacing = 8;
|
package/dist/esm/utils.js
CHANGED
|
@@ -6,7 +6,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
6
6
|
|
|
7
7
|
import { Children, cloneElement } from 'react';
|
|
8
8
|
import { tabbable } from 'tabbable';
|
|
9
|
-
import
|
|
9
|
+
import kebabCase from 'lodash/kebabCase';
|
|
10
10
|
/**
|
|
11
11
|
* Returns true if user platform is an iOS device
|
|
12
12
|
* https://stackoverflow.com/a/9039885/1461204
|
|
@@ -60,6 +60,10 @@ declare type ButtonProps = {
|
|
|
60
60
|
* Where the browser should navigate to when pressed. If you need any element here other than `<a>`, remember to use the `as` prop.
|
|
61
61
|
*/
|
|
62
62
|
to?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Where the browser should navigate to when pressed. If you need any element here other than `<a>`, remember to use the `as` prop.
|
|
65
|
+
*/
|
|
66
|
+
href?: string;
|
|
63
67
|
/**
|
|
64
68
|
* Wraps button in a [`<Tooltip />`](./tooltip). Accepts any valid Tooltip props.
|
|
65
69
|
*/
|
|
@@ -8,11 +8,11 @@ export declare const themeStorage: {
|
|
|
8
8
|
set: (value: any) => void;
|
|
9
9
|
};
|
|
10
10
|
export declare const themeInitializerScript: string;
|
|
11
|
-
|
|
11
|
+
declare type Props = {
|
|
12
12
|
theme?: Theme;
|
|
13
13
|
children: React.ReactNode;
|
|
14
|
-
|
|
15
|
-
}): JSX.Element;
|
|
14
|
+
} & BoxProps;
|
|
15
|
+
export declare function ThemeProvider({ theme, children, ...boxProps }: Props): JSX.Element;
|
|
16
16
|
export declare namespace ThemeProvider {
|
|
17
17
|
var cache: import("@emotion/utils").EmotionCache;
|
|
18
18
|
var setRootStyles: (themeId: any, styles: any) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -350,7 +350,7 @@ export const Checkbox: HTMLInputWrapperComponent
|
|
|
350
350
|
// Input
|
|
351
351
|
// =====
|
|
352
352
|
|
|
353
|
-
export const Input:
|
|
353
|
+
export const Input: HTMLInputWrapperComponent & {
|
|
354
354
|
Inline: HTMLInputWrapperComponent
|
|
355
355
|
Input: HTMLInputWrapperComponent
|
|
356
356
|
InputBox: CommonComponent
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/tapestry-react",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "A collection of flexible React components to help you build resilient, accessible user interfaces quickly and effectively.",
|
|
5
5
|
"author": "Front End Systems Engineering <frontend@pco.bz>",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"husky": "^4.3.8",
|
|
77
77
|
"is-ci-cli": "^2.2.0",
|
|
78
78
|
"jest": "^26.6.3",
|
|
79
|
-
"jest-canvas-mock": "2.
|
|
79
|
+
"jest-canvas-mock": "^2.5.0",
|
|
80
80
|
"jest-watch-typeahead": "0.6.1",
|
|
81
81
|
"react": "^17.0.1",
|
|
82
82
|
"react-dom": "^17.0.1",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"typescript": "^4.1.5"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@planningcenter/icons": "^14.
|
|
91
|
+
"@planningcenter/icons": "^14.12.0",
|
|
92
92
|
"@planningcenter/react-beautiful-dnd": "^13.2.1",
|
|
93
93
|
"@popmotion/popcorn": "^0.4.4",
|
|
94
94
|
"@popperjs/core": "^2.11.6",
|
|
@@ -106,6 +106,6 @@
|
|
|
106
106
|
"stylefire": "^7.0.3",
|
|
107
107
|
"tabbable": "^6.0.0",
|
|
108
108
|
"tiny-spring": "^1.0.0",
|
|
109
|
-
"zustand": "^4.
|
|
109
|
+
"zustand": "^4.3.7"
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -2,12 +2,42 @@ import React from 'react'
|
|
|
2
2
|
import { render, fireEvent } from '@testing-library/react'
|
|
3
3
|
import { Button } from './Button'
|
|
4
4
|
|
|
5
|
+
it(`should render as <button> with type="button" by default`, () => {
|
|
6
|
+
const { container } = render(<Button />)
|
|
7
|
+
const button = container.querySelector('button')
|
|
8
|
+
expect(button.getAttribute('type')).toEqual('button')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it(`should render as <button> with type="submit"`, () => {
|
|
12
|
+
const { container } = render(<Button type='submit' />)
|
|
13
|
+
const button = container.querySelector('button')
|
|
14
|
+
expect(button.getAttribute('type')).toEqual('submit')
|
|
15
|
+
})
|
|
16
|
+
|
|
5
17
|
it(`should render title`, () => {
|
|
6
18
|
const title = 'Hello'
|
|
7
19
|
const { getByText } = render(<Button title={title} />)
|
|
8
20
|
getByText(title)
|
|
9
21
|
})
|
|
10
22
|
|
|
23
|
+
it(`should render <a> without a type if "to" is provided`, () => {
|
|
24
|
+
const { container } = render(<Button to='#' />)
|
|
25
|
+
const button = container.querySelector('a')
|
|
26
|
+
expect(button.getAttribute('type')).toBeNull()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it(`should render <a> without a type if "href" is provided`, () => {
|
|
30
|
+
const { container } = render(<Button href='#' />)
|
|
31
|
+
const button = container.querySelector('a')
|
|
32
|
+
expect(button.getAttribute('type')).toBeNull()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it(`should render <a> with "href" if "to" is specifed`, () => {
|
|
36
|
+
const { container } = render(<Button to='#' />)
|
|
37
|
+
const button = container.querySelector('a')
|
|
38
|
+
expect(button.getAttribute('href')).toEqual('#')
|
|
39
|
+
})
|
|
40
|
+
|
|
11
41
|
it(`should render href and external link values`, () => {
|
|
12
42
|
const title = 'Hello'
|
|
13
43
|
const { getByText } = render(
|
package/src/Button/Button.tsx
CHANGED
|
@@ -86,6 +86,11 @@ type ButtonProps = {
|
|
|
86
86
|
*/
|
|
87
87
|
to?: string
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Where the browser should navigate to when pressed. If you need any element here other than `<a>`, remember to use the `as` prop.
|
|
91
|
+
*/
|
|
92
|
+
href?: string
|
|
93
|
+
|
|
89
94
|
/**
|
|
90
95
|
* Wraps button in a [`<Tooltip />`](./tooltip). Accepts any valid Tooltip props.
|
|
91
96
|
*/
|
|
@@ -287,6 +292,14 @@ export function Button({
|
|
|
287
292
|
restProps['href'] = to
|
|
288
293
|
}
|
|
289
294
|
|
|
295
|
+
// remove `type` if either `to` or `href` is specified
|
|
296
|
+
if (to || (restProps as any).href) {
|
|
297
|
+
buttonProps = {
|
|
298
|
+
...buttonProps,
|
|
299
|
+
type: null,
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
290
303
|
// apply stroke defaults and higher z-index when hovering to show outline in group properly
|
|
291
304
|
if (variant === 'outline') {
|
|
292
305
|
buttonProps = {
|
|
@@ -342,7 +355,7 @@ export function Button({
|
|
|
342
355
|
}
|
|
343
356
|
|
|
344
357
|
if (
|
|
345
|
-
type &&
|
|
358
|
+
buttonProps.type &&
|
|
346
359
|
(restProps as any).as &&
|
|
347
360
|
(restProps as any).as !== "button"
|
|
348
361
|
) {
|
package/src/Collapse/Collapse.js
CHANGED
|
@@ -19,7 +19,7 @@ function BodyRow({
|
|
|
19
19
|
} = useKeyboardShortcuts(keyboardShortcuts, { rowData, rowIndex })
|
|
20
20
|
const props = {
|
|
21
21
|
ref: innerRef,
|
|
22
|
-
onClick:
|
|
22
|
+
onClick: (event) => onRowClick && onRowClick(rowData, rowIndex, event),
|
|
23
23
|
onMouseEnter: bindKeyboardShortcuts,
|
|
24
24
|
onMouseLeave: unbindKeyboardShortcuts,
|
|
25
25
|
style: {
|