@planningcenter/tapestry-react 2.6.0-rc.9 → 2.6.0
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/DataTable/components/BodyRow.js +2 -2
- package/dist/cjs/DataTable/hooks/useCollapsibleRows.js +2 -2
- package/dist/cjs/Dropdown/Dropdown.js +5 -3
- 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 +15 -7
- 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 +1 -1
- package/dist/cjs/Tooltip/Tooltip.js +27 -23
- 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/DataTable/components/BodyRow.js +2 -2
- package/dist/esm/DataTable/hooks/useCollapsibleRows.js +1 -1
- package/dist/esm/Dropdown/Dropdown.js +6 -4
- 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 +13 -7
- 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 +1 -1
- package/dist/esm/Tooltip/Tooltip.js +29 -24
- 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/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/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 +7 -4
- 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 +12 -4
- 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 +1 -1
- package/src/Tooltip/Tooltip.js +19 -21
- package/src/index.d.ts +1 -1
- package/src/system/utils.js +1 -1
- package/src/utils.js +1 -1
package/dist/cjs/system/utils.js
CHANGED
|
@@ -24,7 +24,7 @@ var _react2 = require("@emotion/react");
|
|
|
24
24
|
|
|
25
25
|
var _polished = require("polished");
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
28
28
|
|
|
29
29
|
var _colors = require("./colors");
|
|
30
30
|
|
|
@@ -161,7 +161,7 @@ function getForegroundColor(color) {
|
|
|
161
161
|
|
|
162
162
|
function useThemeValue(path, defaultValue) {
|
|
163
163
|
var userTheme = (0, _react.useContext)(_react2.ThemeContext);
|
|
164
|
-
return path ? (0,
|
|
164
|
+
return path ? (0, _get["default"])(userTheme, path, defaultValue || (0, _get["default"])(_defaultTheme["default"], path)) : userTheme || _defaultTheme["default"];
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
function useThemeProps(path, props) {
|
package/dist/cjs/utils.js
CHANGED
|
@@ -46,7 +46,7 @@ var _react = require("react");
|
|
|
46
46
|
|
|
47
47
|
var _tabbable = require("tabbable");
|
|
48
48
|
|
|
49
|
-
var
|
|
49
|
+
var _kebabCase = _interopRequireDefault(require("lodash/kebabCase"));
|
|
50
50
|
|
|
51
51
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
52
52
|
|
|
@@ -785,11 +785,11 @@ function createCSSProperty(key, value) {
|
|
|
785
785
|
createdCSSProperties.add(key);
|
|
786
786
|
}
|
|
787
787
|
|
|
788
|
-
return "--" + (0,
|
|
788
|
+
return "--" + (0, _kebabCase["default"])(key) + "-" + (0, _kebabCase["default"])(value);
|
|
789
789
|
}
|
|
790
790
|
|
|
791
791
|
function getCSSProperty(key, value) {
|
|
792
|
-
return key && value ? "var(--" + (0,
|
|
792
|
+
return key && value ? "var(--" + (0, _kebabCase["default"])(key) + "-" + (0, _kebabCase["default"])(value) + ")" : undefined;
|
|
793
793
|
}
|
|
794
794
|
|
|
795
795
|
function objectToCSSProperties(themeKey, props) {
|
|
@@ -210,6 +210,13 @@ export function Button(_ref) {
|
|
|
210
210
|
|
|
211
211
|
if (to) {
|
|
212
212
|
restProps['href'] = to;
|
|
213
|
+
} // remove `type` if either `to` or `href` is specified
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
if (to || restProps.href) {
|
|
217
|
+
buttonProps = _objectSpread(_objectSpread({}, buttonProps), {}, {
|
|
218
|
+
type: null
|
|
219
|
+
});
|
|
213
220
|
} // apply stroke defaults and higher z-index when hovering to show outline in group properly
|
|
214
221
|
|
|
215
222
|
|
|
@@ -244,7 +251,7 @@ export function Button(_ref) {
|
|
|
244
251
|
restProps = mergeProps(restProps, wrapperProps);
|
|
245
252
|
}
|
|
246
253
|
|
|
247
|
-
if (type && restProps.as && restProps.as !== "button") {
|
|
254
|
+
if (buttonProps.type && restProps.as && restProps.as !== "button") {
|
|
248
255
|
console.log("Tapestry-React: <Button/> type prop is only supported by <button> and not <" + restProps.as + ">.");
|
|
249
256
|
}
|
|
250
257
|
}
|
|
@@ -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);
|
|
@@ -67,7 +67,7 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
67
67
|
_this.popover.focusAnchor();
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
if (
|
|
70
|
+
if (node.tagName === 'A' && event.type !== 'click') {
|
|
71
71
|
node.click();
|
|
72
72
|
} else if (_this.props.onSelect) {
|
|
73
73
|
_this.props.onSelect(data);
|
|
@@ -96,7 +96,7 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
96
96
|
keepInView = _this$props.keepInView,
|
|
97
97
|
lockScrollWhileOpen = _this$props.lockScrollWhileOpen,
|
|
98
98
|
matchWidths = _this$props.matchWidths,
|
|
99
|
-
|
|
99
|
+
_onClick = _this$props.onClick,
|
|
100
100
|
onClose = _this$props.onClose,
|
|
101
101
|
onKeyDown = _this$props.onKeyDown,
|
|
102
102
|
onOpen = _this$props.onOpen,
|
|
@@ -179,12 +179,14 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
179
179
|
}, _objectSpread2[arrowIconOnly ? 'icon' : 'iconRight'] = {
|
|
180
180
|
name: isPopoverOpen ? 'general.upCaret' : 'general.downCaret',
|
|
181
181
|
size: 'sm'
|
|
182
|
-
}, _objectSpread2.title = arrowIconOnly ? 'arrow down' : restProps.title, _objectSpread2.tabIndex = 0, _objectSpread2.cursor = 'pointer', _objectSpread2.onBlur = requestBlur, _objectSpread2.onClick = function onClick() {
|
|
182
|
+
}, _objectSpread2.title = arrowIconOnly ? 'arrow down' : restProps.title, _objectSpread2.tabIndex = 0, _objectSpread2.cursor = 'pointer', _objectSpread2.onBlur = requestBlur, _objectSpread2.onClick = function onClick(event) {
|
|
183
183
|
_this2.togglePopover();
|
|
184
184
|
|
|
185
185
|
if (!isPopoverOpen) {
|
|
186
186
|
_this2.popover.focusAnchor();
|
|
187
187
|
}
|
|
188
|
+
|
|
189
|
+
_onClick && _onClick(event);
|
|
188
190
|
}, _objectSpread2.onKeyDown = function onKeyDown(event) {
|
|
189
191
|
anchorProps.onKeyDown(event);
|
|
190
192
|
|
|
@@ -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,22 @@ 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",
|
|
40
47
|
innerRef: modalRef,
|
|
41
|
-
|
|
48
|
+
margin: 4,
|
|
42
49
|
maxWidth: 60,
|
|
43
50
|
padding: 2,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}, restProps), children));
|
|
51
|
+
radius: 3,
|
|
52
|
+
width: "100%"
|
|
53
|
+
}, themeProps), children));
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
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';
|
|
@@ -208,7 +208,7 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
208
208
|
highlightOnInteraction: true,
|
|
209
209
|
value: this.state.meridiem,
|
|
210
210
|
grow: 0,
|
|
211
|
-
width:
|
|
211
|
+
width: "2em",
|
|
212
212
|
textAlign: "center",
|
|
213
213
|
"aria-label": "AM/PM",
|
|
214
214
|
onChange: noop // prevent React warnings
|
|
@@ -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,
|
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;
|