@useblu/ocean-react 1.67.0 → 1.69.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
@@ -48117,7 +48117,7 @@ var Shortcut = function (_a) {
48117
48117
  };
48118
48118
 
48119
48119
  var CardListItem = e.forwardRef(function (_a, ref) {
48120
- var title = _a.title, description = _a.description, caption = _a.caption, leadingIcon = _a.leadingIcon, actionIcon = _a.actionIcon, _b = _a.size, size = _b === void 0 ? 'medium' : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.fullWidth, fullWidth = _d === void 0 ? false : _d, onClick = _a.onClick, loading = _a.loading, rest = __rest$2(_a, ["title", "description", "caption", "leadingIcon", "actionIcon", "size", "disabled", "fullWidth", "onClick", "loading"]);
48120
+ var title = _a.title, description = _a.description, caption = _a.caption, leadingIcon = _a.leadingIcon, actionIcon = _a.actionIcon, _b = _a.size, size = _b === void 0 ? 'medium' : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.fullWidth, fullWidth = _d === void 0 ? false : _d, onClick = _a.onClick, loading = _a.loading, tag = _a.tag, rest = __rest$2(_a, ["title", "description", "caption", "leadingIcon", "actionIcon", "size", "disabled", "fullWidth", "onClick", "loading", "tag"]);
48121
48121
  return loading ? (e__default["default"].createElement("div", __assign$2({ ref: ref }, rest, { "data-testid": "card-list-item", className: classNames('ods-card-list-item', "ods-card-list-item--size-".concat(size), { 'ods-card-list-item--full-width': fullWidth }, {
48122
48122
  'ods-card-list-item--loading': loading
48123
48123
  }) }),
@@ -48134,7 +48134,9 @@ var CardListItem = e.forwardRef(function (_a, ref) {
48134
48134
  e__default["default"].createElement("div", { className: "ods-card-list-item__content__title" }, title),
48135
48135
  description && (e__default["default"].createElement("div", { className: "ods-card-list-item__content__description" }, description)),
48136
48136
  caption && size === 'medium' && (e__default["default"].createElement("div", { className: "ods-card-list-item__content__caption" }, caption))),
48137
- actionIcon && (e__default["default"].createElement("div", { className: "ods-card-list-item__action" }, actionIcon))));
48137
+ e__default["default"].createElement("div", { className: "ods-card-list-item__wrapper" },
48138
+ tag && (e__default["default"].createElement(Tag, { variant: "highlight", type: "important" }, tag)),
48139
+ actionIcon && (e__default["default"].createElement("div", { className: "ods-card-list-item__action" }, actionIcon)))));
48138
48140
  });
48139
48141
  CardListItem.displayName = 'CardListItem';
48140
48142
 
@@ -48257,6 +48259,61 @@ var Chips = function (_a) {
48257
48259
  };
48258
48260
  Chips.displayName = 'Chips';
48259
48261
 
48262
+ function useWebNotification(_a) {
48263
+ var setIsOpen = _a.setIsOpen, action = _a.action;
48264
+ var closeWebNotification = e.useCallback(function () {
48265
+ setIsOpen(false);
48266
+ }, [setIsOpen]);
48267
+ var dispatchAction = e.useCallback(function () {
48268
+ if (action)
48269
+ action();
48270
+ }, [action]);
48271
+ return {
48272
+ closeWebNotification: closeWebNotification,
48273
+ dispatchAction: dispatchAction
48274
+ };
48275
+ }
48276
+
48277
+ var WebNotification = e__default["default"].forwardRef(function (_a, ref) {
48278
+ var _b = _a.type, type = _b === void 0 ? 'info' : _b, description = _a.description, isOpen = _a.isOpen, setIsOpen = _a.setIsOpen, action = _a.action, actionLabel = _a.actionLabel, _c = _a.position, position = _c === void 0 ? 'bottom-right' : _c, className = _a.className, title = _a.title;
48279
+ var _d = useWebNotification({
48280
+ type: type,
48281
+ isOpen: isOpen,
48282
+ setIsOpen: setIsOpen,
48283
+ action: action
48284
+ }), closeWebNotification = _d.closeWebNotification, dispatchAction = _d.dispatchAction;
48285
+ var _e = e.useState(0), notificationIndex = _e[0], setNotificationIndex = _e[1];
48286
+ var notificationRef = e.useRef(null);
48287
+ e.useEffect(function () {
48288
+ if (isOpen) {
48289
+ var allOpenedNotifications = Array.from(document.querySelectorAll('.ods-web-notification')).reverse();
48290
+ var notificationPosition = allOpenedNotifications.findIndex(function (el) { return el === notificationRef.current; }) + 1;
48291
+ setNotificationIndex(notificationPosition);
48292
+ }
48293
+ }, [isOpen]);
48294
+ return (e__default["default"].createElement(e__default["default"].Fragment, null, isOpen && (e__default["default"].createElement("div", { className: classNames('ods-web-notification', "position-".concat(notificationIndex), "ods-web-notification__".concat(position, "-").concat(action ? 'action' : 'default'), className), ref: function (el) {
48295
+ notificationRef.current = el;
48296
+ if (ref) {
48297
+ if (typeof ref === 'function') {
48298
+ ref(el);
48299
+ }
48300
+ else {
48301
+ ref.current = el;
48302
+ }
48303
+ }
48304
+ }, "data-testid": "web-notification-test" },
48305
+ e__default["default"].createElement("div", { className: "ods-web-notification__content" },
48306
+ e__default["default"].createElement("div", { className: "ods-web-notification__wrapper" },
48307
+ e__default["default"].createElement("div", { className: "ods-web-notification__body" },
48308
+ e__default["default"].createElement(Typography, { variant: "description", inverse: true }, title),
48309
+ e__default["default"].createElement(Typography, { variant: "caption" }, description)),
48310
+ action && (e__default["default"].createElement(e__default["default"].Fragment, null,
48311
+ e__default["default"].createElement(Link, { onClick: dispatchAction, className: "ods-web-notification__action-text-".concat(type), size: "sm" }, actionLabel !== null && actionLabel !== void 0 ? actionLabel : 'action')))),
48312
+ e__default["default"].createElement("div", { className: "ods-web-notification__close-button" },
48313
+ e__default["default"].createElement(Wa, { size: 16, onClick: closeWebNotification })))))));
48314
+ });
48315
+ WebNotification.displayName = 'WebNotification';
48316
+
48260
48317
  exports.Accordion = Accordion;
48261
48318
  exports.Alert = Alert;
48262
48319
  exports.Badge = Badge;
@@ -48300,4 +48357,5 @@ exports.TopBar = TopBar;
48300
48357
  exports.TransactionListItem = TransactionListItem;
48301
48358
  exports.Typography = Typography;
48302
48359
  exports.UnorderedListItem = UnorderedListItem;
48360
+ exports.WebNotification = WebNotification;
48303
48361
  //# sourceMappingURL=index.js.map