@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
43 lines (41 loc) • 1.47 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
/**
* @jsxRuntime classic
* @jsx jsx
*/
import React from 'react';
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
import { jsx } from '@emotion/react';
import { dropdown } from './styles';
// Ignored via go/ees005
// eslint-disable-next-line @repo/internal/react/no-class-components
export default class DropdownWrapper extends React.Component {
constructor(...args) {
super(...args);
_defineProperty(this, "handleClick", actions => {
const {
actionOnClick,
renderOnClick
} = actions;
const {
editorActions
} = this.props;
if (actionOnClick) {
actionOnClick(editorActions);
this.props.togglePopup();
} else if (renderOnClick) {
this.props.onClick(editorActions, renderOnClick);
}
});
}
render() {
// adding onClick handler to each DropdownItem component
const children = React.Children.map(this.props.children, child => /*#__PURE__*/React.cloneElement(child, {
onClick: this.handleClick
}));
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
return jsx("div", {
css: dropdown
}, children);
}
}