widenarrow-ui 1.1.44 → 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
@@ -2543,11 +2543,12 @@ var styles$i = {"body":"DropDown-module_s-41xK","container":"DropDown-module_ms9
2543
2543
  var s$i = classNames.bind(styles$i);
2544
2544
  var DropDown = function (_a) {
2545
2545
  var _b, _c, _d;
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, _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;
2547
- 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];
2548
2548
  var _m = useState(null), referenceElement = _m[0], setReferenceElement = _m[1];
2549
2549
  var _o = useState(null), popperElement = _o[0], setPopperElement = _o[1];
2550
2550
  var _p = useState(null), arrowElement = _p[0], setArrowElement = _p[1];
2551
+ var isOpenState = is(Boolean, isOpen) ? isOpen : _isOpen;
2551
2552
  var horizontal = offset.horizontal, vertical = offset.vertical;
2552
2553
  var _q = usePopper(referenceElement, popperElement, {
2553
2554
  placement: placement,
@@ -2558,15 +2559,15 @@ var DropDown = function (_a) {
2558
2559
  ]
2559
2560
  }), styles = _q.styles, attributes = _q.attributes;
2560
2561
  var onClose = function () {
2561
- if (isOpen) {
2562
- setIsOpen(!isOpen);
2562
+ if (_isOpen) {
2563
+ _setIsOpen(!_isOpen);
2563
2564
  is(Function, onCloseCallback) && onCloseCallback();
2564
2565
  }
2565
2566
  };
2566
2567
  var onClickButton = function (e) {
2567
2568
  e === null || e === void 0 ? void 0 : e.stopPropagation();
2568
- if (!isOpen) {
2569
- setIsOpen(true);
2569
+ if (!_isOpen) {
2570
+ _setIsOpen(true);
2570
2571
  is(Function, onOpenCallback) && onOpenCallback();
2571
2572
  return;
2572
2573
  }
@@ -2593,7 +2594,7 @@ var DropDown = function (_a) {
2593
2594
  return child;
2594
2595
  };
2595
2596
  var memoizedDropDownChildren = useMemo(function () {
2596
- if (isOpen) {
2597
+ if (isOpenState) {
2597
2598
  // Array of children
2598
2599
  if (is(Array, children) && isArrayWithContent(children)) {
2599
2600
  return children.map(function (child) {
@@ -2613,7 +2614,7 @@ var DropDown = function (_a) {
2613
2614
  return children;
2614
2615
  }
2615
2616
  // eslint-disable-next-line
2616
- }, [isOpen, children]);
2617
+ }, [isOpenState, children]);
2617
2618
  // Get the origin of the animation based on the placement of the DropDown
2618
2619
  var getAnimationOrigin = function (attributes) {
2619
2620
  var placement = path(['popper', 'data-popper-placement'], attributes);
@@ -2655,9 +2656,9 @@ var DropDown = function (_a) {
2655
2656
  _a[childrenClassName] = childrenClassName,
2656
2657
  _a)), children: memoizedDropDownChildren })) : (memoizedDropDownChildren);
2657
2658
  };
2658
- 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)
2659
2660
  ? cloneElement(buttonComponent, (_b = {}, _b[buttonCallbackName] = function (e) { return onClickButton(e); }, _b))
2660
- : null }), isOpen && (jsxs("div", __assign({ className: s$i('container', (_c = {},
2661
+ : null })) : null, isOpenState ? (jsxs("div", __assign({ className: s$i('container', (_c = {},
2661
2662
  _c[className] = className,
2662
2663
  _c)), ref: setPopperElement, style: styles.popper }, attributes.popper, { children: [withArrow && (jsx("div", { ref: setArrowElement, className: s$i('arrow', {
2663
2664
  arrow_topIsDark: title
@@ -2667,7 +2668,7 @@ var DropDown = function (_a) {
2667
2668
  children_noFooter: !footerComponent && title,
2668
2669
  children_noHeader: !title && footerComponent,
2669
2670
  children_noHeaderOrFooter: !title && !footerComponent
2670
- }), 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] }));
2671
2672
  };
2672
2673
 
2673
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"};