1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import composeClasses from '../composeClasses';
|
6 | import { getOptionGroupUtilityClass } from './optionGroupClasses';
|
7 | import { useSlotProps } from '../utils';
|
8 | import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
9 | import { jsx as _jsx } from "react/jsx-runtime";
|
10 | import { jsxs as _jsxs } from "react/jsx-runtime";
|
11 | function useUtilityClasses(disabled) {
|
12 | var slots = {
|
13 | root: ['root', disabled && 'disabled'],
|
14 | label: ['label'],
|
15 | list: ['list']
|
16 | };
|
17 | return composeClasses(slots, useClassNamesOverride(getOptionGroupUtilityClass));
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | var OptionGroup = React.forwardRef(function OptionGroup(props, forwardedRef) {
|
32 | var _props$disabled = props.disabled,
|
33 | disabled = _props$disabled === void 0 ? false : _props$disabled,
|
34 | _props$slotProps = props.slotProps,
|
35 | slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
36 | _props$slots = props.slots,
|
37 | slots = _props$slots === void 0 ? {} : _props$slots,
|
38 | other = _objectWithoutProperties(props, ["disabled", "slotProps", "slots"]);
|
39 | var Root = (slots == null ? void 0 : slots.root) || 'li';
|
40 | var Label = (slots == null ? void 0 : slots.label) || 'span';
|
41 | var List = (slots == null ? void 0 : slots.list) || 'ul';
|
42 | var classes = useUtilityClasses(disabled);
|
43 | var rootProps = useSlotProps({
|
44 | elementType: Root,
|
45 | externalSlotProps: slotProps.root,
|
46 | externalForwardedProps: other,
|
47 | additionalProps: {
|
48 | ref: forwardedRef
|
49 | },
|
50 | ownerState: props,
|
51 | className: classes.root
|
52 | });
|
53 | var labelProps = useSlotProps({
|
54 | elementType: Label,
|
55 | externalSlotProps: slotProps.label,
|
56 | ownerState: props,
|
57 | className: classes.label
|
58 | });
|
59 | var listProps = useSlotProps({
|
60 | elementType: List,
|
61 | externalSlotProps: slotProps.list,
|
62 | ownerState: props,
|
63 | className: classes.list
|
64 | });
|
65 | return _jsxs(Root, _extends({}, rootProps, {
|
66 | children: [_jsx(Label, _extends({}, labelProps, {
|
67 | children: props.label
|
68 | })), _jsx(List, _extends({}, listProps, {
|
69 | children: props.children
|
70 | }))]
|
71 | }));
|
72 | });
|
73 | process.env.NODE_ENV !== "production" ? OptionGroup.propTypes = {
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | |
79 |
|
80 |
|
81 | children: PropTypes.node,
|
82 | |
83 |
|
84 |
|
85 |
|
86 | disabled: PropTypes.bool,
|
87 | |
88 |
|
89 |
|
90 | label: PropTypes.node,
|
91 | |
92 |
|
93 |
|
94 |
|
95 | slotProps: PropTypes.shape({
|
96 | label: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
97 | list: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
98 | root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
99 | }),
|
100 | |
101 |
|
102 |
|
103 |
|
104 |
|
105 | slots: PropTypes.shape({
|
106 | label: PropTypes.elementType,
|
107 | list: PropTypes.elementType,
|
108 | root: PropTypes.elementType
|
109 | })
|
110 | } : void 0;
|
111 | export default OptionGroup; |
\ | No newline at end of file |