UNPKG

@coveord/plasma-mantine

Version:

A Plasma flavoured Mantine theme

64 lines (63 loc) 3.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "CopyToClipboard", { enumerable: true, get: function() { return CopyToClipboard; } }); var _object_spread = require("@swc/helpers/_/_object_spread"); var _object_spread_props = require("@swc/helpers/_/_object_spread_props"); var _object_without_properties = require("@swc/helpers/_/_object_without_properties"); var _jsxruntime = require("react/jsx-runtime"); var _plasmareacticons = require("@coveord/plasma-react-icons"); var _core = require("@mantine/core"); var _ActionIcon = require("../ActionIcon/ActionIcon.js"); var CopyToClipboardButton = function CopyToClipboardButton(_0) { var value = _0.value, onCopy = _0.onCopy, color = _0.color, _0_tooltipLabelCopy = _0.tooltipLabelCopy, tooltipLabelCopy = _0_tooltipLabelCopy === void 0 ? 'Copy to clipboard' : _0_tooltipLabelCopy, _0_tooltipLabelCopied = _0.tooltipLabelCopied, tooltipLabelCopied = _0_tooltipLabelCopied === void 0 ? 'Copied' : _0_tooltipLabelCopied, others = _object_without_properties._(_0, [ "value", "onCopy", "color", "tooltipLabelCopy", "tooltipLabelCopied" ]); return /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.CopyButton, { value: value, timeout: 2000, children: function children(param) { var copied = param.copied, copy = param.copy; return /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.Tooltip, { label: copied ? tooltipLabelCopied : tooltipLabelCopy, children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ActionIcon.ActionIcon.Quaternary, _object_spread_props._(_object_spread._({ "aria-label": tooltipLabelCopy, color: copied ? 'success' : color, onClick: function onClick(clickEvent) { copy(); onCopy === null || onCopy === void 0 ? void 0 : onCopy(clickEvent); } }, others), { children: copied ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_plasmareacticons.IconClipboardCheck, { size: 16 }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_plasmareacticons.IconClipboardText, { size: 16 }) })) }); } }); }; var CopyToClipboard = function CopyToClipboard(_0) { var withLabel = _0.withLabel, others = _object_without_properties._(_0, [ "withLabel" ]); return withLabel ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.TextInput, { value: others.value, readOnly: true, autoComplete: "off", rightSection: /*#__PURE__*/ (0, _jsxruntime.jsx)(CopyToClipboardButton, _object_spread._({}, others)) }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(CopyToClipboardButton, _object_spread._({}, others)); }; CopyToClipboard.displayName = 'CopyToClipboard'; //# sourceMappingURL=CopyToClipboard.js.map