@dile/lib 0.0.1

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.
@@ -0,0 +1,22 @@
1
+ {
2
+ "workbench.colorCustomizations": {
3
+ "activityBar.activeBackground": "#fbed80",
4
+ "activityBar.background": "#fbed80",
5
+ "activityBar.foreground": "#15202b",
6
+ "activityBar.inactiveForeground": "#15202b99",
7
+ "activityBarBadge.background": "#06b9a5",
8
+ "activityBarBadge.foreground": "#15202b",
9
+ "commandCenter.border": "#15202b99",
10
+ "sash.hoverBorder": "#fbed80",
11
+ "statusBar.background": "#f9e64f",
12
+ "statusBar.foreground": "#15202b",
13
+ "statusBarItem.hoverBackground": "#f7df1e",
14
+ "statusBarItem.remoteBackground": "#f9e64f",
15
+ "statusBarItem.remoteForeground": "#15202b",
16
+ "titleBar.activeBackground": "#f9e64f",
17
+ "titleBar.activeForeground": "#15202b",
18
+ "titleBar.inactiveBackground": "#f9e64f99",
19
+ "titleBar.inactiveForeground": "#15202b99"
20
+ },
21
+ "peacock.color": "#f9e64f"
22
+ }
package/index.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@dile/lib",
3
+ "version": "0.0.1",
4
+ "description": "App libraries and helpers",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "test"
8
+ },
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "keywords": [
13
+ "lib",
14
+ "app"
15
+ ],
16
+ "author": "Midesweb",
17
+ "license": "MIT",
18
+ "dependencies": {
19
+ "@reduxjs/toolkit": "^2.5.1"
20
+ }
21
+ }
@@ -0,0 +1,20 @@
1
+ import { store } from '../redux/store';
2
+ import { positiveFeedback, negativeFeedback, neutralFeedback, startLoading, stopLoading } from '../redux/app-slice';
3
+
4
+ export const FeedbackMixin = (Superclass) => class extends Superclass {
5
+ positiveFeedback(msg) {
6
+ store.dispatch(positiveFeedback(msg));
7
+ }
8
+ negativeFeedback(msg) {
9
+ store.dispatch(negativeFeedback(msg));
10
+ }
11
+ neutralFeedback(msg) {
12
+ store.dispatch(neutralFeedback(msg));
13
+ }
14
+ startLoading() {
15
+ store.dispatch(startLoading());
16
+ }
17
+ stopLoading() {
18
+ store.dispatch(stopLoading());
19
+ }
20
+ }
@@ -0,0 +1,26 @@
1
+ import { store } from '../redux/store';
2
+
3
+ export const StateMixin = (superclass) => class extends superclass {
4
+
5
+ connectedCallback() {
6
+ super.connectedCallback();
7
+ this._unsuscribe = store.subscribe(() => {
8
+ const state = this.getState();
9
+ this.stateChanged(state);
10
+ });
11
+ this.stateChanged(this.getState());
12
+ }
13
+
14
+ disconnectedCallback() {
15
+ this._unsuscribe();
16
+ super.disconnectedCallback();
17
+ }
18
+
19
+ stateChanged(state) {
20
+ // Redefinir este método para cachear el estado que necesite el componente
21
+ }
22
+
23
+ getState() {
24
+ return store.getState();
25
+ }
26
+ }
@@ -0,0 +1,43 @@
1
+ import { createSlice } from '@reduxjs/toolkit';
2
+
3
+ export const appSlice = createSlice({
4
+ name: 'app',
5
+ initialState: {
6
+ feedback: null,
7
+ loading: false,
8
+ },
9
+ reducers: {
10
+ positiveFeedback(state, action) {
11
+ state.feedback = {
12
+ status: 'success',
13
+ msg: action.payload,
14
+ }
15
+ },
16
+ negativeFeedback(state, action) {
17
+ state.feedback = {
18
+ status: 'error',
19
+ msg: action.payload,
20
+ }
21
+ },
22
+ neutralFeedback(state, action) {
23
+ state.feedback = {
24
+ status: 'neutral',
25
+ msg: action.payload,
26
+ }
27
+ },
28
+ startLoading(state) {
29
+ state.loading = true;
30
+ },
31
+ stopLoading(state) {
32
+ state.loading = false;
33
+ }
34
+ }
35
+ });
36
+
37
+ export const {
38
+ negativeFeedback,
39
+ positiveFeedback,
40
+ neutralFeedback,
41
+ startLoading,
42
+ stopLoading,
43
+ } = appSlice.actions;
@@ -0,0 +1,10 @@
1
+ import { configureStore } from '@reduxjs/toolkit';
2
+ import { appSlice } from './app-slice';
3
+ import { userSlice } from './user-slice';
4
+
5
+ export const store = configureStore({
6
+ reducer: {
7
+ app: appSlice.reducer,
8
+ user: userSlice.reducer,
9
+ }
10
+ });
@@ -0,0 +1,31 @@
1
+ import { createSlice } from '@reduxjs/toolkit';
2
+
3
+ export const userSlice = createSlice({
4
+ name: 'user',
5
+ initialState: {
6
+ userData: null,
7
+ token: '',
8
+ isLoggedIn: false,
9
+ isInitialized: false,
10
+ },
11
+ reducers: {
12
+ storeUser(state, action) {
13
+ state.userData = action.payload;
14
+ state.isLoggedIn = true;
15
+ state.isInitialized = true;
16
+ },
17
+ removeUser(state) {
18
+ state.userData = null;
19
+ state.isLoggedIn = false;
20
+ state.token = '';
21
+ },
22
+ storeToken(state, action) {
23
+ state.token = action.payload;
24
+ },
25
+ setInitialized(state) {
26
+ state.isInitialized = true;
27
+ }
28
+ }
29
+ })
30
+
31
+ export const { storeUser, removeUser, storeToken, setInitialized } = userSlice.actions;