@pingux/astro 2.57.0-alpha.7 → 2.57.0-alpha.8

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.
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { Item as Tab } from 'react-stately';
3
+ import { TabProps } from '../../types';
4
+ /**
5
+ * Tab control for dividing up closely-related content.
6
+ * Typically used as a child of the Tabs component.
7
+ */
8
+ export declare const CollectionTab: React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLElement>>;
9
+ export declare const TabLine: (props: any) => React.JSX.Element;
10
+ export default Tab;
@@ -10,12 +10,10 @@ _Object$defineProperty(exports, "__esModule", {
10
10
  });
11
11
  exports["default"] = exports.TabLine = exports.CollectionTab = void 0;
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
13
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
14
13
  var _react = _interopRequireWildcard(require("react"));
15
14
  var _reactAria = require("react-aria");
16
15
  var _reactStately = require("react-stately");
17
16
  var _interactions = require("@react-aria/interactions");
18
- var _propTypes = _interopRequireDefault(require("prop-types"));
19
17
  var _ = require("../..");
20
18
  var _hooks = require("../../hooks");
21
19
  var _orientation = _interopRequireDefault(require("../../utils/devUtils/constants/orientation"));
@@ -23,13 +21,13 @@ var _pendoID = require("../../utils/devUtils/constants/pendoID");
23
21
  var _TabPicker = _interopRequireDefault(require("../TabPicker"));
24
22
  var _Tabs = require("../Tabs");
25
23
  var _react2 = require("@emotion/react");
26
- var _excluded = ["icon", "isDisabled", "separator", "tabLabelProps", "tabLineProps", "content", "titleAttr", "title"];
24
+ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
26
  /**
28
27
  * Tab control for dividing up closely-related content.
29
28
  * Typically used as a child of the Tabs component.
30
29
  */
31
- function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
32
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
30
+
33
31
  var CollectionTab = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
34
32
  var className = props.className,
35
33
  item = props.item,
@@ -41,17 +39,8 @@ var CollectionTab = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
41
39
  var key = item.key,
42
40
  rendered = item.rendered,
43
41
  itemProps = item.props;
44
- var icon = itemProps.icon,
45
- tabDisabled = itemProps.isDisabled,
46
- separator = itemProps.separator,
47
- tabLabelProps = itemProps.tabLabelProps,
48
- tabLineProps = itemProps.tabLineProps,
49
- content = itemProps.content,
50
- titleAttr = itemProps.titleAttr,
51
- title = itemProps.title,
52
- otherItemProps = (0, _objectWithoutProperties2["default"])(itemProps, _excluded);
53
42
  var state = (0, _react.useContext)(_Tabs.TabsContext);
54
- var isDisabled = tabsDisabled || tabDisabled || state.disabledKeys.has(key);
43
+ var isDisabled = tabsDisabled || (itemProps === null || itemProps === void 0 ? void 0 : itemProps.isDisabled) || state.disabledKeys.has(key);
55
44
  var isSelected = state.selectedKey === key;
56
45
  var _useFocusRing = (0, _reactAria.useFocusRing)(),
57
46
  isFocusVisible = _useFocusRing.isFocusVisible,
@@ -68,12 +57,8 @@ var CollectionTab = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
68
57
  isSelected: isSelected
69
58
  }),
70
59
  classNames = _useStatusClasses.classNames;
71
- var tabRef = (0, _react.useRef)();
72
60
  (0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
73
- /* istanbul ignore next */
74
- (0, _react.useImperativeHandle)(ref, function () {
75
- return tabRef.current;
76
- });
61
+ var tabRef = (0, _hooks.useLocalOrForwardRef)(ref);
77
62
  var _useTab = (0, _reactAria.useTab)({
78
63
  key: key,
79
64
  isDisabled: isDisabled
@@ -84,58 +69,33 @@ var CollectionTab = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
84
69
  }, slots === null || slots === void 0 ? void 0 : slots.beforeTab, (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
85
70
  className: classNames,
86
71
  variant: "tab"
87
- }, (0, _reactAria.mergeProps)(focusProps, hoverProps, tabProps), (0, _pendoID.getPendoID)('Tab'), otherItemProps, {
88
- ref: tabRef,
89
- title: titleAttr || undefined
90
- }), icon, (0, _react2.jsx)(_.Text, (0, _extends2["default"])({
72
+ // title={itemProps?.titleAttr || undefined}
73
+ }, (0, _reactAria.mergeProps)(focusProps, hoverProps, tabProps), (0, _pendoID.getPendoID)('Tab'), {
74
+ // {...otherItemProps}
75
+ ref: tabRef
76
+ }, itemProps, {
77
+ role: "tab"
78
+ }), (0, _react2.jsx)(_react["default"].Fragment, null, itemProps === null || itemProps === void 0 ? void 0 : itemProps.icon, (0, _react2.jsx)(_.Text, (0, _extends2["default"])({
91
79
  variant: "tabLabel"
92
- }, tabLabelProps), rendered), isSelected && !isDisabled && (0, _react2.jsx)(TabLine, tabLineProps)), slots === null || slots === void 0 ? void 0 : slots.afterTab);
93
- if (mode === 'list' && itemProps.list) {
80
+ }, itemProps === null || itemProps === void 0 ? void 0 : itemProps.tabLabelProps), rendered), isSelected && !isDisabled && (0, _react2.jsx)(TabLine, itemProps === null || itemProps === void 0 ? void 0 : itemProps.tabLineProps))), slots === null || slots === void 0 ? void 0 : slots.afterTab);
81
+ if (mode === 'list' && itemProps !== null && itemProps !== void 0 && itemProps.list) {
94
82
  return (0, _react2.jsx)(_TabPicker["default"], (0, _extends2["default"])({
95
83
  ref: tabRef,
96
84
  className: classNames,
97
- items: itemProps.list,
85
+ items: itemProps === null || itemProps === void 0 ? void 0 : itemProps.list,
98
86
  state: state,
99
87
  item: item
100
- }, (0, _reactAria.mergeProps)(focusProps, hoverProps, tabProps), otherItemProps));
88
+ }, (0, _reactAria.mergeProps)(focusProps, hoverProps, tabProps), itemProps));
101
89
  }
102
90
  if (mode === 'tooltip') {
103
- return (0, _react2.jsx)(_react["default"].Fragment, null, separator, (0, _react2.jsx)(_.TooltipTrigger, (0, _extends2["default"])({}, tooltipTriggerProps, {
91
+ return (0, _react2.jsx)(_react["default"].Fragment, null, itemProps === null || itemProps === void 0 ? void 0 : itemProps.separator, (0, _react2.jsx)(_.TooltipTrigger, (0, _extends2["default"])({}, tooltipTriggerProps, {
104
92
  isOpen: isHovered || isFocusVisible
105
- }), (0, _react2.jsx)(_interactions.Pressable, null, (0, _react2.jsx)("span", {
106
- variant: "quiet"
107
- }, tab)), (0, _react2.jsx)(_.Tooltip, null, itemProps.textValue || itemProps.title)));
93
+ }), (0, _react2.jsx)(_interactions.Pressable, null, (0, _react2.jsx)("span", null, tab)), (0, _react2.jsx)(_.Tooltip, null, (itemProps === null || itemProps === void 0 ? void 0 : itemProps.textValue) || (itemProps === null || itemProps === void 0 ? void 0 : itemProps.title))));
108
94
  }
