UNPKG

@elastic/eui

Version:

Elastic UI Component Library

55 lines (54 loc) 2.42 kB
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ import React, { useContext } from 'react'; import PropTypes from "prop-types"; import { css } from '@emotion/react'; import { logicalCSS } from '../../../../global_styling'; import { EuiCheckbox } from '../../../form/checkbox'; import { EuiMarkdownContext } from '../../markdown_context'; import { useGeneratedHtmlId } from '../../../../services/accessibility'; import { jsx as ___EmotionJSX } from "@emotion/react"; export var CheckboxMarkdownRenderer = function CheckboxMarkdownRenderer(_ref) { var position = _ref.position, lead = _ref.lead, label = _ref.label, isChecked = _ref.isChecked, children = _ref.children; var _useContext = useContext(EuiMarkdownContext), replaceNode = _useContext.replaceNode, readOnly = _useContext.readOnly; return ___EmotionJSX(EuiCheckbox, { id: useGeneratedHtmlId(), checked: isChecked, label: children, onChange: function onChange() { replaceNode(position, "".concat(lead, "[").concat(isChecked ? ' ' : 'x', "]").concat(label)); }, css: markdownCheckboxStyles, readOnly: readOnly }); }; CheckboxMarkdownRenderer.propTypes = { type: PropTypes.oneOf(["checkboxPlugin"]).isRequired, lead: PropTypes.string.isRequired, label: PropTypes.string.isRequired, isChecked: PropTypes.bool.isRequired, position: PropTypes.shape({ start: PropTypes.shape({ line: PropTypes.number.isRequired, column: PropTypes.number.isRequired, offset: PropTypes.number.isRequired }).isRequired, end: PropTypes.shape({ line: PropTypes.number.isRequired, column: PropTypes.number.isRequired, offset: PropTypes.number.isRequired }).isRequired }).isRequired }; var markdownCheckboxStyles = /*#__PURE__*/css("&&{.euiCheckbox__input~.euiCheckbox__label{font-size:inherit;line-height:inherit;", logicalCSS('padding-left', '1.5em'), ";}&:has(+ :not(.euiCheckbox)){", logicalCSS('margin-bottom', '1em'), ";}.euiCheckbox__input+.euiCheckbox__square{", logicalCSS('top', '50%'), " transform:translateY(-50%);}};label:markdownCheckboxStyles;");