@planningcenter/tapestry-react 2.1.2 → 2.3.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 (88) hide show
  1. package/dist/cjs/Badge/Badge.js +5 -1
  2. package/dist/cjs/Button/Button.js +6 -3
  3. package/dist/cjs/Card/Card.js +5 -2
  4. package/dist/cjs/Combobox/Combobox.js +16 -43
  5. package/dist/cjs/Combobox/ComboboxInput.js +112 -146
  6. package/dist/cjs/Combobox/ComboboxItem.js +38 -53
  7. package/dist/cjs/Combobox/ComboboxItems.js +41 -58
  8. package/dist/cjs/Combobox/index.js +12 -0
  9. package/dist/cjs/DateField/DateField.js +109 -128
  10. package/dist/cjs/Field/Field.js +80 -106
  11. package/dist/cjs/Menu/Item.js +1 -0
  12. package/dist/cjs/Popover/utils.js +1 -0
  13. package/dist/cjs/SegmentedControl/SegmentedControl.js +89 -111
  14. package/dist/cjs/SegmentedTabs/SegmentedTabs.js +54 -84
  15. package/dist/cjs/Tabs/Tab.js +9 -6
  16. package/dist/cjs/Tabs/TabList.js +49 -64
  17. package/dist/cjs/Tabs/TabPanel.js +6 -2
  18. package/dist/cjs/Tabs/TabPanels.js +14 -27
  19. package/dist/cjs/Tabs/Tabs.js +72 -106
  20. package/dist/cjs/Tabs/index.js +12 -0
  21. package/dist/cjs/ThemeProvider/ThemeProvider.js +1 -1
  22. package/dist/cjs/Tooltip/Tooltip.js +158 -182
  23. package/dist/cjs/Wizard/Wizard.js +143 -193
  24. package/dist/cjs/Wizard/index.js +3 -0
  25. package/dist/esm/Badge/Badge.js +5 -1
  26. package/dist/esm/Button/Button.js +6 -3
  27. package/dist/esm/Card/Card.js +5 -2
  28. package/dist/esm/Combobox/Combobox.js +18 -43
  29. package/dist/esm/Combobox/ComboboxInput.js +111 -149
  30. package/dist/esm/Combobox/ComboboxItem.js +38 -52
  31. package/dist/esm/Combobox/ComboboxItems.js +38 -56
  32. package/dist/esm/Combobox/index.js +8 -0
  33. package/dist/esm/DateField/DateField.js +106 -133
  34. package/dist/esm/Field/Field.js +76 -103
  35. package/dist/esm/Menu/Item.js +1 -0
  36. package/dist/esm/Popover/utils.js +1 -0
  37. package/dist/esm/SegmentedControl/SegmentedControl.js +90 -114
  38. package/dist/esm/SegmentedTabs/SegmentedTabs.js +51 -83
  39. package/dist/esm/Tabs/Tab.js +8 -6
  40. package/dist/esm/Tabs/TabList.js +49 -66
  41. package/dist/esm/Tabs/TabPanel.js +4 -2
  42. package/dist/esm/Tabs/TabPanels.js +14 -28
  43. package/dist/esm/Tabs/Tabs.js +76 -120
  44. package/dist/esm/Tabs/index.js +8 -0
  45. package/dist/esm/ThemeProvider/ThemeProvider.js +1 -1
  46. package/dist/esm/Tooltip/Tooltip.js +154 -195
  47. package/dist/esm/Wizard/Wizard.js +144 -201
  48. package/dist/esm/Wizard/index.js +2 -0
  49. package/dist/types/Popover/utils.d.ts +3 -0
  50. package/package.json +1 -1
  51. package/src/.DS_Store +0 -0
  52. package/src/Badge/Badge.js +5 -0
  53. package/src/Button/Button.tsx +6 -3
  54. package/src/Card/Card.tsx +22 -1
  55. package/src/Combobox/Combobox.js +18 -32
  56. package/src/Combobox/Combobox.mdx +1 -0
  57. package/src/Combobox/Combobox.test.js +1 -1
  58. package/src/Combobox/ComboboxInput.js +111 -105
  59. package/src/Combobox/ComboboxItem.js +27 -27
  60. package/src/Combobox/ComboboxItems.js +38 -60
  61. package/src/Combobox/index.js +8 -0
  62. package/src/DateField/DateField.js +109 -105
  63. package/src/DateField/DateField.mdx +1 -0
  64. package/src/Field/Field.js +85 -93
  65. package/src/Field/Field.mdx +1 -0
  66. package/src/Menu/Heading.js +5 -1
  67. package/src/Menu/Heading.mdx +20 -0
  68. package/src/Menu/Item.js +13 -1
  69. package/src/Menu/Item.mdx +18 -0
  70. package/src/Menu/Menu.mdx +1 -0
  71. package/src/Popover/utils.ts +1 -0
  72. package/src/SegmentedControl/SegmentedControl.js +88 -92
  73. package/src/SegmentedControl/SegmentedControl.mdx +1 -0
  74. package/src/SegmentedTabs/SegmentedTabs.js +51 -71
  75. package/src/SegmentedTabs/SegmentedTabs.mdx +1 -0
  76. package/src/Tabs/Tab.js +3 -1
  77. package/src/Tabs/TabList.js +56 -62
  78. package/src/Tabs/TabPanel.js +2 -1
  79. package/src/Tabs/TabPanels.js +14 -15
  80. package/src/Tabs/Tabs.js +63 -84
  81. package/src/Tabs/Tabs.mdx +16 -17
  82. package/src/Tabs/index.js +8 -0
  83. package/src/ThemeProvider/ThemeProvider.tsx +1 -1
  84. package/src/Tooltip/Tooltip.js +142 -160
  85. package/src/Tooltip/Tooltip.mdx +1 -0
  86. package/src/Wizard/Wizard.js +141 -170
  87. package/src/Wizard/Wizard.mdx +3 -2
  88. package/src/Wizard/index.js +2 -0
