@paubox/ui 0.20.0 → 0.22.0

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.esm.js CHANGED
@@ -22424,7 +22424,7 @@ var ArrowIcon = styled(ChevronDown)(_templateObject$m(), spacing(1), function(pa
22424
22424
  var DropdownMenu = function(param) {
22425
22425
  var label = param.label, items = param.items, children = param.children, openProp = param.open, onOpenChange = param.onOpenChange, iconLeft = param.iconLeft, _param_size = param.size, size = _param_size === void 0 ? 'small' : _param_size, align = param.align, _param_buttonProps = param.buttonProps, buttonProps = _param_buttonProps === void 0 ? {
22426
22426
  color: 'primary'
22427
- } : _param_buttonProps, _param_testId = param.testId, testId = _param_testId === void 0 ? 'dropdown' : _param_testId, childContainerRefs = param.childContainerRefs;
22427
+ } : _param_buttonProps, _param_testId = param.testId, testId = _param_testId === void 0 ? 'dropdown' : _param_testId, childContainerRefs = param.childContainerRefs, disabled = param.disabled;
22428
22428
  var _useState = _sliced_to_array$e(useState(false), 2), open = _useState[0], setOpen = _useState[1];
22429
22429
  var buttonRef = useRef(null);
22430
22430
  var isControlled = openProp !== undefined && onOpenChange;
@@ -22437,7 +22437,8 @@ var DropdownMenu = function(param) {
22437
22437
  style: {
22438
22438
  whiteSpace: 'nowrap',
22439
22439
  borderColor: openProp || open ? primary600 : undefined
22440
- }
22440
+ },
22441
+ disabled: disabled
22441
22442
  }, buttonProps), {
22442
22443
  onClick: function() {
22443
22444
  if (isControlled) {
@@ -23708,7 +23709,7 @@ var MultiSelect = function(_param) {
23708
23709
  onClick: function() {
23709
23710
  return toggleSelect(option);
23710
23711
  }
23711
- }), option.label);
23712
+ }), option.value);
23712
23713
  })
23713
23714
  })
23714
23715
  ]
@@ -24520,7 +24521,7 @@ var Select = function(_param) {
24520
24521
  onClick: function() {
24521
24522
  return handleSelect(option);
24522
24523
  }
24523
- }), option.label);
24524
+ }), option.value);
24524
24525
  })
24525
24526
  })
24526
24527
  ]
@@ -34592,9 +34593,10 @@ function _templateObject() {
34592
34593
  "\n background-color: ",
34593
34594
  ";\n border-radius: 0.25rem;\n padding: 0.25rem 0.5rem;\n font-size: ",
34594
34595
  ";\n color: ",
34595
- ";\n z-index: 50;\n white-space: 'wrap';\n word-wrap: break-word;\n display: ",
34596
- ";\n width: ",
34597
- ";\n position: fixed;\n align-items: center;\n height: min-content;\n"
34596
+ ";\n white-space: 'wrap';\n word-wrap: break-word;\n display: ",
34597
+ ";\n min-height: 100%;\n width: ",
34598
+ ";\n height: fit-content;\n position: absolute;\n display: flex;\n align-items: center;\n\n ",
34599
+ "\n margin-top: auto;\n margin-bottom: auto;\n"
34598
34600
  ]);
