@deque/cauldron-react 3.0.1-canary.41ff0487 → 3.0.1-canary.4607c120
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.
|
@@ -6,9 +6,13 @@ declare type TabsProps = {
|
|
|
6
6
|
initialActiveIndex?: number;
|
|
7
7
|
thin?: boolean;
|
|
8
8
|
className?: string;
|
|
9
|
+
onChange?: ({ activeTabIndex, target }: {
|
|
10
|
+
activeTabIndex: number;
|
|
11
|
+
target: HTMLLIElement | null;
|
|
12
|
+
}) => void;
|
|
9
13
|
} & Cauldron.LabelProps;
|
|
10
14
|
declare const Tabs: {
|
|
11
|
-
({ children, thin, initialActiveIndex, className, ...labelProp }: TabsProps): JSX.Element;
|
|
15
|
+
({ children, thin, initialActiveIndex, className, onChange, ...labelProp }: TabsProps): JSX.Element;
|
|
12
16
|
displayName: string;
|
|
13
17
|
propTypes: {
|
|
14
18
|
children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
package/lib/index.js
CHANGED
|
@@ -1150,11 +1150,11 @@ var SideBar = /** @class */ (function (_super) {
|
|
|
1150
1150
|
var _a = this.state, animateClass = _a.animateClass, wide = _a.wide;
|
|
1151
1151
|
// disabling no-unused-vars to prevent onDismiss from being passed through to dom element
|
|
1152
1152
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1153
|
-
var _b = this.props, children = _b.children, className = _b.className, show = _b.show, onDismiss = _b.onDismiss, other = tslib.__rest(_b, ["children", "className", "show", "onDismiss"]);
|
|
1153
|
+
var _b = this.props, children = _b.children, className = _b.className, show = _b.show, onDismiss = _b.onDismiss, navProps = _b.navProps, other = tslib.__rest(_b, ["children", "className", "show", "onDismiss", "navProps"]);
|
|
1154
1154
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
1155
1155
|
return (React__default.createElement(React.Fragment, null,
|
|
1156
1156
|
React__default.createElement(ClickOutsideListener, { onClickOutside: this.handleClickOutside },
|
|
1157
|
-
React__default.createElement("nav",
|
|
1157
|
+
React__default.createElement("nav", tslib.__assign({}, navProps),
|
|
1158
1158
|
React__default.createElement("ul", tslib.__assign({ className: classNames('SideBar', className, animateClass) }, other, { ref: this.navList, onKeyDown: this.onKeyDown }), children))),
|
|
1159
1159
|
React__default.createElement(Scrim, { show: !wide && show })));
|
|
1160
1160
|
/* eslint-enable jsx-a11y/no-noninteractive-element-interactions */
|
|
@@ -8048,8 +8048,9 @@ Tab.propTypes = {
|
|
|
8048
8048
|
};
|
|
8049
8049
|
|
|
8050
8050
|
var Tabs = function (_a) {
|
|
8051
|
-
var children = _a.children, thin = _a.thin, _b = _a.initialActiveIndex, initialActiveIndex = _b === void 0 ? 0 : _b, className = _a.className, labelProp = tslib.__rest(_a, ["children", "thin", "initialActiveIndex", "className"]);
|
|
8051
|
+
var children = _a.children, thin = _a.thin, _b = _a.initialActiveIndex, initialActiveIndex = _b === void 0 ? 0 : _b, className = _a.className, onChange = _a.onChange, labelProp = tslib.__rest(_a, ["children", "thin", "initialActiveIndex", "className", "onChange"]);
|
|
8052
8052
|
var _c = React.useState(initialActiveIndex), activeIndex = _c[0], setActiveIndex = _c[1];
|
|
8053
|
+
var tabsRef = React.useRef(null);
|
|
8053
8054
|
var focusedTabRef = React.useRef(null);
|
|
8054
8055
|
var tabs = React__default.Children.toArray(children).filter(function (child) { return child.type === Tab; });
|
|
8055
8056
|
var tabCount = tabs.length;
|
|
@@ -8114,10 +8115,13 @@ var Tabs = function (_a) {
|
|
|
8114
8115
|
useDidUpdate(function () {
|
|
8115
8116
|
var _a;
|
|
8116
8117
|
(_a = focusedTabRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
8118
|
+
if (typeof onChange === 'function') {
|
|
8119
|
+
onChange({ activeTabIndex: activeIndex, target: focusedTabRef.current });
|
|
8120
|
+
}
|
|
8117
8121
|
}, [activeIndex]);
|
|
8118
8122
|
return (React__default.createElement("div", { className: classNames('Tabs', className, {
|
|
8119
8123
|
'Tabs--thin': thin
|
|
8120
|
-
}) },
|
|
8124
|
+
}), ref: tabsRef },
|
|
8121
8125
|
React__default.createElement("ul", tslib.__assign({ role: "tablist", className: "Tablist" }, labelProp, { onKeyDown: handleKeyDown }), tabComponents)));
|
|
8122
8126
|
};
|
|
8123
8127
|
Tabs.displayName = 'Tabs';
|