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