@planningcenter/tapestry-react 2.6.0-rc.8 → 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/DataTable.js +3 -3
- package/dist/cjs/DataTable/components/BodyRow.js +2 -2
- package/dist/cjs/DataTable/components/BodyRows.js +2 -2
- package/dist/cjs/DataTable/components/BodySubRows.js +2 -2
- package/dist/cjs/DataTable/components/CheckboxCell.js +4 -4
- 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 +14 -5
- package/dist/cjs/ThemeProvider/styles.js +1 -1
- package/dist/cjs/TimeField/TimeField.js +1 -1
- package/dist/cjs/Tooltip/Tooltip.js +27 -23
- package/dist/cjs/system/split-styles.js +1 -1
- 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/DataTable.js +3 -3
- package/dist/esm/DataTable/components/BodyRow.js +2 -2
- package/dist/esm/DataTable/components/BodyRows.js +2 -2
- package/dist/esm/DataTable/components/BodySubRows.js +2 -2
- package/dist/esm/DataTable/components/CheckboxCell.js +4 -4
- 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 +14 -5
- package/dist/esm/ThemeProvider/styles.js +1 -1
- package/dist/esm/TimeField/TimeField.js +1 -1
- package/dist/esm/Tooltip/Tooltip.js +29 -24
- package/dist/esm/system/split-styles.js +1 -1
- 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 +10 -4
- package/src/DataTable/components/BodyRow.js +1 -1
- package/src/DataTable/components/BodyRows.js +5 -2
- package/src/DataTable/components/BodySubRows.js +5 -2
- package/src/DataTable/components/CheckboxCell.js +4 -4
- 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 +15 -10
- package/src/ThemeProvider/styles.ts +18 -8
- package/src/TimeField/TimeField.js +1 -1
- package/src/Tooltip/Tooltip.js +19 -21
- package/src/index.d.ts +1 -1
- package/src/system/split-styles.js +3 -1
- package/src/system/utils.js +1 -1
- package/src/utils.js +1 -1
|
@@ -20,7 +20,7 @@ var _react2 = require("@emotion/react");
|
|
|
20
20
|
|
|
21
21
|
var _cache = _interopRequireDefault(require("@emotion/cache"));
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
24
24
|
|
|
25
25
|
var _Box = require("../Box");
|
|
26
26
|
|
|
@@ -44,6 +44,15 @@ var cache = (0, _cache["default"])({
|
|
|
44
44
|
key: 'tapestry-react'
|
|
45
45
|
});
|
|
46
46
|
exports.cache = cache;
|
|
47
|
+
|
|
48
|
+
function mergeIntoNewObject() {
|
|
49
|
+
for (var _len = arguments.length, merges = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
50
|
+
merges[_key] = arguments[_key];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return _merge["default"].apply(void 0, [{}].concat(merges));
|
|
54
|
+
}
|
|
55
|
+
|
|
47
56
|
var themeStorage = {
|
|
48
57
|
get: function get() {
|
|
49
58
|
return window.localStorage.getItem(STORAGE_KEY);
|
|
@@ -70,12 +79,12 @@ function mergeThemes(a, b) {
|
|
|
70
79
|
|
|
71
80
|
return _objectSpread(_objectSpread(_objectSpread({}, a), b), {}, {
|
|
72
81
|
button: _objectSpread(_objectSpread(_objectSpread({}, a.button), b.button), {}, {
|
|
73
|
-
themes: (
|
|
82
|
+
themes: mergeIntoNewObject(((_a$button = a.button) == null ? void 0 : _a$button.themes) || {}, ((_b$button = b.button) == null ? void 0 : _b$button.themes) || {})
|
|
74
83
|
}),
|
|
75
|
-
colors: (
|
|
84
|
+
colors: mergeIntoNewObject((0, _system.flattenPalette)(a.colors || {}), (0, _system.flattenPalette)(b.colors || {})),
|
|
76
85
|
spinner: _objectSpread(_objectSpread(_objectSpread({}, a.spinner), b.spinner), {}, {
|
|
77
|
-
sizes: (
|
|
78
|
-
thickness: (
|
|
86
|
+
sizes: mergeIntoNewObject(((_a$spinner = a.spinner) == null ? void 0 : _a$spinner.sizes) || {}, ((_b$spinner = b.spinner) == null ? void 0 : _b$spinner.sizes) || {}),
|
|
87
|
+
thickness: mergeIntoNewObject(((_a$spinner2 = a.spinner) == null ? void 0 : _a$spinner2.thickness) || {}, ((_b$spinner2 = b.spinner) == null ? void 0 : _b$spinner2.thickness) || {})
|
|
79
88
|
})
|
|
80
89
|
});
|
|
81
90
|
}
|
|
@@ -35,7 +35,7 @@ var setRootStyles = function setRootStyles(themeId, styles) {
|
|
|
35
35
|
exports.setRootStyles = setRootStyles;
|
|
36
36
|
var defaultColorProperties = (0, _utils.objectToCSSProperties)('colors', (0, _system.flattenPalette)(_system.defaultTheme.colors));
|
|
37
37
|
exports.defaultColorProperties = defaultColorProperties;
|
|
38
|
-
var styleReset = ("\n" + getRootStyles(null, defaultColorProperties) + "\n\n.tapestry-react-reset
|
|
38
|
+
var styleReset = ("\n" + getRootStyles(null, defaultColorProperties) + "\n\n.tapestry-react-reset {\n appearance: none;\n background-color: transparent;\n border-width: 0px;\n border-style: solid;\n border-color: transparent;\n box-sizing: border-box;\n color: inherit;\n box-sizing: border-box;\n flex-grow: 0;\n flex-shrink: 0;\n flex-basis: auto;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';\n font-weight: 400;\n margin-top: 0;\n margin-right: 0;\n margin-bottom: 0;\n margin-left: 0;\n min-width: 0px;\n min-height: 0px;\n padding-top: 0;\n padding-right: 0;\n padding-bottom: 0;\n padding-left: 0;\n text-decoration: none;\n}\n\n.tapestry-react-reset::-moz-focus-inner {\n padding-top: 0;\n padding-right: 0;\n padding-bottom: 0;\n padding-left: 0;\n border: none;\n}\n\n.tapestry-react-reset:focus:not(.focus-visible) {\n outline: 0px;\n}\n" // minify string
|
|
39
39
|
).replace(/\n/g, '').replace(/\s\s+/g, ' '); // we use our own global style implementation in place of Emotion Global
|
|
40
40
|
// so we can have more control over when styles are injected since multiple
|
|
41
41
|
// Providers can be used on a page
|
|
@@ -214,7 +214,7 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
214
214
|
highlightOnInteraction: true,
|
|
215
215
|
value: this.state.meridiem,
|
|
216
216
|
grow: 0,
|
|
217
|
-
width:
|
|
217
|
+
width: "2em",
|
|
218
218
|
textAlign: "center",
|
|
219
219
|
"aria-label": "AM/PM",
|
|
220
220
|
onChange: _utils.noop // prevent React warnings
|
|
@@ -57,23 +57,22 @@ function Tooltip(props, ref) {
|
|
|
57
57
|
triggerOnHover = _useThemeProps$trigge2 === void 0 ? true : _useThemeProps$trigge2,
|
|
58
58
|
childProps = (0, _objectWithoutPropertiesLoose2["default"])(_useThemeProps, ["children", "openDelay", "closeDelay", "defaultOpen", "keepInView", "placement", "popoverProps", "renderTo", "title", "triggerOnFocus", "triggerOnHover"]);
|
|
59
59
|
|
|
60
|
-
var isPageInView = true;
|
|
61
|
-
var
|
|
62
|
-
var isMouseDown = false;
|
|
60
|
+
var isPageInView = (0, _react.useRef)(true);
|
|
61
|
+
var isMouseDown = (0, _react.useRef)(false);
|
|
63
62
|
var openTimeoutId = (0, _react.useRef)(null);
|
|
64
|
-
var closeTimeoutId = (0, _react.useRef)(null);
|
|
65
|
-
|
|
66
|
-
var cleanupPageViewChange = (0, _react.useCallback)((0, _utils.pageViewChange)(function (inView) {
|
|
67
|
-
return setTimeout(function () {
|
|
68
|
-
return isPageInView = inView;
|
|
69
|
-
});
|
|
70
|
-
}));
|
|
63
|
+
var closeTimeoutId = (0, _react.useRef)(null);
|
|
71
64
|
|
|
72
65
|
var _useState = (0, _react.useState)(defaultOpen),
|
|
73
66
|
isPopoverOpen = _useState[0],
|
|
74
67
|
setIsPopoverOpen = _useState[1];
|
|
75
68
|
|
|
76
69
|
(0, _react.useEffect)(function () {
|
|
70
|
+
// prevents tooltips showing when focused and navigating back to a page after leaving
|
|
71
|
+
var cleanupPageViewChange = (0, _utils.pageViewChange)(function (inView) {
|
|
72
|
+
return setTimeout(function () {
|
|
73
|
+
return isPageInView.current = inView;
|
|
74
|
+
});
|
|
75
|
+
});
|
|
77
76
|
emitter.on('CLOSE_OPEN_TOOLTIPS', close);
|
|
78
77
|
return function () {
|
|
79
78
|
emitter.off('CLOSE_OPEN_TOOLTIPS', close);
|
|
@@ -116,7 +115,8 @@ function Tooltip(props, ref) {
|
|
|
116
115
|
close();
|
|
117
116
|
}
|
|
118
117
|
}, [triggerOnHover]);
|
|
119
|
-
|
|
118
|
+
|
|
119
|
+
var createOpenTimeout = function createOpenTimeout() {
|
|
120
120
|
clearGlobalTimeout();
|
|
121
121
|
|
|
122
122
|
if (openTimeoutId.current === null) {
|
|
@@ -130,8 +130,9 @@ function Tooltip(props, ref) {
|
|
|
130
130
|
}, instantDelay ? 0 : openDelay);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
var createCloseTimeout = function createCloseTimeout() {
|
|
135
136
|
startGlobalTimeout();
|
|
136
137
|
|
|
137
138
|
if (closeTimeoutId.current === null) {
|
|
@@ -141,19 +142,22 @@ function Tooltip(props, ref) {
|
|
|
141
142
|
return close();
|
|
142
143
|
}, closeDelay);
|
|
143
144
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
var handleFocus = function handleFocus() {
|
|
148
|
+
if (isPageInView.current && !isMouseDown.current) {
|
|
147
149
|
open();
|
|
148
150
|
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
var handleMouseDown = function handleMouseDown() {
|
|
154
|
+
isMouseDown.current = true;
|
|
152
155
|
close();
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
var handleMouseUp = function handleMouseUp() {
|
|
159
|
+
isMouseDown.current = false;
|
|
160
|
+
};
|
|
157
161
|
|
|
158
162
|
var child = _react.Children.only(children);
|
|
159
163
|
|
|
@@ -46,7 +46,7 @@ function SplitStyles(_ref) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return _objectSpread(_objectSpread({}, restProps), {}, {
|
|
49
|
-
className: className,
|
|
49
|
+
className: className ? "tapestry-react-reset " + className : "tapestry-react-reset",
|
|
50
50
|
css: function css(theme) {
|
|
51
51
|
var propStyles = {};
|
|
52
52
|
|
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'
|
|
@@ -182,7 +182,7 @@ var DataTable = function DataTable(props) {
|
|
|
182
182
|
style: isLoadingOrEmpty ? {
|
|
183
183
|
display: 'none'
|
|
184
184
|
} : undefined,
|
|
185
|
-
className: css({
|
|
185
|
+
className: "tapestry-react-reset " + css({
|
|
186
186
|
position: 'relative'
|
|
187
187
|
})
|
|
188
188
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -203,7 +203,7 @@ var DataTable = function DataTable(props) {
|
|
|
203
203
|
column: column,
|
|
204
204
|
columnIndex: columnIndex,
|
|
205
205
|
columnSort: columnSort,
|
|
206
|
-
className: css([].concat(cellVariantClassName, [column.css]))
|
|
206
|
+
className: "tapestry-react-reset " + css([].concat(cellVariantClassName, [column.css]))
|
|
207
207
|
});
|
|
208
208
|
}))), bodyToRender, hasFooterColumns && /*#__PURE__*/React.createElement("div", {
|
|
209
209
|
ref: footerRef,
|
|
@@ -221,7 +221,7 @@ var DataTable = function DataTable(props) {
|
|
|
221
221
|
key: columnIndex,
|
|
222
222
|
role: "cell",
|
|
223
223
|
ref: getColumnRef(columnIndex + "." + (data.length + 1)),
|
|
224
|
-
className: css([].concat(cellVariantClassName, [column.css]))
|
|
224
|
+
className: "tapestry-react-reset " + css([].concat(cellVariantClassName, [column.css]))
|
|
225
225
|
}, typeof column.footer === 'string' || /*#__PURE__*/React.isValidElement(column.footer) ? column.footer : column.footer ? /*#__PURE__*/React.createElement(column.footer, {
|
|
226
226
|
columnIndex: columnIndex
|
|
227
227
|
}) : null);
|
|
@@ -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,
|
|
@@ -42,7 +42,7 @@ function BodyRows(_ref) {
|
|
|
42
42
|
ref: getColumnRef(columnIndex + "." + (rowIndex + 1)) // offset by 1 to account for header row
|
|
43
43
|
,
|
|
44
44
|
role: "cell",
|
|
45
|
-
className: css([].concat(cellVariantStyles, [column.css]))
|
|
45
|
+
className: "tapestry-react-reset " + css([].concat(cellVariantStyles, [column.css]))
|
|
46
46
|
}, getCell(column.cell, {
|
|
47
47
|
columnIndex: columnIndex,
|
|
48
48
|
rowData: rowData,
|
|
@@ -68,7 +68,7 @@ function BodyRows(_ref) {
|
|
|
68
68
|
rowIndex: rowIndex,
|
|
69
69
|
keyboardShortcuts: keyboardShortcuts,
|
|
70
70
|
onRowClick: onRowClick,
|
|
71
|
-
className: css(rowVariantClassName)
|
|
71
|
+
className: "tapestry-react-reset " + css(rowVariantClassName)
|
|
72
72
|
}, getRowLinkProps({
|
|
73
73
|
getRowLink: getRowLink,
|
|
74
74
|
data: rowData,
|
|
@@ -58,7 +58,7 @@ var BodySubRows = function BodySubRows(_ref2) {
|
|
|
58
58
|
rowIndex: rowIndex,
|
|
59
59
|
keyboardShortcuts: keyboardShortcuts,
|
|
60
60
|
onRowClick: onRowClick,
|
|
61
|
-
className: css(rowVariantClassName)
|
|
61
|
+
className: "tapestry-react-reset " + css(rowVariantClassName)
|
|
62
62
|
}, getRowLinkProps({
|
|
63
63
|
getRowLink: getRowLink,
|
|
64
64
|
data: rowData,
|
|
@@ -77,7 +77,7 @@ var BodySubRows = function BodySubRows(_ref2) {
|
|
|
77
77
|
return /*#__PURE__*/React.createElement("div", {
|
|
78
78
|
key: columnIndex,
|
|
79
79
|
ref: getColumnRef(columnIndex + "." + (parentRowIndex + 1) + "." + rowIndex),
|
|
80
|
-
className: css([].concat(cellVariantClassName, [column.css]))
|
|
80
|
+
className: "tapestry-react-reset " + css([].concat(cellVariantClassName, [column.css]))
|
|
81
81
|
}, getCell(column.subCell !== undefined ? column.subCell : column.cell, {
|
|
82
82
|
columnIndex: columnIndex,
|
|
83
83
|
rowData: rowData,
|
|
@@ -85,19 +85,19 @@ function CheckboxCell(_ref) {
|
|
|
85
85
|
onKeyDown: function onKeyDown(event) {
|
|
86
86
|
return event.key === ' ' && handleChange(event);
|
|
87
87
|
},
|
|
88
|
-
className: "tapestry-react-Checkbox",
|
|
88
|
+
className: "tapestry-react-reset tapestry-react-Checkbox",
|
|
89
89
|
css: cssStyles
|
|
90
90
|
}, /*#__PURE__*/React.createElement(Icon.Path, {
|
|
91
91
|
name: iconPaths.fill,
|
|
92
|
-
className: "tapestry-react-Checkbox-Fill",
|
|
92
|
+
className: "tapestry-react-reset tapestry-react-Checkbox-Fill",
|
|
93
93
|
fill: checked || indeterminate ? 'primary' : 'surfaceTertiary',
|
|
94
94
|
stroke: checked || indeterminate ? 'primary' : 'separatorSecondary'
|
|
95
95
|
}), /*#__PURE__*/React.createElement(Icon.Path, {
|
|
96
96
|
name: iconPaths.minus,
|
|
97
|
-
className: "tapestry-react-Checkbox-
|
|
97
|
+
className: "tapestry-react-reset tapestry-react-Checkbox-Fill"
|
|
98
98
|
}), /*#__PURE__*/React.createElement(Icon.Path, {
|
|
99
99
|
name: iconPaths.checked,
|
|
100
|
-
className: "tapestry-react-Checkbox-Checked"
|
|
100
|
+
className: "tapestry-react-reset tapestry-react-Checkbox-Checked"
|
|
101
101
|
}));
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -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;
|