109
95
  return tab;
110
96
  });
111
97
  exports.CollectionTab = CollectionTab;
112
98
  CollectionTab.displayName = 'CollectionTab';
113
- CollectionTab.propTypes = {
114
- isDisabled: _propTypes["default"].bool,
115
- item: _propTypes["default"].shape({
116
- key: _propTypes["default"].string,
117
- props: _propTypes["default"].shape({
118
- icon: _propTypes["default"].shape({}),
119
- isDisabled: _propTypes["default"].bool,
120
- textValue: _propTypes["default"].string,
121
- tabLineProps: _propTypes["default"].shape({}),
122
- tabLabelProps: _propTypes["default"].shape({}),
123
- content: _propTypes["default"].shape({}),
124
- titleAttr: _propTypes["default"].string,
125
- title: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].string, _propTypes["default"].object]),
126
- separator: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].bool]),
127
- list: _propTypes["default"].arrayOf(_propTypes["default"].shape({}))
128
- }),
129
- rendered: _propTypes["default"].node
130
- }),
131
- mode: _propTypes["default"].oneOf(['default', 'tooltip', 'list']),
132
- orientation: _propTypes["default"].oneOf(['horizontal', 'vertical']),
133
- tooltipTriggerProps: _propTypes["default"].shape({}),
134
- slots: _propTypes["default"].shape({
135
- beforeTab: _propTypes["default"].node,
136
- afterTab: _propTypes["default"].node
137
- })
138
- };
139
99
  var TabLine = function TabLine(props) {
140
100
  return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
141
101
  role: "presentation",
@@ -0,0 +1,2 @@
1
+ export { default } from './Tab';
2
+ export * from './Tab';
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { TabsProps } from '../../types';
3
+ export declare const TabsContext: React.Context<{}>;
4
+ declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLElement>>;
5
+ export default Tabs;
@@ -26,14 +26,13 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-c
26
26
  var _react = _interopRequireWildcard(require("react"));
27
27
  var _reactAria = require("react-aria");
28
28
  var _reactStately = require("react-stately");
29
- var _propTypes = _interopRequireDefault(require("prop-types"));
30
29
  var _hooks = require("../../hooks");
31
30
  var _orientation = _interopRequireDefault(require("../../utils/devUtils/constants/orientation"));
32
31
  var _Box = _interopRequireDefault(require("../Box"));
33
32
  var _Tab = require("../Tab");
34
33
  var _react2 = require("@emotion/react");
35
34
  var _excluded = ["state"],
36
- _excluded2 = ["children", "isDisabled", "items", "onSelectionChange", "orientation", "mode", "tabListProps", "tabPanelProps"];
35
+ _excluded2 = ["isDisabled", "items", "onSelectionChange", "orientation", "mode", "tabListProps", "tabPanelProps"];
37
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
38
37
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
38
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -43,23 +42,19 @@ exports.TabsContext = TabsContext;
43
42
  var TabPanel = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
44
43
  var state = _ref.state,
45
44
  props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
46
- var tabPanelRef = (0, _react.useRef)();
47
45
  var children = props.children,
48
46
  tabPanelProps = props.tabPanelProps;
49
- /* istanbul ignore next */
50
- (0, _react.useImperativeHandle)(ref, function () {
51
- return tabPanelRef.current;
52
- });
53
- var _useTabPanel = (0, _reactAria.useTabPanel)(props, state, tabPanelRef),
54
- raTabPanelProps = _useTabPanel.tabPanelProps;
47
+ var tabPanelRef = (0, _hooks.useLocalOrForwardRef)(ref);
48
+ var _ref2 = (0, _reactAria.useTabPanel)(props, state, tabPanelRef),
49
+ raTabPanelProps = _ref2.tabPanelProps;
55
50
  return (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({}, tabPanelProps, raTabPanelProps, {
56
- ref: tabPanelRef
51
+ ref: tabPanelRef,
52
+ role: "tabpanel"
57
53
  }), children);
58
54
  });
59
55
  var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
60
56
  var _context4, _context5, _state$selectedItem, _state$selectedItem2, _state$selectedItem3;
61
- var children = props.children,
62
- isDisabled = props.isDisabled,
57
+ var isDisabled = props.isDisabled,
63
58
  items = props.items,
64
59
  onSelectionChange = props.onSelectionChange,
65
60
  orientation = props.orientation,
@@ -67,14 +62,10 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
67
62
  tabListProps = props.tabListProps,
68
63
  tabPanelProps = props.tabPanelProps,
69
64
  others = (0, _objectWithoutProperties2["default"])(props, _excluded2);
70
- var tabListRef = (0, _react.useRef)();
71
65
  (0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
72
- /* istanbul ignore next */
73
- (0, _react.useImperativeHandle)(ref, function () {
74
- return tabListRef.current;
75
- });
66
+ var tabListRef = (0, _hooks.useLocalOrForwardRef)(ref);
76
67
  var allItems = [];
77
- if (mode === 'list') {
68
+ if (mode === 'list' && items) {
78
69
  (0, _forEach["default"])(items).call(items, function (item) {
79
70
  var _context;
80
71
  allItems = (0, _concat["default"])(_context = []).call(_context, allItems, [item]);
@@ -94,7 +85,8 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
94
85
  items: mode === 'list' ? allItems : items
95
86
  }));
96
87
  var _useTabList = (0, _reactAria.useTabList)(props, state, tabListRef),
97
- raTabListProps = _useTabList.tabListProps;
88
+ raTabListProps = _useTabList.tabListProps; //= useTabList(props, state, tabListRef);
89
+
98
90
  return (0, _react2.jsx)(TabsContext.Provider, {
99
91
  value: state
100
92
  }, (0, _react2.jsx)(_Box["default"], others, (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
@@ -102,19 +94,20 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
102
94
  gap: "25px",
103
95
  isRow: orientation === _orientation["default"].HORIZONTAL
104
96
  }, tabListProps, raTabListProps, {
105
- ref: tabListRef
97
+ ref: tabListRef,
98
+ role: "tablist"
106
99
  }), (0, _map["default"])(_context4 = (0, _filter["default"])(_context5 = (0, _from["default"])(state.collection)).call(_context5, function (item) {
107
- var _item$value;
108
- return !(item !== null && item !== void 0 && (_item$value = item.value) !== null && _item$value !== void 0 && _item$value.isListItem);
109
- })).call(_context4, function (item) {
110
100
  var _item$props;
101
+ return !(item !== null && item !== void 0 && (_item$props = item.props) !== null && _item$props !== void 0 && _item$props.isListItem);
102
+ })).call(_context4, function (item) {
103
+ var _item$props2;
111
104
  return (0, _react2.jsx)(_Tab.CollectionTab, {
112
105
  key: item.key,
113
106
  item: item,
114
107
  isDisabled: isDisabled,
115
108
  orientation: orientation,
116
109
  mode: mode,
117
- slots: item === null || item === void 0 || (_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.slots
110
+ slots: item === null || item === void 0 || (_item$props2 = item.props) === null || _item$props2 === void 0 ? void 0 : _item$props2.slots
118
111
  });
119
112
  })), (0, _react2.jsx)(TabPanel, {
120
113
  key: (_state$selectedItem = state.selectedItem) === null || _state$selectedItem === void 0 ? void 0 : _state$selectedItem.key,
@@ -122,43 +115,12 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
122
115
  tabPanelProps: tabPanelProps
123
116
  }, ((_state$selectedItem2 = state.selectedItem) === null || _state$selectedItem2 === void 0 ? void 0 : _state$selectedItem2.props.children) || ((_state$selectedItem3 = state.selectedItem) === null || _state$selectedItem3 === void 0 ? void 0 : _state$selectedItem3.props.content))));
