pre-installations and preparations
This commit is contained in:
1 parent
3e5a0329cb
commit
201d621ac3
6977 files changed
+742826
No files matched your search
+14
@@ -0,0 +1,14 @@
|
||||
import { PolymorphicComponent } from '../utils';
|
||||
import { TabsTypeMap } from './Tabs.types';
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Tabs](https://mui.com/base-ui/react-tabs/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Tabs API](https://mui.com/base-ui/react-tabs/components-api/#tabs)
|
||||
*/
|
||||
declare const Tabs: PolymorphicComponent<TabsTypeMap<{}, "div">>;
|
||||
export { Tabs };
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["children", "value", "defaultValue", "orientation", "direction", "onChange", "selectionFollowsFocus", "slotProps", "slots"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getTabsUtilityClass } from './tabsClasses';
|
||||
import { useTabs } from '../useTabs';
|
||||
import { TabsProvider } from '../useTabs/TabsProvider';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
orientation
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', orientation]
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getTabsUtilityClass));
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Tabs](https://mui.com/base-ui/react-tabs/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Tabs API](https://mui.com/base-ui/react-tabs/components-api/#tabs)
|
||||
*/
|
||||
const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(props, forwardedRef) {
|
||||
var _slots$root;
|
||||
const {
|
||||
children,
|
||||
orientation = 'horizontal',
|
||||
direction = 'ltr',
|
||||
slotProps = {},
|
||||
slots = {}
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const ownerState = _extends({}, props, {
|
||||
orientation,
|
||||
direction
|
||||
});
|
||||
const {
|
||||
contextValue
|
||||
} = useTabs(ownerState);
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const TabsRoot = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
||||
const tabsRootProps = useSlotProps({
|
||||
elementType: TabsRoot,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
return /*#__PURE__*/_jsx(TabsRoot, _extends({}, tabsRootProps, {
|
||||
children: /*#__PURE__*/_jsx(TabsProvider, {
|
||||
value: contextValue,
|
||||
children: children
|
||||
})
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Tabs.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The default value. Use when the component is not controlled.
|
||||
*/
|
||||
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
/**
|
||||
* The direction of the text.
|
||||
* @default 'ltr'
|
||||
*/
|
||||
direction: PropTypes.oneOf(['ltr', 'rtl']),
|
||||
/**
|
||||
* Callback invoked when new value is being set.
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* The component orientation (layout flow direction).
|
||||
* @default 'horizontal'
|
||||
*/
|
||||
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
||||
/**
|
||||
* If `true` the selected tab changes on focus. Otherwise it only
|
||||
* changes on activation.
|
||||
*/
|
||||
selectionFollowsFocus: PropTypes.bool,
|
||||
/**
|
||||
* The props used for each slot inside the Tabs.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Tabs.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* The value of the currently selected `Tab`.
|
||||
* If you don't want any selected `Tab`, you can set this prop to `null`.
|
||||
*/
|
||||
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
||||
} : void 0;
|
||||
export { Tabs };
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
import * as React from 'react';
|
||||
import { Simplify } from '@mui/types';
|
||||
import { SlotComponentProps } from '../utils';
|
||||
import { PolymorphicProps } from '../utils/PolymorphicComponent';
|
||||
export interface TabsRootSlotPropsOverrides {
|
||||
}
|
||||
type TabsOrientation = 'horizontal' | 'vertical';
|
||||
type TabsDirection = 'ltr' | 'rtl';
|
||||
export interface TabsOwnProps {
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children?: React.ReactNode;
|
||||
/**
|
||||
* The value of the currently selected `Tab`.
|
||||
* If you don't want any selected `Tab`, you can set this prop to `null`.
|
||||
*/
|
||||
value?: string | number | null;
|
||||
/**
|
||||
* The default value. Use when the component is not controlled.
|
||||
*/
|
||||
defaultValue?: string | number | null;
|
||||
/**
|
||||
* The component orientation (layout flow direction).
|
||||
* @default 'horizontal'
|
||||
*/
|
||||
orientation?: TabsOrientation;
|
||||
/**
|
||||
* The direction of the text.
|
||||
* @default 'ltr'
|
||||
*/
|
||||
direction?: TabsDirection;
|
||||
className?: string;
|
||||
/**
|
||||
* Callback invoked when new value is being set.
|
||||
*/
|
||||
onChange?: (event: React.SyntheticEvent | null, value: number | string | null) => void;
|
||||
/**
|
||||
* If `true` the selected tab changes on focus. Otherwise it only
|
||||
* changes on activation.
|
||||
*/
|
||||
selectionFollowsFocus?: boolean;
|
||||
/**
|
||||
* The props used for each slot inside the Tabs.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: {
|
||||
root?: SlotComponentProps<'div', TabsRootSlotPropsOverrides, TabsOwnerState>;
|
||||
};
|
||||
/**
|
||||
* The components used for each slot inside the Tabs.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots?: TabsSlots;
|
||||
}
|
||||
export interface TabsSlots {
|
||||
/**
|
||||
* The component that renders the root.
|
||||
* @default 'div'
|
||||
*/
|
||||
root?: React.ElementType;
|
||||
}
|
||||
export interface TabsTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'div'> {
|
||||
props: TabsOwnProps & AdditionalProps;
|
||||
defaultComponent: RootComponentType;
|
||||
}
|
||||
export type TabsProps<RootComponentType extends React.ElementType = TabsTypeMap['defaultComponent']> = PolymorphicProps<TabsTypeMap<{}, RootComponentType>, RootComponentType>;
|
||||
export type TabsOwnerState = Simplify<TabsOwnProps & {
|
||||
orientation: TabsOrientation;
|
||||
direction: TabsDirection;
|
||||
}>;
|
||||
export type TabsRootSlotProps = {
|
||||
ownerState: TabsOwnerState;
|
||||
ref: React.Ref<any>;
|
||||
className?: string;
|
||||
};
|
||||
export {};
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
import * as React from 'react';
|
||||
export interface TabsContextValue {
|
||||
/**
|
||||
* The currently selected tab's value.
|
||||
*/
|
||||
value: number | string | null;
|
||||
/**
|
||||
* Callback for setting new value.
|
||||
*/
|
||||
onSelected: (event: React.SyntheticEvent | null, value: number | string | null) => void;
|
||||
/**
|
||||
* The component orientation (layout flow direction).
|
||||
*/
|
||||
orientation?: 'horizontal' | 'vertical';
|
||||
/**
|
||||
* The direction of the tabs.
|
||||
*/
|
||||
direction?: 'ltr' | 'rtl';
|
||||
/**
|
||||
* Registers a function that returns the id of the tab with the given value.
|
||||
*/
|
||||
registerTabIdLookup: (lookupFunction: (id: string | number) => string | undefined) => void;
|
||||
/**
|
||||
* If `true` the selected tab changes on focus. Otherwise it only
|
||||
* changes on activation.
|
||||
*/
|
||||
selectionFollowsFocus?: boolean;
|
||||
/**
|
||||
* Gets the id of the tab with the given value.
|
||||
* @param value Value to find the tab for.
|
||||
*/
|
||||
getTabId: (value: number | string) => string | undefined;
|
||||
/**
|
||||
* Gets the id of the tab panel with the given value.
|
||||
* @param value Value to find the tab panel for.
|
||||
*/
|
||||
getTabPanelId: (value: number | string) => string | undefined;
|
||||
}
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
declare const TabsContext: React.Context<TabsContextValue | null>;
|
||||
export declare function useTabsContext(): TabsContextValue;
|
||||
export { TabsContext };
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import * as React from 'react';
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
const TabsContext = /*#__PURE__*/React.createContext(null);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
TabsContext.displayName = 'TabsContext';
|
||||
}
|
||||
export function useTabsContext() {
|
||||
const context = React.useContext(TabsContext);
|
||||
if (context == null) {
|
||||
throw new Error('No TabsContext provided');
|
||||
}
|
||||
return context;
|
||||
}
|
||||
export { TabsContext };
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export { Tabs } from './Tabs';
|
||||
export * from './TabsContext';
|
||||
export * from './tabsClasses';
|
||||
export * from './Tabs.types';
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
'use client';
|
||||
|
||||
export { Tabs } from './Tabs';
|
||||
export * from './TabsContext';
|
||||
export * from './tabsClasses';
|
||||
export * from './Tabs.types';
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sideEffects": false,
|
||||
"module": "./index.js",
|
||||
"main": "../node/Tabs/index.js",
|
||||
"types": "./index.d.ts"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
export interface TabsClasses {
|
||||
/** Class name applied to the root element. */
|
||||
root: string;
|
||||
/** Class name applied to the root element if `orientation='horizontal'`. */
|
||||
horizontal: string;
|
||||
/** Class name applied to the root element if `orientation='vertical'`. */
|
||||
vertical: string;
|
||||
}
|
||||
export type TabsClassKey = keyof TabsClasses;
|
||||
export declare function getTabsUtilityClass(slot: string): string;
|
||||
export declare const tabsClasses: TabsClasses;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
const COMPONENT_NAME = 'Tabs';
|
||||
export function getTabsUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export const tabsClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'horizontal', 'vertical']);
|
||||
Reference in new issue
Block a user