UNPKG

@atlaskit/section-message

Version:

A section message is used to alert users to a particular section of the screen.

81 lines (78 loc) 3.57 kB
/* section-message-action.tsx generated by @compiled/babel-plugin v3.0.2 */ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("./section-message-action.compiled.css"); var _react = _interopRequireWildcard(require("react")); var React = _react; var _runtime = require("@compiled/react/runtime"); var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-button")); var _css = require("@atlaskit/css"); var _link = _interopRequireDefault(require("@atlaskit/link/link")); var _compiled = require("@atlaskit/primitives/compiled"); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); } var styles = { common: "_11c8fhey", anchor: "_k48pi7a9", pressable: "_2rkolb4i _syaz13af _k48p1wq8 _bfhk1j28 _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _9oik1r31 _1bnx8stv _jf4cnqa1 _30l313af _9h8h12zz" }; /** * __Section message action__ * * A section message action is designed to work with the `action` prop from * `SectionMessage`. It renders either a button or a link depending on whether * an `onClick` or `href` prop is supplied, with a dot separator in between actions. * * - [Examples](https://atlassian.design/components/section-message/examples#actions) */ var SectionMessageAction = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) { var children = _ref.children, onClick = _ref.onClick, href = _ref.href, testId = _ref.testId, linkComponent = _ref.linkComponent, target = _ref.target; if (!linkComponent) { if (href) { return /*#__PURE__*/React.createElement("span", { className: (0, _runtime.ax)([styles.common, styles.anchor]) }, /*#__PURE__*/React.createElement(_link.default, { testId: testId, onClick: onClick, href: href, target: target, ref: ref }, children)); } if (onClick) { return /*#__PURE__*/React.createElement(_compiled.Pressable, { testId: testId, onClick: onClick, xcss: (0, _css.cx)(styles.common, styles.pressable), ref: ref }, children); } return /*#__PURE__*/React.createElement(_compiled.Box, { as: "span", testId: testId, xcss: styles.common, ref: ref }, children); } // TODO: Remove this once the deprecated `linkComponent` prop is removed. return onClick || href ? /*#__PURE__*/React.createElement(_standardButton.default, { testId: testId, appearance: "link", spacing: "none", onClick: onClick, href: href, component: href ? linkComponent : undefined, ref: ref }, children) : /*#__PURE__*/React.createElement(_react.Fragment, null, children); })); SectionMessageAction.displayName = 'SectionMessageAction'; var _default = exports.default = SectionMessageAction;