124
117
  });
125
- Tabs.propTypes = {
126
- /** The default tab key to be selected. (uncontrolled) */
127
- defaultSelectedKey: _propTypes["default"].string,
128
- /** Array of keys to disable within the tab list. */
129
- disabledKeys: _propTypes["default"].arrayOf(_propTypes["default"].string),
130
- /** The tab key that is currently selected. (controlled) */
131
- selectedKey: _propTypes["default"].string,
132
- /** Determines the arrangement of the tablist. */
133
- orientation: _propTypes["default"].oneOf(['horizontal', 'vertical']),
134
- /** Determines the behavior model for the tabs. */
135
- mode: _propTypes["default"].oneOf(['default', 'tooltip', 'list']),
136
- /**
137
- * *For performance reasons, use this prop instead of Array.map when iteratively rendering Items*.
138
- * For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
139
- */
140
- items: _propTypes["default"].arrayOf(_propTypes["default"].shape({})),
141
- /** Whether the entire tablist is disabled. */
142
- isDisabled: _propTypes["default"].bool,
143
- /** Handler that is called when the selected tab has changed. */
144
- onSelectionChange: _propTypes["default"].func,
145
- /** A props object that is subsequently spread into the rendered tablist. */
146
- tabListProps: _propTypes["default"].shape({}),
147
- /** Props object that is spread directly into all of the tab panel wrapper elements. */
148
- tabPanelProps: _propTypes["default"].shape({}),
149
- /** Whether tabs are activated automatically on focus or manually¸ */
150
- keyboardActivation: _propTypes["default"].oneOf(['automatic', 'manual'])
151
- };
152
118
  Tabs.defaultProps = {
153
119
  isDisabled: false,
154
120
  orientation: 'horizontal',
155
121
  mode: 'default',
156
122
  keyboardActivation: 'manual'
157
123
  };
158
- TabPanel.propTypes = {
159
- state: _propTypes["default"].shape({}),
160
- tabPanelProps: _propTypes["default"].shape({})
161
- };
162
124
  Tabs.displayName = 'Tabs';
163
125
  var _default = Tabs;
164
126
  exports["default"] = _default;
