@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.
- package/dist/cjs/Badge/Badge.js +5 -1
- package/dist/cjs/Button/Button.js +6 -3
- package/dist/cjs/Card/Card.js +5 -2
- package/dist/cjs/Combobox/Combobox.js +16 -43
- package/dist/cjs/Combobox/ComboboxInput.js +112 -146
- package/dist/cjs/Combobox/ComboboxItem.js +38 -53
- package/dist/cjs/Combobox/ComboboxItems.js +41 -58
- package/dist/cjs/Combobox/index.js +12 -0
- package/dist/cjs/DateField/DateField.js +109 -128
- package/dist/cjs/Field/Field.js +80 -106
- package/dist/cjs/Menu/Item.js +1 -0
- package/dist/cjs/Popover/utils.js +1 -0
- package/dist/cjs/SegmentedControl/SegmentedControl.js +89 -111
- package/dist/cjs/SegmentedTabs/SegmentedTabs.js +54 -84
- package/dist/cjs/Tabs/Tab.js +9 -6
- package/dist/cjs/Tabs/TabList.js +49 -64
- package/dist/cjs/Tabs/TabPanel.js +6 -2
- package/dist/cjs/Tabs/TabPanels.js +14 -27
- package/dist/cjs/Tabs/Tabs.js +72 -106
- package/dist/cjs/Tabs/index.js +12 -0
- package/dist/cjs/ThemeProvider/ThemeProvider.js +1 -1
- package/dist/cjs/Tooltip/Tooltip.js +158 -182
- package/dist/cjs/Wizard/Wizard.js +143 -193
- package/dist/cjs/Wizard/index.js +3 -0
- package/dist/esm/Badge/Badge.js +5 -1
- package/dist/esm/Button/Button.js +6 -3
- package/dist/esm/Card/Card.js +5 -2
- package/dist/esm/Combobox/Combobox.js +18 -43
- package/dist/esm/Combobox/ComboboxInput.js +111 -149
- package/dist/esm/Combobox/ComboboxItem.js +38 -52
- package/dist/esm/Combobox/ComboboxItems.js +38 -56
- package/dist/esm/Combobox/index.js +8 -0
- package/dist/esm/DateField/DateField.js +106 -133
- package/dist/esm/Field/Field.js +76 -103
- package/dist/esm/Menu/Item.js +1 -0
- package/dist/esm/Popover/utils.js +1 -0
- package/dist/esm/SegmentedControl/SegmentedControl.js +90 -114
- package/dist/esm/SegmentedTabs/SegmentedTabs.js +51 -83
- package/dist/esm/Tabs/Tab.js +8 -6
- package/dist/esm/Tabs/TabList.js +49 -66
- package/dist/esm/Tabs/TabPanel.js +4 -2
- package/dist/esm/Tabs/TabPanels.js +14 -28
- package/dist/esm/Tabs/Tabs.js +76 -120
- package/dist/esm/Tabs/index.js +8 -0
- package/dist/esm/ThemeProvider/ThemeProvider.js +1 -1
- package/dist/esm/Tooltip/Tooltip.js +154 -195
- package/dist/esm/Wizard/Wizard.js +144 -201
- package/dist/esm/Wizard/index.js +2 -0
- package/dist/types/Popover/utils.d.ts +3 -0
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/Badge/Badge.js +5 -0
- package/src/Button/Button.tsx +6 -3
- package/src/Card/Card.tsx +22 -1
- package/src/Combobox/Combobox.js +18 -32
- package/src/Combobox/Combobox.mdx +1 -0
- package/src/Combobox/Combobox.test.js +1 -1
- package/src/Combobox/ComboboxInput.js +111 -105
- package/src/Combobox/ComboboxItem.js +27 -27
- package/src/Combobox/ComboboxItems.js +38 -60
- package/src/Combobox/index.js +8 -0
- package/src/DateField/DateField.js +109 -105
- package/src/DateField/DateField.mdx +1 -0
- package/src/Field/Field.js +85 -93
- package/src/Field/Field.mdx +1 -0
- package/src/Menu/Heading.js +5 -1
- package/src/Menu/Heading.mdx +20 -0
- package/src/Menu/Item.js +13 -1
- package/src/Menu/Item.mdx +18 -0
- package/src/Menu/Menu.mdx +1 -0
- package/src/Popover/utils.ts +1 -0
- package/src/SegmentedControl/SegmentedControl.js +88 -92
- package/src/SegmentedControl/SegmentedControl.mdx +1 -0
- package/src/SegmentedTabs/SegmentedTabs.js +51 -71
- package/src/SegmentedTabs/SegmentedTabs.mdx +1 -0
- package/src/Tabs/Tab.js +3 -1
- package/src/Tabs/TabList.js +56 -62
- package/src/Tabs/TabPanel.js +2 -1
- package/src/Tabs/TabPanels.js +14 -15
- package/src/Tabs/Tabs.js +63 -84
- package/src/Tabs/Tabs.mdx +16 -17
- package/src/Tabs/index.js +8 -0
- package/src/ThemeProvider/ThemeProvider.tsx +1 -1
- package/src/Tooltip/Tooltip.js +142 -160
- package/src/Tooltip/Tooltip.mdx +1 -0
- package/src/Wizard/Wizard.js +141 -170
- package/src/Wizard/Wizard.mdx +3 -2
- 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
|
|
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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
48
|
+
if (onChange) {
|
|
49
|
+
onChange(nextSegment.title || nextSegment);
|
|
52
50
|
}
|
|
53
|
-
});
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var _proto = SegmentedControl.prototype;
|
|
66
|
+
});
|
|
67
|
+
useEffect(function () {
|
|
68
|
+
var newActiveIndex = getActiveIndex(props);
|
|
62
69
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.setState({
|
|
66
|
-
activeIndex: this.getActiveIndex(this.props)
|
|
67
|
-
});
|
|
70
|
+
if (activeIndex !== newActiveIndex) {
|
|
71
|
+
setActiveIndex(newActiveIndex);
|
|
68
72
|
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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, {
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
128
|
-
|
|
76
|
+
if (onChange) {
|
|
77
|
+
onChange(tabs[index]);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
useEffect(function () {
|
|
81
|
+
var newActiveIndex = getActiveIndex(props);
|
|
129
82
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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;
|
package/dist/esm/Tabs/Tab.js
CHANGED
|
@@ -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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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,
|
package/dist/esm/Tabs/TabList.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
70
|
-
|
|
41
|
+
if (event.key === forwardKey) {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
moveTabFocus(1);
|
|
44
|
+
}
|
|
71
45
|
|
|
72
|
-
|
|
46
|
+
if (event.key === 'Home') {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
moveTabFocus(0);
|
|
49
|
+
}
|
|
73
50
|
|
|
74
|
-
|
|
75
|
-
|
|
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
|
|
8
|
-
|
|
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
|
|
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
|
-
|
|
9
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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;
|