@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.
Files changed (83) hide show
  1. package/dist/cjs/Button/Button.js +8 -1
  2. package/dist/cjs/Button/Button.test.js +51 -8
  3. package/dist/cjs/DataTable/DataTable.js +3 -3
  4. package/dist/cjs/DataTable/components/BodyRow.js +2 -2
  5. package/dist/cjs/DataTable/components/BodyRows.js +2 -2
  6. package/dist/cjs/DataTable/components/BodySubRows.js +2 -2
  7. package/dist/cjs/DataTable/components/CheckboxCell.js +4 -4
  8. package/dist/cjs/DataTable/hooks/useCollapsibleRows.js +2 -2
  9. package/dist/cjs/Dropdown/Dropdown.js +5 -3
  10. package/dist/cjs/Dropdown/Dropdown.test.js +3 -3
  11. package/dist/cjs/Dropdown/Link.js +2 -4
  12. package/dist/cjs/Input/InputLabel.js +40 -63
  13. package/dist/cjs/Modal/Modal.js +15 -7
  14. package/dist/cjs/Modal/Modal.test.js +2 -2
  15. package/dist/cjs/Popover/Popover.js +10 -2
  16. package/dist/cjs/Scrim/Scrim.js +16 -4
  17. package/dist/cjs/Table/Table.js +5 -3
  18. package/dist/cjs/ThemeProvider/ThemeProvider.js +14 -5
  19. package/dist/cjs/ThemeProvider/styles.js +1 -1
  20. package/dist/cjs/TimeField/TimeField.js +1 -1
  21. package/dist/cjs/Tooltip/Tooltip.js +27 -23
  22. package/dist/cjs/system/split-styles.js +1 -1
  23. package/dist/cjs/system/utils.js +2 -2
  24. package/dist/cjs/utils.js +3 -3
  25. package/dist/esm/Button/Button.js +8 -1
  26. package/dist/esm/Button/Button.test.js +67 -9
  27. package/dist/esm/DataTable/DataTable.js +3 -3
  28. package/dist/esm/DataTable/components/BodyRow.js +2 -2
  29. package/dist/esm/DataTable/components/BodyRows.js +2 -2
  30. package/dist/esm/DataTable/components/BodySubRows.js +2 -2
  31. package/dist/esm/DataTable/components/CheckboxCell.js +4 -4
  32. package/dist/esm/DataTable/hooks/useCollapsibleRows.js +1 -1
  33. package/dist/esm/Dropdown/Dropdown.js +6 -4
  34. package/dist/esm/Dropdown/Dropdown.test.js +1 -1
  35. package/dist/esm/Dropdown/Link.js +1 -2
  36. package/dist/esm/Input/InputLabel.js +40 -63
  37. package/dist/esm/Modal/Modal.js +13 -7
  38. package/dist/esm/Modal/Modal.test.js +1 -1
  39. package/dist/esm/Popover/Popover.js +8 -2
  40. package/dist/esm/Scrim/Scrim.js +15 -4
  41. package/dist/esm/Table/Table.js +2 -1
  42. package/dist/esm/ThemeProvider/ThemeProvider.js +14 -5
  43. package/dist/esm/ThemeProvider/styles.js +1 -1
  44. package/dist/esm/TimeField/TimeField.js +1 -1
  45. package/dist/esm/Tooltip/Tooltip.js +29 -24
  46. package/dist/esm/system/split-styles.js +1 -1
  47. package/dist/esm/system/utils.js +1 -1
  48. package/dist/esm/utils.js +1 -1
  49. package/dist/types/Button/Button.d.ts +4 -0
  50. package/dist/types/ThemeProvider/ThemeProvider.d.ts +3 -3
  51. package/dist/types/index.d.ts +1 -1
  52. package/package.json +4 -4
  53. package/src/Button/Button.test.tsx +30 -0
  54. package/src/Button/Button.tsx +14 -1
  55. package/src/DataTable/DataTable.js +10 -4
  56. package/src/DataTable/components/BodyRow.js +1 -1
  57. package/src/DataTable/components/BodyRows.js +5 -2
  58. package/src/DataTable/components/BodySubRows.js +5 -2
  59. package/src/DataTable/components/CheckboxCell.js +4 -4
  60. package/src/DataTable/hooks/useCollapsibleRows.js +1 -1
  61. package/src/Dropdown/Dropdown.js +7 -4
  62. package/src/Dropdown/Dropdown.mdx +3 -3
  63. package/src/Dropdown/Dropdown.test.tsx +1 -1
  64. package/src/Dropdown/Link.js +1 -7
  65. package/src/Input/InputLabel.js +39 -36
  66. package/src/Input/InputLabel.mdx +1 -0
  67. package/src/Modal/Modal.js +12 -4
  68. package/src/Modal/Modal.mdx +2 -1
  69. package/src/Modal/Modal.test.tsx +1 -1
  70. package/src/Popover/Popover.mdx +1 -0
  71. package/src/Popover/Popover.tsx +8 -2
  72. package/src/Scrim/Scrim.mdx +1 -0
  73. package/src/Scrim/Scrim.tsx +11 -6
  74. package/src/Sidebar/Sidebar.mdx +0 -1
  75. package/src/Table/Table.js +2 -1
  76. package/src/ThemeProvider/ThemeProvider.tsx +15 -10
  77. package/src/ThemeProvider/styles.ts +18 -8
  78. package/src/TimeField/TimeField.js +1 -1
  79. package/src/Tooltip/Tooltip.js +19 -21
  80. package/src/index.d.ts +1 -1
  81. package/src/system/split-styles.js +3 -1
  82. package/src/system/utils.js +1 -1
  83. package/src/utils.js +1 -1
