@opengeoweb/snackbar 9.14.0 → 9.16.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.esm.js CHANGED
@@ -3,8 +3,7 @@ import { useDispatch, useSelector } from 'react-redux';
3
3
  import { CustomIconButton, withEggs } from '@opengeoweb/shared';
4
4
  import { Snackbar } from '@mui/material';
5
5
  import { Close } from '@opengeoweb/theme';
6
- import { createEntityAdapter, createSlice, createSelector } from '@reduxjs/toolkit';
7
- import { takeLatest, select, put, delay } from 'redux-saga/effects';
6
+ import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware } from '@reduxjs/toolkit';
8
7
 
9
8
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
10
9
 
@@ -13,7 +12,7 @@ var check = function (it) {
13
12
  };
14
13
 
15
14
  // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
16
- var global$b =
15
+ var global$a =
17
16
  // eslint-disable-next-line es/no-global-this -- safe
18
17
  check(typeof globalThis == 'object' && globalThis) ||
19
18
  check(typeof window == 'object' && window) ||
@@ -164,7 +163,7 @@ var isObject$5 = function (it) {
164
163
  return typeof it == 'object' ? it !== null : isCallable$a(it);
165
164
  };
166
165
 
167
- var global$a = global$b;
166
+ var global$9 = global$a;
168
167
  var isCallable$9 = isCallable$b;
169
168
 
