UNPKG

@wordpress/block-editor

Version:
8 lines (7 loc) 3.15 kB
{ "version": 3, "sources": ["../../../src/components/letter-spacing-control/index.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport deprecated from '@wordpress/deprecated';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../../components/use-settings';\n\n/**\n * Control for letter-spacing.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.__next40pxDefaultSize Start opting into the larger default height that will become the default size in a future version.\n * @param {string} props.value Currently selected letter-spacing.\n * @param {Function} props.onChange Handles change in letter-spacing selection.\n * @param {string|number|undefined} props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS value.\n *\n * @return {Element} Letter-spacing control.\n */\nexport default function LetterSpacingControl( {\n\t__next40pxDefaultSize = false,\n\tvalue,\n\tonChange,\n\t__unstableInputWidth = '60px',\n\t...otherProps\n} ) {\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [ 'px', 'em', 'rem' ],\n\t\tdefaultValues: { px: 2, em: 0.2, rem: 0.2 },\n\t} );\n\n\tif (\n\t\t! __next40pxDefaultSize &&\n\t\t( otherProps.size === undefined || otherProps.size === 'default' )\n\t) {\n\t\tdeprecated(\n\t\t\t`36px default size for wp.blockEditor.__experimentalLetterSpacingControl`,\n\t\t\t{\n\t\t\t\tsince: '6.8',\n\t\t\t\tversion: '7.1',\n\t\t\t\thint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version.',\n\t\t\t}\n\t\t);\n\t}\n\n\treturn (\n\t\t<UnitControl\n\t\t\t__next40pxDefaultSize={ __next40pxDefaultSize }\n\t\t\t__shouldNotWarnDeprecated36pxSize\n\t\t\t{ ...otherProps }\n\t\t\tlabel={ __( 'Letter spacing' ) }\n\t\t\tvalue={ value }\n\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\tunits={ units }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAGO;AACP,wBAAuB;AACvB,kBAAmB;AAKnB,0BAA4B;AAyC1B;AA5Ba,SAAR,qBAAuC;AAAA,EAC7C,wBAAwB;AAAA,EACxB;AAAA,EACA;AAAA,EACA,uBAAuB;AAAA,EACvB,GAAG;AACJ,GAAI;AACH,QAAM,CAAE,cAAe,QAAI,iCAAa,eAAgB;AACxD,QAAM,YAAQ,kBAAAA,8BAAgB;AAAA,IAC7B,gBAAgB,kBAAkB,CAAE,MAAM,MAAM,KAAM;AAAA,IACtD,eAAe,EAAE,IAAI,GAAG,IAAI,KAAK,KAAK,IAAI;AAAA,EAC3C,CAAE;AAEF,MACC,CAAE,0BACA,WAAW,SAAS,UAAa,WAAW,SAAS,YACtD;AACD,0BAAAC;AAAA,MACC;AAAA,MACA;AAAA,QACC,OAAO;AAAA,QACP,SAAS;AAAA,QACT,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AAEA,SACC;AAAA,IAAC,kBAAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,mCAAiC;AAAA,MAC/B,GAAG;AAAA,MACL,WAAQ,gBAAI,gBAAiB;AAAA,MAC7B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACD;AAEF;", "names": ["useCustomUnits", "deprecated", "UnitControl"] }