bs-unified-ui 1.0.917 → 1.0.922

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.
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Custom hook to track current pathname changes in SPA
3
+ * Uses singleton PathTracker to prevent duplicate history API patches
3
4
  * Listens to:
4
5
  * - popstate (browser back/forward)
5
6
  * - history.pushState (programmatic navigation)
package/index.js CHANGED
@@ -45588,22 +45588,37 @@ var filterIndicatorsByEnabledEvents = function (receivedIndicators, triggerEvent
45588
45588
  };
45589
45589
 
45590
45590
  /**
45591
- * Custom hook to track current pathname changes in SPA
45592
- * Listens to:
45593
- * - popstate (browser back/forward)
45594
- * - history.pushState (programmatic navigation)
45595
- * - history.replaceState (programmatic navigation)
45591
+ * Global singleton to track pathname changes across all hook instances
45592
+ * This prevents multiple hooks from patching history APIs multiple times
45596
45593
  */
45597
- var useCurrentPath = function () {
45598
- var _a = React.useState(typeof window !== 'undefined' ? window.location.pathname : ''), currentPath = _a[0], setCurrentPath = _a[1];
45599
- React.useEffect(function () {
45600
- var handleLocationChange = function () {
45601
- setCurrentPath(window.location.pathname);
45594
+ var PathTracker = /** @class */ (function () {
45595
+ function PathTracker() {
45596
+ this.listeners = new Set();
45597
+ this.currentPath = '';
45598
+ this.isPatched = false;
45599
+ if (typeof window !== 'undefined') {
45600
+ this.currentPath = window.location.pathname;
45601
+ this.patchHistory();
45602
+ }
45603
+ }
45604
+ PathTracker.getInstance = function () {
45605
+ if (!PathTracker.instance) {
45606
+ PathTracker.instance = new PathTracker();
45607
+ }
45608
+ return PathTracker.instance;
45609
+ };
45610
+ PathTracker.prototype.patchHistory = function () {
45611
+ var _this = this;
45612
+ if (this.isPatched)
45613
+ return;
45614
+ this.isPatched = true;
45615
+ var handleChange = function () {
45616
+ _this.currentPath = window.location.pathname;
45617
+ _this.notifyListeners();
45602
45618
  };
45603
45619
  // Listen to popstate event (browser back/forward)
45604
- window.addEventListener('popstate', handleLocationChange);
45605
- // For SPAs, also listen to custom navigation events if needed
45606
- // This covers most routing libraries that update window.location
45620
+ window.addEventListener('popstate', handleChange);
45621
+ // Patch history.pushState and history.replaceState ONCE
45607
45622
  var originalPushState = window.history.pushState;
45608
45623
  var originalReplaceState = window.history.replaceState;
45609
45624
  window.history.pushState = function pushStateWrapper() {
@@ -45612,7 +45627,7 @@ var useCurrentPath = function () {
45612
45627
  args[_i] = arguments[_i];
45613
45628
  }
45614
45629
  originalPushState.apply(this, args);
45615
- handleLocationChange();
45630
+ handleChange();
45616
45631
  };
45617
45632
  window.history.replaceState = function replaceStateWrapper() {
45618
45633
  var args = [];
@@ -45620,14 +45635,45 @@ var useCurrentPath = function () {
45620
45635
  args[_i] = arguments[_i];
45621
45636
  }
45622
45637
  originalReplaceState.apply(this, args);
45623
- handleLocationChange();
45638
+ handleChange();
45624
45639
  };
45640
+ };
45641
+ PathTracker.prototype.subscribe = function (callback) {
45642
+ var _this = this;
45643
+ this.listeners.add(callback);
45625
45644
  return function () {
45626
- window.removeEventListener('popstate', handleLocationChange);
45627
- window.history.pushState = originalPushState;
45628
- window.history.replaceState = originalReplaceState;
45645
+ _this.listeners.delete(callback);
45629
45646
  };
45630
- }, []);
45647
+ };
45648
+ PathTracker.prototype.notifyListeners = function () {
45649
+ var _this = this;
45650
+ this.listeners.forEach(function (callback) {
45651
+ try {
45652
+ callback(_this.currentPath);
45653
+ }
45654
+ catch (e) {
45655
+ // Ignore errors in listeners
45656
+ }
45657
+ });
45658
+ };
45659
+ PathTracker.prototype.getCurrentPath = function () {
45660
+ return this.currentPath;
45661
+ };
45662
+ PathTracker.instance = null;
45663
+ return PathTracker;
45664
+ }());
45665
+ /**
45666
+ * Custom hook to track current pathname changes in SPA
45667
+ * Uses singleton PathTracker to prevent duplicate history API patches
45668
+ * Listens to:
45669
+ * - popstate (browser back/forward)
45670
+ * - history.pushState (programmatic navigation)
45671
+ * - history.replaceState (programmatic navigation)
45672
+ */
45673
+ var useCurrentPath = function () {
45674
+ var tracker = PathTracker.getInstance();
45675
+ var _a = React.useState(tracker.getCurrentPath()), currentPath = _a[0], setCurrentPath = _a[1];
45676
+ React.useEffect(function () { return tracker.subscribe(setCurrentPath); }, [tracker]);
45631
45677
  return currentPath;
45632
45678
  };
45633
45679
 
@@ -45724,10 +45770,12 @@ var ObservableSet = /** @class */ (function () {
45724
45770
  return ObservableSet;
45725
45771
  }());
45726
45772
 
45773
+ // Constant empty array to avoid recreating on each render
45774
+ var EMPTY_WAREHOUSES_CONFIG = [];
45727
45775
  var useNotificationsV2 = function (options) {
45728
45776
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
45729
45777
  if (options === void 0) { options = {}; }
45730
- var onNotification = options.onNotification, onConnectionChange = options.onConnectionChange, onError = options.onError, _k = options.timezone, timezone = _k === void 0 ? 'America/Vancouver' : _k, navigate = options.navigate, bsOrgId = options.bsOrgId, cfWsId = options.cfWsId, soundConfig = options.soundConfig, triggerEvents = options.triggerEvents, _l = options.warehousesConfig, warehousesConfig = _l === void 0 ? [] : _l;
45778
+ var onNotification = options.onNotification, onConnectionChange = options.onConnectionChange, onError = options.onError, _k = options.timezone, timezone = _k === void 0 ? 'America/Vancouver' : _k, navigate = options.navigate, bsOrgId = options.bsOrgId, cfWsId = options.cfWsId, soundConfig = options.soundConfig, triggerEvents = options.triggerEvents, _l = options.warehousesConfig, warehousesConfig = _l === void 0 ? EMPTY_WAREHOUSES_CONFIG : _l;
45731
45779
  var _m = React.useState([]), popoverNotifications = _m[0], setPopoverNotifications = _m[1];
45732
45780
  var _o = React.useState(true), popoverLoading = _o[0], setPopoverLoading = _o[1];
45733
45781
  var _p = React.useState(false), popoverHasNextPage = _p[0], setPopoverHasNextPage = _p[1];
@@ -45770,8 +45818,6 @@ var useNotificationsV2 = function (options) {
45770
45818
  // Single ObservableSet to track all items requiring audio reminders with composite key: `${subType}:${id}`
45771
45819
  var allRemindersRef = React.useRef(new ObservableSet());
45772
45820
  var handleNotificationEventRef = React.useRef(function () { });
45773
- // Refs to always have latest functions (prevents duplicate intervals)
45774
- var playAudioForGroupRef = React.useRef(function () { });
45775
45821
  // Ref to always have latest indicators state
45776
45822
  var indicatorsRef = React.useRef(indicators);
45777
45823
  // Track previous reminder events to detect when events are enabled (falsy -> true)
@@ -45792,12 +45838,16 @@ var useNotificationsV2 = function (options) {
45792
45838
  var prevPageIndicatorRef = React.useRef();
45793
45839
  // Timer for debouncing fetchAudioRepeat calls
45794
45840
  var fetchAudioRepeatTimerRef = React.useRef(null);
45795
- // Ref to always have latest updateIndicators function
45796
- var updateIndicatorsRef = React.useRef();
45797
45841
  // Use refs to store latest callbacks to avoid recreating functions unnecessarily
45842
+ var updateIndicatorsRef = React.useRef();
45843
+ var fetchIndicatorsRef = React.useRef();
45844
+ var playAudioForGroupRef = React.useRef(function () { });
45845
+ var fetchIndicatorsInFlightRef = React.useRef(false);
45846
+ var fetchAudioRepeatInFlightRef = React.useRef(false);
45798
45847
  var onErrorRef = React.useRef(onError);
45799
45848
  var onNotificationRef = React.useRef(onNotification);
45800
45849
  var onConnectionChangeRef = React.useRef(onConnectionChange);
45850
+ var warehousesConfigRef = React.useRef(warehousesConfig);
45801
45851
  // Track current pathname for display indicators
45802
45852
  var currentPath = useCurrentPath();
45803
45853
  // Check which page user is currently on
@@ -45879,6 +45929,8 @@ var useNotificationsV2 = function (options) {
45879
45929
  memoizedTriggerEvents === null || memoizedTriggerEvents === void 0 ? void 0 : memoizedTriggerEvents[DELIVERY_EVENTS.IMPORT_TASK],
45880
45930
  memoizedTriggerEvents === null || memoizedTriggerEvents === void 0 ? void 0 : memoizedTriggerEvents[DELIVERY_EVENTS.NEW_DRIVER],
45881
45931
  ]);
45932
+ // Memoize warehousesConfig to prevent recreating when array content is the same
45933
+ var memoizedWarehousesConfig = React.useMemo(function () { return warehousesConfig; }, [JSON.stringify(warehousesConfig)]);
45882
45934
  var markAsRead = React.useCallback(function (notificationId) { return __awaiter(void 0, void 0, void 0, function () {
45883
45935
  var err_1, errorMessage;
45884
45936
  var _a;
@@ -46018,16 +46070,6 @@ var useNotificationsV2 = function (options) {
46018
46070
  }
46019
46071
  return true;
46020
46072
  }, []);
46021
- // Update refs whenever callbacks change
46022
- React.useEffect(function () {
46023
- onErrorRef.current = onError;
46024
- }, [onError]);
46025
- React.useEffect(function () {
46026
- onNotificationRef.current = onNotification;
46027
- }, [onNotification]);
46028
- React.useEffect(function () {
46029
- onConnectionChangeRef.current = onConnectionChange;
46030
- }, [onConnectionChange]);
46031
46073
  var loadPopoverNotifications = React.useCallback(function (params) { return __awaiter(void 0, void 0, void 0, function () {
46032
46074
  var data_1, err_3, errorMessage;
46033
46075
  var _a;
@@ -46077,6 +46119,7 @@ var useNotificationsV2 = function (options) {
46077
46119
  var startRetryInterval = React.useCallback(function () {
46078
46120
  if (!bsOrgId)
46079
46121
  return;
46122
+ // Clear any existing interval to prevent duplicates
46080
46123
  clearRetryInterval();
46081
46124
  retryIntervalRef.current = setInterval(function () {
46082
46125
  var createdAtGte = isoMinusDaysInTimeZone(timezone, 7);
@@ -46112,14 +46155,6 @@ var useNotificationsV2 = function (options) {
46112
46155
  audioElement.play().catch(function () { });
46113
46156
  }
46114
46157
  }, [memoizedSoundConfig]);
46115
- // Update ref whenever playAudioForGroup changes
46116
- React.useEffect(function () {
46117
- playAudioForGroupRef.current = playAudioForGroup;
46118
- }, [playAudioForGroup]);
46119
- // Update ref whenever indicators changes
46120
- React.useEffect(function () {
46121
- indicatorsRef.current = indicators;
46122
- }, [indicators]);
46123
46158
  // Start audio repeat for specific group
46124
46159
  var startAudioRepeatForGroup = React.useCallback(function (group) {
46125
46160
  var _a;
@@ -46173,12 +46208,17 @@ var useNotificationsV2 = function (options) {
46173
46208
  case 0:
46174
46209
  if (!serviceRef.current || !bsOrgId)
46175
46210
  return [2 /*return*/];
46211
+ // Guard: Skip if already fetching to prevent duplicate calls
46212
+ if (fetchAudioRepeatInFlightRef.current) {
46213
+ return [2 /*return*/];
46214
+ }
46176
46215
  // Clear old reminders first to avoid stale data
46177
46216
  allRemindersRef.current.clear();
46178
46217
  _a.label = 1;
46179
46218
  case 1:
46180
- _a.trys.push([1, 3, , 4]);
46181
- return [4 /*yield*/, serviceRef.current.getAudioRepeat(bsOrgId, warehousesConfig)];
46219
+ _a.trys.push([1, 3, 4, 5]);
46220
+ fetchAudioRepeatInFlightRef.current = true;
46221
+ return [4 /*yield*/, serviceRef.current.getAudioRepeat(bsOrgId, warehousesConfigRef.current)];
46182
46222
  case 2:
46183
46223
  response = _a.sent();
46184
46224
  data = response === null || response === void 0 ? void 0 : response.data;
@@ -46209,15 +46249,19 @@ var useNotificationsV2 = function (options) {
46209
46249
  startAudioRepeatForGroup(group);
46210
46250
  });
46211
46251
  }
46212
- return [3 /*break*/, 4];
46252
+ return [3 /*break*/, 5];
46213
46253
  case 3:
46214
46254
  _a.sent();
46215
- return [3 /*break*/, 4];
46216
- case 4: return [2 /*return*/];
46255
+ return [3 /*break*/, 5];
46256
+ case 4:
46257
+ fetchAudioRepeatInFlightRef.current = false;
46258
+ return [7 /*endfinally*/];
46259
+ case 5: return [2 /*return*/];
46217
46260
  }
46218
46261
  });
46219
46262
  }); }, [
46220
46263
  bsOrgId,
46264
+ memoizedWarehousesConfig,
46221
46265
  memoizedTriggerEvents,
46222
46266
  playAudioForGroup,
46223
46267
  startAudioRepeatForGroup,
@@ -46230,6 +46274,10 @@ var useNotificationsV2 = function (options) {
46230
46274
  case 0:
46231
46275
  if (!serviceRef.current || !bsOrgId)
46232
46276
  return [2 /*return*/];
46277
+ // Guard: Skip if already fetching to prevent duplicate calls
46278
+ if (fetchIndicatorsInFlightRef.current) {
46279
+ return [2 /*return*/];
46280
+ }
46233
46281
  categories = {};
46234
46282
  Object.entries(INDICATOR_MAPPING).forEach(function (_a) {
46235
46283
  var category = _a[0], events = _a[1];
@@ -46242,14 +46290,22 @@ var useNotificationsV2 = function (options) {
46242
46290
  if (Object.keys(categories).length === 0) {
46243
46291
  return [2 /*return*/];
46244
46292
  }
46245
- return [4 /*yield*/, serviceRef.current.getIndicators(bsOrgId, categories)];
46293
+ _a.label = 1;
46246
46294
  case 1:
46295
+ _a.trys.push([1, , 3, 4]);
46296
+ fetchIndicatorsInFlightRef.current = true;
46297
+ return [4 /*yield*/, serviceRef.current.getIndicators(bsOrgId, categories)];
46298
+ case 2:
46247
46299
  response = _a.sent();
46248
46300
  receivedIndicators = response === null || response === void 0 ? void 0 : response.data;
46249
46301
  if (receivedIndicators) {
46250
46302
  setIndicators(receivedIndicators);
46251
46303
  }
46252
- return [2 /*return*/];
46304
+ return [3 /*break*/, 4];
46305
+ case 3:
46306
+ fetchIndicatorsInFlightRef.current = false;
46307
+ return [7 /*endfinally*/];
46308
+ case 4: return [2 /*return*/];
46253
46309
  }
46254
46310
  });
46255
46311
  }); }, [bsOrgId, memoizedTriggerEvents]);
@@ -46288,10 +46344,29 @@ var useNotificationsV2 = function (options) {
46288
46344
  }
46289
46345
  });
46290
46346
  }); }, [bsOrgId, onError, memoizedTriggerEvents]);
