widenarrow-ui 1.1.43 → 1.1.45

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.
@@ -5,5 +5,6 @@ export default meta;
5
5
  type Story = StoryObj<typeof DropDown>;
6
6
  export declare const Default: Story;
7
7
  export declare const WithActiveSelect: Story;
8
+ export declare const WithTriggerComponent: Story;
8
9
  export declare const AsInlineButton: Story;
9
10
  export declare const Complex: Story;
@@ -2,7 +2,8 @@ import { ReactNode } from 'react';
2
2
  import { Placement, PositioningStrategy } from '@popperjs/core';
3
3
  export interface DropDownProps {
4
4
  children: ReactNode[] | ReactNode;
5
- buttonComponent: ReactNode;
5
+ buttonComponent?: ReactNode;
6
+ triggerComponent?: ReactNode;
6
7
  buttonCallbackName?: string;
7
8
  footerComponent?: ReactNode;
8
9
  title?: string;
@@ -11,6 +12,7 @@ export interface DropDownProps {
11
12
  withArrow?: boolean;
12
13
  loading?: boolean;
13
14
  childrenIsList?: boolean;
15
+ isOpen?: boolean;
14
16
  withVisibleOverflow?: boolean;
15
17
  placement?: Placement;
16
18
  strategy?: PositioningStrategy;
package/lib/index.d.ts CHANGED
@@ -493,7 +493,8 @@ declare const RadioButton: FC<RadioButtonProps>;
493
493
 
494
494
  interface DropDownProps {
495
495
  children: ReactNode[] | ReactNode;
496
- buttonComponent: ReactNode;
496
+ buttonComponent?: ReactNode;
497
+ triggerComponent?: ReactNode;
497
498
  buttonCallbackName?: string;
498
499
  footerComponent?: ReactNode;
499
500
  title?: string;
@@ -502,6 +503,7 @@ interface DropDownProps {
502
503
  withArrow?: boolean;
503
504
  loading?: boolean;
504
505
  childrenIsList?: boolean;
506
+ isOpen?: boolean;
505
507
  withVisibleOverflow?: boolean;
506
508
  placement?: Placement;
507
509
  strategy?: PositioningStrategy;
package/lib/index.esm.js CHANGED
@@ -700,7 +700,10 @@ var ToolTip = function (_a) {
700
700
  if (!children) {
701
701
  return null;
702
702
  }
703
- if (disabled || !text) {
703
+ if (disabled) {
704
+ return jsx(Fragment, { children: children });
705
+ }
706
+ if (!text && !component) {
704
707
  return jsx(Fragment, { children: children });
705
708
  }
706
709
  var uniq = id ? "".concat(id) : uuid();
@@ -2540,11 +2543,12 @@ var styles$i = {"body":"DropDown-module_s-41xK","container":"DropDown-module_ms9
2540
2543
  var s$i = classNames.bind(styles$i);
2541
2544
  var DropDown = function (_a) {
2542
2545
  var _b, _c, _d;
2543
- var title = _a.title, _e = _a.offset, offset = _e === void 0 ? { horizontal: 8, vertical: 12 } : _e, arrowPadding = _a.arrowPadding, _f = _a.placement, placement = _f === void 0 ? 'auto' : _f, _g = _a.strategy, strategy = _g === void 0 ? 'absolute' : _g, className = _a.className, buttonComponent = _a.buttonComponent, _h = _a.buttonCallbackName, buttonCallbackName = _h === void 0 ? 'onClickCallback' : _h, footerComponent = _a.footerComponent, onCloseCallback = _a.onCloseCallback, onOpenCallback = _a.onOpenCallback, children = _a.children, childrenClassName = _a.childrenClassName, loading = _a.loading, _j = _a.withArrow, withArrow = _j === void 0 ? true : _j, _k = _a.childrenIsList, childrenIsList = _k === void 0 ? true : _k, withVisibleOverflow = _a.withVisibleOverflow;
2544
- var _l = useState(false), isOpen = _l[0], setIsOpen = _l[1];
2546
+ var title = _a.title, _e = _a.offset, offset = _e === void 0 ? { horizontal: 8, vertical: 12 } : _e, arrowPadding = _a.arrowPadding, _f = _a.placement, placement = _f === void 0 ? 'auto' : _f, _g = _a.strategy, strategy = _g === void 0 ? 'absolute' : _g, className = _a.className, buttonComponent = _a.buttonComponent, triggerComponent = _a.triggerComponent, _h = _a.buttonCallbackName, buttonCallbackName = _h === void 0 ? 'onClickCallback' : _h, footerComponent = _a.footerComponent, onCloseCallback = _a.onCloseCallback, onOpenCallback = _a.onOpenCallback, children = _a.children, childrenClassName = _a.childrenClassName, loading = _a.loading, _j = _a.withArrow, withArrow = _j === void 0 ? true : _j, _k = _a.childrenIsList, childrenIsList = _k === void 0 ? true : _k, isOpen = _a.isOpen, withVisibleOverflow = _a.withVisibleOverflow;
2547
+ var _l = useState(false), _isOpen = _l[0], _setIsOpen = _l[1];
2545
2548
  var _m = useState(null), referenceElement = _m[0], setReferenceElement = _m[1];
2546
2549
  var _o = useState(null), popperElement = _o[0], setPopperElement = _o[1];
2547
2550
  var _p = useState(null), arrowElement = _p[0], setArrowElement = _p[1];
2551
+ var isOpenState = is(Boolean, isOpen) ? isOpen : _isOpen;
2548
2552
  var horizontal = offset.horizontal, vertical = offset.vertical;
2549
2553
  var _q = usePopper(referenceElement, popperElement, {
2550
2554
  placement: placement,
@@ -2555,15 +2559,15 @@ var DropDown = function (_a) {
2555
2559
  ]
2556
2560
  }), styles = _q.styles, attributes = _q.attributes;
2557
2561
  var onClose = function () {
2558
- if (isOpen) {
2559
- setIsOpen(!isOpen);
2562
+ if (_isOpen) {
2563
+ _setIsOpen(!_isOpen);
2560
2564
  is(Function, onCloseCallback) && onCloseCallback();
2561
2565
  }
2562
2566
  };
2563
2567
  var onClickButton = function (e) {
2564
2568
  e === null || e === void 0 ? void 0 : e.stopPropagation();
2565
- if (!isOpen) {
2566
- setIsOpen(true);
2569
+ if (!_isOpen) {
2570
+ _setIsOpen(true);
2567
2571
  is(Function, onOpenCallback) && onOpenCallback();
2568
2572
  return;
2569
2573
  }
@@ -2590,7 +2594,7 @@ var DropDown = function (_a) {
2590
2594
  return child;
2591
2595
  };
2592
2596
  var memoizedDropDownChildren = useMemo(function () {
2593
- if (isOpen) {
2597
+ if (isOpenState) {
2594
2598
  // Array of children
2595
2599
  if (is(Array, children) && isArrayWithContent(children)) {
2596
2600
  return children.map(function (child) {
@@ -2610,7 +2614,7 @@ var DropDown = function (_a) {
2610
2614
  return children;
2611
2615
  }
2612
2616
  // eslint-disable-next-line
2613
- }, [isOpen, children]);
2617
+ }, [isOpenState, children]);
2614
2618
  // Get the origin of the animation based on the placement of the DropDown
2615
2619
  var getAnimationOrigin = function (attributes) {
2616
2620
  var placement = path(['popper', 'data-popper-placement'], attributes);
@@ -2652,9 +2656,9 @@ var DropDown = function (_a) {
2652
2656
  _a[childrenClassName] = childrenClassName,
2653
2657
  _a)), children: memoizedDropDownChildren })) : (memoizedDropDownChildren);
2654
2658
  };
2655
- return (jsxs("div", { ref: containerRef, children: [jsx(Box, { displayFlex: true, alignItems: 'center', ref: setReferenceElement, children: isValidElement(buttonComponent)
2659
+ return (jsxs("div", { ref: containerRef, children: [triggerComponent ? (jsx(Box, { displayFlex: true, alignItems: 'center', ref: setReferenceElement, children: triggerComponent })) : null, buttonComponent ? (jsx(Box, { displayFlex: true, alignItems: 'center', ref: setReferenceElement, children: isValidElement(buttonComponent)
2656
2660
  ? cloneElement(buttonComponent, (_b = {}, _b[buttonCallbackName] = function (e) { return onClickButton(e); }, _b))
2657
- : null }), isOpen && (jsxs("div", __assign({ className: s$i('container', (_c = {},
2661
+ : null })) : null, isOpenState ? (jsxs("div", __assign({ className: s$i('container', (_c = {},
2658
2662
  _c[className] = className,
2659
2663
  _c)), ref: setPopperElement, style: styles.popper }, attributes.popper, { children: [withArrow && (jsx("div", { ref: setArrowElement, className: s$i('arrow', {
2660
2664
  arrow_topIsDark: title
@@ -2664,7 +2668,7 @@ var DropDown = function (_a) {
2664
2668
  children_noFooter: !footerComponent && title,
2665
2669
  children_noHeader: !title && footerComponent,
2666
2670
  children_noHeaderOrFooter: !title && !footerComponent
2667
- }), children: getChildrenListMarkup() }), footerComponent ? jsx("div", { className: s$i('footer'), children: footerComponent }) : null] })] })))] }));
2671
+ }), children: getChildrenListMarkup() }), footerComponent ? jsx("div", { className: s$i('footer'), children: footerComponent }) : null] })] }))) : null] }));
2668
2672
  };
2669
2673
 
2670
2674
  var styles$h = {"body":"DropDownItem-module_UqDzTt","container":"DropDownItem-module_SLjW0W","container_disabled":"DropDownItem-module_n4Ei9p","innerContainer":"DropDownItem-module_yTPeWz","button":"DropDownItem-module_mxcLFJ","button_clickable":"DropDownItem-module_OZsG-E","text":"DropDownItem-module_jUNg9b","button_small":"DropDownItem-module_t-DbXt","button_medium":"DropDownItem-module_RC2tFi","button_large":"DropDownItem-module_cRR335","icon_placeholder":"DropDownItem-module_rnlTmr","icon_small":"DropDownItem-module_IP7eDy","icon_medium":"DropDownItem-module_zAzvAS","icon_large":"DropDownItem-module_evC7qy","icon_left":"DropDownItem-module_qT-IaM","icon_right":"DropDownItem-module_F1274l","text_active":"DropDownItem-module_WKiUMc","text_disabled":"DropDownItem-module_GMkCiF","text_activeDisabled":"DropDownItem-module_vwOfg5"};