@dile/lib 0.1.9 → 0.2.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.
- package/index.js +4 -2
- package/package.json +4 -3
- package/src/components/DileAppModalFeedback.js +99 -0
- package/src/lib/DileFeedback.js +47 -1
- package/src/redux/feedback-slice.js +21 -0
package/index.js
CHANGED
|
@@ -4,7 +4,9 @@ export {
|
|
|
4
4
|
positiveFeedback,
|
|
5
5
|
neutralFeedback,
|
|
6
6
|
startLoading,
|
|
7
|
-
stopLoading
|
|
7
|
+
stopLoading,
|
|
8
|
+
modalMessage,
|
|
9
|
+
modalClose,
|
|
8
10
|
} from './src/redux/feedback-slice.js';
|
|
9
11
|
export {
|
|
10
12
|
userSlice,
|
|
@@ -17,8 +19,8 @@ export { DileFeedback } from './src/lib/DileFeedback.js';
|
|
|
17
19
|
export { DileState } from './src/lib/DileState.js';
|
|
18
20
|
export { DileAppRouter } from './src/lib/DileAppRouter.js';
|
|
19
21
|
export { DileAppNavigate } from './src/lib/DileAppNavigate.js';
|
|
20
|
-
|
|
21
22
|
export { DileAppFeedback } from './src/components/DileAppFeedback.js';
|
|
23
|
+
export { DileAppModalFeedback } from './src/components/DileAppModalFeedback.js';
|
|
22
24
|
export { DileAppLoading } from './src/components/DileAppLoading.js';
|
|
23
25
|
export { DileAuthGuard } from './src/components/DileAuthGuard.js';
|
|
24
26
|
export { DileRouterLink } from './src/components/DileRouterLink.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/lib",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Common App libraries, mixins and helpers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,10 +22,11 @@
|
|
|
22
22
|
"homepage": "https://dile-components.com/",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@dile/
|
|
25
|
+
"@dile/icons": "^2.4.1",
|
|
26
|
+
"@dile/ui": "^2.8.3",
|
|
26
27
|
"@lit-labs/router": "^0.1.4",
|
|
27
28
|
"@reduxjs/toolkit": "^2.5.1",
|
|
28
29
|
"lit": "^2.7.0 || ^3.0.0"
|
|
29
30
|
},
|
|
30
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "fbb7a5933a1ea456601ab8af86da1586b1c1a34e"
|
|
31
32
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { DileState } from '../lib/DileState.js';
|
|
3
|
+
import '@dile/ui/components/modal/modal.js';
|
|
4
|
+
import '@dile/ui/components/icon/icon.js';
|
|
5
|
+
import '@dile/ui/components/button/button.js';
|
|
6
|
+
import { modalClose } from '../redux/feedback-slice.js';
|
|
7
|
+
|
|
8
|
+
export const DileAppModalFeedback = (store) => class extends DileState(store)(LitElement) {
|
|
9
|
+
static styles = [
|
|
10
|
+
css`
|
|
11
|
+
:host {
|
|
12
|
+
display: block;
|
|
13
|
+
}
|
|
14
|
+
.content {
|
|
15
|
+
display: flex;
|
|
16
|
+
margin-bottom: 0.75rem;
|
|
17
|
+
gap: 0.5rem;
|
|
18
|
+
align-items: center;
|
|
19
|
+
}
|
|
20
|
+
.message {
|
|
21
|
+
flex-grow: 1;
|
|
22
|
+
}
|
|
23
|
+
.icon {
|
|
24
|
+
display: flex;
|
|
25
|
+
--dile-icon-size: 32px;
|
|
26
|
+
}
|
|
27
|
+
.warning {
|
|
28
|
+
--dile-icon-color: var(--dile-alert-warning-color, #d7b740);
|
|
29
|
+
}
|
|
30
|
+
.success {
|
|
31
|
+
--dile-icon-color: var(--dile-alert-success-color, #00900f);
|
|
32
|
+
}
|
|
33
|
+
.error {
|
|
34
|
+
--dile-icon-color: var(--dile-alert-error-color, #cf3535);
|
|
35
|
+
}
|
|
36
|
+
.neutral {
|
|
37
|
+
--dile-icon-color: var(--dile-alert-neutral-color, #2889a7);
|
|
38
|
+
}
|
|
39
|
+
`
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
static get properties() {
|
|
43
|
+
return {
|
|
44
|
+
incomingMsg: { type: Object },
|
|
45
|
+
modalOpened: { type: Boolean },
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
constructor() {
|
|
50
|
+
super();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get elmodal() {
|
|
54
|
+
return this.shadowRoot.getElementById('modal');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
stateChanged(state) {
|
|
58
|
+
this.incomingMsg = state.feedback.modalMessage;
|
|
59
|
+
this.modalOpened = state.feedback.modalOpened;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
updated(changedProperties) {
|
|
63
|
+
if (changedProperties.has('modalOpened')) {
|
|
64
|
+
if(this.modalOpened) {
|
|
65
|
+
this.elmodal.open();
|
|
66
|
+
} else if(this.elmodal.opened) {
|
|
67
|
+
this.elmodal.close();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
render() {
|
|
73
|
+
return html`
|
|
74
|
+
${this.modalElement}
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get modalElement() {
|
|
79
|
+
return html`
|
|
80
|
+
<dile-modal id="modal" blocking @dile-modal-closed=${this.close}>
|
|
81
|
+
<div class="content">
|
|
82
|
+
${this.incomingMsg?.icon
|
|
83
|
+
? html`<div class="icon"><dile-icon class="${this.incomingMsg.iconClass}" .icon="${this.incomingMsg.icon}"></dile-icon></div>`
|
|
84
|
+
: ''
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
<div class="message">${this.incomingMsg?.message}</div>
|
|
88
|
+
</div>
|
|
89
|
+
<div class="actions">
|
|
90
|
+
<dile-button class="cancel" @click="${this.close}">${this.incomingMsg?.label}</dile-button>
|
|
91
|
+
</div>
|
|
92
|
+
</dile-modal>
|
|
93
|
+
`
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
close() {
|
|
97
|
+
store.dispatch(modalClose());
|
|
98
|
+
}
|
|
99
|
+
}
|
package/src/lib/DileFeedback.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { infoIcon, warningIcon, doneIcon, errorIcon} from '@dile/icons';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
positiveFeedback,
|
|
5
|
+
negativeFeedback,
|
|
6
|
+
neutralFeedback,
|
|
7
|
+
startLoading,
|
|
8
|
+
stopLoading,
|
|
9
|
+
modalMessage,
|
|
10
|
+
modalClose,
|
|
11
|
+
} from '../redux/feedback-slice';
|
|
12
|
+
|
|
13
|
+
const AVAILABLE_ICONS = [
|
|
14
|
+
{
|
|
15
|
+
name: 'info',
|
|
16
|
+
icon: infoIcon,
|
|
17
|
+
iconClass: 'neutral',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'warning',
|
|
21
|
+
icon: warningIcon,
|
|
22
|
+
iconClass: 'warning',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'success',
|
|
26
|
+
icon: doneIcon,
|
|
27
|
+
iconClass: 'success',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'error',
|
|
31
|
+
icon: errorIcon,
|
|
32
|
+
iconClass: 'error',
|
|
33
|
+
},
|
|
34
|
+
];
|
|
2
35
|
|
|
3
36
|
export const DileFeedback = (store) => (Superclass) => class extends Superclass {
|
|
4
37
|
positiveFeedback(msg) {
|
|
@@ -16,4 +49,17 @@ export const DileFeedback = (store) => (Superclass) => class extends Superclass
|
|
|
16
49
|
stopLoading() {
|
|
17
50
|
store.dispatch(stopLoading());
|
|
18
51
|
}
|
|
52
|
+
modalFeedback(msg, label = "Close", icon = null) {
|
|
53
|
+
let selectedIcon = AVAILABLE_ICONS.find(item => item.name == icon);
|
|
54
|
+
store.dispatch(modalMessage({
|
|
55
|
+
message: msg,
|
|
56
|
+
label,
|
|
57
|
+
icon: selectedIcon?.icon,
|
|
58
|
+
iconClass: selectedIcon?.iconClass
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
closeModalFeedback() {
|
|
63
|
+
store.dispatch(modalClose())
|
|
64
|
+
}
|
|
19
65
|
}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
|
|
3
|
+
const MODAL_DEFAULT_MESSAGE = {
|
|
4
|
+
message: '',
|
|
5
|
+
icon: null,
|
|
6
|
+
iconClass: null,
|
|
7
|
+
label: 'Close',
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
export const feedbackSlice = createSlice({
|
|
4
11
|
name: 'feedback',
|
|
5
12
|
initialState: {
|
|
6
13
|
message: null,
|
|
7
14
|
loading: false,
|
|
15
|
+
modalMessage: null,
|
|
16
|
+
modalOpened: false,
|
|
8
17
|
},
|
|
9
18
|
reducers: {
|
|
10
19
|
positiveFeedback(state, action) {
|
|
@@ -30,6 +39,16 @@ export const feedbackSlice = createSlice({
|
|
|
30
39
|
},
|
|
31
40
|
stopLoading(state) {
|
|
32
41
|
state.loading = false;
|
|
42
|
+
},
|
|
43
|
+
modalMessage(state, action) {
|
|
44
|
+
state.modalMessage = {
|
|
45
|
+
...MODAL_DEFAULT_MESSAGE,
|
|
46
|
+
...action.payload,
|
|
47
|
+
}
|
|
48
|
+
state.modalOpened = true;
|
|
49
|
+
},
|
|
50
|
+
modalClose(state) {
|
|
51
|
+
state.modalOpened = false;
|
|
33
52
|
}
|
|
34
53
|
}
|
|
35
54
|
});
|
|
@@ -40,4 +59,6 @@ export const {
|
|
|
40
59
|
neutralFeedback,
|
|
41
60
|
startLoading,
|
|
42
61
|
stopLoading,
|
|
62
|
+
modalMessage,
|
|
63
|
+
modalClose,
|
|
43
64
|
} = feedbackSlice.actions;
|