UNPKG

2.45 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import RadioButtonUncheckedIcon from "../internal/svg-icons/RadioButtonUnchecked.js";
6import RadioButtonCheckedIcon from "../internal/svg-icons/RadioButtonChecked.js";
7import rootShouldForwardProp from "../styles/rootShouldForwardProp.js";
8import { styled } from "../zero-styled/index.js";
9import memoTheme from "../utils/memoTheme.js";
10import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11const RadioButtonIconRoot = styled('span', {
12 shouldForwardProp: rootShouldForwardProp
13})({
14 position: 'relative',
15 display: 'flex'
16});
17const RadioButtonIconBackground = styled(RadioButtonUncheckedIcon)({
18 // Scale applied to prevent dot misalignment in Safari
19 transform: 'scale(1)'
20});
21const RadioButtonIconDot = styled(RadioButtonCheckedIcon)(memoTheme(({
22 theme
23}) => ({
24 left: 0,
25 position: 'absolute',
26 transform: 'scale(0)',
27 transition: theme.transitions.create('transform', {
28 easing: theme.transitions.easing.easeIn,
29 duration: theme.transitions.duration.shortest
30 }),
31 variants: [{
32 props: {
33 checked: true
34 },
35 style: {
36 transform: 'scale(1)',
37 transition: theme.transitions.create('transform', {
38 easing: theme.transitions.easing.easeOut,
39 duration: theme.transitions.duration.shortest
40 })
41 }
42 }]
43})));
44
45/**
46 * @ignore - internal component.
47 */
48function RadioButtonIcon(props) {
49 const {
50 checked = false,
51 classes = {},
52 fontSize
53 } = props;
54 const ownerState = {
55 ...props,
56 checked
57 };
58 return /*#__PURE__*/_jsxs(RadioButtonIconRoot, {
59 className: classes.root,
60 ownerState: ownerState,
61 children: [/*#__PURE__*/_jsx(RadioButtonIconBackground, {
62 fontSize: fontSize,
63 className: classes.background,
64 ownerState: ownerState
65 }), /*#__PURE__*/_jsx(RadioButtonIconDot, {
66 fontSize: fontSize,
67 className: classes.dot,
68 ownerState: ownerState
69 })]
70 });
71}
72process.env.NODE_ENV !== "production" ? RadioButtonIcon.propTypes /* remove-proptypes */ = {
73 /**
74 * If `true`, the component is checked.
75 */
76 checked: PropTypes.bool,
77 /**
78 * Override or extend the styles applied to the component.
79 */
80 classes: PropTypes.object,
81 /**
82 * The size of the component.
83 * `small` is equivalent to the dense radio styling.
84 */
85 fontSize: PropTypes.oneOf(['small', 'medium'])
86} : void 0;
87export default RadioButtonIcon;
\No newline at end of file