@@ -1,129 +1,105 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
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, { forwardRef, useCallback, useImperativeHandle, useRef, useState, useEffect } from 'react';
7
4
  import Button from '../Button';
8
5
  import InputBox from '../Input/InputBox';
9
6
  import { navigateSize } from '../system';
7
+ import { useThemeProps } from '../system';
8
+
9
+ function SegmentedControl(props, ref) {
10
+ var getActiveIndex = useCallback(function (props) {
11
+ return props.activeSegment === undefined ? 0 : props.segments.indexOf(props.activeSegment);
12
+ });
13
+ var inputBoxRef = useRef(null);
14
+
15
+ var _useThemeProps = useThemeProps('segmentedControl', props),
16
+ activeSegment = _useThemeProps.activeSegment,
17
+ _useThemeProps$color = _useThemeProps.color,
18
+ color = _useThemeProps$color === void 0 ? 'primary' : _useThemeProps$color,
19
+ disabled = _useThemeProps.disabled,
20
+ onChange = _useThemeProps.onChange,
21
+ segments = _useThemeProps.segments,
22
+ _useThemeProps$segmen = _useThemeProps.segmentBasis,
23
+ segmentBasis = _useThemeProps$segmen === void 0 ? 'auto' : _useThemeProps$segmen,
24
+ _useThemeProps$size = _useThemeProps.size,
25
+ size = _useThemeProps$size === void 0 ? 'md' : _useThemeProps$size,
26
+ restProps = _objectWithoutPropertiesLoose(_useThemeProps, ["activeSegment", "color", "disabled", "onChange", "segments", "segmentBasis", "size"]);
27
+
28
+ var _useState = useState(getActiveIndex(props)),
29
+ activeIndex = _useState[0],
30
+ setActiveIndex = _useState[1];
31
+
32
+ var handleKeyDown = useCallback(function (event) {
33
+ if (onChange && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
34
+ var amountToMove = event.key === 'ArrowLeft' ? -1 : 1;
35
+ var nextIndex = activeIndex + amountToMove;
36
+ event.preventDefault();
37
+ changeSegment(nextIndex);
38
+ }
39
+ });
40
+ var changeSegment = useCallback(function (index) {
41
+ var nextSegment = segments[index];
10
42
 
11
- var SegmentedControl = /*#__PURE__*/function (_Component) {
12
- _inheritsLoose(SegmentedControl, _Component);
13
-
14
- function SegmentedControl(_props) {
15
- var _this;
16
-
17
- _this = _Component.call(this, _props) || this;
18
-
19
- _defineProperty(_assertThisInitialized(_this), "getActiveIndex", function (props) {
20
- return props.activeSegment === undefined ? 0 : props.segments.indexOf(props.activeSegment);
21
- });
22
-
23
- _defineProperty(_assertThisInitialized(_this), "setInputBox", function (component) {
24
- _this.inputBox = component;
25
- });
26
-
27
- _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) {
28
- if (_this.props.onChange && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
29
- var amountToMove = event.key === 'ArrowLeft' ? -1 : 1;
30
- var nextIndex = _this.state.activeIndex + amountToMove;
31
- event.preventDefault();
32
-
33
- _this.changeSegment(nextIndex);
43
+ if (nextSegment) {
44
+ if (activeSegment === undefined) {
45
+ setActiveIndex(index);
34
46
  }
35
- });
36
-
37
- _defineProperty(_assertThisInitialized(_this), "changeSegment", function (index) {
38
- var nextSegment = _this.props.segments[index];
39
-
40
- if (nextSegment) {
41
- if (_this.props.activeSegment === undefined) {
42
- _this.setState({
43
- activeIndex: index
44
- });
45
- }
46
-
47
- if (_this.props.onChange) {
48
- _this.props.onChange(nextSegment.title || nextSegment);
49
- }
50
47
 
51
- _this.focus(index);
48
+ if (onChange) {
49
+ onChange(nextSegment.title || nextSegment);
52
50
  }
53
- });
54
51
 
55
- _this.state = {
56
- activeIndex: _this.getActiveIndex(_props)
52
+ focus(index);
53
+ }
54
+ });
55
+ var focus = useCallback(function (index) {
56
+ return inputBoxRef.current.focus(index);
57
+ });
58
+ var blur = useCallback(function () {
59
+ return inputBoxRef.current.blur();
60
+ });
61
+ useImperativeHandle(ref, function () {
62
+ return {
63
+ focus: focus,
64
+ blur: blur
57
65
  };
58
- return _this;
59
- }
60
-
61
- var _proto = SegmentedControl.prototype;
66
+ });
67
+ useEffect(function () {
68
+ var newActiveIndex = getActiveIndex(props);
62
69
 
63
- _proto.componentDidUpdate = function componentDidUpdate(lastProps) {
64
- if (lastProps.activeSegment !== this.props.activeSegment) {
65
- this.setState({
66
- activeIndex: this.getActiveIndex(this.props)
67
- });
70
+ if (activeIndex !== newActiveIndex) {
71
+ setActiveIndex(newActiveIndex);
68
72
  }
69
- };
70
-
71
- _proto.focus = function focus(index) {
72
- this.inputBox.focus(index);
73
- };
74
-
75
- _proto.blur = function blur() {
76
- this.inputBox.blur();
77
- };
78
-
79
- _proto.render = function render() {
80
- var _this2 = this;
81
-
82
- var _this$props = this.props,
83
- activeSegment = _this$props.activeSegment,
84
- _this$props$color = _this$props.color,
85
- color = _this$props$color === void 0 ? 'primary' : _this$props$color,
86
- disabled = _this$props.disabled,
87
- onChange = _this$props.onChange,
88
- segments = _this$props.segments,
89
- _this$props$segmentBa = _this$props.segmentBasis,
90
- segmentBasis = _this$props$segmentBa === void 0 ? 'auto' : _this$props$segmentBa,
91
- _this$props$size = _this$props.size,
92
- size = _this$props$size === void 0 ? 'md' : _this$props$size,
93
- restProps = _objectWithoutPropertiesLoose(_this$props, ["activeSegment", "color", "disabled", "onChange", "segments", "segmentBasis", "size"]);
94
-
95
- var activeIndex = this.state.activeIndex;
96
- return /*#__PURE__*/React.createElement(InputBox, _extends({
97
- ref: this.setInputBox,
98
- size: size,
99
- includeSpacing: true,
100
- evenPadding: true,
101
- role: "group",
102
- cursor: "initial",
103
- disabled: disabled
104
- }, restProps), segments.map(function (segment, segmentIndex) {
105
- var title = segment.title,
106
- restSegmentProps = _objectWithoutPropertiesLoose(segment, ["title"]);
107
-
108
- var buttonProps = title ? restSegmentProps : {};
109
- return /*#__PURE__*/React.createElement(Button, _extends({
110
- key: segmentIndex,
111
- grow: 1,
112
- size: navigateSize(size, -1),
113
- basis: segmentBasis,
114
- theme: segmentIndex === activeIndex ? color : undefined,
115
- variant: segmentIndex === activeIndex ? 'fill' : 'naked',
116
- title: title || segment,
117
- disabled: disabled,
118
- onKeyDown: _this2.handleKeyDown,
119
- onClick: function onClick() {
120
- return segmentIndex !== activeIndex && _this2.changeSegment(segmentIndex);
121
- }
122
- }, buttonProps));
123
- }));
124
- };
125
-
126
- return SegmentedControl;
127
- }(Component);
73
+ }, [activeSegment]);
74
+ return /*#__PURE__*/React.createElement(InputBox, _extends({
75
+ ref: inputBoxRef,
76
+ size: size,
77
+ includeSpacing: true,
78
+ evenPadding: true,
79
+ role: "group",
80
+ cursor: "initial",
81
+ disabled: disabled
82
+ }, restProps), segments.map(function (segment, segmentIndex) {
83
+ var title = segment.title,
84
+ restSegmentProps = _objectWithoutPropertiesLoose(segment, ["title"]);
85
+
86
+ var buttonProps = title ? restSegmentProps : {};
87
+ return /*#__PURE__*/React.createElement(Button, _extends({
88
+ key: segmentIndex,
89
+ grow: 1,
90
+ size: navigateSize(size, -1),
91
+ basis: segmentBasis,
92
+ theme: segmentIndex === activeIndex ? color : undefined,
93
+ variant: segmentIndex === activeIndex ? 'fill' : 'naked',
94
+ title: title || segment,
95
+ disabled: disabled,
96
+ onKeyDown: handleKeyDown,
97
+ onClick: function onClick() {
98
+ return segmentIndex !== activeIndex && changeSegment(segmentIndex);
99
+ }
100
+ }, buttonProps));
101
+ }));
102
+ }
128
103
 
104
+ SegmentedControl = /*#__PURE__*/forwardRef(SegmentedControl);
129
105
  export default SegmentedControl;
@@ -1,11 +1,9 @@
1
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
2
- import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
1
  import _extends from "@babel/runtime/helpers/esm/extends";
5
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
6
- import React, { Component } from 'react';
3
+ import React, { useCallback, useState, useEffect } from 'react';
7
4
  import Text from '../Text';
8
5
  import StackView from '../StackView';
6
+ import { useThemeProps } from '../system';
9
7
 
10
8
  function Tab(_ref) {
11
9
  var isSelected = _ref.isSelected,
@@ -32,48 +30,21 @@ function Tab(_ref) {
32
30
  }, restProps));
33
31
  }
