UNPKG

2.56 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = TabsListProvider;
7var React = _interopRequireWildcard(require("react"));
8var _ListContext = require("../useList/ListContext");
9var _useCompound = require("../utils/useCompound");
10var _jsxRuntime = require("react/jsx-runtime");
11function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12function _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; }
13/**
14 * Sets up the contexts for the underlying Tab components.
15 *
16 * @ignore - do not document.
17 */
18function TabsListProvider(props) {
19 const {
20 value,
21 children
22 } = props;
23 const {
24 dispatch,
25 getItemIndex,
26 getItemState,
27 registerHighlightChangeHandler,
28 registerSelectionChangeHandler,
29 registerItem,
30 totalSubitemCount
31 } = value;
32 const listContextValue = React.useMemo(() => ({
33 dispatch,
34 getItemState,
35 getItemIndex,
36 registerHighlightChangeHandler,
37 registerSelectionChangeHandler
38 }), [dispatch, getItemIndex, getItemState, registerHighlightChangeHandler, registerSelectionChangeHandler]);
39 const compoundComponentContextValue = React.useMemo(() => ({
40 getItemIndex,
41 registerItem,
42 totalSubitemCount
43 }), [registerItem, getItemIndex, totalSubitemCount]);
44 return /*#__PURE__*/(0, _jsxRuntime.jsx)(_useCompound.CompoundComponentContext.Provider, {
45 value: compoundComponentContextValue,
46 children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListContext.ListContext.Provider, {
47 value: listContextValue,
48 children: children
49 })
50 });
51}
\No newline at end of file