@opengeoweb/snackbar 19.1.0 → 19.2.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/dist/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # snackbar
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running unit tests
6
+
7
+ Run `nx test snackbar` to execute the unit tests via [Jest](https://jestjs.io).
8
+
9
+ ### TypeScript Documentation
10
+
11
+ - [TypeScript Docs](https://opengeoweb.gitlab.io/opengeoweb/typescript-docs/snackbar/)
@@ -0,0 +1 @@
1
+ export * from "./src/index";
@@ -0,0 +1,458 @@
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import { useDispatch, useSelector } from 'react-redux';
3
+ import { Snackbar } from '@mui/material';
4
+ import { CustomIconButton } from '@opengeoweb/shared';
5
+ import { Close } from '@opengeoweb/theme';
6
+ import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, combineReducers, configureStore } from '@reduxjs/toolkit';
7
+ import 'i18next';
8
+ import { useTranslation } from 'react-i18next';
9
+
10
+ var en = {
11
+ "snackbar-close": "Close"
12
+ };
13
+ var fi = {
14
+ "snackbar-close": "Sulje"
15
+ };
16
+ var no = {
17
+ "snackbar-close": "Lukk"
18
+ };
19
+ var nl = {
20
+ "snackbar-close": "Sluiten"
21
+ };
22
+ var snackbarTranslations = {
23
+ en: en,
24
+ fi: fi,
25
+ no: no,
26
+ nl: nl
27
+ };
28
+
29
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
30
+ try {
31
+ var i = n[a](c),
32
+ u = i.value;
33
+ } catch (n) {
34
+ return void e(n);
35
+ }
36
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
37
+ }
38
+ function _asyncToGenerator(n) {
39
+ return function () {
40
+ var t = this,
41
+ e = arguments;
42
+ return new Promise(function (r, o) {
43
+ var a = n.apply(t, e);
44
+ function _next(n) {
45
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
46
+ }
47
+ function _throw(n) {
48
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
49
+ }
50
+ _next(void 0);
51
+ });
52
+ };
53
+ }
54
+ function _objectWithoutPropertiesLoose(r, e) {
55
+ if (null == r) return {};
56
+ var t = {};
57
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
58
+ if (-1 !== e.indexOf(n)) continue;
59
+ t[n] = r[n];
60
+ }
61
+ return t;
62
+ }
63
+ function _regenerator() {
64
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
65
+ var e,
66
+ t,
67
+ r = "function" == typeof Symbol ? Symbol : {},
68
+ n = r.iterator || "@@iterator",
69
+ o = r.toStringTag || "@@toStringTag";
70
+ function i(r, n, o, i) {
71
+ var c = n && n.prototype instanceof Generator ? n : Generator,
72
+ u = Object.create(c.prototype);
73
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
74
+ var i,
75
+ c,
76
+ u,
77
+ f = 0,
78
+ p = o || [],
79
+ y = false,
80
+ G = {
81
+ p: 0,
82
+ n: 0,
83
+ v: e,
84
+ a: d,
85
+ f: d.bind(e, 4),
86
+ d: function (t, r) {
87
+ return i = t, c = 0, u = e, G.n = r, a;
88
+ }
89
+ };
90
+ function d(r, n) {
91
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
92
+ var o,
93
+ i = p[t],
94
+ d = G.p,
95
+ l = i[2];
96
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
97
+ }
98
+ if (o || r > 1) return a;
99
+ throw y = true, n;
100
+ }
101
+ return function (o, p, l) {
102
+ if (f > 1) throw TypeError("Generator is already running");
103
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
104
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
105
+ try {
106
+ if (f = 2, i) {
107
+ if (c || (o = "next"), t = i[o]) {
108
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
109
+ if (!t.done) return t;
110
+ u = t.value, c < 2 && (c = 0);
111
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
112
+ i = e;
113
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
114
+ } catch (t) {
115
+ i = e, c = 1, u = t;
116
+ } finally {
117
+ f = 1;
118
+ }
119
+ }
120
+ return {
121
+ value: t,
122
+ done: y
123
+ };
124
+ };
125
+ }(r, o, i), true), u;
126
+ }
127
+ var a = {};
128
+ function Generator() {}
129
+ function GeneratorFunction() {}
130
+ function GeneratorFunctionPrototype() {}
131
+ t = Object.getPrototypeOf;
132
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
133
+ return this;
134
+ }), t),
135
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
136
+ function f(e) {
137
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
138
+ }
139
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
140
+ return this;
141
+ }), _regeneratorDefine(u, "toString", function () {
142
+ return "[object Generator]";
143
+ }), (_regenerator = function () {
144
+ return {
145
+ w: i,
146
+ m: f
147
+ };
148
+ })();
149
+ }
150
+ function _regeneratorDefine(e, r, n, t) {
151
+ var i = Object.defineProperty;
152
+ try {
153
+ i({}, "", {});
154
+ } catch (e) {
155
+ i = 0;
156
+ }
157
+ _regeneratorDefine = function (e, r, n, t) {
158
+ function o(r, n) {
159
+ _regeneratorDefine(e, r, function (e) {
160
+ return this._invoke(r, n, e);
161
+ });
162
+ }
163
+ r ? i ? i(e, r, {
164
+ value: n,
165
+ enumerable: !t,
166
+ configurable: !t,
167
+ writable: !t
168
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
169
+ }, _regeneratorDefine(e, r, n, t);
170
+ }
171
+
172
+ /* *
173
+ * Licensed under the Apache License, Version 2.0 (the "License");
174
+ * you may not use this file except in compliance with the License.
175
+ * You may obtain a copy of the License at
176
+ *
177
+ * http://www.apache.org/licenses/LICENSE-2.0
178
+ *
179
+ * Unless required by applicable law or agreed to in writing, software
180
+ * distributed under the License is distributed on an "AS IS" BASIS,
181
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
182
+ * See the License for the specific language governing permissions and
183
+ * limitations under the License.
184
+ *
185
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
186
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
187
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
188
+ * */
189
+ var snackbarAdapter = createEntityAdapter();
190
+ var initialState = snackbarAdapter.getInitialState();
191
+ var slice = createSlice({
192
+ initialState: initialState,
193
+ name: 'snackbar',
194
+ reducers: {
195
+ // To open the snackbar call this action
196
+ openSnackbar: function openSnackbar(_draft, _action) {},
197
+ // triggerOpenSnackbarByListener is triggered by the listener to open the snackbar after the current snackbars have all been closed
198
+ // DO NOT CALL THIS ACTION DIRECTLY!
199
+ triggerOpenSnackbarByListener: function triggerOpenSnackbarByListener(draft, action) {
200
+ var snackbarContent = action.payload.snackbarContent;
201
+ // Ensure we have an id before proceeding
202
+ if (snackbarContent.id === undefined) {
203
+ return;
204
+ }
205
+ snackbarAdapter.setOne(draft, snackbarContent);
206
+ },
207
+ closeSnackbar: function closeSnackbar(draft) {
208
+ snackbarAdapter.removeAll(draft);
209
+ }
210
+ }
211
+ });
212
+ var snackbarReducer = slice.reducer,
213
+ snackbarActions = slice.actions;
214
+
215
+ /* *
216
+ * Licensed under the Apache License, Version 2.0 (the "License");
217
+ * you may not use this file except in compliance with the License.
218
+ * You may obtain a copy of the License at
219
+ *
220
+ * http://www.apache.org/licenses/LICENSE-2.0
221
+ *
222
+ * Unless required by applicable law or agreed to in writing, software
223
+ * distributed under the License is distributed on an "AS IS" BASIS,
224
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
225
+ * See the License for the specific language governing permissions and
226
+ * limitations under the License.
227
+ *
228
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
229
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
230
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
231
+ * */
232
+ var getSnackbarStore = function getSnackbarStore(store) {
233
+ if (store != null && store.snackbar) {
234
+ return store.snackbar;
235
+ }
236
+ return null;
237
+ };
238
+ var EMPTY_SNACKBAR_STATE = {
239
+ entities: {},
240
+ ids: []
241
+ };
242
+ var _snackbarAdapter$getS = snackbarAdapter.getSelectors(function (state) {
243
+ var _state$snackbar;
244
+ return (_state$snackbar = state == null ? void 0 : state.snackbar) != null ? _state$snackbar : EMPTY_SNACKBAR_STATE;
245
+ }),
246
+ getCurrentSnackbarMessages = _snackbarAdapter$getS.selectAll;
247
+ var getFirstSnackbarMessage = createSelector(getCurrentSnackbarMessages, function (currentMessages) {
248
+ return currentMessages.length > 0 ? currentMessages[0] : undefined;
249
+ });
250
+
251
+ var selectors = /*#__PURE__*/Object.freeze({
252
+ __proto__: null,
253
+ getCurrentSnackbarMessages: getCurrentSnackbarMessages,
254
+ getFirstSnackbarMessage: getFirstSnackbarMessage,
255
+ getSnackbarStore: getSnackbarStore
256
+ });
257
+
258
+ /* *
259
+ * Licensed under the Apache License, Version 2.0 (the "License");
260
+ * you may not use this file except in compliance with the License.
261
+ * You may obtain a copy of the License at
262
+ *
263
+ * http://www.apache.org/licenses/LICENSE-2.0
264
+ *
265
+ * Unless required by applicable law or agreed to in writing, software
266
+ * distributed under the License is distributed on an "AS IS" BASIS,
267
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
268
+ * See the License for the specific language governing permissions and
269
+ * limitations under the License.
270
+ *
271
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
272
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
273
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
274
+ * */
275
+ var SnackbarMessageType;
276
+ (function (SnackbarMessageType) {
277
+ SnackbarMessageType["TRANSLATABLE_MESSAGE"] = "TRANSLATABLE_MESSAGE";
278
+ SnackbarMessageType["VERBATIM_MESSAGE"] = "VERBATIM_MESSAGE";
279
+ })(SnackbarMessageType || (SnackbarMessageType = {}));
280
+
281
+ var types = /*#__PURE__*/Object.freeze({
282
+ __proto__: null,
283
+ get SnackbarMessageType () { return SnackbarMessageType; }
284
+ });
285
+
286
+ var hideTime = 4000;
287
+ var snackbarListener = createListenerMiddleware();
288
+ snackbarListener.startListening({
289
+ actionCreator: snackbarActions.openSnackbar,
290
+ effect: function () {
291
+ var _effect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, listenerApi) {
292
+ var payload, currentSnackbarMessages, id, currentSnackbarMessagesOpen;
293
+ return _regenerator().w(function (_context) {
294
+ while (1) switch (_context.n) {
295
+ case 0:
296
+ payload = _ref.payload;
297
+ listenerApi.cancelActiveListeners();
298
+ currentSnackbarMessages = getCurrentSnackbarMessages(listenerApi.getState()); // If there are currently opened snackbars we need to close these first
299
+ if (currentSnackbarMessages.length) {
300
+ listenerApi.dispatch(snackbarActions.closeSnackbar());
301
+ }
302
+ // Generate a unique id
303
+ id = "snackbar" + Date.now().toString();
304
+ listenerApi.dispatch(snackbarActions.triggerOpenSnackbarByListener({
305
+ snackbarContent: {
306
+ message: payload,
307
+ id: id
308
+ }
309
+ }));
310
+ // If no new snackbar is triggered cancelling this listener, hide the snackbar after X seconds
311
+ _context.n = 1;
312
+ return listenerApi.delay(hideTime);
313
+ case 1:
314
+ currentSnackbarMessagesOpen = getCurrentSnackbarMessages(listenerApi.getState());
315
+ if (currentSnackbarMessagesOpen.length) {
316
+ listenerApi.dispatch(snackbarActions.closeSnackbar());
317
+ }
318
+ case 2:
319
+ return _context.a(2);
320
+ }
321
+ }, _callee);
322
+ }));
323
+ function effect(_x, _x2) {
324
+ return _effect.apply(this, arguments);
325
+ }
326
+ return effect;
327
+ }()
328
+ });
329
+
330
+ /* *
331
+ * Licensed under the Apache License, Version 2.0 (the "License");
332
+ * you may not use this file except in compliance with the License.
333
+ * You may obtain a copy of the License at
334
+ *
335
+ * http://www.apache.org/licenses/LICENSE-2.0
336
+ *
337
+ * Unless required by applicable law or agreed to in writing, software
338
+ * distributed under the License is distributed on an "AS IS" BASIS,
339
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
340
+ * See the License for the specific language governing permissions and
341
+ * limitations under the License.
342
+ *
343
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
344
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
345
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
346
+ * */
347
+ var snackbarReducersMap = {
348
+ snackbar: snackbarReducer
349
+ };
350
+ var snackbarMiddlewares = [snackbarListener.middleware];
351
+ var snackbarRootReuducer = combineReducers(snackbarReducersMap);
352
+ var createMockStore = function createMockStore(mockState) {
353
+ return configureStore({
354
+ reducer: snackbarRootReuducer,
355
+ preloadedState: mockState,
356
+ middleware: function middleware(getDefaultMiddleware) {
357
+ return getDefaultMiddleware().concat(snackbarListener.middleware);
358
+ }
359
+ });
360
+ };
361
+
362
+ /* *
363
+ * Licensed under the Apache License, Version 2.0 (the "License");
364
+ * you may not use this file except in compliance with the License.
365
+ * You may obtain a copy of the License at
366
+ *
367
+ * http://www.apache.org/licenses/LICENSE-2.0
368
+ *
369
+ * Unless required by applicable law or agreed to in writing, software
370
+ * distributed under the License is distributed on an "AS IS" BASIS,
371
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
372
+ * See the License for the specific language governing permissions and
373
+ * limitations under the License.
374
+ *
375
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
376
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
377
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
378
+ * */
379
+ var SNACKBAR_NAMESPACE = 'snackbar';
380
+ var WORKSPACE_NAMESPACE = 'workspace';
381
+ var WARN_NAMESPACE = 'warn';
382
+ var LAYER_SELECT_NAMESPACE = 'layerselect';
383
+ var AUTH_NAMESPACE = 'auth';
384
+ var useSnackbarTranslation = function useSnackbarTranslation() {
385
+ return useTranslation([SNACKBAR_NAMESPACE, WORKSPACE_NAMESPACE, WARN_NAMESPACE, LAYER_SELECT_NAMESPACE, AUTH_NAMESPACE], {
386
+ nsMode: 'fallback'
387
+ });
388
+ };
389
+
390
+ var _excluded = ["children", "isOpen", "onCloseSnackbar", "id", "snackbarMessage"];
391
+ var getMessageString = function getMessageString(t, snackbarMessage) {
392
+ if (!snackbarMessage) {
393
+ return '';
394
+ }
395
+ return snackbarMessage.type === SnackbarMessageType.TRANSLATABLE_MESSAGE ? t(snackbarMessage.key, snackbarMessage.params) : snackbarMessage.message;
396
+ };
397
+ var SnackbarWrapper = function SnackbarWrapper(_ref) {
398
+ var children = _ref.children,
399
+ isOpen = _ref.isOpen,
400
+ onCloseSnackbar = _ref.onCloseSnackbar,
401
+ id = _ref.id,
402
+ snackbarMessage = _ref.snackbarMessage,
403
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
404
+ var _useSnackbarTranslati = useSnackbarTranslation(),
405
+ t = _useSnackbarTranslati.t;
406
+ var messageString = getMessageString(t, snackbarMessage);
407
+ return jsxs(Fragment, {
408
+ children: [children, jsx(Snackbar, Object.assign({
409
+ action: jsx(CustomIconButton, {
410
+ "aria-label": t('snackbar-close'),
411
+ "data-testid": "snackbarCloseButton",
412
+ onClick: onCloseSnackbar,
413
+ size: "large",
414
+ sx: {
415
+ '&.MuiButtonBase-root': {
416
+ borderRadius: 20,
417
+ color: 'geowebColors.snackbar.action',
418
+ '&:hover': {
419
+ color: 'geowebColors.snackbar.action',
420
+ backgroundColor: 'geowebColors.snackbar.actionHover.rgba'
421
+ }
422
+ }
423
+ },
424
+ children: jsx(Close, {})
425
+ }),
426
+ autoHideDuration: null,
427
+ "data-testid": "snackbarComponent",
428
+ message: messageString,
429
+ onClose: onCloseSnackbar,
430
+ open: isOpen,
431
+ slotProps: {
432
+ clickAwayListener: function clickAwayListener() {
433
+ return {
434
+ mouseEvent: false
435
+ };
436
+ }
437
+ }
438
+ }, props), id)]
439
+ });
440
+ };
441
+
442
+ var SnackbarWrapperConnect = function SnackbarWrapperConnect(props) {
443
+ var dispatch = useDispatch();
444
+ var onCloseSnackbar = function onCloseSnackbar() {
445
+ dispatch(snackbarActions.closeSnackbar());
446
+ };
447
+ var currentSnackbarMessage = useSelector(function (store) {
448
+ return getFirstSnackbarMessage(store);
449
+ });
450
+ return jsx(SnackbarWrapper, Object.assign({
451
+ id: currentSnackbarMessage ? currentSnackbarMessage.id : '',
452
+ isOpen: !!currentSnackbarMessage,
453
+ onCloseSnackbar: onCloseSnackbar,
454
+ snackbarMessage: currentSnackbarMessage == null ? void 0 : currentSnackbarMessage.message
455
+ }, props));
456
+ };
457
+
458
+ export { SNACKBAR_NAMESPACE, SnackbarWrapperConnect, createMockStore, hideTime, snackbarActions, snackbarListener, snackbarMiddlewares, snackbarReducer, snackbarReducersMap, selectors as snackbarSelectors, snackbarTranslations, types as snackbarTypes };
@@ -0,0 +1 @@
1
+ export * from './lib';
@@ -0,0 +1,11 @@
1
+ import type { Store } from '@reduxjs/toolkit';
2
+ interface SnackbarTranslationsWrapperProps {
3
+ children?: React.ReactNode;
4
+ }
5
+ export declare const DemoWrapper: React.FC<SnackbarTranslationsWrapperProps>;
6
+ interface ProviderProps {
7
+ children?: React.ReactNode;
8
+ store: Store;
9
+ }
10
+ export declare const DemoWrapperConnect: React.FC<ProviderProps>;
11
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { SnackbarProps } from '@mui/material';
2
+ import React from 'react';
3
+ import { snackbarTypes } from '../../store';
4
+ interface SnackBarWrapperProps extends SnackbarProps {
5
+ isOpen: boolean;
6
+ id: string;
7
+ snackbarMessage?: snackbarTypes.SnackbarMessage;
8
+ onCloseSnackbar: () => void;
9
+ }
10
+ export declare const SnackbarWrapper: React.FC<SnackBarWrapperProps>;
11
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { SnackbarProps } from '@mui/material';
2
+ import React from 'react';
3
+ export declare const SnackbarWrapperConnect: React.FC<SnackbarProps>;
@@ -0,0 +1 @@
1
+ export { SnackbarWrapperConnect } from './SnackbarWrapperConnect';
@@ -0,0 +1,5 @@
1
+ import snackbarTranslations from './locales/snackbar.json';
2
+ export * from './components/Snackbar';
3
+ export * from './store';
4
+ export { SNACKBAR_NAMESPACE } from './utils/i18n';
5
+ export { snackbarTranslations };
@@ -0,0 +1,7 @@
1
+ export { snackbarActions } from './reducer';
2
+ export * as snackbarSelectors from './selectors';
3
+ export * as snackbarTypes from './types';
4
+ export * from './store';
5
+ export { snackbarReducer } from './reducer';
6
+ export * from './listener';
7
+ export type { SnackbarModuleStore } from './types';
@@ -0,0 +1,3 @@
1
+ import type { SnackbarModuleStore } from './types';
2
+ export declare const hideTime = 4000;
3
+ export declare const snackbarListener: import("@reduxjs/toolkit").ListenerMiddlewareInstance<SnackbarModuleStore, import("redux-thunk").ThunkDispatch<SnackbarModuleStore, unknown, import("redux").UnknownAction>, unknown>;
@@ -0,0 +1,10 @@
1
+ import type { PayloadAction, Draft } from '@reduxjs/toolkit';
2
+ import type { OpenSnackbarPayload, SnackbarItem, SnackbarState, TriggerOpenSnackbarByListenerPayload } from './types';
3
+ export declare const snackbarAdapter: import("@reduxjs/toolkit").EntityAdapter<SnackbarItem, string>;
4
+ export declare const initialState: SnackbarState;
5
+ export declare const snackbarReducer: import("redux").Reducer<SnackbarState>, snackbarActions: import("@reduxjs/toolkit").CaseReducerActions<{
6
+ openSnackbar: (_draft: Draft<SnackbarState>, _action: PayloadAction<OpenSnackbarPayload>) => void;
7
+ triggerOpenSnackbarByListener: (draft: Draft<SnackbarState>, action: PayloadAction<TriggerOpenSnackbarByListenerPayload>) => void;
8
+ closeSnackbar: (draft: Draft<SnackbarState>) => void;
9
+ }, "snackbar">;
10
+ export type SnackbarActions = ReturnType<typeof snackbarActions.openSnackbar> | ReturnType<typeof snackbarActions.triggerOpenSnackbarByListener> | ReturnType<typeof snackbarActions.closeSnackbar>;
@@ -0,0 +1,24 @@
1
+ import type { SnackbarModuleStore, SnackbarState } from './types';
2
+ export declare const getSnackbarStore: (store: SnackbarModuleStore) => SnackbarState;
3
+ export declare const getCurrentSnackbarMessages: (state: SnackbarModuleStore) => import("./types").SnackbarItem[];
4
+ export declare const getFirstSnackbarMessage: ((state: SnackbarModuleStore) => import("./types").SnackbarItem | undefined) & {
5
+ clearCache: () => void;
6
+ resultsCount: () => number;
7
+ resetResultsCount: () => void;
8
+ } & {
9
+ resultFunc: (resultFuncArgs_0: import("./types").SnackbarItem[]) => import("./types").SnackbarItem | undefined;
10
+ memoizedResultFunc: ((resultFuncArgs_0: import("./types").SnackbarItem[]) => import("./types").SnackbarItem | undefined) & {
11
+ clearCache: () => void;
12
+ resultsCount: () => number;
13
+ resetResultsCount: () => void;
14
+ };
15
+ lastResult: () => import("./types").SnackbarItem | undefined;
16
+ dependencies: [(state: SnackbarModuleStore) => import("./types").SnackbarItem[]];
17
+ recomputations: () => number;
18
+ resetRecomputations: () => void;
19
+ dependencyRecomputations: () => number;
20
+ resetDependencyRecomputations: () => void;
21
+ } & {
22
+ argsMemoize: typeof import("reselect").weakMapMemoize;
23
+ memoize: typeof import("reselect").weakMapMemoize;
24
+ };
@@ -0,0 +1,7 @@
1
+ import type { Store } from '@reduxjs/toolkit';
2
+ import type { SnackbarModuleStore } from './types';
3
+ export declare const snackbarReducersMap: {
4
+ snackbar: import("redux").Reducer<import("./types").SnackbarState>;
5
+ };
6
+ export declare const snackbarMiddlewares: import("@reduxjs/toolkit").ListenerMiddleware<SnackbarModuleStore, import("redux-thunk").ThunkDispatch<SnackbarModuleStore, unknown, import("redux").UnknownAction>, unknown>[];
7
+ export declare const createMockStore: (mockState?: SnackbarModuleStore) => Store;
@@ -0,0 +1,27 @@
1
+ import type { EntityState } from '@reduxjs/toolkit';
2
+ export interface SnackbarItem {
3
+ message: SnackbarMessage;
4
+ id: string;
5
+ }
6
+ export type SnackbarState = EntityState<SnackbarItem, string>;
7
+ export interface SnackbarModuleStore {
8
+ snackbar?: SnackbarState;
9
+ }
10
+ export declare enum SnackbarMessageType {
11
+ TRANSLATABLE_MESSAGE = "TRANSLATABLE_MESSAGE",
12
+ VERBATIM_MESSAGE = "VERBATIM_MESSAGE"
13
+ }
14
+ export interface TranslatableMessage {
15
+ type: SnackbarMessageType.TRANSLATABLE_MESSAGE;
16
+ key: string;
17
+ params?: Record<string, string | number> | undefined;
18
+ }
19
+ export interface VerbatimMessage {
20
+ type: SnackbarMessageType.VERBATIM_MESSAGE;
21
+ message: string;
22
+ }
23
+ export type SnackbarMessage = TranslatableMessage | VerbatimMessage;
24
+ export type OpenSnackbarPayload = SnackbarMessage;
25
+ export interface TriggerOpenSnackbarByListenerPayload {
26
+ snackbarContent: SnackbarItem;
27
+ }
@@ -0,0 +1,5 @@
1
+ import i18n from 'i18next';
2
+ import type { UseTranslationResponse } from 'react-i18next';
3
+ export declare const SNACKBAR_NAMESPACE = "snackbar";
4
+ export declare const initSnackbarI18n: () => void;
5
+ export declare const useSnackbarTranslation: () => UseTranslationResponse<typeof SNACKBAR_NAMESPACE, typeof i18n>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/snackbar",
3
- "version": "19.1.0",
3
+ "version": "19.2.0",
4
4
  "description": "GeoWeb snackbar library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -38,6 +38,7 @@
38
38
  },
39
39
  "files": [
40
40
  "dist",
41
+ "!dist/package.json",
41
42
  "README.md",
42
43
  "package.json"
43
44
  ]