34
32
 
35
- var SegmentedTabs = /*#__PURE__*/function (_Component) {
36
- _inheritsLoose(SegmentedTabs, _Component);
37
-
38
- function SegmentedTabs(props) {
39
- var _this;
40
-
41
- _this = _Component.call(this, props) || this;
42
-
43
- _defineProperty(_assertThisInitialized(_this), "setIndex", function (index) {
44
- if (_this.props.activeTab === undefined) {
45
- _this.setState({
46
- activeIndex: index
47
- });
48
- }
49
-
50
- if (_this.props.onChange) {
51
- _this.props.onChange(_this.props.tabs[index]);
52
- }
53
- });
54
-
55
- _this.state = {
56
- activeIndex: _this.getActiveIndex(props)
57
- };
58
- return _this;
59
- }
60
-
61
- var _proto = SegmentedTabs.prototype;
62
-
63
- _proto.componentDidUpdate = function componentDidUpdate(lastProps) {
64
- if (this.props.activeTab) {
65
- var lastActiveIndex = this.getActiveIndex(lastProps);
66
- var nextActiveIndex = this.getActiveIndex(this.props);
67
-
68
- if (lastActiveIndex !== nextActiveIndex || this.state.activeIndex !== nextActiveIndex) {
69
- this.setState({
70
- activeIndex: nextActiveIndex
71
- });
72
- }
73
- }
74
- };
33
+ function SegmentedTabs(props) {
34
+ var _useThemeProps = useThemeProps('segmentedTabs', props),
35
+ activeTab = _useThemeProps.activeTab,
36
+ _useThemeProps$color = _useThemeProps.color,
37
+ color = _useThemeProps$color === void 0 ? 'primary' : _useThemeProps$color,
38
+ _useThemeProps$getTab = _useThemeProps.getTabLabel,
39
+ getTabLabel = _useThemeProps$getTab === void 0 ? function (tab) {
40
+ return tab;
41
+ } : _useThemeProps$getTab,
42
+ onChange = _useThemeProps.onChange,
43
+ tabs = _useThemeProps.tabs,
44
+ tabProps = _useThemeProps.tabProps,
45
+ restProps = _objectWithoutPropertiesLoose(_useThemeProps, ["activeTab", "color", "getTabLabel", "onChange", "tabs", "tabProps"]);
75
46
 
76
- _proto.getActiveIndex = function getActiveIndex(_ref2) {
47
+ var getActiveIndex = useCallback(function (_ref2) {
77
48
  var activeTab = _ref2.activeTab,
78
49
  tabs = _ref2.tabs;
79
50
  var index;
@@ -91,47 +62,44 @@ var SegmentedTabs = /*#__PURE__*/function (_Component) {
91
62
  }
92
63
 
93
64
  return index;
94
- };
95
-
96
- _proto.render = function render() {
97
- var _this2 = this;
65
+ });
98
66
 
99
- var _this$props = this.props,
100
- activeTab = _this$props.activeTab,
101
- color = _this$props.color,
102
- getTabLabel = _this$props.getTabLabel,
103
- onChange = _this$props.onChange,
104
- tabs = _this$props.tabs,
105
- tabProps = _this$props.tabProps,
106
- restProps = _objectWithoutPropertiesLoose(_this$props, ["activeTab", "color", "getTabLabel", "onChange", "tabs", "tabProps"]);
67
+ var _useState = useState(getActiveIndex(props)),
68
+ activeIndex = _useState[0],
69
+ setActiveIndex = _useState[1];
107
70
 
108
- var activeIndex = this.state.activeIndex;
109
- return /*#__PURE__*/React.createElement(StackView, _extends({
110
- role: "group",
111
- axis: "horizontal",
112
- distribution: "fill",
113
- position: "relative"
114
- }, restProps), tabs.map(function (tab, index) {
115
- return /*#__PURE__*/React.createElement(Tab, _extends({
116
- key: index,
117
- index: index,
118
- isSelected: index === activeIndex,
119
- selectedColor: color,
120
- onSelect: function onSelect() {
121
- return _this2.setIndex(index);
122
- }
123
- }, tabProps), getTabLabel(tab));
124
- }));
125
- };
71
+ var setIndex = useCallback(function (index) {
72
+ if (activeTab === undefined) {
73
+ setActiveIndex(index);
74
+ }
126
75
 
127
- return SegmentedTabs;
128
- }(Component);
76
+ if (onChange) {
77
+ onChange(tabs[index]);
78
+ }
79
+ });
80
+ useEffect(function () {
81
+ var newActiveIndex = getActiveIndex(props);
129
82
 
130
- _defineProperty(SegmentedTabs, "defaultProps", {
131
- color: 'primary',
132
- getTabLabel: function getTabLabel(tab) {
133
- return tab;
134
- }
135
- });
83
+ if (activeIndex !== newActiveIndex) {
84
+ setActiveIndex(newActiveIndex);
85
+ }
86
+ }, [activeTab]);
87
+ return /*#__PURE__*/React.createElement(StackView, _extends({
88
+ role: "group",
89
+ axis: "horizontal",
90
+ distribution: "fill",
91
+ position: "relative"
92
+ }, restProps), tabs.map(function (tab, index) {
93
+ return /*#__PURE__*/React.createElement(Tab, _extends({
94
+ key: index,
95
+ index: index,
96
+ isSelected: index === activeIndex,
97
+ selectedColor: color,
98
+ onSelect: function onSelect() {
99
+ return setIndex(index);
100
+ }
101
+ }, tabProps), getTabLabel(tab));
102
+ }));
103
+ }
136
104
 
