UNPKG

@react-spectrum/s2

Version:
1 lines 2.97 kB
{"mappings":"AAwC2B;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA","sources":["packages/@react-spectrum/s2/src/ClearButton.tsx"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n Button,\n ButtonProps,\n ButtonRenderProps\n} from 'react-aria-components';\nimport {controlSize} from './style-utils' with {type: 'macro'};\nimport CrossIcon from '../ui-icons/Cross';\nimport {FocusableRef} from '@react-types/shared';\nimport {focusRing, style} from '../style' with {type: 'macro'};\nimport {forwardRef} from 'react';\nimport {pressScale} from './pressScale';\nimport {useFocusableRef} from '@react-spectrum/utils';\ninterface ClearButtonStyleProps {\n /**\n * The size of the ClearButton.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /** Whether the ClearButton should be displayed with a static color. */\n isStaticColor?: boolean\n}\n\ninterface ClearButtonRenderProps extends ButtonRenderProps, ClearButtonStyleProps {}\ninterface ClearButtonProps extends ButtonProps, ClearButtonStyleProps {}\n\nconst focusRingStyles = focusRing();\n\nconst visibleClearButton = style<ClearButtonRenderProps>({\n ...focusRingStyles,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n height: 'full',\n width: controlSize(),\n flexShrink: 0,\n borderRadius: 'full',\n borderStyle: 'none',\n backgroundColor: 'transparent',\n boxSizing: 'border-box',\n padding: 0,\n outlineOffset: -4,\n outlineColor: {\n default: focusRingStyles.outlineColor,\n isStaticColor: 'white'\n },\n color: 'inherit',\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n});\n\nexport const ClearButton = forwardRef(function ClearButton(props: ClearButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n let {size = 'M', isStaticColor = false, ...rest} = props;\n let domRef = useFocusableRef(ref);\n return (\n <Button\n {...rest}\n ref={domRef}\n style={pressScale(domRef)}\n className={renderProps => visibleClearButton({...renderProps, size, isStaticColor})}>\n <CrossIcon size={props.size} />\n </Button>\n );\n});\n"],"names":[],"version":3,"file":"ClearButton.css.map"}