@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
|
@@ -1,25 +1,83 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, fireEvent } from '@testing-library/react';
|
|
3
3
|
import { Button } from './Button';
|
|
4
|
+
|
|
5
|
+
var _ref = /*#__PURE__*/React.createElement(Button, null);
|
|
6
|
+
|
|
7
|
+
it("should render as <button> with type=\"button\" by default", function () {
|
|
8
|
+
var _render = render(_ref),
|
|
9
|
+
container = _render.container;
|
|
10
|
+
|
|
11
|
+
var button = container.querySelector('button');
|
|
12
|
+
expect(button.getAttribute('type')).toEqual('button');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
var _ref2 = /*#__PURE__*/React.createElement(Button, {
|
|
16
|
+
type: "submit"
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should render as <button> with type=\"submit\"", function () {
|
|
20
|
+
var _render2 = render(_ref2),
|
|
21
|
+
container = _render2.container;
|
|
22
|
+
|
|
23
|
+
var button = container.querySelector('button');
|
|
24
|
+
expect(button.getAttribute('type')).toEqual('submit');
|
|
25
|
+
});
|
|
4
26
|
it("should render title", function () {
|
|
5
27
|
var title = 'Hello';
|
|
6
28
|
|
|
7
|
-
var
|
|
29
|
+
var _render3 = render( /*#__PURE__*/React.createElement(Button, {
|
|
8
30
|
title: title
|
|
9
31
|
})),
|
|
10
|
-
getByText =
|
|
32
|
+
getByText = _render3.getByText;
|
|
11
33
|
|
|
12
34
|
getByText(title);
|
|
13
35
|
});
|
|
36
|
+
|
|
37
|
+
var _ref3 = /*#__PURE__*/React.createElement(Button, {
|
|
38
|
+
to: "#"
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should render <a> without a type if \"to\" is provided", function () {
|
|
42
|
+
var _render4 = render(_ref3),
|
|
43
|
+
container = _render4.container;
|
|
44
|
+
|
|
45
|
+
var button = container.querySelector('a');
|
|
46
|
+
expect(button.getAttribute('type')).toBeNull();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
var _ref4 = /*#__PURE__*/React.createElement(Button, {
|
|
50
|
+
href: "#"
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("should render <a> without a type if \"href\" is provided", function () {
|
|
54
|
+
var _render5 = render(_ref4),
|
|
55
|
+
container = _render5.container;
|
|
56
|
+
|
|
57
|
+
var button = container.querySelector('a');
|
|
58
|
+
expect(button.getAttribute('type')).toBeNull();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
var _ref5 = /*#__PURE__*/React.createElement(Button, {
|
|
62
|
+
to: "#"
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should render <a> with \"href\" if \"to\" is specifed", function () {
|
|
66
|
+
var _render6 = render(_ref5),
|
|
67
|
+
container = _render6.container;
|
|
68
|
+
|
|
69
|
+
var button = container.querySelector('a');
|
|
70
|
+
expect(button.getAttribute('href')).toEqual('#');
|
|
71
|
+
});
|
|
14
72
|
it("should render href and external link values", function () {
|
|
15
73
|
var title = 'Hello';
|
|
16
74
|
|
|
17
|
-
var
|
|
75
|
+
var _render7 = render( /*#__PURE__*/React.createElement(Button, {
|
|
18
76
|
external: true,
|
|
19
77
|
title: title,
|
|
20
78
|
to: "https://www.planningcenter.com"
|
|
21
79
|
})),
|
|
22
|
-
getByText =
|
|
80
|
+
getByText = _render7.getByText;
|
|
23
81
|
|
|
24
82
|
var button = getByText(title);
|
|
25
83
|
expect(button.getAttribute('href')).toEqual('https://www.planningcenter.com');
|
|
@@ -29,20 +87,20 @@ it("should render href and external link values", function () {
|
|
|
29
87
|
it("should call onClick when clicked or Enter or Space key is pressed", function () {
|
|
30
88
|
var onClick = jest.fn();
|
|
31
89
|
|
|
32
|
-
var
|
|
90
|
+
var _render8 = render( /*#__PURE__*/React.createElement(Button, {
|
|
33
91
|
onClick: onClick
|
|
34
92
|
})),
|
|
35
|
-
container =
|
|
93
|
+
container = _render8.container;
|
|
36
94
|
|
|
37
95
|
fireEvent.click(container.firstChild);
|
|
38
96
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
39
97
|
});
|
|
40
98
|
|
|
41
|
-
var
|
|
99
|
+
var _ref6 = /*#__PURE__*/React.createElement(Button, null);
|
|
42
100
|
|
|
43
101
|
it("should not call onClick when Enter or Space key is pressed and onClick isn't present", function () {
|
|
44
|
-
var
|
|
45
|
-
container =
|
|
102
|
+
var _render9 = render(_ref6),
|
|
103
|
+
container = _render9.container;
|
|
46
104
|
|
|
47
105
|
fireEvent.keyDown(container.firstChild, {
|
|
48
106
|
key: 'Enter'
|
|
@@ -29,8 +29,8 @@ function BodyRow(_ref) {
|
|
|
29
29
|
|
|
30
30
|
var props = _objectSpread({
|
|
31
31
|
ref: innerRef,
|
|
32
|
-
onClick:
|
|
33
|
-
return onRowClick(rowData, rowIndex);
|
|
32
|
+
onClick: function onClick(event) {
|
|
33
|
+
return onRowClick && onRowClick(rowData, rowIndex, event);
|
|
34
34
|
},
|
|
35
35
|
onMouseEnter: bindKeyboardShortcuts,
|
|
36
36
|
onMouseLeave: unbindKeyboardShortcuts,
|
|
@@ -6,7 +6,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
6
6
|
|
|
7
7
|
import { createContext, useCallback, useContext, useEffect } from 'react';
|
|
8
8
|
import useConstant from '../../hooks/useConstant';
|
|
9
|
-
import create from 'zustand';
|
|
9
|
+
import { create } from 'zustand';
|
|
10
10
|
import { range } from '../../utils';
|
|
11
11
|
export var CollapsibleRowsContext = /*#__PURE__*/createContext(null);
|
|
12
12
|
export function useCollapsibleRowsStore(selector) {
|
|
@@ -16,7 +16,7 @@ import Menu from '../Menu';
|
|
|
16
16
|
import Popover from '../Popover';
|
|
17
17
|
import { cloneChildren, generateId } from '../utils';
|
|
18
18
|
import Item, { ITEM_DISPLAY_NAME } from './Item';
|
|
19
|
-
import Link, { LINK_DISPLAY_NAME
|
|
19
|
+
import Link, { LINK_DISPLAY_NAME } from './Link';
|
|
20
20
|
|
|
21
21
|
var Dropdown = /*#__PURE__*/function (_Component) {
|
|
22
22
|
_inheritsLoose(Dropdown, _Component);
|
|
@@ -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 {
|
|
@@ -67,7 +71,7 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
67
71
|
_this.popover.focusAnchor();
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
if (
|
|
74
|
+
if (node.tagName === 'A' && event.type !== 'click') {
|
|
71
75
|
node.click();
|
|
72
76
|
} else if (_this.props.onSelect) {
|
|
73
77
|
_this.props.onSelect(data);
|
|
@@ -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;
|
|
@@ -96,7 +101,7 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
96
101
|
keepInView = _this$props.keepInView,
|
|
97
102
|
lockScrollWhileOpen = _this$props.lockScrollWhileOpen,
|
|
98
103
|
matchWidths = _this$props.matchWidths,
|
|
99
|
-
|
|
104
|
+
_onClick = _this$props.onClick,
|
|
100
105
|
onClose = _this$props.onClose,
|
|
101
106
|
onKeyDown = _this$props.onKeyDown,
|
|
102
107
|
onOpen = _this$props.onOpen,
|
|
@@ -179,12 +184,22 @@ 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 =
|
|
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) {
|
|
186
199
|
_this2.popover.focusAnchor();
|
|
187
200
|
}
|
|
201
|
+
|
|
202
|
+
_onClick && _onClick(event);
|
|
188
203
|
}, _objectSpread2.onKeyDown = function onKeyDown(event) {
|
|
189
204
|
anchorProps.onKeyDown(event);
|
|
190
205
|
|
|
@@ -243,6 +258,10 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
243
258
|
}
|
|
244
259
|
});
|
|
245
260
|
}
|
|
261
|
+
}, _objectSpread2.onMouseDown = function onMouseDown() {
|
|
262
|
+
_this2.setState({
|
|
263
|
+
preventBlur: true
|
|
264
|
+
});
|
|
246
265
|
}, _objectSpread2), restProps);
|
|
247
266
|
|
|
248
267
|
if ( /*#__PURE__*/React.isValidElement(triggerElement)) {
|
|
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
-
import
|
|
5
|
+
import noop from 'lodash/noop';
|
|
6
6
|
import { Box, Button, Text, ThemeProvider } from '..';
|
|
7
7
|
import Dropdown from './Dropdown';
|
|
8
8
|
|
|
@@ -6,7 +6,6 @@ import React, { Component } from 'react';
|
|
|
6
6
|
import { ItemListItem } from '../ItemList';
|
|
7
7
|
import Menu from '../Menu';
|
|
8
8
|
export var LINK_DISPLAY_NAME = 'Dropdown.Link';
|
|
9
|
-
export var LINK_DATA = 'link';
|
|
10
9
|
|
|
11
10
|
var Link = /*#__PURE__*/function (_Component) {
|
|
12
11
|
_inheritsLoose(Link, _Component);
|
|
@@ -33,7 +32,7 @@ var Link = /*#__PURE__*/function (_Component) {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
return /*#__PURE__*/React.createElement(ItemListItem, {
|
|
36
|
-
data:
|
|
35
|
+
data: "link",
|
|
37
36
|
text: text,
|
|
38
37
|
disabled: disabled,
|
|
39
38
|
index: index
|
|
@@ -1,79 +1,56 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import
|
|
4
|
-
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
|
|
5
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
-
import React, { Component } from 'react';
|
|
3
|
+
import React, { useCallback, useRef, useEffect } from 'react';
|
|
7
4
|
import { getColor } from '../system';
|
|
8
5
|
import Text from '../Text';
|
|
6
|
+
import { useThemeProps } from '../system';
|
|
9
7
|
import { inputs, inputLabels } from './utils';
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
function InputLabel(_ref) {
|
|
10
|
+
var controls = _ref.controls,
|
|
11
|
+
state = _ref.state,
|
|
12
|
+
restProps = _objectWithoutPropertiesLoose(_ref, ["controls", "state"]);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
var _useThemeProps = useThemeProps('inputLabel', restProps),
|
|
15
|
+
themeProps = _extends({}, _useThemeProps);
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
args[_key] = arguments[_key];
|
|
19
|
-
}
|
|
17
|
+
var input = useRef(null);
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
if (controls) {
|
|
20
|
+
themeProps.id = controls + "-label";
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
if (state) {
|
|
24
|
+
themeProps.color = getColor(state);
|
|
25
|
+
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
useEffect(function () {
|
|
28
|
+
input.current = inputs[controls];
|
|
29
|
+
inputLabels[controls] = true;
|
|
30
|
+
return function () {
|
|
31
|
+
delete inputLabels[controls];
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
var focusInput = useCallback(function () {
|
|
35
|
+
input.current && input.current.focus();
|
|
36
|
+
}, [input]);
|
|
37
|
+
var handleMouseOver = useCallback(function () {
|
|
38
|
+
input.current && input.current.setState({
|
|
39
|
+
isHovered: true
|
|
31
40
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
41
|
+
}, [input]);
|
|
42
|
+
var handleMouseOut = useCallback(function () {
|
|
43
|
+
input.current && input.current.setState({
|
|
44
|
+
isHovered: false
|
|
37
45
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
inputLabels[this.props.controls] = true;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
50
|
-
delete inputLabels[this.props.controls];
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
_proto.render = function render() {
|
|
54
|
-
var _this$props = this.props,
|
|
55
|
-
controls = _this$props.controls,
|
|
56
|
-
state = _this$props.state,
|
|
57
|
-
restProps = _objectWithoutPropertiesLoose(_this$props, ["controls", "state"]);
|
|
58
|
-
|
|
59
|
-
if (controls) {
|
|
60
|
-
restProps.id = controls + "-label";
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (state) {
|
|
64
|
-
restProps.color = getColor(state);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return /*#__PURE__*/React.createElement(Text, _extends({
|
|
68
|
-
as: "label",
|
|
69
|
-
onMouseOver: this.handleMouseOver,
|
|
70
|
-
onMouseOut: this.handleMouseOut,
|
|
71
|
-
onClick: this.focusInput
|
|
72
|
-
}, restProps));
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
return InputLabel;
|
|
76
|
-
}(Component);
|
|
46
|
+
}, [input]);
|
|
47
|
+
return /*#__PURE__*/React.createElement(Text, _extends({
|
|
48
|
+
as: "label",
|
|
49
|
+
onMouseOver: handleMouseOver,
|
|
50
|
+
onMouseOut: handleMouseOut,
|
|
51
|
+
onClick: focusInput
|
|
52
|
+
}, themeProps));
|
|
53
|
+
}
|
|
77
54
|
|
|
78
55
|
InputLabel.displayName = 'Input.InputLabel';
|
|
79
56
|
export default InputLabel;
|
package/dist/esm/Modal/Modal.js
CHANGED
|
@@ -5,6 +5,7 @@ import Box from '../Box';
|
|
|
5
5
|
import Scrim from '../Scrim';
|
|
6
6
|
import { useDocumentEvent } from '../hooks';
|
|
7
7
|
import { trapFocus } from '../utils';
|
|
8
|
+
import { useThemeProps } from '../system';
|
|
8
9
|
|
|
9
10
|
function Modal(_ref) {
|
|
10
11
|
var children = _ref.children,
|
|
@@ -13,6 +14,11 @@ function Modal(_ref) {
|
|
|
13
14
|
open = _ref.open,
|
|
14
15
|
restProps = _objectWithoutPropertiesLoose(_ref, ["children", "closeOnOutsideClick", "onRequestClose", "open"]);
|
|
15
16
|
|
|
17
|
+
var _useThemeProps = useThemeProps('modal', restProps),
|
|
18
|
+
_useThemeProps$scrimP = _useThemeProps.scrimProps,
|
|
19
|
+
scrimProps = _useThemeProps$scrimP === void 0 ? {} : _useThemeProps$scrimP,
|
|
20
|
+
themeProps = _objectWithoutPropertiesLoose(_useThemeProps, ["scrimProps"]);
|
|
21
|
+
|
|
16
22
|
var modalRef = useRef(null);
|
|
17
23
|
useLayoutEffect(function () {
|
|
18
24
|
if (open) {
|
|
@@ -29,22 +35,24 @@ function Modal(_ref) {
|
|
|
29
35
|
return null;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
return /*#__PURE__*/React.createElement(Scrim, {
|
|
38
|
+
return /*#__PURE__*/React.createElement(Scrim, _extends({
|
|
33
39
|
alignment: "center",
|
|
34
40
|
onMouseDown: function onMouseDown(event) {
|
|
35
41
|
if (closeOnOutsideClick && event.currentTarget === event.target) {
|
|
36
42
|
onRequestClose();
|
|
37
43
|
}
|
|
38
44
|
}
|
|
39
|
-
}, /*#__PURE__*/React.createElement(Box, _extends({
|
|
45
|
+
}, scrimProps), /*#__PURE__*/React.createElement(Box, _extends({
|
|
46
|
+
backgroundColor: "surface",
|
|
47
|
+
boxShadow: "0 0 20px rgba(0, 0, 0, 0.15)",
|
|
40
48
|
innerRef: modalRef,
|
|
41
|
-
width: "100%",
|
|
42
|
-
maxWidth: 60,
|
|
43
|
-
padding: 2,
|
|
44
49
|
margin: 4,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
maxWidth: 60,
|
|
51
|
+
padding: 4,
|
|
52
|
+
paddingBottom: 3,
|
|
53
|
+
radius: 8,
|
|
54
|
+
width: "100%"
|
|
55
|
+
}, themeProps), children));
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
export default Modal;
|
|
@@ -5,7 +5,7 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
5
5
|
import Dropdown from '../Dropdown';
|
|
6
6
|
import Select from '../Select';
|
|
7
7
|
import { Button, Heading, Modal, ThemeProvider } from '../';
|
|
8
|
-
import
|
|
8
|
+
import noop from 'lodash/noop';
|
|
9
9
|
|
|
10
10
|
var _ref = /*#__PURE__*/React.createElement(Heading, {
|
|
11
11
|
"data-testid": "modal-header"
|
|
@@ -12,6 +12,7 @@ import Portal from '../Portal';
|
|
|
12
12
|
import { lockScroll } from '../utils';
|
|
13
13
|
import rewireTabOrder from './rewireTabOrder';
|
|
14
14
|
import { getFixedParent, getModifiers } from './utils';
|
|
15
|
+
import { useThemeProps } from '../system';
|
|
15
16
|
export var Popover = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
16
17
|
var anchorElement = _ref.anchorElement,
|
|
17
18
|
_ref$as = _ref.as,
|
|
@@ -34,6 +35,11 @@ export var Popover = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
34
35
|
shouldFlip = _ref$shouldFlip === void 0 ? false : _ref$shouldFlip,
|
|
35
36
|
restProps = _objectWithoutPropertiesLoose(_ref, ["anchorElement", "as", "innerRef", "keepInView", "lockScrollWhileOpen", "matchWidths", "offset", "open", "onKeyDown", "onRequestClose", "placement", "relativeTo", "renderTo", "shouldFlip"]);
|
|
36
37
|
|
|
38
|
+
var _useThemeProps = useThemeProps('popover', restProps),
|
|
39
|
+
_useThemeProps$zIndex = _useThemeProps.zIndex,
|
|
40
|
+
zIndex = _useThemeProps$zIndex === void 0 ? 10000 : _useThemeProps$zIndex,
|
|
41
|
+
themeProps = _objectWithoutPropertiesLoose(_useThemeProps, ["zIndex"]);
|
|
42
|
+
|
|
37
43
|
var anchorRef = React.useRef(null);
|
|
38
44
|
var popperRef = React.useRef(null);
|
|
39
45
|
var unlockScroll = React.useRef(null);
|
|
@@ -194,8 +200,8 @@ export var Popover = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
194
200
|
}),
|
|
195
201
|
// ideally this should be pulled out to something like ThemeProvider for predictable z indices
|
|
196
202
|
style: {
|
|
197
|
-
zIndex:
|
|
203
|
+
zIndex: zIndex
|
|
198
204
|
}
|
|
199
|
-
},
|
|
205
|
+
}, themeProps)) : null);
|
|
200
206
|
});
|
|
201
207
|
Popover.displayName = 'Popover';
|
package/dist/esm/Scrim/Scrim.js
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import StackView from '../StackView';
|
|
4
|
-
|
|
5
|
+
import { useThemeProps } from '../system';
|
|
6
|
+
var Scrim = /*#__PURE__*/React.forwardRef(function (_ref2, _ref) {
|
|
7
|
+
var ref = _ref2.ref,
|
|
8
|
+
restProps = _objectWithoutPropertiesLoose(_ref2, ["ref"]);
|
|
9
|
+
|
|
5
10
|
React.useLayoutEffect(function () {
|
|
6
11
|
document.body.style.overflow = 'hidden';
|
|
7
12
|
return function () {
|
|
8
13
|
document.body.style.overflow = '';
|
|
9
14
|
};
|
|
10
15
|
}, []);
|
|
16
|
+
|
|
17
|
+
var _useThemeProps = useThemeProps('scrim', restProps),
|
|
18
|
+
_useThemeProps$zIndex = _useThemeProps.zIndex,
|
|
19
|
+
zIndex = _useThemeProps$zIndex === void 0 ? 10000 : _useThemeProps$zIndex,
|
|
20
|
+
themeProps = _objectWithoutPropertiesLoose(_useThemeProps, ["zIndex"]);
|
|
21
|
+
|
|
11
22
|
return /*#__PURE__*/React.createElement(StackView, _extends({
|
|
12
|
-
innerRef:
|
|
23
|
+
innerRef: ref,
|
|
13
24
|
position: "fixed",
|
|
14
25
|
top: 0,
|
|
15
26
|
right: 0,
|
|
16
27
|
bottom: 0,
|
|
17
28
|
left: 0,
|
|
18
|
-
zIndex:
|
|
29
|
+
zIndex: zIndex,
|
|
19
30
|
overflow: "auto" // @ts-ignore
|
|
20
31
|
,
|
|
21
32
|
backgroundColor: "hsla(0,0%,0%,0.4)"
|
|
22
|
-
},
|
|
33
|
+
}, themeProps));
|
|
23
34
|
});
|
|
24
35
|
export { Scrim };
|
package/dist/esm/Table/Table.js
CHANGED
|
@@ -10,7 +10,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
10
10
|
|
|
11
11
|
import React, { PureComponent, Children, Fragment } from 'react';
|
|
12
12
|
import { Global } from '@emotion/react';
|
|
13
|
-
import
|
|
13
|
+
import camelCase from 'lodash/camelCase';
|
|
14
|
+
import snakeCase from 'lodash/snakeCase';
|
|
14
15
|
import Button from '../Button';
|
|
15
16
|
import DragDrop from '../DragDrop';
|
|
16
17
|
import Pagination from '../Pagination';
|
|
@@ -10,7 +10,7 @@ import React, { useLayoutEffect, useState } from 'react';
|
|
|
10
10
|
import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
|
|
11
11
|
import { CacheProvider } from '@emotion/react';
|
|
12
12
|
import createCache from '@emotion/cache';
|
|
13
|
-
import
|
|
13
|
+
import merge from 'lodash/merge';
|
|
14
14
|
import { Box } from '../Box';
|
|
15
15
|
import defaultTheme from '../system/default-theme';
|
|
16
16
|
import { flattenPalette } from '../system';
|
|
@@ -11,6 +11,8 @@ import InputField from '../Input/InputField';
|
|
|
11
11
|
import NumberField from '../NumberField';
|
|
12
12
|
import { isIOS, noop, padNumber } from '../utils';
|
|
13
13
|
import { HOURS_TO_NOON, HOURS_IN_DAY, addHoursToTime, addMinutesToTime, addTimeToDate, getMeridiem, getTimeFromDate } from './utils';
|
|
14
|
+
var MIN_MINUTE = 0;
|
|
15
|
+
var MAX_MINUTE = 59;
|
|
14
16
|
|
|
15
17
|
var _ref = /*#__PURE__*/React.createElement(Box, {
|
|
16
18
|
as: "span",
|
|
@@ -82,9 +84,31 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
82
84
|
});
|
|
83
85
|
|
|
84
86
|
_defineProperty(_assertThisInitialized(_this), "handleHoursKeyDown", function (event) {
|
|
87
|
+
var hour = Number(event.target.value);
|
|
88
|
+
var isTwelveHourClock = _this.props.twelveHourClock;
|
|
89
|
+
var isHourEleven = HOURS_TO_NOON - 1;
|
|
90
|
+
var maxHour = isTwelveHourClock ? HOURS_TO_NOON : HOURS_IN_DAY - 1;
|
|
91
|
+
var minHour = isTwelveHourClock ? 1 : 0;
|
|
92
|
+
|
|
85
93
|
if (event.key === 'ArrowRight') {
|
|
86
94
|
_this.inputBox.focus(1);
|
|
87
95
|
}
|
|
96
|
+
|
|
97
|
+
if (event.key === 'ArrowUp' && isTwelveHourClock && hour === isHourEleven) {
|
|
98
|
+
_this.toggleMeridiem();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (event.key === 'ArrowUp' && hour === maxHour) {
|
|
102
|
+
_this.updateHours(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (event.key === 'ArrowDown' && isTwelveHourClock && hour === minHour) {
|
|
106
|
+
_this.toggleMeridiem();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (event.key === 'ArrowDown' && hour === minHour) {
|
|
110
|
+
_this.updateHours(-1);
|
|
111
|
+
}
|
|
88
112
|
});
|
|
89
113
|
|
|
90
114
|
_defineProperty(_assertThisInitialized(_this), "handleMinutesChange", function (minutes) {
|
|
@@ -94,6 +118,8 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
94
118
|
});
|
|
95
119
|
|
|
96
120
|
_defineProperty(_assertThisInitialized(_this), "handleMinutesKeyDown", function (event) {
|
|
121
|
+
var minute = Number(event.target.value);
|
|
122
|
+
|
|
97
123
|
if (_this.props.ignoredKeys.includes(event.key)) {
|
|
98
124
|
return;
|
|
99
125
|
}
|
|
@@ -105,6 +131,14 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
105
131
|
if (event.key === 'ArrowRight') {
|
|
106
132
|
_this.inputBox.focus(2);
|
|
107
133
|
}
|
|
134
|
+
|
|
135
|
+
if (event.key === 'ArrowUp' && minute >= MAX_MINUTE) {
|
|
136
|
+
_this.updateMinutes(1);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (event.key === 'ArrowDown' && minute <= MIN_MINUTE) {
|
|
140
|
+
_this.updateMinutes(-1);
|
|
141
|
+
}
|
|
108
142
|
});
|
|
109
143
|
|
|
110
144
|
_defineProperty(_assertThisInitialized(_this), "handleAMPMKeyDown", function (event) {
|
|
@@ -194,8 +228,8 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
194
228
|
fontVariantNumeric: "tabular-nums",
|
|
195
229
|
moveFocusOnMax: true,
|
|
196
230
|
value: minutes,
|
|
197
|
-
min:
|
|
198
|
-
max:
|
|
231
|
+
min: MIN_MINUTE,
|
|
232
|
+
max: MAX_MINUTE,
|
|
199
233
|
pad: 2,
|
|
200
234
|
grow: 0,
|
|
201
235
|
width: "2ch",
|
|
@@ -208,7 +242,7 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
208
242
|
highlightOnInteraction: true,
|
|
209
243
|
value: this.state.meridiem,
|
|
210
244
|
grow: 0,
|
|
211
|
-
width:
|
|
245
|
+
width: "2em",
|
|
212
246
|
textAlign: "center",
|
|
213
247
|
"aria-label": "AM/PM",
|
|
214
248
|
onChange: noop // prevent React warnings
|