46291
- // Update ref whenever updateIndicators changes
46347
+ // Update function refs to avoid stale closures
46348
+ React.useEffect(function () {
46349
+ onErrorRef.current = onError;
46350
+ }, [onError]);
46351
+ React.useEffect(function () {
46352
+ onNotificationRef.current = onNotification;
46353
+ }, [onNotification]);
46354
+ React.useEffect(function () {
46355
+ onConnectionChangeRef.current = onConnectionChange;
46356
+ }, [onConnectionChange]);
46292
46357
  React.useEffect(function () {
46293
46358
  updateIndicatorsRef.current = updateIndicators;
46294
46359
  }, [updateIndicators]);
46360
+ React.useEffect(function () {
46361
+ fetchIndicatorsRef.current = fetchIndicators;
46362
+ }, [fetchIndicators]);
46363
+ React.useEffect(function () {
46364
+ playAudioForGroupRef.current = playAudioForGroup;
46365
+ }, [playAudioForGroup]);
46366
+ // Update state ref
46367
+ React.useEffect(function () {
46368
+ indicatorsRef.current = indicators;
46369
+ }, [indicators]);
46295
46370
  // Queue indicator update to batch multiple updates together
46296
46371
  var queueUpdateIndicators = React.useCallback(function (indicator, value) {
46297
46372
  // Add to pending queue
@@ -46683,10 +46758,11 @@ var useNotificationsV2 = function (options) {
46683
46758
  if (!isInitialized || !bsOrgId)
46684
46759
  return undefined;
46685
46760
  var timeoutId = setTimeout(function () {
46686
- fetchIndicators();
46687
- }, 2000);
46761
+ var _a;
46762
+ (_a = fetchIndicatorsRef.current) === null || _a === void 0 ? void 0 : _a.call(fetchIndicatorsRef);
46763
+ }, 3000);
46688
46764
  return function () { return clearTimeout(timeoutId); };
46689
- }, [isInitialized, bsOrgId, fetchIndicators]);
46765
+ }, [isInitialized, bsOrgId]);
46690
46766
  React.useEffect(function () {
46691
46767
  if (isInitialized && isActiveNotificationPage && bsOrgId) {
46692
46768
  var apiParams = __assign({}, filter);
@@ -46788,6 +46864,11 @@ var useNotificationsV2 = function (options) {
46788
46864
  }
46789
46865
  }
46790
46866
  });
