UNPKG

@wordpress/block-editor

Version:
88 lines (84 loc) 2.9 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = FontFamilyControl; var _clsx = _interopRequireDefault(require("clsx")); var _components = require("@wordpress/components"); var _deprecated = _interopRequireDefault(require("@wordpress/deprecated")); var _i18n = require("@wordpress/i18n"); var _useSettings = require("../use-settings"); var _jsxRuntime = require("react/jsx-runtime"); /** * External dependencies */ /** * WordPress dependencies */ /** * Internal dependencies */ function FontFamilyControl({ /** Start opting into the larger default height that will become the default size in a future version. */ __next40pxDefaultSize = false, /** Start opting into the new margin-free styles that will become the default in a future version. */ __nextHasNoMarginBottom = false, value = '', onChange, fontFamilies, className, ...props }) { var _options$find; const [blockLevelFontFamilies] = (0, _useSettings.useSettings)('typography.fontFamilies'); if (!fontFamilies) { fontFamilies = blockLevelFontFamilies; } if (!fontFamilies || fontFamilies.length === 0) { return null; } const options = [{ key: '', name: (0, _i18n.__)('Default') }, ...fontFamilies.map(({ fontFamily, name }) => ({ key: fontFamily, name: name || fontFamily, style: { fontFamily } }))]; if (!__nextHasNoMarginBottom) { (0, _deprecated.default)('Bottom margin styles for wp.blockEditor.FontFamilyControl', { since: '6.7', version: '7.0', hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version' }); } if (!__next40pxDefaultSize && (props.size === undefined || props.size === 'default')) { (0, _deprecated.default)(`36px default size for wp.blockEditor.__experimentalFontFamilyControl`, { since: '6.8', version: '7.1', hint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version.' }); } const selectedValue = (_options$find = options.find(option => option.key === value)) !== null && _options$find !== void 0 ? _options$find : ''; return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CustomSelectControl, { __next40pxDefaultSize: __next40pxDefaultSize, __shouldNotWarnDeprecated36pxSize: true, label: (0, _i18n.__)('Font'), value: selectedValue, onChange: ({ selectedItem }) => onChange(selectedItem.key), options: options, className: (0, _clsx.default)('block-editor-font-family-control', className, { 'is-next-has-no-margin-bottom': __nextHasNoMarginBottom }), ...props }); } //# sourceMappingURL=index.js.map