UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

937 lines (936 loc) 32.4 kB
"use client"; import _extends from "@babel/runtime/helpers/esm/extends"; import _objectDestructuringEmpty from "@babel/runtime/helpers/esm/objectDestructuringEmpty"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; const _excluded = ["title", "key", "hash"], _excluded2 = ["children"], _excluded3 = ["children", "className"]; import "core-js/modules/web.dom-collections.iterator.js"; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import Context from '../../shared/Context'; import { warn, slugify, isTrue, makeUniqueId, extendPropsWithContextInClassComponent, validateDOMAttributes, dispatchCustomElementEvent, getPreviousSibling, filterProps, combineLabelledBy, keycode } from '../../shared/component-helper'; import { spacingPropTypes, createSpacingClasses } from '../space/SpacingHelper'; import { createSkeletonClass, skeletonDOMAttributes } from '../skeleton/SkeletonHelper'; import Button from '../button/Button'; import whatInput from 'what-input'; import CustomContent from './TabsCustomContent'; import ContentWrapper from './TabsContentWrapper'; import EventEmitter from '../../shared/helpers/EventEmitter'; export default class Tabs extends React.PureComponent { static getSelectedKeyOrFallback(selected_key, data) { let useKey = selected_key; if (!useKey) { useKey = data.reduce((acc, _ref) => { let { selected, key } = _ref; return selected ? key : acc; }, null) || data[0] && data[0].key; } else { const keyExists = data.findIndex(_ref2 => { let { key } = _ref2; return key == selected_key; }); if (keyExists === -1) { useKey = data[0] && data[0].key; } } return useKey; } static getDerivedStateFromProps(props, state) { if (state._listenForPropChanges) { if (props.data) { if (state._data !== props.data) { state._data = props.data; state.data = Tabs.getData(props); } } else if (props.children) { if (state._data !== props.children) { state._data = props.children; state.data = Tabs.getData(props); } } if (props.selected_key && state._selected_key !== props.selected_key) { state.selected_key = state._selected_key = Tabs.getSelectedKeyOrFallback(props.selected_key, state.data); } } state._listenForPropChanges = true; return state; } static getData(props) { const addReactElement = (list, reactElem, reactElemIndex) => { if (reactElem && reactElem.props && reactElem.props.displayName === 'CustomContent') { const dataProps = props.children && Array.isArray(props.children) && props.children[reactElemIndex] || {}; const componentProps = _objectSpread({}, reactElem.props); if (componentProps.title === null) { delete componentProps.title; } const _dataProps$componentP = _objectSpread(_objectSpread(_objectSpread({}, dataProps), componentProps), { children: null }), { title, key: _key, hash } = _dataProps$componentP, rest = _objectWithoutProperties(_dataProps$componentP, _excluded); list.push(_objectSpread({ title, key: (!_key && hash ? hash : _key) || slugify(title), content: reactElem }, rest)); } }; let res = []; const data = !props.data && props.children ? props.children : props.data; if (Array.isArray(props.children) && props.children.some(element => typeof element === 'function' || React.isValidElement(element))) { res = props.children.reduce((list, reactElem, i) => { addReactElement(list, reactElem, i); return list; }, []); } if (!Array.isArray(props.children) && (typeof props.children === 'function' || React.isValidElement(props.children))) { addReactElement(res, props.children); } if (!(res && res.length > 0)) { if (props.data && Array.isArray(data)) { res = data; } else if (typeof data === 'string') { res = data[0] === '[' ? JSON.parse(data) : []; } else if (data && typeof data === 'object') { res = Object.entries(data).reduce((acc, _ref3) => { let [key, obj] = _ref3; if (obj) { acc.push(_objectSpread({ key }, obj)); } return acc; }, []); } } return res || []; } constructor(_props) { var _this; super(_props); _this = this; _defineProperty(this, "init", () => { if (this._isMounted) { this.addScrollBehavior(); const hasScrollbar = this.hasScrollbar(); const hasLastPosition = this.hasLastPosition(); this.setScrollbarState({ hasScrollbar }); if (hasLastPosition) { this.setLeftPosition(this.state.lastPosition); } if (hasScrollbar) { this.scrollToTab({ type: 'selected', behavior: hasLastPosition ? 'smooth' : 'auto' }); } if (this.hasLastUsedTab() !== null) { this.setState(null, this.setFocusOnTabButton); } } }); _defineProperty(this, "setScrollbarState", function () { let { hasScrollbar = _this.hasScrollbar() } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; if (hasScrollbar !== _this.state.hasScrollbar) { _this.setState({ hasScrollbar }); } }); _defineProperty(this, "onResizeHandler", () => { const hasScrollbar = this.hasScrollbar(); this.setScrollbarState({ hasScrollbar }); if (hasScrollbar) { this.scrollToTab({ type: 'selected' }); } }); _defineProperty(this, "onTablistKeyDownHandler", e => { switch (keycode(e)) { case 'up': case 'page up': case 'left': e.preventDefault(); this.focusPrevTab(e); break; case 'down': case 'page down': case 'right': e.preventDefault(); this.focusNextTab(e); break; case 'home': e.preventDefault(); this.focusFirstTab(e); break; case 'end': e.preventDefault(); this.focusLastTab(e); break; } }); _defineProperty(this, "focusFirstTab", e => { const key = this.state.data[0].key; this.focusTab(key, e, 'step'); this.scrollToTab({ type: 'focus' }); }); _defineProperty(this, "focusLastTab", e => { const key = this.state.data[this.state.data.length - 1].key; this.focusTab(key, e, 'step'); this.scrollToTab({ type: 'focus' }); }); _defineProperty(this, "focusPrevTab", e => { this.focusTab(-1, e, 'step'); this.scrollToTab({ type: 'focus' }); }); _defineProperty(this, "focusNextTab", e => { this.focusTab(+1, e, 'step'); this.scrollToTab({ type: 'focus' }); }); _defineProperty(this, "openPrevTab", e => { this.openTab(-1, e, 'step'); this.scrollToTab({ type: 'selected' }); }); _defineProperty(this, "openNextTab", e => { this.openTab(+1, e, 'step'); this.scrollToTab({ type: 'selected' }); }); _defineProperty(this, "handleVerticalScroll", () => { if (isTrue(this.props.scroll) && this._tablistRef.current && typeof this._tablistRef.current.scrollIntoView === 'function') { this._tablistRef.current.scrollIntoView({ block: 'start', behavior: 'smooth' }); } }); _defineProperty(this, "onMouseDown", event => { event.preventDefault(); }); _defineProperty(this, "onKeyDownHandler", event => { switch (keycode(event)) { case 'enter': try { const elem = document.getElementById(`${this._id}-content`); elem.focus({ preventScroll: true }); } catch (e) { this.warnAboutMissingContainer(); } break; } }); _defineProperty(this, "onMouseEnterHandler", event => { const selected_key = this.getCurrentKey(event); if (selected_key) { dispatchCustomElementEvent(this, 'on_mouse_enter', this.getEventArgs({ event, selected_key })); } }); _defineProperty(this, "onClickHandler", event => { const selected_key = this.getCurrentKey(event); if (selected_key) { const ret = dispatchCustomElementEvent(this, 'on_click', this.getEventArgs({ event, selected_key })); if (ret !== false) { this.openTab(selected_key, event); this.scrollToTab({ type: 'selected' }); } } }); _defineProperty(this, "getCurrentKey", event => { let selected_key; try { selected_key = function (elem) { return getPreviousSibling('dnb-tabs__button', elem) || { dataset: {} }; }(event.target).dataset.tabKey; } catch (e) { warn('Tabs Error:', e); } return selected_key; }); _defineProperty(this, "getCurrentTitle", function () { let selected_key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.state.selected_key; const current = _this.state.data.filter(_ref4 => { let { key } = _ref4; return key == selected_key; })[0]; return current && current.title || null; }); _defineProperty(this, "focusTab", function (focus_key) { let event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; let mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; if (mode === 'step' && parseFloat(focus_key)) { focus_key = _this.getStepKey(focus_key, _this.state.focus_key); } _this.setState({ focus_key, _listenForPropChanges: false }, _this.setFocusOnTabButton); dispatchCustomElementEvent(_this, 'on_focus', _this.getEventArgs({ event, focus_key })); _this.setWhatInput(); }); _defineProperty(this, "setFocusOnTabButton", () => { try { const elem = this._tablistRef.current.querySelector('.dnb-tabs__button.focus'); elem.focus({ preventScroll: true }); if (!document.getElementById(`${this._id}-content`) && typeof process !== 'undefined' && process.env.NODE_ENV !== 'test') { this.warnAboutMissingContainer(); } } catch (e) { warn(e); } }); _defineProperty(this, "openTab", function (selected_key) { let event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; let mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; _this.saveLastPosition(); _this.saveLastUsedTab(); _this.resetWhatInput(); if (mode === 'step' && parseFloat(selected_key)) { selected_key = _this.getStepKey(selected_key, _this.state.selected_key); } if (typeof selected_key !== 'undefined') { _this.setState({ selected_key, focus_key: selected_key, _listenForPropChanges: false }, _this.handleVerticalScroll); } dispatchCustomElementEvent(_this, 'on_change', _this.getEventArgs({ event, selected_key })); if (_this.props.onOpenTabNavigationFn && typeof window !== 'undefined') { try { _this.props.onOpenTabNavigationFn(selected_key); } catch (e) { warn('Tabs Error:', e); } } if (_this._eventEmitter) { _this._eventEmitter.update(_this.getEventArgs({ event, selected_key })); } }); _defineProperty(this, "getContent", selected_key => { const { children, content: _content } = this.props; const contentToRender = children || _content; let content = null; if (contentToRender) { if (typeof contentToRender === 'object' && contentToRender[selected_key]) { content = contentToRender[selected_key]; } else if (typeof contentToRender === 'function') { content = contentToRender.apply(this, [selected_key]); } else if (React.isValidElement(contentToRender)) { content = contentToRender; } } if (!content) { let items = []; if (Array.isArray(this.state.data)) { items = this.state.data; } else if (Array.isArray(contentToRender)) { items = contentToRender; } if (items) { content = items.filter(_ref5 => { let { key } = _ref5; return key && selected_key && key == selected_key; }).reduce((acc, _ref6) => { let { content } = _ref6; return content || acc; }, null); } } if (typeof content === 'function') { const Component = content; content = React.createElement(Component, null); } return content; }); _defineProperty(this, "TabsWrapperHandler", _ref7 => { let { children } = _ref7, rest = _objectWithoutProperties(_ref7, _excluded2); const { className, class: _className } = this.props; const _filterProps = filterProps(this.props, Tabs.defaultProps), attributes = Object.assign({}, (_objectDestructuringEmpty(_filterProps), _filterProps)); const params = _objectSpread(_objectSpread({}, attributes), {}, { className: classnames('dnb-tabs', createSpacingClasses(this.props), className, _className) }); validateDOMAttributes(this.props, params); return React.createElement("div", _extends({}, params, rest), children); }); _defineProperty(this, "TabsListHandler", _ref8 => { let { children, className } = _ref8, rest = _objectWithoutProperties(_ref8, _excluded3); const { align, tabs_style, tabs_spacing, no_border, nav_button_edge, breakout } = this.props; const { hasScrollbar } = this.state; return React.createElement("div", _extends({ className: classnames('dnb-tabs__tabs', className, align && `dnb-tabs__tabs--${align}`, tabs_style && `dnb-section dnb-section--${tabs_style}`, tabs_spacing && `dnb-section--spacing-${isTrue(tabs_spacing) ? 'large' : tabs_spacing}`, hasScrollbar && 'dnb-tabs--has-scrollbar', nav_button_edge && 'dnb-tabs--at-edge', no_border && 'dnb-tabs__tabs--no-border', breakout && 'dnb-tabs__tabs--breakout'), ref: this._tabsRef }, rest), React.createElement(ScrollNavButton, { onMouseDown: this.openPrevTab, icon: "chevron_left", className: classnames(hasScrollbar && (typeof this.state.isFirst !== 'undefined' || this.hasLastPosition()) && 'dnb-tabs__scroll-nav-button--visible', this.state.isFirst && 'dnb-tabs__scroll-nav-button--hide') }), children, React.createElement(ScrollNavButton, { onMouseDown: this.openNextTab, icon: "chevron_right", className: classnames(hasScrollbar && (typeof this.state.isLast !== 'undefined' || this.hasLastPosition()) && 'dnb-tabs__scroll-nav-button--visible', this.state.isLast && 'dnb-tabs__scroll-nav-button--hide') })); }); _defineProperty(this, "TabContentHandler", () => { const { selected_key } = this.state; const content = this.renderContent(); if (!this._eventEmitter && !content) { warn(`No content was given to the Tabs component! Tip: Check out other solutions like <Tabs.Content id="unique">Your content, outside of the Tabs component</Tabs.Content> `); } return React.createElement(ContentWrapper, { id: this._id, selected_key: selected_key, content_style: this.props.content_style, content_spacing: this.props.content_spacing, animate: this.props.prerender }, content); }); _defineProperty(this, "TabsHandler", props => { const { label, skeleton, tab_element } = _objectSpread(_objectSpread({}, this._props), props); const { selected_key } = this.state; const TabElement = tab_element || 'button'; const tabs = this.state.data.map(_ref9 => { let { title, key, disabled = false, to, href } = _ref9; const itemParams = { to, href }; const isFocus = this.isFocus(key); const isSelected = this.isSelected(key); if (isSelected) { itemParams['aria-controls'] = `${this._id}-content`; } if (isTrue(disabled)) { itemParams.disabled = true; itemParams['aria-disabled'] = true; } if (TabElement === 'button') { itemParams.type = 'button'; } skeletonDOMAttributes(itemParams, skeleton, this.context); return React.createElement("div", { className: classnames('dnb-tabs__button__snap', isFocus && 'focus', isSelected && 'selected'), key: `tab-${key}` }, React.createElement(TabElement, _extends({ role: "tab", tabIndex: "-1", id: `${this._id}-tab-${key}`, "aria-selected": isSelected, className: classnames('dnb-tabs__button', isFocus && 'focus', isSelected && 'selected'), onMouseEnter: this.onMouseEnterHandler, onClick: this.onClickHandler, onKeyUp: this.onKeyDownHandler, onMouseDown: this.onMouseDown, "data-tab-key": key }, itemParams), React.createElement("span", { className: classnames('dnb-tabs__button__title', createSkeletonClass('font', skeleton, this.context)) }, title), React.createElement(Dummy, null, title))); }); const params = {}; if (label) { params['aria-label'] = label; } if (selected_key) { params['aria-labelledby'] = combineLabelledBy(params, `${this._id}-tab-${selected_key}`); } return React.createElement("div", _extends({ role: "tablist", className: "dnb-tabs__tabs__tablist", tabIndex: "0", onKeyDown: this.onTablistKeyDownHandler, ref: this._tablistRef }, params), tabs); }); this._id = _props.id || makeUniqueId(); const data = Tabs.getData(_props); let _selected_key = Tabs.getSelectedKeyOrFallback(_props.selected_key, data); const lastPosition = this.getLastPosition(); this.state = { data, selected_key: _selected_key, focus_key: _selected_key, atEdge: false, lastPosition, hasScrollbar: lastPosition > -1, _selected_key: _selected_key, _data: _props.data || _props.children, _listenForPropChanges: true }; this._tabsRef = React.createRef(); this._tablistRef = React.createRef(); if (_props.id) { this._eventEmitter = EventEmitter.createInstance(_props.id); this._eventEmitter.set(this.getEventArgs({ selected_key: _selected_key })); } } componentDidMount() { this._isMounted = true; if (document.readyState === 'complete') { this.init(); } else if (typeof window !== 'undefined') { window.addEventListener('load', this.init); } } componentWillUnmount() { this._isMounted = false; this.resetWhatInput(); if (this._eventEmitter) { this._eventEmitter.remove(); this._eventEmitter = null; } if (typeof window !== 'undefined') { window.removeEventListener('resize', this.onResizeHandler); window.removeEventListener('load', this.init); } } componentDidUpdate(props) { if (this._eventEmitter && (this.props.selected_key !== props.selected_key || this.props.data !== props.data)) { this.onResizeHandler(); if (this._eventEmitter) { const selected_key = this.state.selected_key; this._eventEmitter.update(this.getEventArgs({ selected_key })); } } } hasLastPosition() { return this.state.lastPosition > -1; } getLastPosition() { if (typeof window !== 'undefined') { try { const pos = parseFloat(window.localStorage.getItem(`tabs-pos-${this._id}`)); window.localStorage.removeItem(`tabs-pos-${this._id}`); return isNaN(pos) ? -1 : pos; } catch (e) { warn(e); } } return -1; } hasLastUsedTab() { if (typeof window !== 'undefined') { try { const key = window.localStorage.getItem(`tabs-last-${this._id}`) || null; window.localStorage.removeItem(`tabs-last-${this._id}`); return key; } catch (e) { warn(e); } } return -1; } saveLastUsedTab() { if (typeof window !== 'undefined') { try { window.localStorage.setItem(`tabs-last-${this._id}`, this.state.selected_key); } catch (e) { warn(e); } } } saveLastPosition() { let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._tablistRef.current.scrollLeft; if (typeof window !== 'undefined') { try { window.localStorage.setItem(`tabs-pos-${this._id}`, position); } catch (e) { warn(e); } } } hasScrollbar() { return (this._tablistRef.current.scrollWidth - 1 > this._tablistRef.current.offsetWidth ); } addScrollBehavior() { if (typeof window !== 'undefined') { window.addEventListener('resize', this.onResizeHandler); } } setLeftPosition(scrollLeft) { try { this._tablistRef.current.style.scrollBehavior = 'auto'; this._tablistRef.current.scrollLeft = scrollLeft; this._tablistRef.current.style.scrollBehavior = 'smooth'; } catch (e) {} } scrollToTab(_ref10) { let { type, behavior = 'smooth' } = _ref10; if (typeof window === 'undefined') { return; } if (window.IS_TEST) { behavior = 'auto'; } const delay = () => { try { if (this.state.hasScrollbar && this._tablistRef.current) { const first = this._tablistRef.current.querySelector('.dnb-tabs__button__snap:first-of-type'); const isFirst = first.classList.contains(type); const last = this._tablistRef.current.querySelector('.dnb-tabs__button__snap:last-of-type'); const isLast = last.classList.contains(type); const elem = this._tablistRef.current.querySelector(`.dnb-tabs__button.${type}`); const style = window.getComputedStyle(this._tabsRef.current); const margin = parseFloat(style.marginLeft); let padding = margin < 0 ? parseFloat(style.paddingLeft) : 0; if (!isFirst && !isLast && parseFloat(style.paddingLeft) < 16) { const navButton = this._tabsRef.current.querySelector('.dnb-tabs__scroll-nav-button:first-of-type'); const additionalSpace = parseFloat(window.getComputedStyle(navButton).width) * 1.5; padding += additionalSpace; } let leftPadding = (margin < 0 ? Math.abs(margin) : 0) + padding + parseFloat(window.getComputedStyle(first).paddingLeft); const offsetLeft = elem.offsetLeft; const left = elem && !isFirst ? offsetLeft - leftPadding : 0; if (behavior === 'auto') { this._tablistRef.current.style.scrollBehavior = 'auto'; } this._tablistRef.current.scrollTo({ left, behavior }); if (behavior === 'auto') { this._tablistRef.current.style.scrollBehavior = ''; } this.setState({ isFirst, isLast }); } } catch (e) { warn(e); } }; window.requestAnimationFrame(delay); } getStepKey(useKey, stateKey) { const currentData = this.state.data.filter(_ref11 => { let { disabled } = _ref11; return !disabled; }); const currentIndex = currentData.reduce((acc, _ref12, i) => { let { key } = _ref12; return key == stateKey ? i : acc; }, -1); let nextIndex = currentIndex + useKey; if (nextIndex < 0) { nextIndex = currentData.length - 1; } if (nextIndex >= currentData.length) { nextIndex = 0; } return currentData.reduce((acc, _ref13, i) => { let { key } = _ref13; return i === nextIndex ? key : acc; }, null); } setWhatInput() { whatInput.specificKeys([9, 37, 39, 33, 34, 35, 36]); } resetWhatInput() { whatInput.specificKeys([9]); } warnAboutMissingContainer() { warn(`Could not find the required <Tabs.Content id="${this._id}-content" ... /> that provides role="tabpanel"`); } getEventArgs(args) { const { selected_key, focus_key } = this.state; const key = typeof args.selected_key !== 'undefined' ? args.selected_key : selected_key; return _objectSpread({ key, selected_key, focus_key, title: this.getCurrentTitle(key) }, args); } isFocus(tabKey) { return this.state.focus_key == tabKey; } isSelected(tabKey) { return this.state.selected_key == tabKey; } renderCachedContent() { const { selected_key, data } = this.state; const { prevent_rerender, prerender } = this.props; if (isTrue(prerender)) { this._cache = Object.entries(data).reduce((acc, _ref14) => { let [idx, cur] = _ref14; acc[cur.key] = _objectSpread(_objectSpread({}, cur), {}, { content: this.getContent(cur.key) }); return acc; }, {}); } else if (isTrue(prevent_rerender)) { this._cache = _objectSpread(_objectSpread({}, this._cache || {}), {}, { [selected_key]: { content: this.getContent(selected_key) } }); } const cachedContent = Object.entries(this._cache).map(_ref15 => { let [key, { content }] = _ref15; const hide = key !== String(selected_key); return React.createElement("div", { key: key, "aria-hidden": hide ? true : undefined, className: 'dnb-tabs__cached' + (hide ? " dnb-tabs__cached--hidden" : "") }, content); }); return cachedContent; } renderContent() { const { prevent_rerender, prerender } = this.props; if (isTrue(prevent_rerender) || isTrue(prerender)) { return this.renderCachedContent(); } return this.getContent(this.state.selected_key); } render() { var _this$context; const props = this._props = extendPropsWithContextInClassComponent(this.props, Tabs.defaultProps, { skeleton: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.skeleton }); const { render: customRenderer } = props; const TabItems = this.TabsHandler; TabItems.displayName = 'Tabs'; const TabsList = this.TabsListHandler; TabsList.displayName = 'TabsList'; const Wrapper = this.TabsWrapperHandler; Wrapper.displayName = 'TabsWrapper'; const Content = this.TabContentHandler; Content.displayName = 'TabContent'; if (typeof customRenderer === 'function') { return customRenderer({ Wrapper, Content, TabsList, Tabs: TabItems }); } return React.createElement(Wrapper, null, React.createElement(TabsList, null, React.createElement(TabItems, null)), React.createElement(Content, null)); } } _defineProperty(Tabs, "contextType", Context); _defineProperty(Tabs, "defaultProps", { data: null, content: null, content_style: null, content_spacing: true, label: null, tab_element: 'button', selected_key: null, align: 'left', tabs_style: null, tabs_spacing: null, no_border: false, nav_button_edge: false, onOpenTabNavigationFn: null, prerender: false, prevent_rerender: false, scroll: null, skeleton: null, id: null, className: null, children: null, render: null, on_change: null, on_mouse_enter: null, on_click: null, on_focus: null, breakout: true }); _defineProperty(Tabs, "Content", CustomContent); _defineProperty(Tabs, "ContentWrapper", ContentWrapper); process.env.NODE_ENV !== "production" ? Tabs.propTypes = _objectSpread(_objectSpread({ data: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.shape({ title: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.func]).isRequired, key: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, selected: PropTypes.bool, disabled: PropTypes.bool })), PropTypes.objectOf(PropTypes.shape({ title: PropTypes.string.isRequired, selected: PropTypes.bool, disabled: PropTypes.bool }))]), content: PropTypes.oneOfType([PropTypes.object, PropTypes.node, PropTypes.func]), content_style: PropTypes.string, content_spacing: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), label: PropTypes.string, tab_element: PropTypes.oneOfType([PropTypes.object, PropTypes.node, PropTypes.func]), selected_key: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), align: PropTypes.oneOf(['left', 'center', 'right']), tabs_style: PropTypes.string, tabs_spacing: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), no_border: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), breakout: PropTypes.bool, nav_button_edge: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), onOpenTabNavigationFn: PropTypes.func, prerender: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), prevent_rerender: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), scroll: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), skeleton: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), id: PropTypes.string }, spacingPropTypes), {}, { className: PropTypes.string, children: PropTypes.oneOfType([PropTypes.object, PropTypes.node, PropTypes.func]), render: PropTypes.func, on_change: PropTypes.func, on_mouse_enter: PropTypes.func, on_click: PropTypes.func, on_focus: PropTypes.func }) : void 0; export const Dummy = _ref16 => { let { children } = _ref16; return React.createElement("span", { "aria-hidden": true, hidden: true, className: "dnb-dummy" }, children); }; process.env.NODE_ENV !== "production" ? Dummy.propTypes = { children: PropTypes.node.isRequired } : void 0; const ScrollNavButton = props => { return React.createElement(Button, _extends({ size: "medium", variant: "primary", tabIndex: "-1", bounding: true, "aria-hidden": true }, props, { className: classnames('dnb-tabs__scroll-nav-button', props.className) })); }; process.env.NODE_ENV !== "production" ? ScrollNavButton.propTypes = { className: PropTypes.node.isRequired } : void 0; Tabs._supportsSpacingProps = true; //# sourceMappingURL=Tabs.js.map