pre-installations and preparations

This commit is contained in:
MuhammadKhalilzadeh committed 2024-05-05 11:21:00 +03:30
1 parent 3e5a0329cb
commit 201d621ac3
6977 files changed
+742826

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
'use client';
import * as React from 'react';
import { TabsContext } from '../Tabs/TabsContext';
import { CompoundComponentContext } from '../useCompound';
import { jsx as _jsx } from "react/jsx-runtime";
/**
* Sets up the contexts for the underlying Tab and TabPanel components.
*
* @ignore - do not document.
*/
export function TabsProvider(props) {
var valueProp = props.value,
children = props.children;
var direction = valueProp.direction,
getItemIndex = valueProp.getItemIndex,
onSelected = valueProp.onSelected,
orientation = valueProp.orientation,
registerItem = valueProp.registerItem,
registerTabIdLookup = valueProp.registerTabIdLookup,
selectionFollowsFocus = valueProp.selectionFollowsFocus,
totalSubitemCount = valueProp.totalSubitemCount,
value = valueProp.value,
getTabId = valueProp.getTabId,
getTabPanelId = valueProp.getTabPanelId;
var compoundComponentContextValue = React.useMemo(function () {
return {
getItemIndex: getItemIndex,
registerItem: registerItem,
totalSubitemCount: totalSubitemCount
};
}, [registerItem, getItemIndex, totalSubitemCount]);
var tabsContextValue = React.useMemo(function () {
return {
direction: direction,
getTabId: getTabId,
getTabPanelId: getTabPanelId,
onSelected: onSelected,
orientation: orientation,
registerTabIdLookup: registerTabIdLookup,
selectionFollowsFocus: selectionFollowsFocus,
value: value
};
}, [direction, getTabId, getTabPanelId, onSelected, orientation, registerTabIdLookup, selectionFollowsFocus, value]);
return /*#__PURE__*/_jsx(CompoundComponentContext.Provider, {
value: compoundComponentContextValue,
children: /*#__PURE__*/_jsx(TabsContext.Provider, {
value: tabsContextValue,
children: children
})
});
}
+5
View File
@@ -0,0 +1,5 @@
'use client';
export * from './useTabs';
export * from './useTabs.types';
export * from './TabsProvider';
+70
View File
@@ -0,0 +1,70 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import * as React from 'react';
import { unstable_useControlled as useControlled } from '@mui/utils';
import { useCompoundParent } from '../useCompound';
/**
*
* 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) {
var valueProp = parameters.value,
defaultValue = parameters.defaultValue,
onChange = parameters.onChange,
_parameters$orientati = parameters.orientation,
orientation = _parameters$orientati === void 0 ? 'horizontal' : _parameters$orientati,
_parameters$direction = parameters.direction,
direction = _parameters$direction === void 0 ? 'ltr' : _parameters$direction,
_parameters$selection = parameters.selectionFollowsFocus,
selectionFollowsFocus = _parameters$selection === void 0 ? false : _parameters$selection;
var _useControlled = useControlled({
controlled: valueProp,
default: defaultValue,
name: 'Tabs',
state: 'value'
}),
_useControlled2 = _slicedToArray(_useControlled, 2),
value = _useControlled2[0],
setValue = _useControlled2[1];
var onSelected = React.useCallback(function (event, newValue) {
setValue(newValue);
onChange == null || onChange(event, newValue);
}, [onChange, setValue]);
var _useCompoundParent = useCompoundParent(),
tabPanels = _useCompoundParent.subitems,
compoundComponentContextValue = _useCompoundParent.contextValue;
var tabIdLookup = React.useRef(function () {
return undefined;
});
var getTabPanelId = React.useCallback(function (tabValue) {
var _tabPanels$get;
return (_tabPanels$get = tabPanels.get(tabValue)) == null ? void 0 : _tabPanels$get.id;
}, [tabPanels]);
var getTabId = React.useCallback(function (tabPanelId) {
return tabIdLookup.current(tabPanelId);
}, []);
var registerTabIdLookup = React.useCallback(function (lookupFunction) {
tabIdLookup.current = lookupFunction;
}, []);
return {
contextValue: _extends({
direction: direction,
getTabId: getTabId,
getTabPanelId: getTabPanelId,
onSelected: onSelected,
orientation: orientation,
registerTabIdLookup: registerTabIdLookup,
selectionFollowsFocus: selectionFollowsFocus,
value: value
}, compoundComponentContextValue)
};
}
export { useTabs };
+1
View File
@@ -0,0 +1 @@
export {};