@redsift/charts 7.4.2 → 7.5.0-alpha.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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { scaleOrdinal, select, axisBottom, scaleLinear, sum, pie, arc } from 'd3';
2
- import React, { forwardRef, useState, useRef, useEffect, useImperativeHandle, useLayoutEffect, useId } from 'react';
2
+ import React, { forwardRef, useRef, useEffect, useId } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
- import ReactDOM from 'react-dom';
4
+ import { Tooltip } from '@redsift/popovers';
5
5
 
6
6
  const ColorTheme = {
7
7
  default: 'default',
@@ -12,7 +12,7 @@ const ColorTheme = {
12
12
 
13
13
  /**
14
14
  * Do not edit directly
15
- * Generated on Thu, 09 Feb 2023 16:05:01 GMT
15
+ * Generated on Tue, 21 Feb 2023 15:02:26 GMT
16
16
  */
17
17
  const RedsiftDataVizColorPurpleDefault = '#C1AAEA';
18
18
  const RedsiftDataVizColorPurpleDark = '#A78ADB';
@@ -128,8 +128,8 @@ function _defineProperty(obj, key, value) {
128
128
  }
129
129
  return obj;
130
130
  }
131
- function _extends$1() {
132
- _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
131
+ function _extends() {
132
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
133
133
  for (var i = 1; i < arguments.length; i++) {
134
134
  var source = arguments[i];
135
135
  for (var key in source) {
@@ -140,7 +140,7 @@ function _extends$1() {
140
140
  }
141
141
  return target;
142
142
  };
143
- return _extends$1.apply(this, arguments);
143
+ return _extends.apply(this, arguments);
144
144
  }
145
145
  function _objectWithoutPropertiesLoose(source, excluded) {
146
146
  if (source == null) return {};
@@ -316,14 +316,6 @@ const StyledHorizontalBarChartBar = styled.g`
316
316
  ` : '';
317
317
  }}}
318
318
  `;
319
- const StyledHorizontalBarChartTooltip = styled.div`
320
- font-family: var(--redsift-typography-font-family-raleway);
321
- border: 1px solid rgb(0 0 0 / 20%);
322
- padding: 10px;
323
- box-shadow: 0 2px 1px -1px rgb(0 0 0 / 20%), 0 1px 1px 0 rgb(0 0 0 / 14%),
324
- 0 1px 3px 0 rgb(0 0 0 / 12%);
325
- background-color: var(--redsift-color-neutral-white);
326
- `;
327
319
  const StyledHorizontalBarChartAxisBottom = styled.g`
328
320
  line.grid-line {
329
321
  fill: none;
@@ -337,630 +329,6 @@ const StyledHorizontalBarChartAxisBottom = styled.g`
337
329
  }
338
330
  `;
339
331
 
340
- function _extends() {
341
- _extends = Object.assign || function (target) {
342
- for (var i = 1; i < arguments.length; i++) {
343
- var source = arguments[i];
344
-
345
- for (var key in source) {
346
- if (Object.prototype.hasOwnProperty.call(source, key)) {
347
- target[key] = source[key];
348
- }
349
- }
350
- }
351
-
352
- return target;
353
- };
354
-
355
- return _extends.apply(this, arguments);
356
- }
357
-
358
- var useOnEscape = function useOnEscape(handler, active) {
359
- if (active === void 0) {
360
- active = true;
361
- }
362
-
363
- useEffect(function () {
364
- if (!active) return;
365
-
366
- var listener = function listener(event) {
367
- // check if key is an Escape
368
- if (event.key === 'Escape') handler(event);
369
- };
370
-
371
- document.addEventListener('keyup', listener);
372
- return function () {
373
- if (!active) return;
374
- document.removeEventListener('keyup', listener);
375
- };
376
- }, [handler, active]);
377
- };
378
- var useRepositionOnResize = function useRepositionOnResize(handler, active) {
379
- if (active === void 0) {
380
- active = true;
381
- }
382
-
383
- useEffect(function () {
384
- if (!active) return;
385
-
386
- var listener = function listener() {
387
- handler();
388
- };
389
-
390
- window.addEventListener('resize', listener);
391
- return function () {
392
- if (!active) return;
393
- window.removeEventListener('resize', listener);
394
- };
395
- }, [handler, active]);
396
- };
397
- var useOnClickOutside = function useOnClickOutside(ref, handler, active) {
398
- if (active === void 0) {
399
- active = true;
400
- }
401
-
402
- useEffect(function () {
403
- if (!active) return;
404
-
405
- var listener = function listener(event) {
406
- // Do nothing if clicking ref's element or descendent elements
407
- var refs = Array.isArray(ref) ? ref : [ref];
408
- var contains = false;
409
- refs.forEach(function (r) {
410
- if (!r.current || r.current.contains(event.target)) {
411
- contains = true;
412
- return;
413
- }
414
- });
415
- event.stopPropagation();
416
- if (!contains) handler(event);
417
- };
418
-
419
- document.addEventListener('mousedown', listener);
420
- document.addEventListener('touchstart', listener);
421
- return function () {
422
- if (!active) return;
423
- document.removeEventListener('mousedown', listener);
424
- document.removeEventListener('touchstart', listener);
425
- };
426
- }, [ref, handler, active]);
427
- }; // Make sure that user is not able TAB out of the Modal content on Open
428
-
429
- var useTabbing = function useTabbing(contentRef, active) {
430
- if (active === void 0) {
431
- active = true;
432
- }
433
-
434
- useEffect(function () {
435
- if (!active) return;
436
-
437
- var listener = function listener(event) {
438
- // check if key is an Tab
439
- if (event.keyCode === 9) {
440
- var _contentRef$current;
441
-
442
- var els = contentRef === null || contentRef === void 0 ? void 0 : (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]');
443
- var focusableEls = Array.prototype.slice.call(els);
444
-
445
- if (focusableEls.length === 1) {
446
- event.preventDefault();
447
- return;
448
- }
449
-
450
- var firstFocusableEl = focusableEls[0];
451
- var lastFocusableEl = focusableEls[focusableEls.length - 1];
452
-
453
- if (event.shiftKey && document.activeElement === firstFocusableEl) {
454
- event.preventDefault();
455
- lastFocusableEl.focus();
456
- } else if (document.activeElement === lastFocusableEl) {
457
- event.preventDefault();
458
- firstFocusableEl.focus();
459
- }
460
- }
461
- };
462
-
463
- document.addEventListener('keydown', listener);
464
- return function () {
465
- if (!active) return;
466
- document.removeEventListener('keydown', listener);
467
- };
468
- }, [contentRef, active]);
469
- };
470
- var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
471
-
472
- var Style = {
473
- popupContent: {
474
- tooltip: {
475
- position: 'absolute',
476
- zIndex: 999
477
- },
478
- modal: {
479
- position: 'relative',
480
- margin: 'auto'
481
- }
482
- },
483
- popupArrow: {
484
- height: '8px',
485
- width: '16px',
486
- position: 'absolute',
487
- background: 'transparent',
488
- color: '#FFF',
489
- zIndex: -1
490
- },
491
- overlay: {
492
- tooltip: {
493
- position: 'fixed',
494
- top: '0',
495
- bottom: '0',
496
- left: '0',
497
- right: '0',
498
- zIndex: 999
499
- },
500
- modal: {
501
- position: 'fixed',
502
- top: '0',
503
- bottom: '0',
504
- left: '0',
505
- right: '0',
506
- display: 'flex',
507
- zIndex: 999
508
- }
509
- }
510
- };
511
-
512
- var POSITION_TYPES = ['top left', 'top center', 'top right', 'right top', 'right center', 'right bottom', 'bottom left', 'bottom center', 'bottom right', 'left top', 'left center', 'left bottom'];
513
-
514
- var getCoordinatesForPosition = function getCoordinatesForPosition(triggerBounding, ContentBounding, position, //PopupPosition | PopupPosition[],
515
- arrow, _ref) {
516
- var offsetX = _ref.offsetX,
517
- offsetY = _ref.offsetY;
518
- var margin = arrow ? 8 : 0;
519
- var args = position.split(' '); // the step N 1 : center the popup content => ok
520
-
521
- var CenterTop = triggerBounding.top + triggerBounding.height / 2;
522
- var CenterLeft = triggerBounding.left + triggerBounding.width / 2;
523
- var height = ContentBounding.height,
524
- width = ContentBounding.width;
525
- var top = CenterTop - height / 2;
526
- var left = CenterLeft - width / 2;
527
- var transform = '';
528
- var arrowTop = '0%';
529
- var arrowLeft = '0%'; // the step N 2 : => ok
530
-
531
- switch (args[0]) {
532
- case 'top':
533
- top -= height / 2 + triggerBounding.height / 2 + margin;
534
- transform = "rotate(180deg) translateX(50%)";
535
- arrowTop = '100%';
536
- arrowLeft = '50%';
537
- break;
538
-
539
- case 'bottom':
540
- top += height / 2 + triggerBounding.height / 2 + margin;
541
- transform = "rotate(0deg) translateY(-100%) translateX(-50%)";
542
- arrowLeft = '50%';
543
- break;
544
-
545
- case 'left':
546
- left -= width / 2 + triggerBounding.width / 2 + margin;
547
- transform = " rotate(90deg) translateY(50%) translateX(-25%)";
548
- arrowLeft = '100%';
549
- arrowTop = '50%';
550
- break;
551
-
552
- case 'right':
553
- left += width / 2 + triggerBounding.width / 2 + margin;
554
- transform = "rotate(-90deg) translateY(-150%) translateX(25%)";
555
- arrowTop = '50%';
556
- break;
557
- }
558
-
559
- switch (args[1]) {
560
- case 'top':
561
- top = triggerBounding.top;
562
- arrowTop = triggerBounding.height / 2 + "px";
563
- break;
564
-
565
- case 'bottom':
566
- top = triggerBounding.top - height + triggerBounding.height;
567
- arrowTop = height - triggerBounding.height / 2 + "px";
568
- break;
569
-
570
- case 'left':
571
- left = triggerBounding.left;
572
- arrowLeft = triggerBounding.width / 2 + "px";
573
- break;
574
-
575
- case 'right':
576
- left = triggerBounding.left - width + triggerBounding.width;
577
- arrowLeft = width - triggerBounding.width / 2 + "px";
578
- break;
579
- }
580
-
581
- top = args[0] === 'top' ? top - offsetY : top + offsetY;
582
- left = args[0] === 'left' ? left - offsetX : left + offsetX;
583
- return {
584
- top: top,
585
- left: left,
586
- transform: transform,
587
- arrowLeft: arrowLeft,
588
- arrowTop: arrowTop
589
- };
590
- };
591
-
592
- var getTooltipBoundary = function getTooltipBoundary(keepTooltipInside) {
593
- // add viewport
594
- var boundingBox = {
595
- top: 0,
596
- left: 0,
597
-
598
- /* eslint-disable-next-line no-undef */
599
- width: window.innerWidth,
600
-
601
- /* eslint-disable-next-line no-undef */
602
- height: window.innerHeight
603
- };
604
-
605
- if (typeof keepTooltipInside === 'string') {
606
- /* eslint-disable-next-line no-undef */
607
- var selector = document.querySelector(keepTooltipInside);
608
-
609
- if (process.env.NODE_ENV !== 'production') {
610
- if (selector === null) throw new Error(keepTooltipInside + " selector does not exist : keepTooltipInside must be a valid html selector 'class' or 'Id' or a boolean value");
611
- }
612
-
613
- if (selector !== null) boundingBox = selector.getBoundingClientRect();
614
- }
615
-
616
- return boundingBox;
617
- };
618
-
619
- var calculatePosition = function calculatePosition(triggerBounding, ContentBounding, position, arrow, _ref2, keepTooltipInside) {
620
- var offsetX = _ref2.offsetX,
621
- offsetY = _ref2.offsetY;
622
- var bestCoords = {
623
- arrowLeft: '0%',
624
- arrowTop: '0%',
625
- left: 0,
626
- top: 0,
627
- transform: 'rotate(135deg)'
628
- };
629
- var i = 0;
630
- var wrapperBox = getTooltipBoundary(keepTooltipInside);
631
- var positions = Array.isArray(position) ? position : [position]; // keepTooltipInside would be activated if the keepTooltipInside exist or the position is Array
632
-
633
- if (keepTooltipInside || Array.isArray(position)) positions = [].concat(positions, POSITION_TYPES); // add viewPort for WarpperBox
634
- // wrapperBox.top = wrapperBox.top + window.scrollY;
635
- // wrapperBox.left = wrapperBox.left + window.scrollX;
636
-
637
- while (i < positions.length) {
638
- bestCoords = getCoordinatesForPosition(triggerBounding, ContentBounding, positions[i], arrow, {
639
- offsetX: offsetX,
640
- offsetY: offsetY
641
- });
642
- var contentBox = {
643
- top: bestCoords.top,
644
- left: bestCoords.left,
645
- width: ContentBounding.width,
646
- height: ContentBounding.height
647
- };
648
-
649
- if (contentBox.top <= wrapperBox.top || contentBox.left <= wrapperBox.left || contentBox.top + contentBox.height >= wrapperBox.top + wrapperBox.height || contentBox.left + contentBox.width >= wrapperBox.left + wrapperBox.width) {
650
- i++;
651
- } else {
652
- break;
653
- }
654
- }
655
-
656
- return bestCoords;
657
- };
658
-
659
- var popupIdCounter = 0;
660
-
661
- var getRootPopup = function getRootPopup() {
662
- var PopupRoot = document.getElementById('popup-root');
663
-
664
- if (PopupRoot === null) {
665
- PopupRoot = document.createElement('div');
666
- PopupRoot.setAttribute('id', 'popup-root');
667
- document.body.appendChild(PopupRoot);
668
- }
669
-
670
- return PopupRoot;
671
- };
672
-
673
- var Popup = /*#__PURE__*/forwardRef(function (_ref, ref) {
674
- var _ref$trigger = _ref.trigger,
675
- trigger = _ref$trigger === void 0 ? null : _ref$trigger,
676
- _ref$onOpen = _ref.onOpen,
677
- onOpen = _ref$onOpen === void 0 ? function () {} : _ref$onOpen,
678
- _ref$onClose = _ref.onClose,
679
- onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
680
- _ref$defaultOpen = _ref.defaultOpen,
681
- defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
682
- _ref$open = _ref.open,
683
- open = _ref$open === void 0 ? undefined : _ref$open,
684
- _ref$disabled = _ref.disabled,
685
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
686
- _ref$nested = _ref.nested,
687
- nested = _ref$nested === void 0 ? false : _ref$nested,
688
- _ref$closeOnDocumentC = _ref.closeOnDocumentClick,
689
- closeOnDocumentClick = _ref$closeOnDocumentC === void 0 ? true : _ref$closeOnDocumentC,
690
- _ref$repositionOnResi = _ref.repositionOnResize,
691
- repositionOnResize = _ref$repositionOnResi === void 0 ? true : _ref$repositionOnResi,
692
- _ref$closeOnEscape = _ref.closeOnEscape,
693
- closeOnEscape = _ref$closeOnEscape === void 0 ? true : _ref$closeOnEscape,
694
- _ref$on = _ref.on,
695
- on = _ref$on === void 0 ? ['click'] : _ref$on,
696
- _ref$contentStyle = _ref.contentStyle,
697
- contentStyle = _ref$contentStyle === void 0 ? {} : _ref$contentStyle,
698
- _ref$arrowStyle = _ref.arrowStyle,
699
- arrowStyle = _ref$arrowStyle === void 0 ? {} : _ref$arrowStyle,
700
- _ref$overlayStyle = _ref.overlayStyle,
701
- overlayStyle = _ref$overlayStyle === void 0 ? {} : _ref$overlayStyle,
702
- _ref$className = _ref.className,
703
- className = _ref$className === void 0 ? '' : _ref$className,
704
- _ref$position = _ref.position,
705
- position = _ref$position === void 0 ? 'bottom center' : _ref$position,
706
- _ref$modal = _ref.modal,
707
- modal = _ref$modal === void 0 ? false : _ref$modal,
708
- _ref$lockScroll = _ref.lockScroll,
709
- lockScroll = _ref$lockScroll === void 0 ? false : _ref$lockScroll,
710
- _ref$arrow = _ref.arrow,
711
- arrow = _ref$arrow === void 0 ? true : _ref$arrow,
712
- _ref$offsetX = _ref.offsetX,
713
- offsetX = _ref$offsetX === void 0 ? 0 : _ref$offsetX,
714
- _ref$offsetY = _ref.offsetY,
715
- offsetY = _ref$offsetY === void 0 ? 0 : _ref$offsetY,
716
- _ref$mouseEnterDelay = _ref.mouseEnterDelay,
717
- mouseEnterDelay = _ref$mouseEnterDelay === void 0 ? 100 : _ref$mouseEnterDelay,
718
- _ref$mouseLeaveDelay = _ref.mouseLeaveDelay,
719
- mouseLeaveDelay = _ref$mouseLeaveDelay === void 0 ? 100 : _ref$mouseLeaveDelay,
720
- _ref$keepTooltipInsid = _ref.keepTooltipInside,
721
- keepTooltipInside = _ref$keepTooltipInsid === void 0 ? false : _ref$keepTooltipInsid,
722
- children = _ref.children;
723
-
724
- var _useState = useState(open || defaultOpen),
725
- isOpen = _useState[0],
726
- setIsOpen = _useState[1];
727
-
728
- var triggerRef = useRef(null);
729
- var contentRef = useRef(null);
730
- var arrowRef = useRef(null);
731
- var focusedElBeforeOpen = useRef(null);
732
- var popupId = useRef("popup-" + ++popupIdCounter);
733
- var isModal = modal ? true : !trigger;
734
- var timeOut = useRef(0);
735
- useIsomorphicLayoutEffect(function () {
736
- if (isOpen) {
737
- focusedElBeforeOpen.current = document.activeElement;
738
- setPosition();
739
- focusContentOnOpen(); // for accessibility
740
-
741
- lockScrolll();
742
- } else {
743
- resetScroll();
744
- }
745
-
746
- return function () {
747
- clearTimeout(timeOut.current);
748
- };
749
- }, [isOpen]); // for uncontrolled popup we need to sync isOpen with open prop
750
-
751
- useEffect(function () {
752
- if (typeof open === 'boolean') {
753
- if (open) openPopup();else closePopup();
754
- }
755
- }, [open, disabled]);
756
-
757
- var openPopup = function openPopup(event) {
758
- if (isOpen || disabled) return;
759
- setIsOpen(true);
760
- setTimeout(function () {
761
- return onOpen(event);
762
- }, 0);
763
- };
764
-
765
- var closePopup = function closePopup(event) {
766
- var _focusedElBeforeOpen$;
767
-
768
- if (!isOpen || disabled) return;
769
- setIsOpen(false);
770
- if (isModal) (_focusedElBeforeOpen$ = focusedElBeforeOpen.current) === null || _focusedElBeforeOpen$ === void 0 ? void 0 : _focusedElBeforeOpen$.focus();
771
- setTimeout(function () {
772
- return onClose(event);
773
- }, 0);
774
- };
775
-
776
- var togglePopup = function togglePopup(event) {
777
- event === null || event === void 0 ? void 0 : event.stopPropagation();
778
- if (!isOpen) openPopup(event);else closePopup(event);
779
- };
780
-
781
- var onMouseEnter = function onMouseEnter(event) {
782
- clearTimeout(timeOut.current);
783
- timeOut.current = setTimeout(function () {
784
- return openPopup(event);
785
- }, mouseEnterDelay);
786
- };
787
-
788
- var onContextMenu = function onContextMenu(event) {
789
- event === null || event === void 0 ? void 0 : event.preventDefault();
790
- togglePopup();
791
- };
792
-
793
- var onMouseLeave = function onMouseLeave(event) {
794
- clearTimeout(timeOut.current);
795
- timeOut.current = setTimeout(function () {
796
- return closePopup(event);
797
- }, mouseLeaveDelay);
798
- };
799
-
800
- var lockScrolll = function lockScrolll() {
801
- if (isModal && lockScroll) document.getElementsByTagName('body')[0].style.overflow = 'hidden'; // migrate to document.body
802
- };
803
-
804
- var resetScroll = function resetScroll() {
805
- if (isModal && lockScroll) document.getElementsByTagName('body')[0].style.overflow = 'auto';
806
- };
807
-
808
- var focusContentOnOpen = function focusContentOnOpen() {
809
- var _contentRef$current;
810
-
811
- var focusableEls = contentRef === null || contentRef === void 0 ? void 0 : (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]');
812
- var firstEl = Array.prototype.slice.call(focusableEls)[0];
813
- firstEl === null || firstEl === void 0 ? void 0 : firstEl.focus();
814
- };
815
-
816
- useImperativeHandle(ref, function () {
817
- return {
818
- open: function open() {
819
- openPopup();
820
- },
821
- close: function close() {
822
- closePopup();
823
- },
824
- toggle: function toggle() {
825
- togglePopup();
826
- }
827
- };
828
- }); // set Position
829
-
830
- var setPosition = function setPosition() {
831
- if (isModal || !isOpen) return;
832
- if (!(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) || !(triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) || !(contentRef === null || contentRef === void 0 ? void 0 : contentRef.current)) return; /// show error as one of ref is undefined
833
-
834
- var trigger = triggerRef.current.getBoundingClientRect();
835
- var content = contentRef.current.getBoundingClientRect();
836
- var cords = calculatePosition(trigger, content, position, arrow, {
837
- offsetX: offsetX,
838
- offsetY: offsetY
839
- }, keepTooltipInside);
840
- contentRef.current.style.top = cords.top + window.scrollY + "px";
841
- contentRef.current.style.left = cords.left + window.scrollX + "px";
842
-
843
- if (arrow && !!arrowRef.current) {
844
- var _arrowStyle$top, _arrowStyle$left;
845
-
846
- arrowRef.current.style.transform = cords.transform;
847
- arrowRef.current.style.setProperty('-ms-transform', cords.transform);
848
- arrowRef.current.style.setProperty('-webkit-transform', cords.transform);
849
- arrowRef.current.style.top = ((_arrowStyle$top = arrowStyle.top) === null || _arrowStyle$top === void 0 ? void 0 : _arrowStyle$top.toString()) || cords.arrowTop;
850
- arrowRef.current.style.left = ((_arrowStyle$left = arrowStyle.left) === null || _arrowStyle$left === void 0 ? void 0 : _arrowStyle$left.toString()) || cords.arrowLeft;
851
- }
852
- }; // hooks
853
-
854
-
855
- useOnEscape(closePopup, closeOnEscape); // can be optimized if we disabled for hover
856
-
857
- useTabbing(contentRef, isOpen && isModal);
858
- useRepositionOnResize(setPosition, repositionOnResize);
859
- useOnClickOutside(!!trigger ? [contentRef, triggerRef] : [contentRef], closePopup, closeOnDocumentClick && !nested); // we need to add a ne
860
- // render the trigger element and add events
861
-
862
- var renderTrigger = function renderTrigger() {
863
- var triggerProps = {
864
- key: 'T',
865
- ref: triggerRef,
866
- 'aria-describedby': popupId.current
867
- };
868
- var onAsArray = Array.isArray(on) ? on : [on];
869
-
870
- for (var i = 0, len = onAsArray.length; i < len; i++) {
871
- switch (onAsArray[i]) {
872
- case 'click':
873
- triggerProps.onClick = togglePopup;
874
- break;
875
-
876
- case 'right-click':
877
- triggerProps.onContextMenu = onContextMenu;
878
- break;
879
-
880
- case 'hover':
881
- triggerProps.onMouseEnter = onMouseEnter;
882
- triggerProps.onMouseLeave = onMouseLeave;
883
- break;
884
-
885
- case 'focus':
886
- triggerProps.onFocus = onMouseEnter;
887
- triggerProps.onBlur = onMouseLeave;
888
- break;
889
- }
890
- }
891
-
892
- if (typeof trigger === 'function') {
893
- var comp = trigger(isOpen);
894
- return !!trigger && React.cloneElement(comp, triggerProps);
895
- }
896
-
897
- return !!trigger && React.cloneElement(trigger, triggerProps);
898
- };
899
-
900
- var addWarperAction = function addWarperAction() {
901
- var popupContentStyle = isModal ? Style.popupContent.modal : Style.popupContent.tooltip;
902
- var childrenElementProps = {
903
- className: "popup-content " + (className !== '' ? className.split(' ').map(function (c) {
904
- return c + "-content";
905
- }).join(' ') : ''),
906
- style: _extends({}, popupContentStyle, contentStyle, {
907
- pointerEvents: 'auto'
908
- }),
909
- ref: contentRef,
910
- onClick: function onClick(e) {
911
- e.stopPropagation();
912
- }
913
- };
914
-
915
- if (!modal && on.indexOf('hover') >= 0) {
916
- childrenElementProps.onMouseEnter = onMouseEnter;
917
- childrenElementProps.onMouseLeave = onMouseLeave;
918
- }
919
-
920
- return childrenElementProps;
921
- };
922
-
923
- var renderContent = function renderContent() {
924
- return React.createElement("div", Object.assign({}, addWarperAction(), {
925
- key: "C",
926
- role: isModal ? 'dialog' : 'tooltip',
927
- id: popupId.current
928
- }), arrow && !isModal && React.createElement("div", {
929
- ref: arrowRef,
930
- style: Style.popupArrow
931
- }, React.createElement("svg", {
932
- "data-testid": "arrow",
933
- className: "popup-arrow " + (className !== '' ? className.split(' ').map(function (c) {
934
- return c + "-arrow";
935
- }).join(' ') : ''),
936
- viewBox: "0 0 32 16",
937
- style: _extends({
938
- position: 'absolute'
939
- }, arrowStyle)
940
- }, React.createElement("path", {
941
- d: "M16 0l16 16H0z",
942
- fill: "currentcolor"
943
- }))), children && typeof children === 'function' ? children(closePopup, isOpen) : children);
944
- };
945
-
946
- var overlay = !(on.indexOf('hover') >= 0);
947
- var ovStyle = isModal ? Style.overlay.modal : Style.overlay.tooltip;
948
- var content = [overlay && React.createElement("div", {
949
- key: "O",
950
- "data-testid": "overlay",
951
- "data-popup": isModal ? 'modal' : 'tooltip',
952
- className: "popup-overlay " + (className !== '' ? className.split(' ').map(function (c) {
953
- return c + "-overlay";
954
- }).join(' ') : ''),
955
- style: _extends({}, ovStyle, overlayStyle, {
956
- pointerEvents: closeOnDocumentClick && nested || isModal ? 'auto' : 'none'
957
- }),
958
- onClick: closeOnDocumentClick && nested ? closePopup : undefined,
959
- tabIndex: -1
960
- }, isModal && renderContent()), !isModal && renderContent()];
961
- return React.createElement(React.Fragment, null, renderTrigger(), isOpen && ReactDOM.createPortal(content, getRootPopup()));
962
- });
963
-
964
332
  const _excluded$4 = ["chartId", "color", "data", "gap", "height", "index", "isEmpty", "onClick", "role", "showTooltip", "tooltipLabelOnly", "tooltipPercent", "width"];
965
333
  const COMPONENT_NAME$4 = 'HorizontalBarChartBar';
966
334
  const CLASSNAME$4 = 'redsift-horizontal-barchart-bar';
@@ -991,9 +359,8 @@ const HorizontalBarChartBar = /*#__PURE__*/forwardRef((props, ref) => {
991
359
  }
992
360
  }
993
361
  };
994
- const Bar = /*#__PURE__*/React.createElement(StyledHorizontalBarChartBar, _extends$1({
995
- ref: ref
996
- }, forwardedProps, {
362
+ const Bar = /*#__PURE__*/React.createElement(StyledHorizontalBarChartBar, _extends({}, forwardedProps, {
363
+ ref: ref,
997
364
  "aria-label": showTooltip && !isEmpty ? `${data.name}: ${data.value}` : undefined,
998
365
  "aria-labelledby": !showTooltip && !isEmpty ? `id${chartId}__slice-${index}-title` : undefined,
999
366
  id: `id${chartId}__slice-${index}`,
@@ -1016,12 +383,9 @@ const HorizontalBarChartBar = /*#__PURE__*/forwardRef((props, ref) => {
1016
383
  }, data.name), !showTooltip && !isEmpty && /*#__PURE__*/React.createElement("title", null, `${data.name}: ${data.value}`));
1017
384
  if (showTooltip) {
1018
385
  const tooltipValue = tooltipPercent !== null ? `${tooltipPercent}%` : data.value;
1019
- return /*#__PURE__*/React.createElement(Popup, {
1020
- on: "hover",
1021
- arrow: false,
1022
- position: "right center",
1023
- trigger: Bar
1024
- }, /*#__PURE__*/React.createElement(StyledHorizontalBarChartTooltip, null, `${data.name}${tooltipLabelOnly ? '' : ` - ${tooltipValue}`}`));
386
+ return /*#__PURE__*/React.createElement(Tooltip, {
387
+ placement: "right"
388
+ }, /*#__PURE__*/React.createElement(Tooltip.Trigger, null, Bar), /*#__PURE__*/React.createElement(Tooltip.Content, null, `${data.name}${tooltipLabelOnly ? '' : ` - ${tooltipValue}`}`));
1025
389
  }
1026
390
  return Bar;
1027
391
  });
@@ -1051,7 +415,7 @@ const HorizontalBarChartAxisBottom = /*#__PURE__*/forwardRef((props, ref) => {
1051
415
  }
1052
416
  }
1053
417
  }, [d3scale]);
1054
- return /*#__PURE__*/React.createElement(StyledHorizontalBarChartAxisBottom, _extends$1({
418
+ return /*#__PURE__*/React.createElement(StyledHorizontalBarChartAxisBottom, _extends({
1055
419
  className: "axis"
1056
420
  }, forwardedProps, {
1057
421
  ref: axisRef
@@ -1180,9 +544,8 @@ const HorizontalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1180
544
  }))]).range([0, width - 32]);
1181
545
  const barHeight = (chartHeight - (numberOfRows + 1) * gap) / numberOfRows;
1182
546
  const total = sum(data, d => d.value);
1183
- return /*#__PURE__*/React.createElement(StyledHorizontalBarChart, _extends$1({
1184
- ref: ref
1185
- }, forwardedProps, {
547
+ return /*#__PURE__*/React.createElement(StyledHorizontalBarChart, _extends({}, forwardedProps, {
548
+ ref: ref,
1186
549
  className: className
1187
550
  }), title ? /*#__PURE__*/React.createElement(StyledHorizontalBarChartTitle, {
1188
551
  className: `${HorizontalBarChart.className}__title`,
@@ -1518,14 +881,6 @@ const StyledPieChartArc = styled.g`
1518
881
  ` : '';
1519
882
  }}}
1520
883
  `;
1521
- const StyledPieChartTooltip = styled.div`
1522
- font-family: var(--redsift-typography-font-family-raleway);
1523
- border: 1px solid rgb(0 0 0 / 20%);
1524
- padding: 10px;
1525
- box-shadow: 0 2px 1px -1px rgb(0 0 0 / 20%), 0 1px 1px 0 rgb(0 0 0 / 14%),
1526
- 0 1px 3px 0 rgb(0 0 0 / 12%);
1527
- background-color: var(--redsift-color-neutral-white);
1528
- `;
1529
884
 
1530
885
  const _excluded$1 = ["chartId", "color", "data", "index", "onClick", "path", "role", "spaced", "showTooltip", "tooltipPercent", "tooltipLabelOnly", "isEmpty"];
1531
886
  const COMPONENT_NAME$1 = 'PieChartArc';
@@ -1556,9 +911,8 @@ const PieChartArc = /*#__PURE__*/forwardRef((props, ref) => {
1556
911
  }
1557
912
  }
1558
913
  };
1559
- const Arc = /*#__PURE__*/React.createElement(StyledPieChartArc, _extends$1({
1560
- ref: ref
1561
- }, forwardedProps, {
914
+ const Arc = /*#__PURE__*/React.createElement(StyledPieChartArc, _extends({}, forwardedProps, {
915
+ ref: ref,
1562
916
  "aria-label": showTooltip && !isEmpty ? `${data.name}: ${data.value}` : undefined,
1563
917
  "aria-labelledby": !showTooltip && !isEmpty ? `id${chartId}__slice-${index}-title` : undefined,
1564
918
  className: `pie-slice _${index}`,
@@ -1577,12 +931,9 @@ const PieChartArc = /*#__PURE__*/forwardRef((props, ref) => {
1577
931
  }, `${data.name}: ${data.value}`) : null);
1578
932
  if (showTooltip) {
1579
933
  const tooltipValue = tooltipPercent !== null ? `${tooltipPercent}%` : data.value;
1580
- return /*#__PURE__*/React.createElement(Popup, {
1581
- on: "hover",
1582
- arrow: false,
1583
- position: "right center",
1584
- trigger: Arc
1585
- }, /*#__PURE__*/React.createElement(StyledPieChartTooltip, null, `${data.name}${tooltipLabelOnly ? '' : ` - ${tooltipValue}`}`));
934
+ return /*#__PURE__*/React.createElement(Tooltip, {
935
+ placement: "right"
936
+ }, /*#__PURE__*/React.createElement(Tooltip.Trigger, null, Arc), /*#__PURE__*/React.createElement(Tooltip.Content, null, `${data.name}${tooltipLabelOnly ? '' : ` - ${tooltipValue}`}`));
1586
937
  }
1587
938
  return Arc;
1588
939
  });
@@ -1728,9 +1079,8 @@ const PieChart = /*#__PURE__*/forwardRef((props, ref) => {
1728
1079
  const createArc = arc().innerRadius(isDonut ? innerRadius : 0).outerRadius(chartDimensions.width / 2 - externalRadiusPadding);
1729
1080
  const pieData = createPie(data);
1730
1081
  const total = sum(data, d => d.value);
1731
- return /*#__PURE__*/React.createElement(StyledPieChart, _extends$1({
1732
- ref: ref
1733
- }, forwardedProps, {
1082
+ return /*#__PURE__*/React.createElement(StyledPieChart, _extends({}, forwardedProps, {
1083
+ ref: ref,
1734
1084
  className: className
1735
1085
  }), title ? /*#__PURE__*/React.createElement(StyledPieChartTitle, {
1736
1086
  className: `${PieChart.className}__title`,
@@ -1800,5 +1150,5 @@ PieChart.className = CLASSNAME;
1800
1150
  PieChart.defaultProps = DEFAULT_PROPS;
1801
1151
  PieChart.displayName = COMPONENT_NAME;
1802
1152
 
1803
- export { ColorTheme, HorizontalBarChart, HorizontalBarChartSize, HorizontalBarChartTheme, HorizontalBarChartTooltipVariant, PieChart, PieChartLabelVariant, PieChartSize, PieChartTheme, PieChartTooltipVariant, PieChartVariant, StyledHorizontalBarChart, StyledHorizontalBarChartAxisBottom, StyledHorizontalBarChartBar, StyledHorizontalBarChartCaption, StyledHorizontalBarChartEmptyText, StyledHorizontalBarChartTitle, StyledHorizontalBarChartTooltip, StyledPieChart, StyledPieChartArc, StyledPieChartCaption, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartLabel, StyledPieChartTitle, StyledPieChartTooltip, getColorScale, monochrome, scheme, successDangerScheme };
1153
+ export { ColorTheme, HorizontalBarChart, HorizontalBarChartSize, HorizontalBarChartTheme, HorizontalBarChartTooltipVariant, PieChart, PieChartLabelVariant, PieChartSize, PieChartTheme, PieChartTooltipVariant, PieChartVariant, StyledHorizontalBarChart, StyledHorizontalBarChartAxisBottom, StyledHorizontalBarChartBar, StyledHorizontalBarChartCaption, StyledHorizontalBarChartEmptyText, StyledHorizontalBarChartTitle, StyledPieChart, StyledPieChartArc, StyledPieChartCaption, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartLabel, StyledPieChartTitle, getColorScale, monochrome, scheme, successDangerScheme };
1804
1154
  //# sourceMappingURL=index.js.map