@useblu/ocean-react 1.67.0 → 1.68.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/CHANGELOG.md +6 -0
- package/WebNotification/WebNotification.d.ts +26 -0
- package/WebNotification/WebNotification.d.ts.map +1 -0
- package/WebNotification/hook/useWebNotification.d.ts +9 -0
- package/WebNotification/hook/useWebNotification.d.ts.map +1 -0
- package/WebNotification/index.d.ts +2 -0
- package/WebNotification/index.d.ts.map +1 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.es.js +56 -1
- package/index.es.js.map +1 -1
- package/index.js +56 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -48257,6 +48257,61 @@ var Chips = function (_a) {
|
|
|
48257
48257
|
};
|
|
48258
48258
|
Chips.displayName = 'Chips';
|
|
48259
48259
|
|
|
48260
|
+
function useWebNotification(_a) {
|
|
48261
|
+
var setIsOpen = _a.setIsOpen, action = _a.action;
|
|
48262
|
+
var closeWebNotification = e.useCallback(function () {
|
|
48263
|
+
setIsOpen(false);
|
|
48264
|
+
}, [setIsOpen]);
|
|
48265
|
+
var dispatchAction = e.useCallback(function () {
|
|
48266
|
+
if (action)
|
|
48267
|
+
action();
|
|
48268
|
+
}, [action]);
|
|
48269
|
+
return {
|
|
48270
|
+
closeWebNotification: closeWebNotification,
|
|
48271
|
+
dispatchAction: dispatchAction
|
|
48272
|
+
};
|
|
48273
|
+
}
|
|
48274
|
+
|
|
48275
|
+
var WebNotification = e__default["default"].forwardRef(function (_a, ref) {
|
|
48276
|
+
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;
|
|
48277
|
+
var _d = useWebNotification({
|
|
48278
|
+
type: type,
|
|
48279
|
+
isOpen: isOpen,
|
|
48280
|
+
setIsOpen: setIsOpen,
|
|
48281
|
+
action: action
|
|
48282
|
+
}), closeWebNotification = _d.closeWebNotification, dispatchAction = _d.dispatchAction;
|
|
48283
|
+
var _e = e.useState(0), notificationIndex = _e[0], setNotificationIndex = _e[1];
|
|
48284
|
+
var notificationRef = e.useRef(null);
|
|
48285
|
+
e.useEffect(function () {
|
|
48286
|
+
if (isOpen) {
|
|
48287
|
+
var allOpenedNotifications = Array.from(document.querySelectorAll('.ods-web-notification')).reverse();
|
|
48288
|
+
var notificationPosition = allOpenedNotifications.findIndex(function (el) { return el === notificationRef.current; }) + 1;
|
|
48289
|
+
setNotificationIndex(notificationPosition);
|
|
48290
|
+
}
|
|
48291
|
+
}, [isOpen]);
|
|
48292
|
+
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) {
|
|
48293
|
+
notificationRef.current = el;
|
|
48294
|
+
if (ref) {
|
|
48295
|
+
if (typeof ref === 'function') {
|
|
48296
|
+
ref(el);
|
|
48297
|
+
}
|
|
48298
|
+
else {
|
|
48299
|
+
ref.current = el;
|
|
48300
|
+
}
|
|
48301
|
+
}
|
|
48302
|
+
}, "data-testid": "web-notification-test" },
|
|
48303
|
+
e__default["default"].createElement("div", { className: "ods-web-notification__content" },
|
|
48304
|
+
e__default["default"].createElement("div", { className: "ods-web-notification__wrapper" },
|
|
48305
|
+
e__default["default"].createElement("div", { className: "ods-web-notification__body" },
|
|
48306
|
+
e__default["default"].createElement(Typography, { variant: "description", inverse: true }, title),
|
|
48307
|
+
e__default["default"].createElement(Typography, { variant: "caption" }, description)),
|
|
48308
|
+
action && (e__default["default"].createElement(e__default["default"].Fragment, null,
|
|
48309
|
+
e__default["default"].createElement(Link, { onClick: dispatchAction, className: "ods-web-notification__action-text-".concat(type), size: "sm" }, actionLabel !== null && actionLabel !== void 0 ? actionLabel : 'action')))),
|
|
48310
|
+
e__default["default"].createElement("div", { className: "ods-web-notification__close-button" },
|
|
48311
|
+
e__default["default"].createElement(Wa, { size: 16, onClick: closeWebNotification })))))));
|
|
48312
|
+
});
|
|
48313
|
+
WebNotification.displayName = 'WebNotification';
|
|
48314
|
+
|
|
48260
48315
|
exports.Accordion = Accordion;
|
|
48261
48316
|
exports.Alert = Alert;
|
|
48262
48317
|
exports.Badge = Badge;
|
|
@@ -48300,4 +48355,5 @@ exports.TopBar = TopBar;
|
|
|
48300
48355
|
exports.TransactionListItem = TransactionListItem;
|
|
48301
48356
|
exports.Typography = Typography;
|
|
48302
48357
|
exports.UnorderedListItem = UnorderedListItem;
|
|
48358
|
+
exports.WebNotification = WebNotification;
|
|
48303
48359
|
//# sourceMappingURL=index.js.map
|