UNPKG

@wordpress/block-editor

Version:
65 lines (61 loc) 1.94 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = WritingModeControl; var _clsx = _interopRequireDefault(require("clsx")); var _i18n = require("@wordpress/i18n"); var _icons = require("@wordpress/icons"); var _components = require("@wordpress/components"); var _jsxRuntime = require("react/jsx-runtime"); /** * External dependencies */ /** * WordPress dependencies */ const WRITING_MODES = [{ label: (0, _i18n.__)('Horizontal'), value: 'horizontal-tb', icon: _icons.textHorizontal }, { label: (0, _i18n.__)('Vertical'), value: (0, _i18n.isRTL)() ? 'vertical-lr' : 'vertical-rl', icon: _icons.textVertical }]; /** * Control to facilitate writing mode selections. * * @param {Object} props Component props. * @param {string} props.className Class name to add to the control. * @param {string} props.value Currently selected writing mode. * @param {Function} props.onChange Handles change in the writing mode selection. * * @return {Element} Writing Mode control. */ function WritingModeControl({ className, value, onChange }) { return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToggleGroupControl, { isDeselectable: true, __nextHasNoMarginBottom: true, __next40pxDefaultSize: true, label: (0, _i18n.__)('Orientation'), className: (0, _clsx.default)('block-editor-writing-mode-control', className), value: value, onChange: newValue => { onChange(newValue === value ? undefined : newValue); }, children: WRITING_MODES.map(option => { return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToggleGroupControlOptionIcon, { value: option.value, icon: option.icon, label: option.label }, option.value); }) }); } //# sourceMappingURL=index.js.map