pre-installations and preparations
This commit is contained in:
1 parent
3e5a0329cb
commit
201d621ac3
6977 files changed
+742826
No files matched your search
+71
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
'use client';
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useTabs = useTabs;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _utils = require("@mui/utils");
|
||||
var _useCompound = require("../useCompound");
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Tabs](https://mui.com/base-ui/react-tabs/#hooks)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [useTabs API](https://mui.com/base-ui/react-tabs/hooks-api/#use-tabs)
|
||||
*/
|
||||
function useTabs(parameters) {
|
||||
const {
|
||||
value: valueProp,
|
||||
defaultValue,
|
||||
onChange,
|
||||
orientation = 'horizontal',
|
||||
direction = 'ltr',
|
||||
selectionFollowsFocus = false
|
||||
} = parameters;
|
||||
const [value, setValue] = (0, _utils.unstable_useControlled)({
|
||||
controlled: valueProp,
|
||||
default: defaultValue,
|
||||
name: 'Tabs',
|
||||
state: 'value'
|
||||
});
|
||||
const onSelected = React.useCallback((event, newValue) => {
|
||||
setValue(newValue);
|
||||
onChange == null || onChange(event, newValue);
|
||||
}, [onChange, setValue]);
|
||||
const {
|
||||
subitems: tabPanels,
|
||||
contextValue: compoundComponentContextValue
|
||||
} = (0, _useCompound.useCompoundParent)();
|
||||
const tabIdLookup = React.useRef(() => undefined);
|
||||
const getTabPanelId = React.useCallback(tabValue => {
|
||||
var _tabPanels$get;
|
||||
return (_tabPanels$get = tabPanels.get(tabValue)) == null ? void 0 : _tabPanels$get.id;
|
||||
}, [tabPanels]);
|
||||
const getTabId = React.useCallback(tabPanelId => {
|
||||
return tabIdLookup.current(tabPanelId);
|
||||
}, []);
|
||||
const registerTabIdLookup = React.useCallback(lookupFunction => {
|
||||
tabIdLookup.current = lookupFunction;
|
||||
}, []);
|
||||
return {
|
||||
contextValue: (0, _extends2.default)({
|
||||
direction,
|
||||
getTabId,
|
||||
getTabPanelId,
|
||||
onSelected,
|
||||
orientation,
|
||||
registerTabIdLookup,
|
||||
selectionFollowsFocus,
|
||||
value
|
||||
}, compoundComponentContextValue)
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user