137
105
  export default SegmentedTabs;
@@ -3,14 +3,16 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  import React from 'react';
4
4
  import StackView from '../StackView';
5
5
  import { useHover } from '../hooks';
6
+ import { useThemeProps } from '../system';
6
7
 
7
8
  function Tab(props) {
8
- var axis = props.axis,
9
- children = props.children,
10
- disabled = props.disabled,
11
- id = props.id,
12
- isActive = props.isActive,
13
- restProps = _objectWithoutPropertiesLoose(props, ["axis", "children", "disabled", "id", "isActive"]);
9
+ var _useThemeProps = useThemeProps('tabs.tab', props),
10
+ axis = _useThemeProps.axis,
11
+ children = _useThemeProps.children,
12
+ disabled = _useThemeProps.disabled,
13
+ id = _useThemeProps.id,
14
+ isActive = _useThemeProps.isActive,
15
+ restProps = _objectWithoutPropertiesLoose(_useThemeProps, ["axis", "children", "disabled", "id", "isActive"]);
14
16
 
15
17
  var _useHover = useHover(),
16
18
  hover = _useHover.hover,
@@ -1,78 +1,61 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
4
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
- import React, { Component, Children, cloneElement } from 'react';
3
+ import React, { Children, cloneElement } from 'react';
6
4
  import StackView from '../StackView';
5
+ import { useThemeProps } from '../system';
7
6
  export var TABLIST_DISPLAY_NAME = 'TabList';
8
7
 
9
- var TabList = /*#__PURE__*/function (_Component) {
10
- _inheritsLoose(TabList, _Component);
11
-
12
- function TabList() {
13
- return _Component.apply(this, arguments) || this;
14
- }
15
-
16
- var _proto = TabList.prototype;
17
-
18
- _proto.render = function render() {
19
- var _this$props = this.props,
20
- activeIndex = _this$props.activeIndex,
21
- axis = _this$props.axis,
22
- children = _this$props.children,
23
- id = _this$props.id,
24
- moveTabFocus = _this$props.moveTabFocus,
25
- setActiveIndex = _this$props.setActiveIndex,
26
- restProps = _objectWithoutPropertiesLoose(_this$props, ["activeIndex", "axis", "children", "id", "moveTabFocus", "setActiveIndex"]);
27
-
28
- var backwardKey = axis === 'horizontal' ? 'ArrowLeft' : 'ArrowUp';
29
- var forwardKey = axis === 'horizontal' ? 'ArrowRight' : 'ArrowDown';
30
- return /*#__PURE__*/React.createElement(StackView, _extends({
31
- role: "tablist",
32
- "aria-orientation": axis,
8
+ function TabList(props) {
9
+ var _useThemeProps = useThemeProps('tabs.tabList', props),
10
+ activeIndex = _useThemeProps.activeIndex,
11
+ _useThemeProps$axis = _useThemeProps.axis,
12
+ axis = _useThemeProps$axis === void 0 ? 'horizontal' : _useThemeProps$axis,
13
+ children = _useThemeProps.children,
14
+ id = _useThemeProps.id,
15
+ moveTabFocus = _useThemeProps.moveTabFocus,
16
+ setActiveIndex = _useThemeProps.setActiveIndex,
17
+ restProps = _objectWithoutPropertiesLoose(_useThemeProps, ["activeIndex", "axis", "children", "id", "moveTabFocus", "setActiveIndex"]);
18
+
19
+ var backwardKey = axis === 'horizontal' ? 'ArrowLeft' : 'ArrowUp';
20
+ var forwardKey = axis === 'horizontal' ? 'ArrowRight' : 'ArrowDown';
21
+ return /*#__PURE__*/React.createElement(StackView, _extends({
22
+ role: "tablist",
23
+ "aria-orientation": axis,
24
+ axis: axis,
25
+ distribution: "fill"
26
+ }, restProps), Children.map(children, function (child, index) {
27
+ return /*#__PURE__*/cloneElement(child, {
33
28
  axis: axis,
34
- distribution: "fill"
35
- }, restProps), Children.map(children, function (child, index) {
36
- return /*#__PURE__*/cloneElement(child, {
37
- axis: axis,
38
- id: id + "-" + index,
39
- isActive: index === activeIndex,
40
- tabIndex: child.props.disabled ? undefined : index !== activeIndex ? -1 : 0,
41
- onFocus: function onFocus() {
42
- return setActiveIndex(index);
43
- },
44
- onKeyDown: function onKeyDown(event) {
45
- if (event.key === backwardKey) {
46
- event.preventDefault();
47
- moveTabFocus(-1);
48
- }
49
-
50
- if (event.key === forwardKey) {
51
- event.preventDefault();
52
- moveTabFocus(1);
53
- }
54
-
55
- if (event.key === 'Home') {
56
- event.preventDefault();
57
- moveTabFocus(0);
58
- }
59
-
60
- if (event.key === 'End') {
61
- event.preventDefault();
62
- moveTabFocus(Children.count(children) - 1);
63
- }
29
+ id: id + "-" + index,
30
+ isActive: index === activeIndex,
31
+ tabIndex: child.props.disabled ? undefined : index !== activeIndex ? -1 : 0,
32
+ onFocus: function onFocus() {
33
+ return setActiveIndex(index);
34
+ },
35
+ onKeyDown: function onKeyDown(event) {
36
+ if (event.key === backwardKey) {
37
+ event.preventDefault();
38
+ moveTabFocus(-1);
64
39
  }
65
- });
66
- }));
67
- };
68
40
 
69
- return TabList;
70
- }(Component);
41
+ if (event.key === forwardKey) {
42
+ event.preventDefault();
43
+ moveTabFocus(1);
44
+ }
71
45
 
72
- _defineProperty(TabList, "displayName", TABLIST_DISPLAY_NAME);
46
+ if (event.key === 'Home') {
47
+ event.preventDefault();
48
+ moveTabFocus(0);
49
+ }
73
50
 
74
- _defineProperty(TabList, "defaultProps", {
75
- axis: 'horizontal'
76
- });
51
+ if (event.key === 'End') {
52
+ event.preventDefault();
53
+ moveTabFocus(Children.count(children) - 1);
54
+ }
55
+ }
56
+ });
57
+ }));
58
+ }
77
59
 
60
+ TabList.displayName = TABLIST_DISPLAY_NAME;
78
61
  export default TabList;
@@ -2,10 +2,12 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  import React from 'react';
4
4
  import Box from '../Box';
5
+ import { useThemeProps } from '../system';
5
6
 
6
7
  function TabPanel(props) {
7
- var activeId = props.activeId,
8
- restProps = _objectWithoutPropertiesLoose(props, ["activeId"]);
8
+ var _useThemeProps = useThemeProps('tabs.tabPanel', props),
9
+ activeId = _useThemeProps.activeId,
10
+ restProps = _objectWithoutPropertiesLoose(_useThemeProps, ["activeId"]);
9
11
 
10
12
  return /*#__PURE__*/React.createElement(Box, _extends({
11
13
  role: "tabpanel",
@@ -1,35 +1,21 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
- import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- import React, { Component, cloneElement } from 'react';
2
+ import React, { cloneElement } from 'react';
5
3
  import Box from '../Box';
4
+ import { useThemeProps } from '../system';
6
5
  export var TABPANELS_DISPLAY_NAME = 'TabPanels';
7
6
 
8
- var TabPanels = /*#__PURE__*/function (_Component) {
9
- _inheritsLoose(TabPanels, _Component);
7
+ function TabPanels(props) {
8
+ var _useThemeProps = useThemeProps('tabs.tabPanels', props),
9
+ activeIndex = _useThemeProps.activeIndex,
10
+ children = _useThemeProps.children,
11
+ id = _useThemeProps.id,
12
+ restProps = _objectWithoutPropertiesLoose(_useThemeProps, ["activeIndex", "children", "id"]);
10
13
 
11
- function TabPanels() {
12
- return _Component.apply(this, arguments) || this;
13
- }
14
-
15
- var _proto = TabPanels.prototype;
16
-
17
- _proto.render = function render() {
18
- var _this$props = this.props,
19
- activeIndex = _this$props.activeIndex,
20
- children = _this$props.children,
21
- id = _this$props.id,
22
- restProps = _objectWithoutPropertiesLoose(_this$props, ["activeIndex", "children", "id"]);
23
-
24
- var child = children[activeIndex];
25
- return /*#__PURE__*/React.createElement(Box, restProps, child ? /*#__PURE__*/cloneElement(child, {
26
- activeId: id + "-" + activeIndex
27
- }) : null);
28
- };
29
-
30
- return TabPanels;
31
- }(Component);
32
-
33
- _defineProperty(TabPanels, "displayName", TABPANELS_DISPLAY_NAME);
14
+ var child = children[activeIndex];
15
+ return /*#__PURE__*/React.createElement(Box, restProps, child ? /*#__PURE__*/cloneElement(child, {
16
+ activeId: id + "-" + activeIndex
17
+ }) : null);
18
+ }
34
19
 
20
+ TabPanels.displayName = TABPANELS_DISPLAY_NAME;
35
21
  export default TabPanels;