{"version":3,"file":"index.cjs","names":["__","isRTL","InputControlPrefixWrapper","InputControlSuffixWrapper","Flex","FlexBlock","NumberControl","Spacer","AngleCircle","forwardRef"],"sources":["../../src/angle-picker-control/index.tsx"],"sourcesContent":["import type { ForwardedRef } from 'react';\nimport clsx from 'clsx';\nimport { forwardRef } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { Flex, FlexBlock } from '../flex';\nimport { Spacer } from '../spacer';\nimport NumberControl from '../number-control';\nimport InputControlPrefixWrapper from '../input-control/input-prefix-wrapper';\nimport InputControlSuffixWrapper from '../input-control/input-suffix-wrapper';\nimport AngleCircle from './angle-circle';\nimport type { WordPressComponentProps } from '../context';\nimport type { AnglePickerControlProps } from './types';\n\nfunction UnforwardedAnglePickerControl(\n\tprops: WordPressComponentProps< AnglePickerControlProps, 'div' >,\n\tref: ForwardedRef< any >\n) {\n\tconst {\n\t\tclassName,\n\t\tlabel = __( 'Angle' ),\n\t\tonChange,\n\t\tvalue,\n\t\t...restProps\n\t} = props;\n\n\tconst handleOnNumberChange = ( unprocessedValue: string | undefined ) => {\n\t\tif ( onChange === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst inputValue =\n\t\t\tunprocessedValue !== undefined && unprocessedValue !== ''\n\t\t\t\t? parseInt( unprocessedValue, 10 )\n\t\t\t\t: 0;\n\t\tonChange( inputValue );\n\t};\n\n\tconst classes = clsx( 'components-angle-picker-control', className );\n\n\t// Override the default behavior and position the degree symbol to the\n\t// right of the number, regardless of the language direction.\n\tconst prefixOrSuffixProp = isRTL()\n\t\t? { prefix: <InputControlPrefixWrapper>°</InputControlPrefixWrapper> }\n\t\t: { suffix: <InputControlSuffixWrapper>°</InputControlSuffixWrapper> };\n\n\treturn (\n\t\t<Flex { ...restProps } ref={ ref } className={ classes } gap={ 2 }>\n\t\t\t<FlexBlock>\n\t\t\t\t<NumberControl\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tclassName=\"components-angle-picker-control__input-field\"\n\t\t\t\t\tmax={ 360 }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonChange={ handleOnNumberChange }\n\t\t\t\t\tstep=\"1\"\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tspinControls=\"none\"\n\t\t\t\t\t{ ...prefixOrSuffixProp }\n\t\t\t\t/>\n\t\t\t</FlexBlock>\n\t\t\t<Spacer marginBottom=\"1\" marginTop=\"auto\">\n\t\t\t\t<AngleCircle\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</Spacer>\n\t\t</Flex>\n\t);\n}\n\n/**\n * `AnglePickerControl` is a React component to render a UI that allows users to\n * pick an angle. Users can choose an angle in a visual UI with the mouse by\n * dragging an angle indicator inside a circle or by directly inserting the\n * desired angle in a text field.\n *\n * ```jsx\n * import { useState } from '@wordpress/element';\n * import { AnglePickerControl } from '@wordpress/components';\n *\n * function Example() {\n *   const [ angle, setAngle ] = useState( 0 );\n *   return (\n *     <AnglePickerControl\n *       value={ angle }\n *       onChange={ setAngle }\n *     />\n *   );\n * }\n * ```\n */\nexport const AnglePickerControl = forwardRef( UnforwardedAnglePickerControl );\nAnglePickerControl.displayName = 'AnglePickerControl';\n\nexport default AnglePickerControl;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAAS,8BACR,OACA,KACC;CACD,MAAM,EACL,WACA,SAAA,GAAQA,gBAAAA,GAAAA,CAAI,OAAQ,GACpB,UACA,OACA,GAAG,cACA;CAEJ,MAAM,wBAAyB,qBAA0C;EACxE,IAAK,aAAa,KAAA,GACjB;EAOD,SAHC,qBAAqB,KAAA,KAAa,qBAAqB,KACpD,SAAU,kBAAkB,EAAG,IAC/B,CACiB;CACtB;CAEA,MAAM,WAAA,GAAU,KAAA,QAAA,CAAM,mCAAmC,SAAU;CAInE,MAAM,sBAAA,GAAqBC,gBAAAA,MAA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