@@ -0,0 +1,14 @@
1
+ import { StoryFn } from '@storybook/react';
2
+ import { TabsProps } from '../../types';
3
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
4
+ export default _default;
5
+ export declare const Uncontrolled: StoryFn<TabsProps>;
6
+ export declare const Controlled: StoryFn;
7
+ export declare const WithTooltips: StoryFn;
8
+ export declare const Centered: StoryFn;
9
+ export declare const DisabledSingleTab: StoryFn;
10
+ export declare const DisabledAllTabs: StoryFn;
11
+ export declare const CustomTabLine: StoryFn;
12
+ export declare const TabPanelProps: StoryFn;
13
+ export declare const ContentSlots: StoryFn;
14
+ export declare const WithList: StoryFn;
@@ -0,0 +1,52 @@
1
+ export declare const tab: {
2
+ pt: number;
3
+ cursor: string;
4
+ alignItems: string;
5
+ display: string;
6
+ outline: string;
7
+ transform: string;
8
+ '&.is-focused': {
9
+ '& > span': {
10
+ boxShadow: string;
11
+ outline: string;
12
+ outlineColor: string;
13
+ outlineOffset: string;
14
+ };
15
+ };
16
+ '&.is-disabled': {
17
+ cursor: string;
18
+ };
19
+ '&.is-selected.is-vertical': {
20
+ bg: string;
21
+ };
22
+ '& > svg': {
23
+ flexShrink: number;
24
+ };
25
+ };
26
+ export declare const tabLine: {
27
+ height: string;
28
+ width: string;
29
+ bg: string;
30
+ flexShrink: number;
31
+ };
32
+ export declare const tabPanel: {
33
+ outline: string;
34
+ };
35
+ export declare const tabs: {
36
+ borderBottomWidth: number;
37
+ borderBottomStyle: string;
38
+ borderBottomColor: string;
39
+ mb: string;
40
+ };
41
+ export declare const menuTab: {
42
+ color: string;
43
+ alignItems: string;
44
+ '&.is-selected *, &.is-hovered *': {
45
+ color: string;
46
+ };
47
+ '& + *:not(div:first-of-type)': {
48
+ ml: string;
49
+ };
50
+ all: string;
51
+ display: string;
52
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -38,17 +38,21 @@ emotionCache.compat = true;
38
38
  var testId = 'testId';
39
39
  var defaultTabs = [{
40
40
  name: 'Tab 1',
41
- children: 'Tab 1 body'
41
+ children: 'Tab 1 body',
42
+ props: {}
42
43
  }, {
43
44
  name: 'Tab 2',
44
- children: 'Tab 2 body'
45
+ children: 'Tab 2 body',
46
+ props: {}
45
47
  }, {
46
48
  name: 'Tab 3',
47
- children: 'Tab 3 body'
49
+ children: 'Tab 3 body',
50
+ props: {}
48
51
  }];
49
52
  var tabsWithList = [{
50
53
  name: 'Tab 1',
51
- children: 'Tab 1 body'
54
+ children: 'Tab 1 body',
55
+ props: {}
52
56
  }, {
53
57
  name: 'Tab 2',
54
58
  list: [{
@@ -61,7 +65,8 @@ var tabsWithList = [{
61
65
  name: 'Tab 2 list',
62
66
  children: 'Tab 2 from list',
63
67
  role: 'menuitemradio'
64
- }]
68
+ }],
69
+ props: {}
65
70
  }];
66
71
  var defaultProps = {
67
72
  'data-testid': testId,
@@ -78,8 +83,8 @@ var getComponent = function getComponent() {
78
83
  value: emotionCache
79
84
  }, (0, _react2.jsx)(_Tabs["default"], (0, _extends2["default"])({}, defaultProps, props), (0, _map["default"])(tabs).call(tabs, function (_ref2) {
80
85
  var name = _ref2.name,
81
- tabProps = _ref2.props,
82
- children = _ref2.children;
86
+ children = _ref2.children,
87
+ tabProps = _ref2.props;
83
88
  return (0, _react2.jsx)(_Tab["default"], (0, _extends2["default"])({
84
89
  key: name,
85
90
  title: name
@@ -115,7 +120,10 @@ var getTabs = function getTabs() {
115
120
  var testTabPanel = function testTabPanel(expectedTabIndex) {
116
121
  return (0, _forEach["default"])(defaultTabs).call(defaultTabs, function (_ref4, index) {
117
122
  var children = _ref4.children;
118
- return index === expectedTabIndex ? expect(_testWrapper.screen.queryByText(children)).toBeInTheDocument() : expect(_testWrapper.screen.queryByText(children)).not.toBeInTheDocument();
123
+ if (typeof children === 'string') {
124
+ return index === expectedTabIndex ? expect(_testWrapper.screen.queryByText(children)).toBeInTheDocument() : expect(_testWrapper.screen.queryByText(children)).not.toBeInTheDocument();
125
+ }
126
+ return null;
119
127
  });
120
128
  };
121
129
  var testSingleTab = function testSingleTab(tabs, tab, thisTest) {
@@ -265,9 +273,11 @@ test('disabled all tabs', function () {
265
273
 
266
274
  // Tabs cannot be DOM disabled so must check visuals
267
275
  (0, _forEach["default"])(defaultTabs).call(defaultTabs, function (tab) {
268
- var tabText = _testWrapper.screen.getByText(tab.name);
269
- var parentElement = tabText.parentElement;
270
- expect(parentElement).toHaveClass('is-disabled');
276
+ if (tab.name) {
277
+ var tabText = _testWrapper.screen.getByText(tab.name);
278
+ var parentElement = tabText.parentElement;
279
+ expect(parentElement).toHaveClass('is-disabled');
280
+ }
271
281
  });
272
282
  expect(tabLine).not.toBeInTheDocument();
273
283
 
@@ -414,7 +424,7 @@ test('tabs without selected keys show null tab panel content', function () {
414
424
  getComponent({
415
425
  defaultSelectedKey: undefined
416
426
  });
417
- expect(_testWrapper.screen.queryByRole('tabpanel')).not.toHaveTextContent();
427
+ expect(_testWrapper.screen.queryByRole('tabpanel')).not.toHaveTextContent('');
418
428
  });
419
429
  test('hover tab style', function () {
420
430
  getComponent();
@@ -469,17 +479,21 @@ test('will render tab with list if provided', /*#__PURE__*/(0, _asyncToGenerator
469
479
  });
470
480
  testTabPanel(0);
471
481
  _getTabs12 = getTabs(), menuBtn = _getTabs12.tab1.parentElement;
472
- _userEvent["default"].click(menuBtn);
482
+ if (menuBtn) _userEvent["default"].click(menuBtn);
473
483
  expect(_testWrapper.screen.queryByRole('menu')).toBeInTheDocument();
474
484
  testTabPanel(0);
475
485
  menuItems = _testWrapper.screen.queryAllByRole('menuitemradio');
476
- expect(menuItems).toHaveLength(tabsWithList[1].list.length);
486
+ if (tabsWithList[1].list) {
487
+ expect(menuItems).toHaveLength(tabsWithList[1].list.length);
488
+ }
477
489
  expect(menuItems[0]).not.toHaveFocus();
478
490
  _userEvent["default"].click(menuItems[0]);
479
- firstListItemContent = tabsWithList[1].list[0].children;
480
- expect(_testWrapper.screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
491
+ if (tabsWithList[1].list) {
492
+ firstListItemContent = tabsWithList[1].list[0].children;
493
+ expect(_testWrapper.screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
494
+ }
481
495
  expect(_testWrapper.screen.queryByRole('menu')).not.toBeInTheDocument();
482
- case 13:
496
+ case 12:
483
497
  case "end":
484
498
  return _context2.stop();
485
499
  }
@@ -511,13 +525,17 @@ test('tab list is accessible via keyboard', function () {
511
525
  expect(_testWrapper.screen.queryByRole('menu')).toBeInTheDocument();
512
526
  testTabPanel(0);
513
527
  var menuItems = _testWrapper.screen.queryAllByRole('menuitemradio');
514
- expect(menuItems).toHaveLength(tabsWithList[1].list.length);
528
+ if (tabsWithList[1].list) {
529
+ expect(menuItems).toHaveLength(tabsWithList[1].list.length);
530
+ }
515
531
  expect(menuItems[0]).toHaveFocus();
516
532
  _testWrapper.fireEvent.keyDown(menuItems[0], {
517
533
  key: 'Enter',
518
534
  code: 'Enter'
519
535
  });
520
- var firstListItemContent = tabsWithList[1].list[0].children;
521
- expect(_testWrapper.screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
536
+ if (tabsWithList[1].list) {
537
+ var firstListItemContent = tabsWithList[1].list[0].children;
538
+ expect(_testWrapper.screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
539
+ }
522
540
  expect(_testWrapper.screen.queryByRole('menu')).not.toBeInTheDocument();
523
541
  });
@@ -0,0 +1,2 @@
1
+ export { default } from './Tabs';
2
+ export * from './Tabs';
@@ -34,6 +34,8 @@ export * from './rockerButtonGroup';
34
34
  export * from './scrollBox';
35
35
  export * from './separator';
36
36
  export * from './shared';
37
+ export * from './tab';
37
38
  export * from './table';
39
+ export * from './tabs';
38
40
  export * from './text';
39
41
  export * from './tooltipTrigger';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39;
3
+ var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40, _context41;
4
4
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
5
5
  var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
6
6
  var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
@@ -403,8 +403,19 @@ _forEachInstanceProperty(_context36 = _Object$keys(_shared)).call(_context36, fu
403
403
  }
404
404
  });
405
405
  });
406
+ var _tab = require("./tab");
407
+ _forEachInstanceProperty(_context37 = _Object$keys(_tab)).call(_context37, function (key) {
408
+ if (key === "default" || key === "__esModule") return;
409
+ if (key in exports && exports[key] === _tab[key]) return;
410
+ _Object$defineProperty(exports, key, {
411
+ enumerable: true,
412
+ get: function get() {
413
+ return _tab[key];
414
+ }
415
+ });
416
+ });
406
417
  var _table = require("./table");
407
- _forEachInstanceProperty(_context37 = _Object$keys(_table)).call(_context37, function (key) {
418
+ _forEachInstanceProperty(_context38 = _Object$keys(_table)).call(_context38, function (key) {
408
419
  if (key === "default" || key === "__esModule") return;
409
420
  if (key in exports && exports[key] === _table[key]) return;
410
421
  _Object$defineProperty(exports, key, {
@@ -414,8 +425,19 @@ _forEachInstanceProperty(_context37 = _Object$keys(_table)).call(_context37, fun
414
425
  }
415
426
  });
416
427
  });
428
+ var _tabs = require("./tabs");
429
+ _forEachInstanceProperty(_context39 = _Object$keys(_tabs)).call(_context39, function (key) {
430
+ if (key === "default" || key === "__esModule") return;
431
+ if (key in exports && exports[key] === _tabs[key]) return;
432
+ _Object$defineProperty(exports, key, {
433
+ enumerable: true,
434
+ get: function get() {
435
+ return _tabs[key];
436
+ }
437
+ });
438
+ });
417
439
  var _text = require("./text");
418
- _forEachInstanceProperty(_context38 = _Object$keys(_text)).call(_context38, function (key) {
440
+ _forEachInstanceProperty(_context40 = _Object$keys(_text)).call(_context40, function (key) {
419
441
  if (key === "default" || key === "__esModule") return;
420
442
  if (key in exports && exports[key] === _text[key]) return;
421
443
  _Object$defineProperty(exports, key, {
@@ -426,7 +448,7 @@ _forEachInstanceProperty(_context38 = _Object$keys(_text)).call(_context38, func
426
448
  });
427
449
  });
428
450
  var _tooltipTrigger = require("./tooltipTrigger");
429
- _forEachInstanceProperty(_context39 = _Object$keys(_tooltipTrigger)).call(_context39, function (key) {
451
+ _forEachInstanceProperty(_context41 = _Object$keys(_tooltipTrigger)).call(_context41, function (key) {
430
452
  if (key === "default" || key === "__esModule") return;
431
453
  if (key in exports && exports[key] === _tooltipTrigger[key]) return;
432
454
  _Object$defineProperty(exports, key, {
@@ -1,4 +1,4 @@
1
- import { ElementType, Key } from 'react';
1
+ import { ElementType, Key, ReactNode } from 'react';
2
2
  import type { ItemProps } from '@react-types/shared';
3
3
  import { IconTypeExtended } from './icon';
4
4
  import { DOMAttributes, StyleProps } from './shared';
@@ -8,13 +8,15 @@ export interface Status {
8
8
  declare module '@react-types/shared' {
9
9
  interface ItemProps<T> extends StyleProps, DOMAttributes {
10
10
  /** The rendered label for the item. */
11
- label?: string | React.ReactNode;
11
+ label?: string | ReactNode;
12
12
  /** Props for the accordion item content element. */
13
13
  regionProps?: StyleProps;
14
14
  /** Props for the accordion item content element. */
15
15
  containerProps?: StyleProps;
16
16
  /** Props for the accordion item button element. */
17
17
  buttonProps?: StyleProps;
18
+ /** Props for the tab line element. */
19
+ tabLineProps?: StyleProps;
18
20
  /** Whether the item has a separator */
19
21
  isSeparator?: boolean;
20
22
  /** Whether the item is pressed */
@@ -30,7 +32,9 @@ declare module '@react-types/shared' {
30
32
  /** Key for the item. */
31
33
  key?: Key;
32
34
  slots?: {
33
- postHeading: React.ReactNode;
35
+ postHeading?: ReactNode;
36
+ afterTab?: ReactNode;
37
+ beforeTab?: ReactNode;
34
38
  };
35
39
  icon?: IconTypeExtended;
36
40
  /** isCurrent for the Breadcrumbs item. */
@@ -0,0 +1,32 @@
1
+ import { ElementType, ReactNode } from 'react';
2
+ import { ThemeUICSSProperties } from 'theme-ui';
3
+ import { TestingAttributes } from './shared/test';
4
+ import { DOMAttributes, OrientationProps, StyleProps } from './shared';
5
+ export interface TabProps extends StyleProps, DOMAttributes, OrientationProps, TestingAttributes {
6
+ isDisabled?: boolean;
7
+ item: {
8
+ key: string | number;
9
+ props?: {
10
+ icon: ElementType | ReactNode;
11
+ isDisabled: boolean;
12
+ textValue: string;
13
+ tabLineProps?: ThemeUICSSProperties;
14
+ tabLabelProps: object;
15
+ content: object;
16
+ titleAttr: string;
17
+ title: string;
18
+ separator: Element | boolean;
19
+ list: object[];
20
+ };
21
+ rendered?: string | ReactNode;
22
+ };
23
+ mode?: 'default' | 'tooltip' | 'list';
24
+ tooltipTriggerProps?: object;
25
+ title?: string;
26
+ textValue?: string;
27
+ tabLineProps?: object;
28
+ slots?: {
29
+ beforeTab?: ReactNode;
30
+ afterTab?: ReactNode;
31
+ };
32
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
@@ -0,0 +1,51 @@
1
+ import { Dispatch, ReactNode, SetStateAction } from 'react';
2
+ import { AriaTabListProps } from '@react-aria/tabs';
3
+ import { TabListState } from '@react-stately/tabs';
4
+ import type { CollectionChildren } from '@react-types/shared';
5
+ import { TestingAttributes } from './shared/test';
6
+ import { DOMAttributes, OrientationProps, StyleProps } from './shared';
7
+ export interface TabsProps extends StyleProps, TestingAttributes, OrientationProps {
8
+ /** The default tab key to be selected. (uncontrolled) */
9
+ defaultSelectedKey?: string;
10
+ /** Array of keys to disable within the tab list. */
11
+ disabledKeys?: string[];
12
+ /** The tab key that is currently selected. (controlled) */
13
+ selectedKey?: string;
14
+ /** Determines the behavior model for the tabs. */
15
+ mode?: 'default' | 'tooltip' | 'list';
16
+ /**
17
+ * *For performance reasons, use this prop instead of Array.map when iteratively rendering Items*.
18
+ * For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
19
+ */
20
+ items?: Array<TabListItemProps>;
21
+ /** Whether the entire tablist is disabled. */
22
+ isDisabled?: boolean;
23
+ /** Handler that is called when the selected tab has changed. */
24
+ onSelectionChange?: Dispatch<SetStateAction<string | undefined>>;
25
+ /** A props object that is subsequently spread into the rendered tablist. */
26
+ tabListProps?: object;
27
+ /** Props object that is spread directly into all of the tab panel wrapper elements. */
28
+ tabPanelProps?: object;
29
+ /** Whether tabs are activated automatically on focus or manually¸ */
30
+ keyboardActivation?: 'automatic' | 'manual';
31
+ children?: CollectionChildren<object>;
32
+ }
33
+ export interface AriaTabListOptions<T> extends Omit<AriaTabListProps<T>, 'children'> {
34
+ children: CollectionChildren<T>;
35
+ }
36
+ export interface TabPanelProps extends StyleProps, DOMAttributes {
37
+ state?: TabListState<object>;
38
+ tabPanelProps?: object;
39
+ children?: ReactNode | string;
40
+ }
41
+ export interface TabListItemProps {
42
+ name?: string;
43
+ children?: ReactNode | string;
44
+ list?: Array<{
45
+ key?: string | number;
46
+ name: string;
47
+ children: string;
48
+ role?: string;
49
+ }>;
50
+ props?: object;
51
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
@@ -1,13 +1,10 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
- import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["icon", "isDisabled", "separator", "tabLabelProps", "tabLineProps", "content", "titleAttr", "title"];
4
- import React, { forwardRef, useContext, useImperativeHandle, useRef } from 'react';
2
+ import React, { forwardRef, useContext } from 'react';
5
3
  import { mergeProps, useFocusRing, useTab } from 'react-aria';
6
4
  import { Item as Tab } from 'react-stately';
7
5
  import { Pressable, useHover } from '@react-aria/interactions';
8
- import PropTypes from 'prop-types';
9
6
  import { Box, Text, Tooltip, TooltipTrigger } from '../..';
10
- import { usePropWarning, useStatusClasses } from '../../hooks';
7
+ import { useLocalOrForwardRef, usePropWarning, useStatusClasses } from '../../hooks';
11
8
  import ORIENTATION from '../../utils/devUtils/constants/orientation';
12
9
  import { getPendoID } from '../../utils/devUtils/constants/pendoID';
13
10
  import TabPicker from '../TabPicker';
@@ -29,17 +26,8 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
29
26
  var key = item.key,
30
27
  rendered = item.rendered,
31
28
  itemProps = item.props;
32
- var icon = itemProps.icon,
33
- tabDisabled = itemProps.isDisabled,
34
- separator = itemProps.separator,
35
- tabLabelProps = itemProps.tabLabelProps,
36
- tabLineProps = itemProps.tabLineProps,
37
- content = itemProps.content,
38
- titleAttr = itemProps.titleAttr,
39
- title = itemProps.title,
40
- otherItemProps = _objectWithoutProperties(itemProps, _excluded);
41
29
  var state = useContext(TabsContext);
42
- var isDisabled = tabsDisabled || tabDisabled || state.disabledKeys.has(key);
30
+ var isDisabled = tabsDisabled || (itemProps === null || itemProps === void 0 ? void 0 : itemProps.isDisabled) || state.disabledKeys.has(key);
43
31
  var isSelected = state.selectedKey === key;
44
32
  var _useFocusRing = useFocusRing(),
45
33
  isFocusVisible = _useFocusRing.isFocusVisible,
@@ -56,12 +44,8 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
56
44
  isSelected: isSelected
57
45
  }),
58
46
  classNames = _useStatusClasses.classNames;
59
- var tabRef = useRef();
60
47
  usePropWarning(props, 'disabled', 'isDisabled');
61
- /* istanbul ignore next */
62
- useImperativeHandle(ref, function () {
63
- return tabRef.current;
64
- });
48
+ var tabRef = useLocalOrForwardRef(ref);
65
49
  var _useTab = useTab({
66
50
  key: key,
67
51
  isDisabled: isDisabled
@@ -72,57 +56,32 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
72
56
  }, slots === null || slots === void 0 ? void 0 : slots.beforeTab, ___EmotionJSX(Box, _extends({
73
57
  className: classNames,
74
58
  variant: "tab"
75
- }, mergeProps(focusProps, hoverProps, tabProps), getPendoID('Tab'), otherItemProps, {
76
- ref: tabRef,
77
- title: titleAttr || undefined
78
- }), icon, ___EmotionJSX(Text, _extends({
59
+ // title={itemProps?.titleAttr || undefined}
60
+ }, mergeProps(focusProps, hoverProps, tabProps), getPendoID('Tab'), {
61
+ // {...otherItemProps}
62
+ ref: tabRef
63
+ }, itemProps, {
64
+ role: "tab"
65
+ }), ___EmotionJSX(React.Fragment, null, itemProps === null || itemProps === void 0 ? void 0 : itemProps.icon, ___EmotionJSX(Text, _extends({
79
66
  variant: "tabLabel"
80
- }, tabLabelProps), rendered), isSelected && !isDisabled && ___EmotionJSX(TabLine, tabLineProps)), slots === null || slots === void 0 ? void 0 : slots.afterTab);
81
- if (mode === 'list' && itemProps.list) {
67
+ }, itemProps === null || itemProps === void 0 ? void 0 : itemProps.tabLabelProps), rendered), isSelected && !isDisabled && ___EmotionJSX(TabLine, itemProps === null || itemProps === void 0 ? void 0 : itemProps.tabLineProps))), slots === null || slots === void 0 ? void 0 : slots.afterTab);
68
+ if (mode === 'list' && itemProps !== null && itemProps !== void 0 && itemProps.list) {
82
69
  return ___EmotionJSX(TabPicker, _extends({
83
70
  ref: tabRef,
84
71
  className: classNames,
85
- items: itemProps.list,
72
+ items: itemProps === null || itemProps === void 0 ? void 0 : itemProps.list,
86
73
  state: state,
87
74
  item: item
88
- }, mergeProps(focusProps, hoverProps, tabProps), otherItemProps));
75
+ }, mergeProps(focusProps, hoverProps, tabProps), itemProps));
89
76
  }
90
77
  if (mode === 'tooltip') {
91
- return ___EmotionJSX(React.Fragment, null, separator, ___EmotionJSX(TooltipTrigger, _extends({}, tooltipTriggerProps, {
78
+ return ___EmotionJSX(React.Fragment, null, itemProps === null || itemProps === void 0 ? void 0 : itemProps.separator, ___EmotionJSX(TooltipTrigger, _extends({}, tooltipTriggerProps, {
92
79
  isOpen: isHovered || isFocusVisible
93
- }), ___EmotionJSX(Pressable, null, ___EmotionJSX("span", {
94
- variant: "quiet"
95
- }, tab)), ___EmotionJSX(Tooltip, null, itemProps.textValue || itemProps.title)));
80
+ }), ___EmotionJSX(Pressable, null, ___EmotionJSX("span", null, tab)), ___EmotionJSX(Tooltip, null, (itemProps === null || itemProps === void 0 ? void 0 : itemProps.textValue) || (itemProps === null || itemProps === void 0 ? void 0 : itemProps.title))));
96
81
  }
97
82
  return tab;
98
83
  });
99
84
  CollectionTab.displayName = 'CollectionTab';
100
- CollectionTab.propTypes = {
101
- isDisabled: PropTypes.bool,
102
- item: PropTypes.shape({
103
- key: PropTypes.string,
104
- props: PropTypes.shape({
105
- icon: PropTypes.shape({}),
106
- isDisabled: PropTypes.bool,
107
- textValue: PropTypes.string,
108
- tabLineProps: PropTypes.shape({}),
109
- tabLabelProps: PropTypes.shape({}),
110
- content: PropTypes.shape({}),
111
- titleAttr: PropTypes.string,
112
- title: PropTypes.oneOfType([PropTypes.element, PropTypes.string, PropTypes.object]),
113
- separator: PropTypes.oneOfType([PropTypes.element, PropTypes.bool]),
114
- list: PropTypes.arrayOf(PropTypes.shape({}))
115
- }),
116
- rendered: PropTypes.node
117
- }),
118
- mode: PropTypes.oneOf(['default', 'tooltip', 'list']),
119
- orientation: PropTypes.oneOf(['horizontal', 'vertical']),
120
- tooltipTriggerProps: PropTypes.shape({}),
121
- slots: PropTypes.shape({
122
- beforeTab: PropTypes.node,
123
- afterTab: PropTypes.node
124
- })
125
- };
126
85
  export var TabLine = function TabLine(props) {
127
86
  return ___EmotionJSX(Box, _extends({
128
87
  role: "presentation",
@@ -8,7 +8,7 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
8
8
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
9
9
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
10
10
  var _excluded = ["state"],
11
- _excluded2 = ["children", "isDisabled", "items", "onSelectionChange", "orientation", "mode", "tabListProps", "tabPanelProps"];
11
+ _excluded2 = ["isDisabled", "items", "onSelectionChange", "orientation", "mode", "tabListProps", "tabPanelProps"];
12
12
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
13
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context6, _context7; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(source), !0)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
14
14
  import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
@@ -16,11 +16,10 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
16
16
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
17
17
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
18
18
  import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
19
- import React, { forwardRef, useImperativeHandle, useRef } from 'react';
19
+ import React, { forwardRef } from 'react';
20
20
  import { useTabList, useTabPanel } from 'react-aria';
21
21
  import { useTabListState } from 'react-stately';
22
- import PropTypes from 'prop-types';
23
- import { usePropWarning } from '../../hooks';
22
+ import { useLocalOrForwardRef, usePropWarning } from '../../hooks';
24
23
  import ORIENTATION from '../../utils/devUtils/constants/orientation';
25
24
  import Box from '../Box';
26
25
  import { CollectionTab } from '../Tab';
@@ -29,23 +28,19 @@ export var TabsContext = /*#__PURE__*/React.createContext({});
29
28
  var TabPanel = /*#__PURE__*/forwardRef(function (_ref, ref) {
30
29
  var state = _ref.state,
31
30
  props = _objectWithoutProperties(_ref, _excluded);
32
- var tabPanelRef = useRef();
33
31
  var children = props.children,
34
32
  tabPanelProps = props.tabPanelProps;
35
- /* istanbul ignore next */
36
- useImperativeHandle(ref, function () {
37
- return tabPanelRef.current;
38
- });
39
- var _useTabPanel = useTabPanel(props, state, tabPanelRef),
40
- raTabPanelProps = _useTabPanel.tabPanelProps;
33
+ var tabPanelRef = useLocalOrForwardRef(ref);
34
+ var _ref2 = useTabPanel(props, state, tabPanelRef),
35
+ raTabPanelProps = _ref2.tabPanelProps;
41
36
  return ___EmotionJSX(Box, _extends({}, tabPanelProps, raTabPanelProps, {
42
- ref: tabPanelRef
37
+ ref: tabPanelRef,
38
+ role: "tabpanel"
43
39
  }), children);
44
40
  });
45
41
  var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
46
42
  var _context4, _context5, _state$selectedItem, _state$selectedItem2, _state$selectedItem3;
47
- var children = props.children,
48
- isDisabled = props.isDisabled,
43
+ var isDisabled = props.isDisabled,
49
44
  items = props.items,
50
45
  onSelectionChange = props.onSelectionChange,
51
46
  orientation = props.orientation,
@@ -53,14 +48,10 @@ var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
53
48
  tabListProps = props.tabListProps,
54
49
  tabPanelProps = props.tabPanelProps,
55
50
  others = _objectWithoutProperties(props, _excluded2);
56
- var tabListRef = useRef();
57
51
  usePropWarning(props, 'disabled', 'isDisabled');
58
- /* istanbul ignore next */
59
- useImperativeHandle(ref, function () {
60
- return tabListRef.current;
61
- });
52
+ var tabListRef = useLocalOrForwardRef(ref);
62
53
  var allItems = [];
63
- if (mode === 'list') {
54
+ if (mode === 'list' && items) {
64
55
  _forEachInstanceProperty(items).call(items, function (item) {
65
56
  var _context;
66
57
  allItems = _concatInstanceProperty(_context = []).call(_context, allItems, [item]);
@@ -80,7 +71,8 @@ var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
80
71
  items: mode === 'list' ? allItems : items
81
72
  }));
82
73
  var _useTabList = useTabList(props, state, tabListRef),
83
- raTabListProps = _useTabList.tabListProps;
74
+ raTabListProps = _useTabList.tabListProps; //= useTabList(props, state, tabListRef);
75
+
84
76
  return ___EmotionJSX(TabsContext.Provider, {
85
77
  value: state
86
78
  }, ___EmotionJSX(Box, others, ___EmotionJSX(Box, _extends({
@@ -88,19 +80,20 @@ var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
88
80
  gap: "25px",
89
81
  isRow: orientation === ORIENTATION.HORIZONTAL
90
82
  }, tabListProps, raTabListProps, {
91
- ref: tabListRef
83
+ ref: tabListRef,
84
+ role: "tablist"
92
85
  }), _mapInstanceProperty(_context4 = _filterInstanceProperty(_context5 = _Array$from(state.collection)).call(_context5, function (item) {
93
- var _item$value;
94
- return !(item !== null && item !== void 0 && (_item$value = item.value) !== null && _item$value !== void 0 && _item$value.isListItem);
95
- })).call(_context4, function (item) {
96
86
  var _item$props;
87
+ return !(item !== null && item !== void 0 && (_item$props = item.props) !== null && _item$props !== void 0 && _item$props.isListItem);
88
+ })).call(_context4, function (item) {
89
+ var _item$props2;
97
90
  return ___EmotionJSX(CollectionTab, {
98
91
  key: item.key,
99
92
  item: item,
100
93
  isDisabled: isDisabled,
101
94
  orientation: orientation,
102
95
  mode: mode,
103
- slots: item === null || item === void 0 || (_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.slots
96
+ slots: item === null || item === void 0 || (_item$props2 = item.props) === null || _item$props2 === void 0 ? void 0 : _item$props2.slots
104
97
  });
105
98
  })), ___EmotionJSX(TabPanel, {
106
99
  key: (_state$selectedItem = state.selectedItem) === null || _state$selectedItem === void 0 ? void 0 : _state$selectedItem.key,
@@ -108,42 +101,11 @@ var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
108
101
  tabPanelProps: tabPanelProps
109
102
  }, ((_state$selectedItem2 = state.selectedItem) === null || _state$selectedItem2 === void 0 ? void 0 : _state$selectedItem2.props.children) || ((_state$selectedItem3 = state.selectedItem) === null || _state$selectedItem3 === void 0 ? void 0 : _state$selectedItem3.props.content))));
110
103
  });
111
- Tabs.propTypes = {
112
- /** The default tab key to be selected. (uncontrolled) */
113
- defaultSelectedKey: PropTypes.string,
114
- /** Array of keys to disable within the tab list. */
115
- disabledKeys: PropTypes.arrayOf(PropTypes.string),
116
- /** The tab key that is currently selected. (controlled) */
117
- selectedKey: PropTypes.string,
118
- /** Determines the arrangement of the tablist. */
119
- orientation: PropTypes.oneOf(['horizontal', 'vertical']),
120
- /** Determines the behavior model for the tabs. */
121
- mode: PropTypes.oneOf(['default', 'tooltip', 'list']),
122
- /**
123
- * *For performance reasons, use this prop instead of Array.map when iteratively rendering Items*.
124
- * For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
125
- */
126
- items: PropTypes.arrayOf(PropTypes.shape({})),
127
- /** Whether the entire tablist is disabled. */
128
- isDisabled: PropTypes.bool,
129
- /** Handler that is called when the selected tab has changed. */
130
- onSelectionChange: PropTypes.func,
131
- /** A props object that is subsequently spread into the rendered tablist. */
132
- tabListProps: PropTypes.shape({}),
133
- /** Props object that is spread directly into all of the tab panel wrapper elements. */
134
- tabPanelProps: PropTypes.shape({}),
135
- /** Whether tabs are activated automatically on focus or manually¸ */
136
- keyboardActivation: PropTypes.oneOf(['automatic', 'manual'])
137
- };
138
104
  Tabs.defaultProps = {
139
105
  isDisabled: false,
140
106
  orientation: 'horizontal',
141
107
  mode: 'default',
142
108
  keyboardActivation: 'manual'
143
109
  };
144
- TabPanel.propTypes = {
145
- state: PropTypes.shape({}),
146
- tabPanelProps: PropTypes.shape({})
147
- };
148
110
  Tabs.displayName = 'Tabs';
149
111
  export default Tabs;
@@ -37,17 +37,21 @@ emotionCache.compat = true;
37
37
  var testId = 'testId';
38
38
  var defaultTabs = [{
39
39
  name: 'Tab 1',
40
- children: 'Tab 1 body'
40
+ children: 'Tab 1 body',
41
+ props: {}
41
42
  }, {
42
43
  name: 'Tab 2',
43
- children: 'Tab 2 body'
44
+ children: 'Tab 2 body',
45
+ props: {}
44
46
  }, {
45
47
  name: 'Tab 3',
46
- children: 'Tab 3 body'
48
+ children: 'Tab 3 body',
49
+ props: {}
47
50
  }];
48
51
  var tabsWithList = [{
49
52
  name: 'Tab 1',
50
- children: 'Tab 1 body'
53
+ children: 'Tab 1 body',
54
+ props: {}
51
55
  }, {
52
56
  name: 'Tab 2',
53
57
  list: [{
@@ -60,7 +64,8 @@ var tabsWithList = [{
60
64
  name: 'Tab 2 list',
61
65
  children: 'Tab 2 from list',
62
66
  role: 'menuitemradio'
63
- }]
67
+ }],
68
+ props: {}
64
69
  }];
65
70
  var defaultProps = {
66
71
  'data-testid': testId,
@@ -77,8 +82,8 @@ var getComponent = function getComponent() {
77
82
  value: emotionCache
78
83
  }, ___EmotionJSX(Tabs, _extends({}, defaultProps, props), _mapInstanceProperty(tabs).call(tabs, function (_ref2) {
79
84
  var name = _ref2.name,
80
- tabProps = _ref2.props,
81
- children = _ref2.children;
85
+ children = _ref2.children,
86
+ tabProps = _ref2.props;
82
87
  return ___EmotionJSX(Tab, _extends({
83
88
  key: name,
84
89
  title: name
@@ -114,7 +119,10 @@ var getTabs = function getTabs() {
114
119
  var testTabPanel = function testTabPanel(expectedTabIndex) {
115
120
  return _forEachInstanceProperty(defaultTabs).call(defaultTabs, function (_ref4, index) {
116
121
  var children = _ref4.children;
117
- return index === expectedTabIndex ? expect(screen.queryByText(children)).toBeInTheDocument() : expect(screen.queryByText(children)).not.toBeInTheDocument();
122
+ if (typeof children === 'string') {
123
+ return index === expectedTabIndex ? expect(screen.queryByText(children)).toBeInTheDocument() : expect(screen.queryByText(children)).not.toBeInTheDocument();
124
+ }
125
+ return null;
118
126
  });
119
127
  };
120
128
  var testSingleTab = function testSingleTab(tabs, tab, thisTest) {
@@ -264,9 +272,11 @@ test('disabled all tabs', function () {
264
272
 
265
273
  // Tabs cannot be DOM disabled so must check visuals
266
274
  _forEachInstanceProperty(defaultTabs).call(defaultTabs, function (tab) {
267
- var tabText = screen.getByText(tab.name);
268
- var parentElement = tabText.parentElement;
269
- expect(parentElement).toHaveClass('is-disabled');
275
+ if (tab.name) {
276
+ var tabText = screen.getByText(tab.name);
277
+ var parentElement = tabText.parentElement;
278
+ expect(parentElement).toHaveClass('is-disabled');
279
+ }
270
280
  });
271
281
  expect(tabLine).not.toBeInTheDocument();
272
282
 
@@ -413,7 +423,7 @@ test('tabs without selected keys show null tab panel content', function () {
413
423
  getComponent({
414
424
  defaultSelectedKey: undefined
415
425
  });
416
- expect(screen.queryByRole('tabpanel')).not.toHaveTextContent();
426
+ expect(screen.queryByRole('tabpanel')).not.toHaveTextContent('');
417
427
  });
418
428
  test('hover tab style', function () {
419
429
  getComponent();
@@ -468,17 +478,21 @@ test('will render tab with list if provided', /*#__PURE__*/_asyncToGenerator( /*
468
478
  });
469
479
  testTabPanel(0);
470
480
  _getTabs12 = getTabs(), menuBtn = _getTabs12.tab1.parentElement;
471
- userEvent.click(menuBtn);
481
+ if (menuBtn) userEvent.click(menuBtn);
472
482
  expect(screen.queryByRole('menu')).toBeInTheDocument();
473
483
  testTabPanel(0);
474
484
  menuItems = screen.queryAllByRole('menuitemradio');
475
- expect(menuItems).toHaveLength(tabsWithList[1].list.length);
485
+ if (tabsWithList[1].list) {
486
+ expect(menuItems).toHaveLength(tabsWithList[1].list.length);
487
+ }
476
488
  expect(menuItems[0]).not.toHaveFocus();
477
489
  userEvent.click(menuItems[0]);
478
- firstListItemContent = tabsWithList[1].list[0].children;
479
- expect(screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
490
+ if (tabsWithList[1].list) {
491
+ firstListItemContent = tabsWithList[1].list[0].children;
492
+ expect(screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
493
+ }
480
494
  expect(screen.queryByRole('menu')).not.toBeInTheDocument();
481
- case 13:
495
+ case 12:
482
496
  case "end":
483
497
  return _context2.stop();
484
498
  }
@@ -510,13 +524,17 @@ test('tab list is accessible via keyboard', function () {
510
524
  expect(screen.queryByRole('menu')).toBeInTheDocument();
511
525
  testTabPanel(0);
512
526
  var menuItems = screen.queryAllByRole('menuitemradio');
513
- expect(menuItems).toHaveLength(tabsWithList[1].list.length);
527
+ if (tabsWithList[1].list) {
528
+ expect(menuItems).toHaveLength(tabsWithList[1].list.length);
529
+ }
514
530
  expect(menuItems[0]).toHaveFocus();
515
531
  fireEvent.keyDown(menuItems[0], {
516
532
  key: 'Enter',
517
533
  code: 'Enter'
518
534
  });
519
- var firstListItemContent = tabsWithList[1].list[0].children;
520
- expect(screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
535
+ if (tabsWithList[1].list) {
536
+ var firstListItemContent = tabsWithList[1].list[0].children;
537
+ expect(screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
538
+ }
521
539
  expect(screen.queryByRole('menu')).not.toBeInTheDocument();
522
540
  });
@@ -34,6 +34,8 @@ export * from './rockerButtonGroup';
34
34
  export * from './scrollBox';
35
35
  export * from './separator';
36
36
  export * from './shared';
37
+ export * from './tab';
37
38
  export * from './table';
39
+ export * from './tabs';
38
40
  export * from './text';
39
41
  export * from './tooltipTrigger';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.57.0-alpha.7",
3
+ "version": "2.57.0-alpha.8",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",