34599
34601
  _templateObject = function _templateObject() {
34600
34602
  return data;
@@ -34613,7 +34615,7 @@ function _templateObject1() {
34613
34615
  }
34614
34616
  function _templateObject2() {
34615
34617
  var data = _tagged_template_literal([
34616
- "\n position: absolute;\n ",
34618
+ "\n margin: auto;\n position: absolute;\n inset: 0;\n\n ",
34617
34619
  "\n"
34618
34620
  ]);
34619
34621
  _templateObject2 = function _templateObject() {
@@ -34623,10 +34625,13 @@ function _templateObject2() {
34623
34625
  }
34624
34626
  var TooltipWrapper = styled.div(_templateObject(), neutral900, $paragraph300Regular, textPrimaryWhite, function(param) {
34625
34627
  var hover = param.hover;
34626
- return hover ? 'flex' : 'none';
34628
+ return hover ? 'block' : 'none';
34627
34629
  }, function(param) {
34628
34630
  var size = param.size;
34629
34631
  return size === 'small' ? 'min-content' : 'max-content';
34632
+ }, function(param) {
34633
+ var _param_x = param.x, x = _param_x === void 0 ? 'bottom' : _param_x, _param_y = param.y, y = _param_y === void 0 ? 'left' : _param_y;
34634
+ return "\n margin-right: ".concat(x === 'left' ? '100%' : 'auto', ";\n margin-left: ").concat(x === 'right' ? '100%' : 'auto', ";\n z-index: 50;\n top: ").concat(y === 'bottom' ? '150%' : y === 'center' ? '0rem' : 'auto', ";\n bottom: ").concat(y === 'top' ? '150%' : y === 'center' ? '0rem' : 'auto', ";\n left: ").concat(y === 'center' ? x === 'right' ? '1rem' : 'auto' : x === 'right' ? '-1.5rem' : x === 'center' ? '0' : 'auto', ";\n right: ").concat(y === 'center' ? x === 'left' ? '1rem' : 'auto' : x === 'left' ? '-1.5rem' : x === 'center' ? '0' : 'auto', ";\n ");
34630
34635
  });
34631
34636
  var TooltipContainer = styled.div(_templateObject1(), function(param) {
34632
34637
  var hover = param.hover;
@@ -34648,110 +34653,34 @@ var Triangle = function(param) {
34648
34653
  });
34649
34654
  };
34650
34655
  var ToolTipTriangle = styled(Triangle)(_templateObject2(), function(param) {
34651
- var _param_placement = param.placement, placement = _param_placement === void 0 ? 'bottom' : _param_placement;
34652
- if (placement === 'top') {
34653
- return "\n bottom: -0.375rem;\n left: 50%;\n transform: translateX(-50%) rotate(180deg);\n display: block;\n ";
34654
- }
34655
- if (placement === 'bottom') {
34656
- return "\n top: -0.375rem;\n left: 50%;\n transform: translateX(-50%) rotate(0deg);\n display: block;\n ";
34657
- }
34658
- if (placement === 'left') {
34659
- return "\n right: -0.375rem;\n top: 50%;\n transform: translateY(-50%) rotate(90deg);\n display: block;\n ";
34660
- }
34661
- if (placement === 'right') {
34662
- return "\n left: -0.375rem;\n top: 50%;\n transform: translateY(-50%) rotate(-90deg);\n display: block;\n ";
34663
- }
34664
- return '';
34656
+ var _param_x = param.x, x = _param_x === void 0 ? 'bottom' : _param_x, _param_y = param.y, y = _param_y === void 0 ? 'left' : _param_y;
34657
+ return "\n\n top: ".concat(y === 'bottom' ? '-0.375rem' : y === 'center' ? '0' : 'auto', ";\n bottom: ").concat(y === 'top' ? '-0.375rem' : y === 'center' ? '0' : 'auto', ";\n left: ").concat(y === 'center' ? x === 'right' ? '-0.4rem' : 'auto' : x === 'right' ? '0.5rem' : x === 'center' ? '50%' : 'auto', ";\n right: ").concat(y === 'center' ? x === 'left' ? '-0.4rem' : 'auto' : x === 'left' ? '0.5rem' : x === 'center' ? '50%' : 'auto', ";\n\n display: ").concat(y === 'center' && x === 'center' ? 'none' : 'block', ";\n transform: ").concat(y === 'top' ? 'rotate(180deg)' : y === 'bottom' ? 'rotate(0deg)' : x === 'left' ? 'rotate(90deg)' : x === 'right' ? 'rotate(-90deg)' : 'rotate(0deg)', ";\n ");
34665
34658
  });
34666
34659
  var Tooltip = function(_param) {
34667
- var children = _param.children, content = _param.content, className = _param.className, placement = _param.placement, rest = _object_without_properties(_param, [
34660
+ var children = _param.children, content = _param.content, rest = _object_without_properties(_param, [
34668
34661
  "children",
34669
- "content",
34670
- "className",
34671
- "placement"
34662
+ "content"
34672
34663
  ]);
34673
- var tooltipRef = useRef(null);
34674
- var childRef = useRef(null);
34675
- var _useState = _sliced_to_array(useState({
34676
- top: 0,
34677
- left: 0
34678
- }), 2), position = _useState[0], setPosition = _useState[1];
34679
- var _useState1 = _sliced_to_array(useState(false), 2), hover = _useState1[0], setHover = _useState1[1];
34664
+ var _useState = _sliced_to_array(useState(false), 2), hover = _useState[0], setHover = _useState[1];
34680
34665
  var handleMouseEnter = function() {
34681
34666
  setHover(true);
34682
34667
  };
34683
34668
  var handleMouseLeave = function() {
34684
34669
  setHover(false);
34685
34670
  };
34686
- useEffect(function() {
34687
- var updatePosition = function() {
34688
- if (!childRef.current || !tooltipRef.current) return;
34689
- var childRect = childRef.current.getBoundingClientRect();
34690
- var tooltipRect = tooltipRef.current.getBoundingClientRect();
34691
- var scrollX = window.scrollX || window.pageXOffset;
34692
- var scrollY = window.scrollY || window.pageYOffset;
34693
- var top = 0, left = 0;
34694
- switch(placement || 'bottom'){
34695
- case 'top':
34696
- top = childRect.top + scrollY - tooltipRect.height - 5;
34697
- left = childRect.left + scrollX + (childRect.width - tooltipRect.width) / 2;
34698
- break;
34699
- case 'bottom':
34700
- top = childRect.bottom + scrollY + 5;
34701
- left = childRect.left + scrollX + (childRect.width - tooltipRect.width) / 2;
34702
- break;
34703
- case 'left':
34704
- top = childRect.top + scrollY + (childRect.height - tooltipRect.height) / 2;
34705
- left = childRect.left + scrollX - tooltipRect.width - 5;
34706
- break;
34707
- case 'right':
34708
- top = childRect.top + scrollY + (childRect.height - tooltipRect.height) / 2;
34709
- left = childRect.right + scrollX + 5;
34710
- break;
34711
- }
34712
- setPosition({
34713
- top: top,
34714
- left: left
34715
- });
34716
- };
34717
- if (hover) {
34718
- updatePosition();
34719
- window.addEventListener('resize', updatePosition);
34720
- window.addEventListener('scroll', updatePosition);
34721
- }
34722
- return function() {
34723
- window.removeEventListener('resize', updatePosition);
34724
- window.removeEventListener('scroll', updatePosition);
34725
- };
34726
- }, [
34727
- hover,
34728
- placement
34729
- ]);
34730
34671
  return /*#__PURE__*/ jsxs(TooltipContainer, {
34731
34672
  onMouseEnter: handleMouseEnter,
34732
34673
  onMouseLeave: handleMouseLeave,
34733
34674
  hover: hover,
34734
34675
  children: [
34735
34676
  /*#__PURE__*/ jsx("div", {
34736
- ref: childRef,
34737
34677
  children: children
34738
34678
  }),
34739
- /*#__PURE__*/ jsxs(TooltipWrapper, _object_spread_props(_object_spread({
34740
- className: className,
34741
- ref: tooltipRef,
34742
- style: {
34743
- top: position.top,
34744
- left: position.left
34745
- }
34746
- }, rest), {
34679
+ /*#__PURE__*/ jsxs(TooltipWrapper, _object_spread_props(_object_spread({}, rest), {
34747
34680
  hover: hover,
34748
34681
  children: [
34749
- /*#__PURE__*/ jsx("div", {
34750
- children: content
34751
- }),
34752
- /*#__PURE__*/ jsx(ToolTipTriangle, _object_spread({
34753
- placement: placement
34754
- }, rest))
34682
+ content,
34683
+ /*#__PURE__*/ jsx(ToolTipTriangle, _object_spread({}, rest))
34755
34684
  ]
34756
34685
  }))
34757
34686
  ]
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@paubox/ui",
3
3
  "author": "Paubox, Inc.",
4
4
  "description": "Paubox Component Library",
5
- "version": "0.20.0",
5
+ "version": "0.22.0",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "publishConfig": {
@@ -1,5 +1,5 @@
1
- import { Button, MenuItemProps } from '@components';
2
1
  import { ComponentProps, ElementType, ReactNode, RefObject } from 'react';
2
+ import { Button, MenuItemProps } from '@components';
3
3
  export interface DropdownMenuProps {
4
4
  label: string;
5
5
  items?: MenuItemProps[];
@@ -12,5 +12,6 @@ export interface DropdownMenuProps {
12
12
  testId?: string;
13
13
  size?: 'small' | 'large';
14
14
  childContainerRefs?: RefObject<HTMLElement>[];
15
+ disabled?: boolean;
15
16
  }
16
- export declare const DropdownMenu: ({ label, items, children, open: openProp, onOpenChange, iconLeft, size, align, buttonProps, testId, childContainerRefs, }: DropdownMenuProps) => import("@emotion/react/jsx-runtime").JSX.Element;
17
+ export declare const DropdownMenu: ({ label, items, children, open: openProp, onOpenChange, iconLeft, size, align, buttonProps, testId, childContainerRefs, disabled, }: DropdownMenuProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  export interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {
2
- placement?: 'top' | 'bottom' | 'left' | 'right';
2
+ y?: 'top' | 'bottom' | 'center';
3
+ x?: 'left' | 'right' | 'center';
3
4
  size?: 'small' | 'large';
4
- className?: string;
5
5
  children: React.ReactNode;
6
6
  content: string;
7
7
  }