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 { TabTypeMap } from './Tab.types';
|
||||
import { PolymorphicComponent } from '../utils';
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Tabs](https://mui.com/base-ui/react-tabs/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Tab API](https://mui.com/base-ui/react-tabs/components-api/#tab)
|
||||
*/
|
||||
declare const Tab: PolymorphicComponent<TabTypeMap<{}, "button">>;
|
||||
export { Tab };
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["action", "children", "disabled", "onChange", "onClick", "onFocus", "slotProps", "slots", "value"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getTabUtilityClass } from './tabClasses';
|
||||
import { useTab } from '../useTab';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
selected,
|
||||
disabled
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', selected && 'selected', disabled && 'disabled']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getTabUtilityClass));
|
||||
};
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Tabs](https://mui.com/base-ui/react-tabs/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Tab API](https://mui.com/base-ui/react-tabs/components-api/#tab)
|
||||
*/
|
||||
const Tab = /*#__PURE__*/React.forwardRef(function Tab(props, forwardedRef) {
|
||||
var _slots$root;
|
||||
const {
|
||||
children,
|
||||
disabled = false,
|
||||
slotProps = {},
|
||||
slots = {},
|
||||
value
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const tabRef = React.useRef();
|
||||
const handleRef = useForkRef(tabRef, forwardedRef);
|
||||
const {
|
||||
active,
|
||||
highlighted,
|
||||
selected,
|
||||
getRootProps
|
||||
} = useTab(_extends({}, props, {
|
||||
rootRef: handleRef,
|
||||
value
|
||||
}));
|
||||
const ownerState = _extends({}, props, {
|
||||
active,
|
||||
disabled,
|
||||
highlighted,
|
||||
selected
|
||||
});
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
const TabRoot = (_slots$root = slots.root) != null ? _slots$root : 'button';
|
||||
const tabRootProps = useSlotProps({
|
||||
elementType: TabRoot,
|
||||
getSlotProps: getRootProps,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState,
|
||||
className: classes.root
|
||||
});
|
||||
return /*#__PURE__*/_jsx(TabRoot, _extends({}, tabRootProps, {
|
||||
children: children
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? Tab.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* A ref for imperative actions. It currently only supports `focusVisible()` action.
|
||||
*/
|
||||
action: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
||||
current: PropTypes.shape({
|
||||
focusVisible: PropTypes.func.isRequired
|
||||
})
|
||||
})]),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* Callback invoked when new value is being set.
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* The props used for each slot inside the Tab.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the Tab.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
root: PropTypes.elementType
|
||||
}),
|
||||
/**
|
||||
* You can provide your own value. Otherwise, it falls back to the child position index.
|
||||
*/
|
||||
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
||||
} : void 0;
|
||||
export { Tab };
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
import { Simplify } from '@mui/types';
|
||||
import * as React from 'react';
|
||||
import { ButtonOwnProps } from '../Button';
|
||||
import { SlotComponentProps } from '../utils';
|
||||
import { UseTabRootSlotProps } from '../useTab';
|
||||
import { PolymorphicProps } from '../utils/PolymorphicComponent';
|
||||
export interface TabRootSlotPropsOverrides {
|
||||
}
|
||||
export interface TabOwnProps extends Omit<ButtonOwnProps, 'onChange' | 'slots' | 'slotProps'> {
|
||||
/**
|
||||
* You can provide your own value. Otherwise, it falls back to the child position index.
|
||||
*/
|
||||
value?: number | string;
|
||||
/**
|
||||
* Callback invoked when new value is being set.
|
||||
*/
|
||||
onChange?: (event: React.SyntheticEvent, value: number | string) => void;
|
||||
/**
|
||||
* The props used for each slot inside the Tab.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: {
|
||||
root?: SlotComponentProps<'button', TabRootSlotPropsOverrides, TabOwnerState>;
|
||||
};
|
||||
/**
|
||||
* The components used for each slot inside the Tab.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots?: TabSlots;
|
||||
}
|
||||
export interface TabSlots {
|
||||
/**
|
||||
* The component that renders the root.
|
||||
* @default 'button'
|
||||
*/
|
||||
root?: React.ElementType;
|
||||
}
|
||||
export type TabProps<RootComponentType extends React.ElementType = TabTypeMap['defaultComponent']> = PolymorphicProps<TabTypeMap<{}, RootComponentType>, RootComponentType>;
|
||||
export interface TabTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'button'> {
|
||||
props: TabOwnProps & AdditionalProps;
|
||||
defaultComponent: RootComponentType;
|
||||
}
|
||||
export type TabOwnerState = Simplify<TabOwnProps & {
|
||||
active: boolean;
|
||||
disabled: boolean;
|
||||
highlighted: boolean;
|
||||
selected: boolean;
|
||||
}>;
|
||||
export type TabRootSlotProps = Simplify<UseTabRootSlotProps & {
|
||||
className?: string;
|
||||
ref: React.Ref<any>;
|
||||
ownerState: TabOwnerState;
|
||||
}>;
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export { Tab } from './Tab';
|
||||
export * from './Tab.types';
|
||||
export * from './tabClasses';
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { Tab } from './Tab';
|
||||
export * from './Tab.types';
|
||||
export * from './tabClasses';
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sideEffects": false,
|
||||
"module": "./index.js",
|
||||
"main": "../node/Tab/index.js",
|
||||
"types": "./index.d.ts"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
export interface TabClasses {
|
||||
/** Class name applied to the root element. */
|
||||
root: string;
|
||||
/** State class applied to the root `button` element if `selected={true}`. */
|
||||
selected: string;
|
||||
/** State class applied to the root `button` element if `disabled={true}`. */
|
||||
disabled: string;
|
||||
}
|
||||
export type TabClassKey = keyof TabClasses;
|
||||
export declare function getTabUtilityClass(slot: string): string;
|
||||
export declare const tabClasses: TabClasses;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
const COMPONENT_NAME = 'Tab';
|
||||
export function getTabUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export const tabClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'selected', 'disabled']);
|
||||
Reference in new issue
Block a user