UNPKG

@atlaskit/editor-common

Version:

A package that contains common classes and components for editor and renderer

77 lines 4.24 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** * @jsxRuntime classic * @jsx jsx */ import { Fragment } from 'react'; // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766 import { jsx } from '@emotion/react'; import EditorFileIcon from '@atlaskit/icon/glyph/editor/file'; import { placeholderFallback, placeholderFallbackParams } from '../styles'; import { EditToggle } from './EditToggle'; import { ExtensionLabel } from './ExtensionLabel'; export var ICON_SIZE = 24; var capitalizeFirstLetter = function capitalizeFirstLetter(str) { return str.charAt(0).toUpperCase() + str.slice(1); }; export var LozengeComponent = function LozengeComponent(_ref) { var lozengeData = _ref.lozengeData, extensionName = _ref.extensionName, title = _ref.title, params = _ref.params, renderImage = _ref.renderImage, showMacroInteractionDesignUpdates = _ref.showMacroInteractionDesignUpdates, customContainerStyles = _ref.customContainerStyles, isNodeHovered = _ref.isNodeHovered, isNodeNested = _ref.isNodeNested, setIsNodeHovered = _ref.setIsNodeHovered, isBodiedMacro = _ref.isBodiedMacro, showLivePagesBodiedMacrosRendererView = _ref.showLivePagesBodiedMacrosRendererView, showUpdatedLivePages1PBodiedExtensionUI = _ref.showUpdatedLivePages1PBodiedExtensionUI, showBodiedExtensionRendererView = _ref.showBodiedExtensionRendererView, setShowBodiedExtensionRendererView = _ref.setShowBodiedExtensionRendererView; var capitalizedTitle = capitalizeFirstLetter(title); if (showMacroInteractionDesignUpdates) { return jsx(Fragment, null, jsx(ExtensionLabel, { text: capitalizedTitle, extensionName: extensionName, isNodeHovered: isNodeHovered, isNodeNested: isNodeNested, customContainerStyles: customContainerStyles, setIsNodeHovered: setIsNodeHovered, isBodiedMacro: isBodiedMacro, showLivePagesBodiedMacrosRendererView: showLivePagesBodiedMacrosRendererView, showUpdatedLivePages1PBodiedExtensionUI: showUpdatedLivePages1PBodiedExtensionUI, showBodiedExtensionRendererView: showBodiedExtensionRendererView }), showLivePagesBodiedMacrosRendererView && isBodiedMacro && jsx(EditToggle, { isNodeHovered: isNodeHovered, setIsNodeHovered: setIsNodeHovered, customContainerStyles: customContainerStyles, showBodiedExtensionRendererView: showBodiedExtensionRendererView, setShowBodiedExtensionRendererView: setShowBodiedExtensionRendererView })); } var isBlockExtension = extensionName === 'extension'; return ( // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766 jsx("div", { "data-testid": "lozenge-fallback", css: placeholderFallback }, lozengeData && !isBlockExtension ? renderImage(_objectSpread({ height: ICON_SIZE, width: ICON_SIZE }, lozengeData)) : jsx(EditorFileIcon, { label: title }), jsx("span", { className: "extension-title" }, capitalizedTitle), params && !isBlockExtension && // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766 jsx("span", { css: placeholderFallbackParams }, Object.keys(params).map(function (key) { return key && " | ".concat(key, " = ").concat(params[key].value); }))) ); };