@@ -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
- width: "100%",
48
+ margin: 4,
42
49
  maxWidth: 60,
43
50
  padding: 2,
44
- margin: 4,
45
- backgroundColor: "surface",
46
- radius: 3
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 { noop } from 'lodash';
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: 10000
203
+ zIndex: zIndex
198
204
  }
199
- }, restProps)) : null);
205
+ }, themeProps)) : null);
200
206
  });
201
207
  Popover.displayName = 'Popover';
@@ -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
- var Scrim = /*#__PURE__*/React.forwardRef(function (props, _ref) {
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: props.ref,
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: 10000,
29
+ zIndex: zIndex,
19
30
  overflow: "auto" // @ts-ignore
20
31
  ,
21
32
  backgroundColor: "hsla(0,0%,0%,0.4)"
22
- }, props));
33
+ }, themeProps));
23
34
  });
24
35
  export { Scrim };
@@ -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 { camelCase, snakeCase } from 'lodash';
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 { merge } from 'lodash';
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';
@@ -20,6 +20,15 @@ var STORAGE_KEY = 'tapestry-react-theme';
20
20
  export var cache = createCache({
21
21
  key: 'tapestry-react'
22
22
  });
23
+
24
+ function mergeIntoNewObject() {
25
+ for (var _len = arguments.length, merges = new Array(_len), _key = 0; _key < _len; _key++) {
26
+ merges[_key] = arguments[_key];
27
+ }
28
+
29
+ return merge.apply(void 0, [{}].concat(merges));
30
+ }
31
+
23
32
  export var themeStorage = {
24
33
  get: function get() {
25
34
  return window.localStorage.getItem(STORAGE_KEY);
@@ -44,12 +53,12 @@ function mergeThemes(a, b) {
44
53
 
45
54
  return _objectSpread(_objectSpread(_objectSpread({}, a), b), {}, {
46
55
  button: _objectSpread(_objectSpread(_objectSpread({}, a.button), b.button), {}, {
47
- themes: merge(((_a$button = a.button) == null ? void 0 : _a$button.themes) || {}, ((_b$button = b.button) == null ? void 0 : _b$button.themes) || {})
56
+ themes: mergeIntoNewObject(((_a$button = a.button) == null ? void 0 : _a$button.themes) || {}, ((_b$button = b.button) == null ? void 0 : _b$button.themes) || {})
48
57
  }),
49
- colors: merge(flattenPalette(a.colors || {}), flattenPalette(b.colors || {})),
58
+ colors: mergeIntoNewObject(flattenPalette(a.colors || {}), flattenPalette(b.colors || {})),
50
59
  spinner: _objectSpread(_objectSpread(_objectSpread({}, a.spinner), b.spinner), {}, {
51
- sizes: merge(((_a$spinner = a.spinner) == null ? void 0 : _a$spinner.sizes) || {}, ((_b$spinner = b.spinner) == null ? void 0 : _b$spinner.sizes) || {}),
52
- thickness: merge(((_a$spinner2 = a.spinner) == null ? void 0 : _a$spinner2.thickness) || {}, ((_b$spinner2 = b.spinner) == null ? void 0 : _b$spinner2.thickness) || {})
60
+ sizes: mergeIntoNewObject(((_a$spinner = a.spinner) == null ? void 0 : _a$spinner.sizes) || {}, ((_b$spinner = b.spinner) == null ? void 0 : _b$spinner.sizes) || {}),
61
+ thickness: mergeIntoNewObject(((_a$spinner2 = a.spinner) == null ? void 0 : _a$spinner2.thickness) || {}, ((_b$spinner2 = b.spinner) == null ? void 0 : _b$spinner2.thickness) || {})
53
62
  })
54
63
  });
55
64
  }
@@ -24,7 +24,7 @@ export var setRootStyles = function setRootStyles(themeId, styles) {
24
24
  sheet.insertRule(styleString, 0);
25
25
  };
26
26
  export var defaultColorProperties = objectToCSSProperties('colors', flattenPalette(defaultTheme.colors));
27
- export 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 font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';\n flex-grow: 0;\n flex-shrink: 0;\n flex-basis: auto;\n font-weight: 400;\n margin: 0px;\n min-height: 0px;\n min-width: 0px;\n padding: 0px;\n text-decoration: none;\n}\n\n.tapestry-react-reset *::-moz-focus-inner {\n border: none;\n padding: 0px;\n}\n\n.tapestry-react-reset *:focus:not(.focus-visible) {\n outline: 0px;\n}\n" // minify string
27
+ export 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
28
28
  ).replace(/\n/g, '').replace(/\s\s+/g, ' '); // we use our own global style implementation in place of Emotion Global
29
29
  // so we can have more control over when styles are injected since multiple
30
30
  // Providers can be used on a page
@@ -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: 3,
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, useCallback, useImperativeHandle, useEffect } from 'react';
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 isFocused = false;
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); // prevents tooltips showing when focused and navigating back to a page after leaving
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
- var createOpenTimeout = useCallback(function () {
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
- var createCloseTimeout = useCallback(function () {
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
- var handleFocus = useCallback(function () {
130
- if (isPageInView && !isMouseDown) {
129
+ };
130
+
131
+ var handleFocus = function handleFocus() {
132
+ if (isPageInView.current && !isMouseDown.current) {
131
133
  open();
132
134
  }
133
- });
134
- var handleMouseDown = useCallback(function () {
135
- isMouseDown = true;
135
+ };
136
+
137
+ var handleMouseDown = function handleMouseDown() {
138
+ isMouseDown.current = true;
136
139
  close();
137
- });
138
- var handleMouseUp = useCallback(function () {
139
- isMouseDown = false;
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,
@@ -37,7 +37,7 @@ export default function SplitStyles(_ref) {
37
37
  }
38
38
 
39
39
  return _objectSpread(_objectSpread({}, restProps), {}, {
40
- className: className,
40
+ className: className ? "tapestry-react-reset " + className : "tapestry-react-reset",
41
41
  css: function css(theme) {
42
42
  var propStyles = {};
43
43
 
@@ -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 { get } from 'lodash';
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 { kebabCase } from 'lodash';
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
- export declare function ThemeProvider({ theme, children, ...boxProps }: {
11
+ declare type Props = {
12
12
  theme?: Theme;
13
13
  children: React.ReactNode;
14
- boxProps?: BoxProps;
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;
@@ -350,7 +350,7 @@ export const Checkbox: HTMLInputWrapperComponent
350
350
  // Input
351
351
  // =====
352
352
 
353
- export const Input: CommonComponent & {
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.0-rc.8",
3
+ "version": "2.6.0",
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.3.1",
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.11.0",
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.1.1"
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(
@@ -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
  ) {
@@ -242,7 +242,7 @@ export type Props = {
242
242
  onColumnSort?: Function,
243
243
 
244
244
  /**
245
- * `(rowData: any, rowIndex: number) => void`
245
+ * `(rowData: any, rowIndex: number, event: React.SyntheticEvent) => void`
246
246
  *
247
247
  * Callback when a row has been clicked.
248
248
  */
@@ -480,7 +480,7 @@ const DataTable = (props: Props) => {
480
480
  <div
481
481
  role={getRowLink ? undefined : 'grid'}
482
482
  style={isLoadingOrEmpty ? { display: 'none' } : undefined}
483
- className={css({ position: 'relative' })}
483
+ className={`tapestry-react-reset ${css({ position: 'relative' })}`}
484
484
  >
485
485
  <div
486
486
  ref={headerRef}
@@ -500,7 +500,10 @@ const DataTable = (props: Props) => {
500
500
  column={column}
501
501
  columnIndex={columnIndex}
502
502
  columnSort={columnSort}
503
- className={css([...cellVariantClassName, column.css])}
503
+ className={`tapestry-react-reset ${css([
504
+ ...cellVariantClassName,
505
+ column.css,
506
+ ])}`}
504
507
  />
505
508
  )
506
509
  })}
@@ -524,7 +527,10 @@ const DataTable = (props: Props) => {
524
527
  key={columnIndex}
525
528
  role="cell"
526
529
  ref={getColumnRef(`${columnIndex}.${data.length + 1}`)}
527
- className={css([...cellVariantClassName, column.css])}
530
+ className={`tapestry-react-reset ${css([
531
+ ...cellVariantClassName,
532
+ column.css,
533
+ ])}`}
528
534
  >
529
535
  {typeof column.footer === 'string' ||
530
536
  React.isValidElement(column.footer)
@@ -19,7 +19,7 @@ function BodyRow({
19
19
  } = useKeyboardShortcuts(keyboardShortcuts, { rowData, rowIndex })
20
20
  const props = {
21
21
  ref: innerRef,
22
- onClick: onRowClick && (() => onRowClick(rowData, rowIndex)),
22
+ onClick: (event) => onRowClick && onRowClick(rowData, rowIndex, event),
23
23
  onMouseEnter: bindKeyboardShortcuts,
24
24
  onMouseLeave: unbindKeyboardShortcuts,
25
25
  style: {
@@ -38,7 +38,10 @@ function BodyRows({
38
38
  key={columnIndex}
39
39
  ref={getColumnRef(`${columnIndex}.${rowIndex + 1}`)} // offset by 1 to account for header row
40
40
  role="cell"
41
- className={css([...cellVariantStyles, column.css])}
41
+ className={`tapestry-react-reset ${css([
42
+ ...cellVariantStyles,
43
+ column.css,
44
+ ])}`}
42
45
  >
43
46
  {getCell(column.cell, {
44
47
  columnIndex,
@@ -64,7 +67,7 @@ function BodyRows({
64
67
  rowIndex,
65
68
  keyboardShortcuts,
66
69
  onRowClick,
67
- className: css(rowVariantClassName),
70
+ className: `tapestry-react-reset ${css(rowVariantClassName)}`,
68
71
  ...getRowLinkProps({ getRowLink, data: rowData, isSubRow: false }),
69
72
  }
70
73
  const subRowData = getSubData ? getSubData(rowData) : null
@@ -57,7 +57,7 @@ const BodySubRows = ({
57
57
  rowIndex={rowIndex}
58
58
  keyboardShortcuts={keyboardShortcuts}
59
59
  onRowClick={onRowClick}
60
- className={css(rowVariantClassName)}
60
+ className={`tapestry-react-reset ${css(rowVariantClassName)}`}
61
61
  {...getRowLinkProps({ getRowLink, data: rowData, isSubRow: true })}
62
62
  >
63
63
  {columns.map((column, columnIndex) => {
@@ -77,7 +77,10 @@ const BodySubRows = ({
77
77
  ref={getColumnRef(
78
78
  `${columnIndex}.${parentRowIndex + 1}.${rowIndex}`
79
79
  )}
80
- className={css([...cellVariantClassName, column.css])}
80
+ className={`tapestry-react-reset ${css([
81
+ ...cellVariantClassName,
82
+ column.css,
83
+ ])}`}
81
84
  >
82
85
  {getCell(
83
86
  column.subCell !== undefined ? column.subCell : column.cell,
@@ -87,22 +87,22 @@ function CheckboxCell({
87
87
  onFocus={onFocus}
88
88
  onClick={handleChange}
89
89
  onKeyDown={(event) => event.key === ' ' && handleChange(event)}
90
- className="tapestry-react-Checkbox"
90
+ className="tapestry-react-reset tapestry-react-Checkbox"
91
91
  css={cssStyles}
92
92
  >
93
93
  <Icon.Path
94
94
  name={iconPaths.fill}
95
- className="tapestry-react-Checkbox-Fill"
95
+ className="tapestry-react-reset tapestry-react-Checkbox-Fill"
96
96
  fill={checked || indeterminate ? 'primary' : 'surfaceTertiary'}
97
97
  stroke={checked || indeterminate ? 'primary' : 'separatorSecondary'}
98
98
  />
99
99
  <Icon.Path
100
100
  name={iconPaths.minus}
101
- className="tapestry-react-Checkbox-Minus"
101
+ className="tapestry-react-reset tapestry-react-Checkbox-Fill"
102
102
  />
103
103
  <Icon.Path
104
104
  name={iconPaths.checked}
105
- className="tapestry-react-Checkbox-Checked"
105
+ className="tapestry-react-reset tapestry-react-Checkbox-Checked"
106
106
  />
107
107
  </Icon>
108
108
  )
@@ -1,6 +1,6 @@
1
1
  import { createContext, useCallback, useContext, useEffect } from 'react'
2
2
  import useConstant from '../../hooks/useConstant'
3
- import create from 'zustand'
3
+ import { create } from 'zustand'
4
4
 
5
5
  import { range } from '../../utils'
6
6