@thecb/components 7.0.1-beta.1 → 7.0.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -22874,7 +22874,7 @@ var Popover = function Popover(_ref) {
22874
22874
  tabIndex: popoverFocus && popoverOpen ? "0" : "-1",
22875
22875
  minWidth: minWidth,
22876
22876
  maxWidth: maxWidth,
22877
- extraStyles: "\n display: ".concat(popoverOpen ? "block" : "none", "; \n position: absolute; \n top: ").concat(top, "; \n right: ").concat(right, "; \n bottom: ").concat(bottom, "; \n left: ").concat(left, ";\n height: ").concat(height, "\n ")
22877
+ extraStyles: "\n display: ".concat(popoverOpen ? "block" : "none", "; \n position: absolute; \n top: ").concat(top, "; \n right: ").concat(right, "; \n bottom: ").concat(bottom, "; \n left: ").concat(left, ";\n height: ").concat(height, ";\n ")
22878
22878
  }, /*#__PURE__*/React__default.createElement(Paragraph$1, null, content), /*#__PURE__*/React__default.createElement(Box, {
22879
22879
  padding: "0",
22880
22880
  extraStyles: "position: absolute; content: \"\"; width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 8px solid rgba(255, 255, 255, 0.85); filter: drop-shadow(2px 8px 14px black); bottom: ".concat(arrowBottom, "; right: ").concat(arrowRight, "; top: ").concat(arrowTop, "; left: ").concat(arrowLeft, ";")
@@ -37539,6 +37539,135 @@ var CollapsibleSection = function CollapsibleSection(_ref) {
37539
37539
 
37540
37540
  var CollapsibleSection$1 = themeComponent(CollapsibleSection, "CollapsibleSection", fallbackValues$z);
37541
37541
 
37542
+ var ClipboardIcon = function ClipboardIcon(_ref) {
37543
+ var themeValues = _ref.themeValues;
37544
+ return /*#__PURE__*/React__default.createElement("svg", {
37545
+ width: "24",
37546
+ height: "24",
37547
+ viewBox: "0 0 24 24",
37548
+ fill: "none",
37549
+ xmlns: "http://www.w3.org/2000/svg"
37550
+ }, /*#__PURE__*/React__default.createElement("mask", {
37551
+ id: "mask0_1104_623",
37552
+ style: {
37553
+ maskType: "alpha"
37554
+ },
37555
+ maskUnits: "userSpaceOnUse",
37556
+ x: "4",
37557
+ y: "2",
37558
+ width: "16",
37559
+ height: "18"
37560
+ }, /*#__PURE__*/React__default.createElement("path", {
37561
+ "fill-rule": "evenodd",
37562
+ "clip-rule": "evenodd",
37563
+ d: "M9.83929 3.43753H14.1607V5.59825H9.83929L9.83929 3.43753ZM8.75893 3.43753C8.75893 2.84087 9.24262 2.35718 9.83929 2.35718H14.1607C14.7574 2.35718 15.2411 2.84087 15.2411 3.43753V5.59825C15.2411 6.19491 14.7574 6.67861 14.1607 6.67861H9.83929C9.24262 6.67861 8.75893 6.19491 8.75893 5.59825V3.43753ZM6.59821 3.70762H7.94866V5.32816H6.59821C6.29988 5.32816 6.05804 5.57001 6.05804 5.86834V17.4822C6.05804 17.7805 6.29988 18.0224 6.59821 18.0224H17.4018C17.7001 18.0224 17.942 17.7805 17.942 17.4822V5.86834C17.942 5.57001 17.7001 5.32816 17.4018 5.32816H16.0513V3.70762H17.4018C18.5951 3.70762 19.5625 4.67501 19.5625 5.86834V17.4822C19.5625 18.6755 18.5951 19.6429 17.4018 19.6429H6.59821C5.40488 19.6429 4.4375 18.6755 4.4375 17.4822V5.86834C4.4375 4.67501 5.40488 3.70762 6.59821 3.70762Z",
37564
+ fill: themeValues.singleIconColor
37565
+ })), /*#__PURE__*/React__default.createElement("g", {
37566
+ mask: "url(#mask0_1104_623)"
37567
+ }, /*#__PURE__*/React__default.createElement("rect", {
37568
+ width: "24",
37569
+ height: "24",
37570
+ fill: themeValues.singleIconColor
37571
+ })));
37572
+ };
37573
+
37574
+ var ClipboardIcon$1 = themeComponent(ClipboardIcon, "Icons", fallbackValues$2, "primary");
37575
+
37576
+ /*
37577
+ This component will render `text` and a clipboard icon. When hovered, a popover with content `initialPopoverContent` will be displayed.
37578
+ When clicked, `text` will be copied to the clipboard, the popover content will change to `copiedPopoverContent` for `copiedPopoverContentDuration` milliseconds,
37579
+ and the `onCopy` callback will be executed.
37580
+ */
37581
+
37582
+ var CopyableText = function CopyableText(_ref) {
37583
+ var text = _ref.text,
37584
+ onClick = _ref.onClick;
37585
+ return /*#__PURE__*/React__default.createElement(ButtonWithAction, {
37586
+ "data-testid": "copyable-trigger",
37587
+ contentOverride: true,
37588
+ action: onClick,
37589
+ variant: "ghost",
37590
+ extraStyles: "padding: 0; margin: 0; min-height: initial; min-width: initial"
37591
+ }, /*#__PURE__*/React__default.createElement(Stack, {
37592
+ direction: "row",
37593
+ childGap: "0.25rem"
37594
+ }, /*#__PURE__*/React__default.createElement(Text$1, null, text), /*#__PURE__*/React__default.createElement(ClipboardIcon$1, null)));
37595
+ };
37596
+
37597
+ var Copyable = function Copyable(_ref2) {
37598
+ var text = _ref2.text,
37599
+ onCopy = _ref2.onCopy,
37600
+ _ref2$initialPopoverC = _ref2.initialPopoverContent,
37601
+ initialPopoverContent = _ref2$initialPopoverC === void 0 ? "Click to copy to clipboard" : _ref2$initialPopoverC,
37602
+ _ref2$copiedPopoverCo = _ref2.copiedPopoverContent,
37603
+ copiedPopoverContent = _ref2$copiedPopoverCo === void 0 ? "Copied!" : _ref2$copiedPopoverCo,
37604
+ _ref2$withPopover = _ref2.withPopover,
37605
+ withPopover = _ref2$withPopover === void 0 ? true : _ref2$withPopover,
37606
+ _ref2$popoverMinWidth = _ref2.popoverMinWidth,
37607
+ popoverMinWidth = _ref2$popoverMinWidth === void 0 ? "210px" : _ref2$popoverMinWidth,
37608
+ _ref2$copiedPopoverCo2 = _ref2.copiedPopoverContentDuration,
37609
+ copiedPopoverContentDuration = _ref2$copiedPopoverCo2 === void 0 ? 1000 : _ref2$copiedPopoverCo2,
37610
+ _ref2$popoverID = _ref2.popoverID,
37611
+ popoverID = _ref2$popoverID === void 0 ? 0 : _ref2$popoverID,
37612
+ extraStyles = _ref2.extraStyles;
37613
+ var popoverPosition = {
37614
+ top: "-65px",
37615
+ right: "auto",
37616
+ bottom: "auto",
37617
+ left: "50%"
37618
+ };
37619
+ var popoverArrowPosition = {
37620
+ arrowTop: "auto",
37621
+ arrowRight: "auto",
37622
+ arrowBottom: "-8px",
37623
+ arrowLeft: "calc(50% - 4px)" // Popover arrow is 8px wide. This places the middle of the arrow in the middle of the popover.
37624
+
37625
+ };
37626
+
37627
+ var _useState = React.useState(initialPopoverContent),
37628
+ _useState2 = _slicedToArray(_useState, 2),
37629
+ popoverContent = _useState2[0],
37630
+ setPopoverContent = _useState2[1];
37631
+
37632
+ var _useState3 = React.useState(undefined),
37633
+ _useState4 = _slicedToArray(_useState3, 2),
37634
+ timer = _useState4[0],
37635
+ setTimer = _useState4[1];
37636
+
37637
+ var onClick = function onClick() {
37638
+ setPopoverContent(copiedPopoverContent);
37639
+ navigator.clipboard.writeText(text)["catch"](function (e) {
37640
+ return console.error(e);
37641
+ });
37642
+ onCopy === null || onCopy === void 0 ? void 0 : onCopy();
37643
+
37644
+ if (timer) {
37645
+ clearTimeout(timer);
37646
+ }
37647
+
37648
+ setTimer(setTimeout(function () {
37649
+ setPopoverContent(initialPopoverContent);
37650
+ setTimer(undefined);
37651
+ }, copiedPopoverContentDuration));
37652
+ };
37653
+
37654
+ return withPopover ? /*#__PURE__*/React__default.createElement(Popover$1, {
37655
+ minWidth: popoverMinWidth,
37656
+ position: popoverPosition,
37657
+ arrowPosition: popoverArrowPosition,
37658
+ popoverID: popoverID,
37659
+ extraStyles: "> button#btnPopover".concat(popoverID, " { margin: 0 }; #Disclosed").concat(popoverID, " { transform: translateX(-50%); }; ").concat(extraStyles),
37660
+ triggerText: CopyableText({
37661
+ text: text,
37662
+ onClick: onClick
37663
+ }),
37664
+ content: popoverContent
37665
+ }) : CopyableText({
37666
+ text: text,
37667
+ onClick: onClick
37668
+ });
37669
+ };
37670
+
37542
37671
  var EditNameForm = function EditNameForm(_ref) {
37543
37672
  var fields = _ref.fields,
37544
37673
  actions = _ref.actions,
@@ -46739,6 +46868,7 @@ exports.CheckmarkIcon = CheckmarkIcon;
46739
46868
  exports.ChevronIcon = ChevronIcon$1;
46740
46869
  exports.Cluster = Cluster;
46741
46870
  exports.CollapsibleSection = CollapsibleSection$1;
46871
+ exports.Copyable = Copyable;
46742
46872
  exports.CountryDropdown = CountryDropdown;
46743
46873
  exports.Cover = Cover;
46744
46874
  exports.CustomerSearchIcon = CustomerSearchIcon;