170
169
  var aFunction = function (argument) {
@@ -172,7 +171,7 @@ var aFunction = function (argument) {
172
171
  };
173
172
 
174
173
  var getBuiltIn$2 = function (namespace, method) {
175
- return arguments.length < 2 ? aFunction(global$a[namespace]) : global$a[namespace] && global$a[namespace][method];
174
+ return arguments.length < 2 ? aFunction(global$9[namespace]) : global$9[namespace] && global$9[namespace][method];
176
175
  };
177
176
 
178
177
  var uncurryThis$7 = functionUncurryThis;
@@ -181,11 +180,11 @@ var objectIsPrototypeOf = uncurryThis$7({}.isPrototypeOf);
181
180
 
182
181
  var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
183
182
 
184
- var global$9 = global$b;
183
+ var global$8 = global$a;
185
184
  var userAgent = engineUserAgent;
186
185
 
187
- var process = global$9.process;
188
- var Deno = global$9.Deno;
186
+ var process = global$8.process;
187
+ var Deno = global$8.Deno;
189
188
  var versions = process && process.versions || Deno && Deno.version;
190
189
  var v8 = versions && versions.v8;
191
190
  var match, version;
@@ -212,9 +211,9 @@ var engineV8Version = version;
212
211
  /* eslint-disable es/no-symbol -- required for testing */
213
212
  var V8_VERSION = engineV8Version;
214
213
  var fails$6 = fails$a;
215
- var global$8 = global$b;
214
+ var global$7 = global$a;
216
215
 
217
- var $String$4 = global$8.String;
216
+ var $String$4 = global$7.String;
218
217
 
219
218
  // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
220
219
  var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$6(function () {
@@ -296,41 +295,41 @@ var ordinaryToPrimitive$1 = function (input, pref) {
296
295
  throw new $TypeError$3("Can't convert object to primitive value");
297
296
  };
298
297
 
299
- var shared$3 = {exports: {}};
298
+ var sharedStore = {exports: {}};
300
299
 
301
- var global$7 = global$b;
300
+ var global$6 = global$a;
302
301
 
303
302
  // eslint-disable-next-line es/no-object-defineproperty -- safe
304
303
  var defineProperty$2 = Object.defineProperty;
305
304
 
306
305
  var defineGlobalProperty$3 = function (key, value) {
307
306
  try {
308
- defineProperty$2(global$7, key, { value: value, configurable: true, writable: true });
307
+ defineProperty$2(global$6, key, { value: value, configurable: true, writable: true });
309
308
  } catch (error) {
310
- global$7[key] = value;
309
+ global$6[key] = value;
311
310
  } return value;
312
311
  };
313
312
 
314
- var global$6 = global$b;
313
+ var globalThis$1 = global$a;
315
314
  var defineGlobalProperty$2 = defineGlobalProperty$3;
316
315
 
317
316
  var SHARED = '__core-js_shared__';
318
- var store$3 = global$6[SHARED] || defineGlobalProperty$2(SHARED, {});
317
+ var store$3 = sharedStore.exports = globalThis$1[SHARED] || defineGlobalProperty$2(SHARED, {});
319
318
 
320
- var sharedStore = store$3;
321
-
322
- var store$2 = sharedStore;
323
-
324
- (shared$3.exports = function (key, value) {
325
- return store$2[key] || (store$2[key] = value !== undefined ? value : {});
326
- })('versions', []).push({
327
- version: '3.35.1',
319
+ (store$3.versions || (store$3.versions = [])).push({
320
+ version: '3.36.1',
328
321
  mode: 'global',
329
322
  copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
330
- license: 'https://github.com/zloirock/core-js/blob/v3.35.1/LICENSE',
323
+ license: 'https://github.com/zloirock/core-js/blob/v3.36.1/LICENSE',
331
324
  source: 'https://github.com/zloirock/core-js'
332
325
  });
333
326
 
327
+ var store$2 = sharedStore.exports;
328
+
329
+ var shared$3 = function (key, value) {
330
+ return store$2[key] || (store$2[key] = value || {});
331
+ };
332
+
334
333
  var requireObjectCoercible = requireObjectCoercible$2;
335
334
 
336
335
  var $Object$1 = Object;
@@ -363,8 +362,8 @@ var uid$2 = function (key) {
363
362
  return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36);
364
363
  };
365
364
 
366
- var global$5 = global$b;
367
- var shared$2 = shared$3.exports;
365
+ var global$5 = global$a;
366
+ var shared$2 = shared$3;
368
367
  var hasOwn$7 = hasOwnProperty_1;
369
368
  var uid$1 = uid$2;
370
369
  var NATIVE_SYMBOL = symbolConstructorDetection;
@@ -418,7 +417,7 @@ var toPropertyKey$2 = function (argument) {
418
417
  return isSymbol(key) ? key : key + '';
419
418
  };
420
419
 
421
- var global$4 = global$b;
420
+ var global$4 = global$a;
422
421
  var isObject$2 = isObject$5;
423
422
 
424
423
  var document$1 = global$4.document;
@@ -567,7 +566,7 @@ var functionName = {
567
566
 
568
567
  var uncurryThis$4 = functionUncurryThis;
569
568
  var isCallable$5 = isCallable$b;
570
- var store$1 = sharedStore;
569
+ var store$1 = sharedStore.exports;
571
570
 
572
571
  var functionToString = uncurryThis$4(Function.toString);
573
572
 
@@ -580,14 +579,14 @@ if (!isCallable$5(store$1.inspectSource)) {
580
579
 
581
580
  var inspectSource$1 = store$1.inspectSource;
582
581
 
583
- var global$3 = global$b;
582
+ var global$3 = global$a;
584
583
  var isCallable$4 = isCallable$b;
585
584
 
586
585
  var WeakMap$1 = global$3.WeakMap;
587
586
 
588
587
  var weakMapBasicDetection = isCallable$4(WeakMap$1) && /native code/.test(String(WeakMap$1));
589
588
 
590
- var shared$1 = shared$3.exports;
589
+ var shared$1 = shared$3;
591
590
  var uid = uid$2;
592
591
 
593
592
  var keys = shared$1('keys');
@@ -599,11 +598,11 @@ var sharedKey$1 = function (key) {
599
598
  var hiddenKeys$3 = {};
600
599
 
601
600
  var NATIVE_WEAK_MAP = weakMapBasicDetection;
602
- var global$2 = global$b;
601
+ var global$2 = global$a;
603
602
  var isObject = isObject$5;
604
603
  var createNonEnumerableProperty$1 = createNonEnumerableProperty$2;
605
604
  var hasOwn$4 = hasOwnProperty_1;
606
- var shared = sharedStore;
605
+ var shared = sharedStore.exports;
607
606
  var sharedKey = sharedKey$1;
608
607
  var hiddenKeys$2 = hiddenKeys$3;
609
608
 
@@ -816,6 +815,7 @@ var createMethod = function (IS_INCLUDES) {
816
815
  return function ($this, el, fromIndex) {
817
816
  var O = toIndexedObject$1($this);
818
817
  var length = lengthOfArrayLike(O);
818
+ if (length === 0) return !IS_INCLUDES && -1;
819
819
  var index = toAbsoluteIndex(fromIndex, length);
820
820
  var value;
821
821
  // Array#includes uses SameValueZero equality algorithm
@@ -944,7 +944,7 @@ var POLYFILL = isForced$1.POLYFILL = 'P';
944
944
 
945
945
  var isForced_1 = isForced$1;
946
946
 
947
- var global$1 = global$b;
947
+ var global$1 = global$a;
948
948
  var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
949
949
  var createNonEnumerableProperty = createNonEnumerableProperty$2;
950
950
  var defineBuiltIn$1 = defineBuiltIn$2;
@@ -1103,6 +1103,16 @@ function __rest(s, e) {
1103
1103
  return t;
1104
1104
  }
1105
1105
 
1106
+ function __awaiter(thisArg, _arguments, P, generator) {
1107
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1108
+ return new (P || (P = Promise))(function (resolve, reject) {
1109
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1110
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1111
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1112
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1113
+ });
1114
+ }
1115
+
1106
1116
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1107
1117
  var e = new Error(message);
1108
1118
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -1175,9 +1185,9 @@ const slice = createSlice({
1175
1185
  draft,
1176
1186
  // eslint-disable-next-line no-unused-vars
1177
1187
  action) => {},
1178
- // triggerOpenSnackbarBySaga is triggered by the saga to open the snackbar after the current snackbars have all been closed
1188
+ // triggerOpenSnackbarByListener is triggered by the listener to open the snackbar after the current snackbars have all been closed
1179
1189
  // DO NOT CALL THIS ACTION DIRECTLY!
1180
- triggerOpenSnackbarBySaga: (draft, action) => {
1190
+ triggerOpenSnackbarByListener: (draft, action) => {
1181
1191
  const {
1182
1192
  snackbarContent
1183
1193
  } = action.payload;
@@ -1366,31 +1376,37 @@ if (NOT_GENERIC || INCORRECT_NAME) {
1366
1376
  }
1367
1377
 
1368
1378
  const hideTime = 4000;
1369
- function* openSnackbarSaga(capturedAction) {
1370
- const snackbarMessage = capturedAction.payload.message;
1371
- const currentSnackbarMessages = yield select(getCurrentSnackbarMessages);
1372
- // If there are currently opened snackbars we need to close these first
1373
- if (currentSnackbarMessages.length) {
1374
- yield put(snackbarActions.closeSnackbar());
1375
- }
1376
- // Generate a unique id
1377
- const id = `snackbar${Date.now().toString()}`;
1378
- yield put(snackbarActions.triggerOpenSnackbarBySaga({
1379
- snackbarContent: {
1380
- message: snackbarMessage,
1381
- id
1379
+ const snackbarListener = createListenerMiddleware();
1380
+ snackbarListener.startListening({
1381
+ actionCreator: snackbarActions.openSnackbar,
1382
+ effect: ({
1383
+ payload
1384
+ }, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
1385
+ listenerApi.cancelActiveListeners();
1386
+ const {
1387
+ message: snackbarMessage
1388
+ } = payload;
1389
+ const currentSnackbarMessages = getCurrentSnackbarMessages(listenerApi.getState());
1390
+ // If there are currently opened snackbars we need to close these first
1391
+ if (currentSnackbarMessages.length) {
1392
+ listenerApi.dispatch(snackbarActions.closeSnackbar());
1382
1393
  }
1383
- }));
1384
- // If no new snackbar is triggered cancelling this saga, hide the snackbar after X seconds
1385
- yield delay(hideTime);
1386
- const currentSnackbarMessagesOpen = yield select(getCurrentSnackbarMessages);
1387
- if (currentSnackbarMessagesOpen.length) {
1388
- yield put(snackbarActions.closeSnackbar());
1389
- }
1390
- }
1391
- function* rootSaga() {
1392
- yield takeLatest(snackbarActions.openSnackbar.type, openSnackbarSaga);
1393
- }
1394
+ // Generate a unique id
1395
+ const id = `snackbar${Date.now().toString()}`;
1396
+ listenerApi.dispatch(snackbarActions.triggerOpenSnackbarByListener({
1397
+ snackbarContent: {
1398
+ message: snackbarMessage,
1399
+ id
1400
+ }
1401
+ }));
1402
+ // If no new snackbar is triggered cancelling this listener, hide the snackbar after X seconds
1403
+ yield listenerApi.delay(hideTime);
1404
+ const currentSnackbarMessagesOpen = getCurrentSnackbarMessages(listenerApi.getState());
1405
+ if (currentSnackbarMessagesOpen.length) {
1406
+ listenerApi.dispatch(snackbarActions.closeSnackbar());
1407
+ }
1408
+ })
1409
+ });
1394
1410
 
1395
1411
  /* *
1396
1412
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -1413,7 +1429,7 @@ const snackbarModuleConfig = {
1413
1429
  reducersMap: {
1414
1430
  snackbar: reducer
1415
1431
  },
1416
- sagas: [rootSaga]
1432
+ middlewares: [snackbarListener.middleware]
1417
1433
  };
1418
1434
 
1419
1435
  const SnackbarWrapperConnect = withEggs([snackbarModuleConfig])(props => {
@@ -1430,4 +1446,4 @@ const SnackbarWrapperConnect = withEggs([snackbarModuleConfig])(props => {
1430
1446
  }, props));
1431
1447
  });
1432
1448
 
1433
- export { SnackbarWrapperConnect, snackbarActions, snackbarModuleConfig, reducer as snackbarReducer, rootSaga as snackbarSaga, selectors as snackbarSelectors, types as snackbarTypes };
1449
+ export { SnackbarWrapperConnect, hideTime, snackbarActions, snackbarListener, snackbarModuleConfig, reducer as snackbarReducer, selectors as snackbarSelectors, types as snackbarTypes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/snackbar",
3
- "version": "9.14.0",
3
+ "version": "9.16.0",
4
4
  "description": "GeoWeb snackbar library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -13,8 +13,7 @@
13
13
  "@opengeoweb/shared": "*",
14
14
  "react-redux": "^8.1.3",
15
15
  "@reduxjs/toolkit": "^1.9.7",
16
- "@redux-eggs/core": "^2.2.0",
17
- "redux-saga": "^1.2.3"
16
+ "@redux-eggs/core": "^2.2.0"
18
17
  },
19
18
  "peerDependencies": {
20
19
  "react": "18"
@@ -3,4 +3,4 @@ export * as snackbarSelectors from './selectors';
3
3
  export * as snackbarTypes from './types';
4
4
  export * from './config';
5
5
  export { reducer as snackbarReducer } from './reducer';
6
- export { rootSaga as snackbarSaga } from './sagas';
6
+ export * from './listener';
@@ -0,0 +1,3 @@
1
+ import { SnackbarModuleStore } from './types';
2
+ export declare const hideTime = 4000;
3
+ export declare const snackbarListener: import("@reduxjs/toolkit").ListenerMiddlewareInstance<SnackbarModuleStore, import("@reduxjs/toolkit").ThunkDispatch<SnackbarModuleStore, unknown, import("redux").AnyAction>, unknown>;
@@ -1,11 +1,11 @@
1
1
  import { PayloadAction, Draft } from '@reduxjs/toolkit';
2
- import { OpenSnackbarPayload, SnackbarItem, SnackbarState, TriggerOpenSnackbarBySagaPayload } from './types';
2
+ import { OpenSnackbarPayload, SnackbarItem, SnackbarState, TriggerOpenSnackbarByListenerPayload } from './types';
3
3
  export declare const snackbarAdapter: import("@reduxjs/toolkit").EntityAdapter<SnackbarItem>;
4
4
  export declare const initialState: SnackbarState;
5
5
  export declare const reducer: import("redux").Reducer<SnackbarState, import("redux").AnyAction>;
6
6
  export declare const snackbarActions: import("@reduxjs/toolkit").CaseReducerActions<{
7
7
  openSnackbar: (draft: Draft<SnackbarState>, action: PayloadAction<OpenSnackbarPayload>) => void;
8
- triggerOpenSnackbarBySaga: (draft: Draft<SnackbarState>, action: PayloadAction<TriggerOpenSnackbarBySagaPayload>) => void;
8
+ triggerOpenSnackbarByListener: (draft: Draft<SnackbarState>, action: PayloadAction<TriggerOpenSnackbarByListenerPayload>) => void;
9
9
  closeSnackbar: (draft: Draft<SnackbarState>) => void;
10
10
  }, "snackbar">;
11
- export type SnackbarActions = ReturnType<typeof snackbarActions.openSnackbar> | ReturnType<typeof snackbarActions.triggerOpenSnackbarBySaga> | ReturnType<typeof snackbarActions.closeSnackbar>;
11
+ export type SnackbarActions = ReturnType<typeof snackbarActions.openSnackbar> | ReturnType<typeof snackbarActions.triggerOpenSnackbarByListener> | ReturnType<typeof snackbarActions.closeSnackbar>;
@@ -10,6 +10,6 @@ export interface SnackbarModuleStore {
10
10
  export interface OpenSnackbarPayload {
11
11
  message: string;
12
12
  }
13
- export interface TriggerOpenSnackbarBySagaPayload {
13
+ export interface TriggerOpenSnackbarByListenerPayload {
14
14
  snackbarContent: SnackbarItem;
15
15
  }
@@ -1,5 +0,0 @@
1
- import { SagaIterator } from 'redux-saga';
2
- import { SnackbarActions } from './reducer';
3
- export declare function openSnackbarSaga(capturedAction: SnackbarActions): SagaIterator;
4
- export declare function rootSaga(): SagaIterator;
5
- export default rootSaga;