/** @jsx jsx */ import { jsx } from '@emotion/react'; // eslint-disable-line no-unused-vars import { CSSObject } from '@emotion/serialize'; import { ReactNode, useState } from 'react'; import CodeSandboxer, { GitInfo } from 'react-codesandboxer'; import { CodeBlock } from './markdown/renderer'; import pkg from '../packages/react-select/package.json'; import { defaultTheme } from 'react-select'; import Svg, { SvgProps } from './Svg'; const { colors } = defaultTheme; const gitInfo: GitInfo = { account: 'JedWatson', repository: 'react-select', branch: 'master', host: 'github', }; const sourceUrl = `https://github.com/${gitInfo.account}/react-select/tree/${gitInfo.branch}`; interface Props { children?: ReactNode; readonly label: string; readonly raw: { readonly default: string }; readonly urlPath: string; readonly isEditable?: boolean; } export default ({ children, label, raw, urlPath, isEditable = true, }: Props) => { const [showCode, setShowCode] = useState(false); return (

{label}

{raw ? ( setShowCode((prev) => !prev)} title="View Source" > ) : ( )} {isEditable ? ( {({ isLoading }) => ( {isLoading ? : } )} ) : null}
{showCode && raw ? ( ) : null} {children}
); }; const ExampleHeading = (props: any) => (
h4': { margin: 0, }, }} {...props} /> ); // ============================== // Source & Sandbox Actions // ============================== const SourceIcon = (props: Omit) => ( Source Code Icon ); const NewWindowIcon = (props: Omit) => ( New Window Icon ); const actionCSS: CSSObject = { alignItems: 'center', background: 0, border: 0, borderRadius: 3, boxSizing: 'border-box', color: colors.neutral40, cursor: 'pointer', display: 'flex', fontSize: 'inherit', height: 24, marginLeft: 2, justifyContent: 'center', position: 'relative', transition: 'background-color 150ms, box-shadow 150ms, color 150ms', width: 30, ':hover': { backgroundColor: colors.neutral5, outline: 0, }, ':active': { backgroundColor: colors.neutral10, bottom: -1, }, }; interface ActionProps { readonly css?: CSSObject; } const ButtonAction = ({ css, ...props }: ActionProps & Omit) => { return (