46867
+ // Check condition 4: warehousesConfig changed
46868
+ if (warehousesConfigRef.current !== memoizedWarehousesConfig) {
46869
+ warehousesConfigRef.current = memoizedWarehousesConfig;
46870
+ shouldFetch = true;
46871
+ }
46791
46872
  // Update refs for next comparison
46792
46873
  prevReminderEventsRef.current = __assign({}, memoizedReminderEvents);
46793
46874
  prevSoundConfigRef.current = {
@@ -46817,9 +46898,9 @@ var useNotificationsV2 = function (options) {
46817
46898
  fetchAudioRepeatTimerRef.current = setTimeout(function () {
46818
46899
  fetchAudioRepeat();
46819
46900
  fetchAudioRepeatTimerRef.current = null;
46820
- }, 2000);
46901
+ }, 3000);
46821
46902
  }
46822
- }, [fetchAudioRepeat, memoizedSoundConfig, memoizedReminderEvents]);
46903
+ }, [fetchAudioRepeat, memoizedSoundConfig, memoizedReminderEvents, memoizedWarehousesConfig]);
46823
46904
  // Restart interval when repeatingInterval or mute changes per group
46824
46905
  React.useEffect(function () {
46825
46906
  if (!memoizedSoundConfig)
@@ -47127,29 +47208,63 @@ var NotificationToast = React.forwardRef(function (props, ref) {
47127
47208
  var NotificationContext = React.createContext(null);
47128
47209
  var NotificationProviderBase = function (_a) {
47129
47210
  var children = _a.children, config = _a.config, useNotificationsHook = _a.useNotificationsHook;
47130
- // Memoize callbacks to prevent recreating on every render
47211
+ // Use refs to store callbacks to avoid recreating them
47212
+ var onNotificationRef = React.useRef(config.onNotification);
47213
+ var onConnectionChangeRef = React.useRef(config.onConnectionChange);
47214
+ var onErrorRef = React.useRef(config.onError);
47215
+ // Update refs when callbacks change
47216
+ onNotificationRef.current = config.onNotification;
47217
+ onConnectionChangeRef.current = config.onConnectionChange;
47218
+ onErrorRef.current = config.onError;
47219
+ // Create stable callbacks that use refs
47131
47220
  var onNotificationCb = React.useCallback(function (notification) {
47132
47221
  var _a;
47133
- (_a = config.onNotification) === null || _a === void 0 ? void 0 : _a.call(config, notification);
47134
- }, [config.onNotification]);
47222
+ (_a = onNotificationRef.current) === null || _a === void 0 ? void 0 : _a.call(onNotificationRef, notification);
47223
+ }, []);
47135
47224
  var onConnectionChangeCb = React.useCallback(function (isConnected) {
47136
47225
  var _a;
47137
- (_a = config.onConnectionChange) === null || _a === void 0 ? void 0 : _a.call(config, isConnected);
47138
- }, [config.onConnectionChange]);
47226
+ (_a = onConnectionChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onConnectionChangeRef, isConnected);
47227
+ }, []);
47139
47228
  var onErrorCb = React.useCallback(function (error) {
47140
47229
  var _a;
47141
- (_a = config.onError) === null || _a === void 0 ? void 0 : _a.call(config, error);
47142
- }, [config.onError]);
47143
- var notificationState = useNotificationsHook(__assign(__assign({}, config), { onNotification: onNotificationCb, onConnectionChange: onConnectionChangeCb, onError: onErrorCb }));
47144
- return (React.createElement(SnackbarProvider, { maxSnack: (config === null || config === void 0 ? void 0 : config.maxVisibleToasts) || 5, autoHideDuration: (config === null || config === void 0 ? void 0 : config.autoRemoveDelay) || 5000, anchorOrigin: {
47230
+ (_a = onErrorRef.current) === null || _a === void 0 ? void 0 : _a.call(onErrorRef, error);
47231
+ }, []);
47232
+ // Memoize the config object to prevent recreating it
47233
+ var memoizedConfig = React.useMemo(function () { return (__assign(__assign({}, config), { onNotification: onNotificationCb, onConnectionChange: onConnectionChangeCb, onError: onErrorCb })); }, [
47234
+ config.bsOrgId,
47235
+ config.cfWsId,
47236
+ config.timezone,
47237
+ config.navigate,
47238
+ config.soundConfig,
47239
+ config.triggerEvents,
47240
+ config.warehousesConfig,
47241
+ config.maxVisibleToasts,
47242
+ config.autoRemoveDelay,
47243
+ onNotificationCb,
47244
+ onConnectionChangeCb,
47245
+ onErrorCb,
47246
+ ]);
47247
+ var notificationState = useNotificationsHook(memoizedConfig);
47248
+ // Memoize SnackbarProvider props to prevent re-renders
47249
+ var snackbarProps = React.useMemo(function () { return ({
47250
+ maxSnack: (config === null || config === void 0 ? void 0 : config.maxVisibleToasts) || 5,
47251
+ autoHideDuration: (config === null || config === void 0 ? void 0 : config.autoRemoveDelay) || 5000,
47252
+ anchorOrigin: {
47145
47253
  vertical: 'top',
47146
47254
  horizontal: 'right',
47147
- }, dense: true, preventDuplicate: true, disableWindowBlurListener: true, classes: {
47255
+ },
47256
+ dense: true,
47257
+ preventDuplicate: true,
47258
+ disableWindowBlurListener: true,
47259
+ classes: {
47148
47260
  containerRoot: 'snackbarStack',
47149
47261
  containerAnchorOriginTopRight: 'snackbarStack',
47150
- }, Components: {
47262
+ },
47263
+ Components: {
47151
47264
  notification: NotificationToast,
47152
- } },
47265
+ },
47266
+ }); }, [config === null || config === void 0 ? void 0 : config.maxVisibleToasts, config === null || config === void 0 ? void 0 : config.autoRemoveDelay]);
47267
+ return (React.createElement(SnackbarProvider, __assign({}, snackbarProps),
47153
47268
  React.createElement(material.GlobalStyles, { styles: {
47154
47269
  '.snackbarStack': {
47155
47270
  display: 'flex !important',
@@ -47159,12 +47274,22 @@ var NotificationProviderBase = function (_a) {
47159
47274
  } }),
47160
47275
  React.createElement(NotificationContext.Provider, { value: notificationState }, children)));
47161
47276
  };
47277
+ // Default empty config to prevent creating new object on each render
47278
+ var EMPTY_CONFIG = {};
47162
47279
  var NotificationProvider = function (_a) {
47163
- var children = _a.children, _b = _a.config, config = _b === void 0 ? {} : _b;
47164
- var isV2 = config.isV2, restConfig = __rest(config, ["isV2"]);
47165
- if (isV2)
47166
- return (React.createElement(NotificationProviderBase, { config: restConfig, useNotificationsHook: useNotificationsV2 }, children));
47167
- return (React.createElement(NotificationProviderBase, { config: restConfig, useNotificationsHook: useNotifications }, children));
47280
+ var children = _a.children, _b = _a.config, config = _b === void 0 ? EMPTY_CONFIG : _b;
47281
+ // Extract isV2 flag
47282
+ var isV2 = config === null || config === void 0 ? void 0 : config.isV2;
47283
+ // Memoize the config without isV2 to prevent recreating object
47284
+ var restConfig = React.useMemo(function () {
47285
+ if (!config)
47286
+ return {};
47287
+ config.isV2; var rest = __rest(config, ["isV2"]);
47288
+ return rest;
47289
+ }, [config]);
47290
+ // Memoize the hook selection
47291
+ var useNotificationsHook = React.useMemo(function () { return (isV2 ? useNotificationsV2 : useNotifications); }, [isV2]);
47292
+ return (React.createElement(NotificationProviderBase, { config: restConfig, useNotificationsHook: useNotificationsHook }, children));
47168
47293
  };
47169
47294
  var useNotificationContext = function () {
47170
47295
  var context = React.useContext(NotificationContext);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bs-unified-ui",
3
- "version": "1.0.917",
3
+ "version": "1.0.922",
4
4
  "license": "MIT",
5
5
  "author": "Advesa",
6
6
  "description": "UI Components for Unified Breadstack UI",