@nuralyui/alert 0.0.5 → 0.0.6
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/bundle.js +216 -2
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -3,7 +3,183 @@ import{css as r,LitElement as e,nothing as t,html as a}from"lit";import{property
|
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
|
-
*/const c=r
|
|
6
|
+
*/const c=r`
|
|
7
|
+
:host {
|
|
8
|
+
display: block;
|
|
9
|
+
font-family: var(--nuraly-font-family);
|
|
10
|
+
font-size: var(--nuraly-font-size-base);
|
|
11
|
+
line-height: var(--nuraly-line-height-base);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:host([hidden]) {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.alert {
|
|
19
|
+
position: relative;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: flex-start;
|
|
22
|
+
gap: var(--nuraly-alert-gap);
|
|
23
|
+
padding: var(--nuraly-alert-padding);
|
|
24
|
+
border: 1px solid transparent;
|
|
25
|
+
border-radius: var(--nuraly-alert-border-radius);
|
|
26
|
+
transition: var(--nuraly-alert-transition);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.alert--banner {
|
|
30
|
+
border-radius: 0;
|
|
31
|
+
border-left: none;
|
|
32
|
+
border-right: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Alert type variants - Success */
|
|
36
|
+
.alert--success {
|
|
37
|
+
background-color: var(--nuraly-color-success-light, #f6ffed);
|
|
38
|
+
border-color: var(--nuraly-color-success, #52c41a);
|
|
39
|
+
color: var(--nuraly-color-success-dark, #389e0d);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.alert--success .alert__icon {
|
|
43
|
+
color: var(--nuraly-color-success, #52c41a);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Alert type variants - Info */
|
|
47
|
+
.alert--info {
|
|
48
|
+
background-color: var(--nuraly-color-info-light, #e6f7ff);
|
|
49
|
+
border-color: var(--nuraly-color-info, #1890ff);
|
|
50
|
+
color: var(--nuraly-color-info-dark, #096dd9);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.alert--info .alert__icon {
|
|
54
|
+
color: var(--nuraly-color-info, #1890ff);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* Alert type variants - Warning */
|
|
58
|
+
.alert--warning {
|
|
59
|
+
background-color: var(--nuraly-color-warning-light, #fffbe6);
|
|
60
|
+
border-color: var(--nuraly-color-warning, #faad14);
|
|
61
|
+
color: var(--nuraly-color-warning-dark, #d48806);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.alert--warning .alert__icon {
|
|
65
|
+
color: var(--nuraly-color-warning, #faad14);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Alert type variants - Error */
|
|
69
|
+
.alert--error {
|
|
70
|
+
background-color: var(--nuraly-color-error-light, #fff2f0);
|
|
71
|
+
border-color: var(--nuraly-color-error, #ff4d4f);
|
|
72
|
+
color: var(--nuraly-color-error-dark, #cf1322);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.alert--error .alert__icon {
|
|
76
|
+
color: var(--nuraly-color-error, #ff4d4f);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Alert with description */
|
|
80
|
+
.alert--with-description {
|
|
81
|
+
padding: var(--nuraly-alert-padding-with-description);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.alert--with-description .alert__icon {
|
|
85
|
+
font-size: 1.5rem;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.alert__icon {
|
|
89
|
+
flex-shrink: 0;
|
|
90
|
+
display: flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
justify-content: center;
|
|
93
|
+
font-size: 1rem;
|
|
94
|
+
line-height: 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.alert__content {
|
|
98
|
+
flex: 1;
|
|
99
|
+
min-width: 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.alert__message {
|
|
103
|
+
font-weight: var(--nuraly-font-weight-medium, 500);
|
|
104
|
+
margin: 0;
|
|
105
|
+
line-height: var(--nuraly-line-height-base);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.alert--with-description .alert__message {
|
|
109
|
+
font-size: var(--nuraly-font-size-lg, 1.125rem);
|
|
110
|
+
margin-bottom: var(--nuraly-spacing-1);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.alert__description {
|
|
114
|
+
margin: var(--nuraly-spacing-1) 0 0;
|
|
115
|
+
font-size: var(--nuraly-font-size-sm, 0.875rem);
|
|
116
|
+
line-height: var(--nuraly-line-height-relaxed, 1.6);
|
|
117
|
+
opacity: 0.85;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.alert__close {
|
|
121
|
+
flex-shrink: 0;
|
|
122
|
+
background: none;
|
|
123
|
+
border: none;
|
|
124
|
+
padding: 0;
|
|
125
|
+
margin: 0;
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
display: flex;
|
|
128
|
+
align-items: center;
|
|
129
|
+
justify-content: center;
|
|
130
|
+
color: currentColor;
|
|
131
|
+
opacity: 0.6;
|
|
132
|
+
transition: opacity var(--nuraly-transition-fast) ease;
|
|
133
|
+
line-height: 1;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.alert__close:hover {
|
|
137
|
+
opacity: 1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.alert__close:focus {
|
|
141
|
+
outline: none;
|
|
142
|
+
opacity: 1;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.alert__close:focus-visible {
|
|
146
|
+
outline: 2px solid currentColor;
|
|
147
|
+
outline-offset: 2px;
|
|
148
|
+
border-radius: var(--nuraly-border-radius-sm, 2px);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* Animation for closing */
|
|
152
|
+
@keyframes alertFadeOut {
|
|
153
|
+
from {
|
|
154
|
+
opacity: 1;
|
|
155
|
+
max-height: 200px;
|
|
156
|
+
}
|
|
157
|
+
to {
|
|
158
|
+
opacity: 0;
|
|
159
|
+
max-height: 0;
|
|
160
|
+
padding-top: 0;
|
|
161
|
+
padding-bottom: 0;
|
|
162
|
+
margin-top: 0;
|
|
163
|
+
margin-bottom: 0;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.alert--closing {
|
|
168
|
+
animation: alertFadeOut 0.3s ease forwards;
|
|
169
|
+
overflow: hidden;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/* Responsive adjustments */
|
|
173
|
+
@media (max-width: 768px) {
|
|
174
|
+
.alert {
|
|
175
|
+
padding: var(--nuraly-spacing-2) var(--nuraly-spacing-3);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.alert--with-description {
|
|
179
|
+
padding: var(--nuraly-spacing-3) var(--nuraly-spacing-4);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
`
|
|
7
183
|
/**
|
|
8
184
|
* @license
|
|
9
185
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
@@ -14,4 +190,42 @@ import{css as r,LitElement as e,nothing as t,html as a}from"lit";import{property
|
|
|
14
190
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
15
191
|
* SPDX-License-Identifier: MIT
|
|
16
192
|
*/
|
|
17
|
-
var u=function(r,e,t,a){for(var i,o=arguments.length,n=o<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,t):a,l=r.length-1;l>=0;l--)(i=r[l])&&(n=(o<3?i(n):o>3?i(e,t,n):i(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n};let h=class extends(s(e)){constructor(){super(...arguments),this.requiredComponents=["nr-icon"],this.message="",this.type="info",this.description="",this.closable=!1,this.showIcon=!1,this.icon="",this.banner=!1,this.visible=!0,this.closing=!1}close(){this.visible&&!this.closing&&(this.closing=!0,setTimeout((()=>{this.visible=!1,this.closing=!1,this.dispatchEvent(new CustomEvent("nr-alert-close",{detail:{message:this.message,type:this.type},bubbles:!0,composed:!0}))}),300))}handleCloseClick(r){r.stopPropagation(),this.close()}getDefaultIcon(){if(this.icon)return this.icon;switch(this.type){case"success":return"check-circle";case"info":return"info";case"warning":return"alert-triangle";case"error":return"x-circle";default:return""}}hasDescription(){return!!this.description}render(){if(!this.visible)return t;const r={alert:!0,[`alert--${this.type}`]:!0,"alert--with-description":this.hasDescription(),"alert--banner":this.banner,"alert--closing":this.closing};return a
|
|
193
|
+
var u=function(r,e,t,a){for(var i,o=arguments.length,n=o<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,t):a,l=r.length-1;l>=0;l--)(i=r[l])&&(n=(o<3?i(n):o>3?i(e,t,n):i(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n};let h=class extends(s(e)){constructor(){super(...arguments),this.requiredComponents=["nr-icon"],this.message="",this.type="info",this.description="",this.closable=!1,this.showIcon=!1,this.icon="",this.banner=!1,this.visible=!0,this.closing=!1}close(){this.visible&&!this.closing&&(this.closing=!0,setTimeout((()=>{this.visible=!1,this.closing=!1,this.dispatchEvent(new CustomEvent("nr-alert-close",{detail:{message:this.message,type:this.type},bubbles:!0,composed:!0}))}),300))}handleCloseClick(r){r.stopPropagation(),this.close()}getDefaultIcon(){if(this.icon)return this.icon;switch(this.type){case"success":return"check-circle";case"info":return"info";case"warning":return"alert-triangle";case"error":return"x-circle";default:return""}}hasDescription(){return!!this.description}render(){if(!this.visible)return t;const r={alert:!0,[`alert--${this.type}`]:!0,"alert--with-description":this.hasDescription(),"alert--banner":this.banner,"alert--closing":this.closing};return a`
|
|
194
|
+
<div class=${l(r)} role="alert">
|
|
195
|
+
${this.showIcon?a`
|
|
196
|
+
<div class="alert__icon">
|
|
197
|
+
<slot name="icon">
|
|
198
|
+
<nr-icon
|
|
199
|
+
name=${this.getDefaultIcon()}
|
|
200
|
+
size=${this.hasDescription()?"large":"small"}
|
|
201
|
+
></nr-icon>
|
|
202
|
+
</slot>
|
|
203
|
+
</div>
|
|
204
|
+
`:t}
|
|
205
|
+
|
|
206
|
+
<div class="alert__content">
|
|
207
|
+
${this.message?a`
|
|
208
|
+
<div class="alert__message">${this.message}</div>
|
|
209
|
+
`:t}
|
|
210
|
+
|
|
211
|
+
${this.description?a`
|
|
212
|
+
<div class="alert__description">${this.description}</div>
|
|
213
|
+
`:t}
|
|
214
|
+
|
|
215
|
+
<slot></slot>
|
|
216
|
+
|
|
217
|
+
<slot name="action"></slot>
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
${this.closable?a`
|
|
221
|
+
<button
|
|
222
|
+
class="alert__close"
|
|
223
|
+
@click=${this.handleCloseClick}
|
|
224
|
+
aria-label="Close alert"
|
|
225
|
+
type="button"
|
|
226
|
+
>
|
|
227
|
+
<nr-icon name="x" size="small"></nr-icon>
|
|
228
|
+
</button>
|
|
229
|
+
`:t}
|
|
230
|
+
</div>
|
|
231
|
+
`}};h.styles=c,u([i({type:String})],h.prototype,"message",void 0),u([i({type:String,reflect:!0})],h.prototype,"type",void 0),u([i({type:String})],h.prototype,"description",void 0),u([i({type:Boolean})],h.prototype,"closable",void 0),u([i({type:Boolean,attribute:"show-icon"})],h.prototype,"showIcon",void 0),u([i({type:String})],h.prototype,"icon",void 0),u([i({type:Boolean})],h.prototype,"banner",void 0),u([o()],h.prototype,"visible",void 0),u([o()],h.prototype,"closing",void 0),h=u([n("nr-alert")],h);export{d as EMPTY_STRING,h as NrAlertElement};
|