@useblu/ocean-react 1.117.0 → 1.118.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.js CHANGED
@@ -47399,13 +47399,28 @@ var TriggerButton = function (_a) {
47399
47399
  };
47400
47400
 
47401
47401
  var InternalListActions = e.forwardRef(function (_a, forwardedRef) {
47402
- var actions = _a.actions, _b = _a.actionType, actionType = _b === void 0 ? 'menu' : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.position, position = _d === void 0 ? 'bottom-right' : _d, className = _a.className, rest = __rest$1(_a, ["actions", "actionType", "disabled", "position", "className"]);
47402
+ var actions = _a.actions, _b = _a.actionType, actionType = _b === void 0 ? 'menu' : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.position, position = _d === void 0 ? 'bottom-right' : _d, className = _a.className, onOpenChange = _a.onOpenChange, rest = __rest$1(_a, ["actions", "actionType", "disabled", "position", "className", "onOpenChange"]);
47403
47403
  var _e = e.useState(false), isOpen = _e[0], setIsOpen = _e[1];
47404
47404
  var _f = e.useState(false), isClosing = _f[0], setIsClosing = _f[1];
47405
47405
  var wrapperRef = e.useRef(null);
47406
47406
  var triggerRef = e.useRef(null);
47407
47407
  var menuRef = e.useRef(null);
47408
47408
  var isSwipeMode = actionType === 'swipe';
47409
+ var notifyOpenChange = function (open) {
47410
+ if (open && isSwipeMode && menuRef.current) {
47411
+ requestAnimationFrame(function () {
47412
+ var _a;
47413
+ var menuWidth = ((_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
47414
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true, menuWidth);
47415
+ });
47416
+ }
47417
+ else if (open) {
47418
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
47419
+ }
47420
+ else {
47421
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
47422
+ }
47423
+ };
47409
47424
  var handleSwipeLeft = function () {
47410
47425
  setIsOpen(true);
47411
47426
  setIsClosing(false);
@@ -47413,6 +47428,7 @@ var InternalListActions = e.forwardRef(function (_a, forwardedRef) {
47413
47428
  var handleClose = function () {
47414
47429
  if (isSwipeMode) {
47415
47430
  setIsClosing(true);
47431
+ notifyOpenChange(false);
47416
47432
  setTimeout(function () {
47417
47433
  setIsOpen(false);
47418
47434
  setIsClosing(false);
@@ -47420,6 +47436,7 @@ var InternalListActions = e.forwardRef(function (_a, forwardedRef) {
47420
47436
  }
47421
47437
  else {
47422
47438
  setIsOpen(false);
47439
+ notifyOpenChange(false);
47423
47440
  }
47424
47441
  };
47425
47442
  useSwipeGesture(triggerRef, isSwipeMode, isOpen, handleSwipeLeft);
@@ -47434,6 +47451,11 @@ var InternalListActions = e.forwardRef(function (_a, forwardedRef) {
47434
47451
  }
47435
47452
  }
47436
47453
  }, [forwardedRef]);
47454
+ e.useEffect(function () {
47455
+ if (isOpen && isSwipeMode && !isClosing) {
47456
+ notifyOpenChange(true);
47457
+ }
47458
+ }, [isOpen, isSwipeMode, isClosing]);
47437
47459
  var handleToggle = function () {
47438
47460
  if (!disabled) {
47439
47461
  if (isOpen) {
@@ -47470,31 +47492,43 @@ InternalListActions.displayName = 'InternalListActions';
47470
47492
  var ListAction = e.forwardRef(function (_a, ref) {
47471
47493
  var _b;
47472
47494
  var title = _a.title, description = _a.description, strikethroughDescription = _a.strikethroughDescription, caption = _a.caption, _c = _a.inverted, inverted = _c === void 0 ? false : _c, _d = _a.type, type = _d === void 0 ? 'card' : _d, _e = _a.status, status = _e === void 0 ? 'default' : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.loading, loading = _g === void 0 ? false : _g, icon = _a.icon, indicator = _a.indicator, _h = _a.actionType, actionType = _h === void 0 ? 'chevron' : _h, menuActions = _a.menuActions, _j = _a.menuPosition, menuPosition = _j === void 0 ? 'bottom-right' : _j, onClick = _a.onClick, className = _a.className, _k = _a.showDivider, showDivider = _k === void 0 ? false : _k, rest = __rest$1(_a, ["title", "description", "strikethroughDescription", "caption", "inverted", "type", "status", "disabled", "loading", "icon", "indicator", "actionType", "menuActions", "menuPosition", "onClick", "className", "showDivider"]);
47495
+ var _l = e.useState(false), isSwipeOpen = _l[0], setIsSwipeOpen = _l[1];
47496
+ var _m = e.useState(0), menuWidth = _m[0], setMenuWidth = _m[1];
47497
+ var handleSwipeOpenChange = function (isOpen, width) {
47498
+ setIsSwipeOpen(isOpen);
47499
+ if (width !== undefined) {
47500
+ setMenuWidth(width);
47501
+ }
47502
+ };
47473
47503
  var renderActionIcon = function () {
47474
47504
  if (actionType === 'chevron') {
47475
47505
  return (e.createElement("div", { className: 'ods-list-action__action' },
47476
47506
  e.createElement(re, { size: 20 })));
47477
47507
  }
47478
47508
  if (actionType === 'menu' || actionType === 'swipe') {
47479
- return (e.createElement(InternalListActions, { actions: menuActions || [], disabled: disabled, position: menuPosition, actionType: actionType }));
47509
+ return (e.createElement(InternalListActions, { actions: menuActions || [], disabled: disabled, position: menuPosition, actionType: actionType, onOpenChange: actionType === 'swipe' ? handleSwipeOpenChange : undefined }));
47480
47510
  }
47481
47511
  return null;
47482
47512
  };
47483
47513
  var renderLoadingContent = function () { return (e.createElement("div", { className: 'ods-list-action__skeleton' },
47484
47514
  e.createElement(SkeletonBar, { width: '40%', height: '16px' }),
47485
47515
  e.createElement(SkeletonBar, { width: '100%', height: '16px' }))); };
47516
+ var contentStyle = isSwipeOpen && menuWidth > 0
47517
+ ? { transform: "translateX(-".concat(menuWidth, "px)") }
47518
+ : {};
47486
47519
  var renderContent = function () { return (e.createElement(e.Fragment, null,
47487
- icon && (e.createElement("div", { className: classNames('ods-list-action__icon', {
47488
- 'ods-list-action__icon--inactive': status === 'inactive',
47489
- }) }, icon)),
47490
- e.createElement(ContentList, { title: title, description: description, strikethroughDescription: strikethroughDescription, caption: caption, inverted: inverted, type: status }),
47491
- e.createElement("div", { className: 'ods-list-action__trailing' },
47492
- indicator && (e.createElement("div", { className: 'ods-list-action__indicator' }, indicator)),
47493
- renderActionIcon()))); };
47520
+ e.createElement("div", { className: 'ods-list-action__content', style: contentStyle },
47521
+ icon && (e.createElement("div", { className: classNames('ods-list-action__icon', {
47522
+ 'ods-list-action__icon--inactive': status === 'inactive',
47523
+ }) }, icon)),
47524
+ e.createElement(ContentList, { title: title, description: description, strikethroughDescription: strikethroughDescription, caption: caption, inverted: inverted, type: status }),
47525
+ indicator && (e.createElement("div", { className: 'ods-list-action__indicator' }, indicator))),
47526
+ renderActionIcon())); };
47494
47527
  var buttonClassName = classNames('ods-list-action', className, (_b = {
47495
47528
  'ods-list-action--loading': loading,
47496
47529
  'ods-list-action--disabled': disabled,
47497
- 'ods-list-action--swipe-mode': actionType === 'swipe'
47530
+ 'ods-list-action--swipe-mode': actionType === 'swipe',
47531
+ 'ods-list-action--swipe-open': isSwipeOpen
47498
47532
  },
47499
47533
  _b["ods-list-action--".concat(type)] = type,
47500
47534
  _b));
@@ -47504,12 +47538,51 @@ var ListAction = e.forwardRef(function (_a, ref) {
47504
47538
  });
47505
47539
  ListAction.displayName = 'ListAction';
47506
47540
 
47541
+ var ListExpandable = e.forwardRef(function (_a, ref) {
47542
+ var _b;
47543
+ var title = _a.title, description = _a.description, strikethroughDescription = _a.strikethroughDescription, caption = _a.caption, _c = _a.inverted, inverted = _c === void 0 ? false : _c, _d = _a.type, type = _d === void 0 ? 'card' : _d, _e = _a.status, status = _e === void 0 ? 'default' : _e, _f = _a.loading, loading = _f === void 0 ? false : _f, icon = _a.icon, indicator = _a.indicator, controlledExpanded = _a.expanded, _g = _a.defaultExpanded, defaultExpanded = _g === void 0 ? false : _g, onToggle = _a.onToggle, children = _a.children, className = _a.className, _h = _a.disabled, disabled = _h === void 0 ? false : _h, _j = _a.showDivider, showDivider = _j === void 0 ? false : _j, rest = __rest$1(_a, ["title", "description", "strikethroughDescription", "caption", "inverted", "type", "status", "loading", "icon", "indicator", "expanded", "defaultExpanded", "onToggle", "children", "className", "disabled", "showDivider"]);
47544
+ var _k = e.useState(defaultExpanded), internalExpanded = _k[0], setInternalExpanded = _k[1];
47545
+ var isControlled = controlledExpanded !== undefined;
47546
+ var isExpanded = isControlled ? controlledExpanded : internalExpanded;
47547
+ var handleToggle = function () {
47548
+ var newExpandedState = !isExpanded;
47549
+ if (!isControlled) {
47550
+ setInternalExpanded(newExpandedState);
47551
+ }
47552
+ onToggle === null || onToggle === void 0 ? void 0 : onToggle(newExpandedState);
47553
+ };
47554
+ var renderLoadingContent = function () { return (e.createElement("div", { className: "ods-list-expandable__skeleton" },
47555
+ e.createElement(SkeletonBar, { width: "40%", height: "16px" }),
47556
+ e.createElement(SkeletonBar, { width: "100%", height: "16px" }))); };
47557
+ var renderContent = function () { return (e.createElement(e.Fragment, null,
47558
+ icon && (e.createElement("div", { className: classNames('ods-list-expandable__icon', {
47559
+ 'ods-list-expandable__icon--inactive': status === 'inactive',
47560
+ }) }, icon)),
47561
+ e.createElement(ContentList, { title: title, description: description, strikethroughDescription: strikethroughDescription, caption: caption, inverted: inverted, type: status }),
47562
+ e.createElement("div", { className: "ods-list-expandable__trailing" },
47563
+ indicator && (e.createElement("div", { className: "ods-list-expandable__indicator" }, indicator)),
47564
+ e.createElement("div", { className: "ods-list-expandable__action" }, isExpanded ? e.createElement(ae, { size: 20 }) : e.createElement(ee, { size: 20 }))))); };
47565
+ var containerClassName = classNames('ods-list-expandable', className, (_b = {
47566
+ 'ods-list-expandable--expanded': isExpanded,
47567
+ 'ods-list-expandable--disabled': disabled,
47568
+ 'ods-list-expandable--loading': loading
47569
+ },
47570
+ _b["ods-list-expandable--".concat(type)] = type,
47571
+ _b));
47572
+ return (e.createElement("div", __assign$1({ ref: ref, "data-testid": "list-expandable", className: containerClassName }, rest),
47573
+ e.createElement("button", { type: "button", className: "ods-list-expandable__main", onClick: loading ? undefined : handleToggle, disabled: disabled || loading, "aria-expanded": isExpanded, "aria-label": "".concat(isExpanded ? 'Recolher' : 'Expandir', " ").concat(title), "data-testid": "list-expandable-button" }, loading ? renderLoadingContent() : renderContent()),
47574
+ showDivider && e.createElement("div", { className: "ods-list-expandable__divider", "data-testid": "list-expandable-divider" }),
47575
+ isExpanded && children && (e.createElement("div", { className: "ods-list-expandable__content" }, children))));
47576
+ });
47577
+ ListExpandable.displayName = 'ListExpandable';
47578
+
47507
47579
  exports.Accordion = Accordion;
47508
47580
  exports.Alert = Alert;
47509
47581
  exports.Badge = Badge;
47510
47582
  exports.Breadcrumb = Breadcrumb;
47511
47583
  exports.Button = Button$1;
47512
47584
  exports.CardGroup = CardGroup;
47585
+ exports.CardListExpandable = ListExpandable;
47513
47586
  exports.CardListItem = CardListItem;
47514
47587
  exports.Carousel = Carousel;
47515
47588
  exports.Chart = DoughnutChart;