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) {
const {
value: valueProp,
children
} = props;
const {
direction,
getItemIndex,
onSelected,
orientation,
registerItem,
registerTabIdLookup,
selectionFollowsFocus,
totalSubitemCount,
value,
getTabId,
getTabPanelId
} = valueProp;
const compoundComponentContextValue = React.useMemo(() => ({
getItemIndex,
registerItem,
totalSubitemCount
}), [registerItem, getItemIndex, totalSubitemCount]);
const tabsContextValue = React.useMemo(() => ({
direction,
getTabId,
getTabPanelId,
onSelected,
orientation,
registerTabIdLookup,
selectionFollowsFocus,
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';
+63
View File
@@ -0,0 +1,63 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
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) {
const {
value: valueProp,
defaultValue,
onChange,
orientation = 'horizontal',
direction = 'ltr',
selectionFollowsFocus = false
} = parameters;
const [value, setValue] = useControlled({
controlled: valueProp,
default: defaultValue,
name: 'Tabs',
state: 'value'
});
const onSelected = React.useCallback((event, newValue) => {
setValue(newValue);
onChange?.(event, newValue);
}, [onChange, setValue]);
const {
subitems: tabPanels,
contextValue: compoundComponentContextValue
} = useCompoundParent();
const tabIdLookup = React.useRef(() => undefined);
const getTabPanelId = React.useCallback(tabValue => {
return tabPanels.get(tabValue)?.id;
}, [tabPanels]);
const getTabId = React.useCallback(tabPanelId => {
return tabIdLookup.current(tabPanelId);
}, []);
const registerTabIdLookup = React.useCallback(lookupFunction => {
tabIdLookup.current = lookupFunction;
}, []);
return {
contextValue: _extends({
direction,
getTabId,
getTabPanelId,
onSelected,
orientation,
registerTabIdLookup,
selectionFollowsFocus,
value
}, compoundComponentContextValue)
};
}
export { useTabs };
+1
View File
@@ -0,0 +1 @@
export {};