pre-installations and preparations
This commit is contained in:
1 parent
3e5a0329cb
commit
201d621ac3
6977 files changed
+742826
No files matched your search
+15
@@ -0,0 +1,15 @@
|
||||
import { PolymorphicComponent } from '../utils/PolymorphicComponent';
|
||||
import { OptionGroupTypeMap } from './OptionGroup.types';
|
||||
/**
|
||||
* An unstyled option group to be used within a Select.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Select](https://mui.com/base-ui/react-select/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [OptionGroup API](https://mui.com/base-ui/react-select/components-api/#option-group)
|
||||
*/
|
||||
declare const OptionGroup: PolymorphicComponent<OptionGroupTypeMap<{}, "li">>;
|
||||
export { OptionGroup };
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
'use client';
|
||||
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
const _excluded = ["disabled", "slotProps", "slots"];
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { unstable_composeClasses as composeClasses } from '../composeClasses';
|
||||
import { getOptionGroupUtilityClass } from './optionGroupClasses';
|
||||
import { useSlotProps } from '../utils';
|
||||
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
function useUtilityClasses(disabled) {
|
||||
const slots = {
|
||||
root: ['root', disabled && 'disabled'],
|
||||
label: ['label'],
|
||||
list: ['list']
|
||||
};
|
||||
return composeClasses(slots, useClassNamesOverride(getOptionGroupUtilityClass));
|
||||
}
|
||||
|
||||
/**
|
||||
* An unstyled option group to be used within a Select.
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Select](https://mui.com/base-ui/react-select/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [OptionGroup API](https://mui.com/base-ui/react-select/components-api/#option-group)
|
||||
*/
|
||||
const OptionGroup = /*#__PURE__*/React.forwardRef(function OptionGroup(props, forwardedRef) {
|
||||
const {
|
||||
disabled = false,
|
||||
slotProps = {},
|
||||
slots = {}
|
||||
} = props,
|
||||
other = _objectWithoutPropertiesLoose(props, _excluded);
|
||||
const Root = (slots == null ? void 0 : slots.root) || 'li';
|
||||
const Label = (slots == null ? void 0 : slots.label) || 'span';
|
||||
const List = (slots == null ? void 0 : slots.list) || 'ul';
|
||||
const classes = useUtilityClasses(disabled);
|
||||
const rootProps = useSlotProps({
|
||||
elementType: Root,
|
||||
externalSlotProps: slotProps.root,
|
||||
externalForwardedProps: other,
|
||||
additionalProps: {
|
||||
ref: forwardedRef
|
||||
},
|
||||
ownerState: props,
|
||||
className: classes.root
|
||||
});
|
||||
const labelProps = useSlotProps({
|
||||
elementType: Label,
|
||||
externalSlotProps: slotProps.label,
|
||||
ownerState: props,
|
||||
className: classes.label
|
||||
});
|
||||
const listProps = useSlotProps({
|
||||
elementType: List,
|
||||
externalSlotProps: slotProps.list,
|
||||
ownerState: props,
|
||||
className: classes.list
|
||||
});
|
||||
return /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
|
||||
children: [/*#__PURE__*/_jsx(Label, _extends({}, labelProps, {
|
||||
children: props.label
|
||||
})), /*#__PURE__*/_jsx(List, _extends({}, listProps, {
|
||||
children: props.children
|
||||
}))]
|
||||
}));
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? OptionGroup.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true` all the options in the group will be disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* The human-readable description of the group.
|
||||
*/
|
||||
label: PropTypes.node,
|
||||
/**
|
||||
* The props used for each slot inside the Input.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps: PropTypes.shape({
|
||||
label: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
list: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
||||
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
||||
}),
|
||||
/**
|
||||
* The components used for each slot inside the OptionGroup.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots: PropTypes.shape({
|
||||
label: PropTypes.elementType,
|
||||
list: PropTypes.elementType,
|
||||
root: PropTypes.elementType
|
||||
})
|
||||
} : void 0;
|
||||
export { OptionGroup };
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
import * as React from 'react';
|
||||
import { PolymorphicProps, SlotComponentProps } from '../utils';
|
||||
export interface OptionGroupRootSlotPropsOverrides {
|
||||
}
|
||||
export interface OptionGroupLabelSlotPropsOverrides {
|
||||
}
|
||||
export interface OptionGroupListSlotPropsOverrides {
|
||||
}
|
||||
export interface OptionGroupOwnProps {
|
||||
/**
|
||||
* The human-readable description of the group.
|
||||
*/
|
||||
label?: React.ReactNode;
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
/**
|
||||
* If `true` all the options in the group will be disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled?: boolean;
|
||||
/**
|
||||
* The components used for each slot inside the OptionGroup.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots?: OptionGroupSlots;
|
||||
/**
|
||||
* The props used for each slot inside the Input.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: {
|
||||
root?: SlotComponentProps<'li', OptionGroupRootSlotPropsOverrides, OptionGroupOwnerState>;
|
||||
label?: SlotComponentProps<'span', OptionGroupLabelSlotPropsOverrides, OptionGroupOwnerState>;
|
||||
list?: SlotComponentProps<'ul', OptionGroupListSlotPropsOverrides, OptionGroupOwnerState>;
|
||||
};
|
||||
}
|
||||
export interface OptionGroupSlots {
|
||||
/**
|
||||
* The component that renders the root.
|
||||
* @default 'li'
|
||||
*/
|
||||
root?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the label.
|
||||
* @default 'span'
|
||||
*/
|
||||
label?: React.ElementType;
|
||||
/**
|
||||
* The component that renders the list.
|
||||
* @default 'ul'
|
||||
*/
|
||||
list?: React.ElementType;
|
||||
}
|
||||
export interface OptionGroupTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'li'> {
|
||||
props: OptionGroupOwnProps & AdditionalProps;
|
||||
defaultComponent: RootComponentType;
|
||||
}
|
||||
export type OptionGroupProps<RootComponentType extends React.ElementType = OptionGroupTypeMap['defaultComponent']> = PolymorphicProps<OptionGroupTypeMap<{}, RootComponentType>, RootComponentType>;
|
||||
export type OptionGroupOwnerState = OptionGroupOwnProps;
|
||||
export type OptionGroupRootSlotProps = {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
ownerState: OptionGroupOwnerState;
|
||||
ref: React.Ref<HTMLLIElement>;
|
||||
};
|
||||
export type OptionGroupLabelSlotProps = {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
ownerState: OptionGroupOwnerState;
|
||||
};
|
||||
export type OptionGroupListSlotProps = {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
ownerState: OptionGroupOwnerState;
|
||||
};
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export { OptionGroup } from './OptionGroup';
|
||||
export * from './OptionGroup.types';
|
||||
export * from './optionGroupClasses';
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export { OptionGroup } from './OptionGroup';
|
||||
export * from './OptionGroup.types';
|
||||
export * from './optionGroupClasses';
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
export interface OptionGroupClasses {
|
||||
/** Class name applied to the root element. */
|
||||
root: string;
|
||||
/** State class applied to the root `li` element if `disabled={true}`. */
|
||||
disabled: string;
|
||||
/** Class name applied to the label element. */
|
||||
label: string;
|
||||
/** Class name applied to the list element. */
|
||||
list: string;
|
||||
}
|
||||
export type OptionGroupClassKey = keyof OptionGroupClasses;
|
||||
export declare function getOptionGroupUtilityClass(slot: string): string;
|
||||
export declare const optionGroupClasses: OptionGroupClasses;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { generateUtilityClass } from '../generateUtilityClass';
|
||||
import { generateUtilityClasses } from '../generateUtilityClasses';
|
||||
const COMPONENT_NAME = 'OptionGroup';
|
||||
export function getOptionGroupUtilityClass(slot) {
|
||||
return generateUtilityClass(COMPONENT_NAME, slot);
|
||||
}
|
||||
export const optionGroupClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'disabled', 'label', 'list']);
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sideEffects": false,
|
||||
"module": "./index.js",
|
||||
"main": "../node/OptionGroup/index.js",
|
||||
"types": "./index.d.ts"
|
||||
}
|
||||
Reference in new issue
Block a user