@nuralyui/image 0.0.10 → 0.0.11
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 +98 -1
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -1 +1,98 @@
|
|
|
1
|
-
import{css as i,LitElement as t,html as r}from"lit";import{property as e,state as o,customElement as s}from"lit/decorators.js";import{classMap as a}from"lit/directives/class-map.js";import{styleMap as l}from"lit/directives/style-map.js";import{NuralyUIBaseMixin as d}from"@nuralyui/common/mixins";var g=i`
|
|
1
|
+
import{css as i,LitElement as t,html as r}from"lit";import{property as e,state as o,customElement as s}from"lit/decorators.js";import{classMap as a}from"lit/directives/class-map.js";import{styleMap as l}from"lit/directives/style-map.js";import{NuralyUIBaseMixin as d}from"@nuralyui/common/mixins";var g=i`
|
|
2
|
+
img{
|
|
3
|
+
border-top-left-radius:var(--nuraly-image-border-top-left-radius,var(--nuraly-image-local-border-top-left-radius)) ;
|
|
4
|
+
border-top-right-radius: var(--nuraly-image-border-top-right-radius,var(--nuraly-image-local-border-top-right-radius));
|
|
5
|
+
border-bottom-left-radius: var(--nuraly-image-border-bottom-left-radius,var(--nuraly-image-local-border-bottom-left-radius));
|
|
6
|
+
border-bottom-right-radius: var(--nuraly-image-border-bottom-right-radius,var(--nuraly-image-local-border-bottom-right-radius));
|
|
7
|
+
}
|
|
8
|
+
.image-container {
|
|
9
|
+
position: relative;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
img {
|
|
13
|
+
display: block;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.preview-modal {
|
|
18
|
+
position: fixed;
|
|
19
|
+
top: 0;
|
|
20
|
+
left: 0;
|
|
21
|
+
right: 0;
|
|
22
|
+
bottom: 0;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
27
|
+
z-index: 1000;
|
|
28
|
+
animation: fadeIn 0.3s ease;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.preview-modal img {
|
|
32
|
+
max-width: 90%;
|
|
33
|
+
max-height: 90%;
|
|
34
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
35
|
+
border-radius: 4px;
|
|
36
|
+
animation: zoomIn 0.3s ease;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.preview-close {
|
|
40
|
+
position: absolute;
|
|
41
|
+
top: 20px;
|
|
42
|
+
right: 20px;
|
|
43
|
+
width: 40px;
|
|
44
|
+
height: 40px;
|
|
45
|
+
background: rgba(255, 255, 255, 0.2);
|
|
46
|
+
border: none;
|
|
47
|
+
border-radius: 50%;
|
|
48
|
+
color: white;
|
|
49
|
+
font-size: 24px;
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
outline: none;
|
|
55
|
+
transition: background-color 0.3s;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.preview-close:hover {
|
|
59
|
+
background: rgba(255, 255, 255, 0.4);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@keyframes fadeIn {
|
|
63
|
+
from {
|
|
64
|
+
opacity: 0;
|
|
65
|
+
}
|
|
66
|
+
to {
|
|
67
|
+
opacity: 1;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@keyframes zoomIn {
|
|
72
|
+
from {
|
|
73
|
+
transform: scale(0.9);
|
|
74
|
+
opacity: 0;
|
|
75
|
+
}
|
|
76
|
+
to {
|
|
77
|
+
transform: scale(1);
|
|
78
|
+
opacity: 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`,c=function(i,t,r,e){for(var o,s=arguments.length,a=s<3?t:null===e?e=Object.getOwnPropertyDescriptor(t,r):e,l=i.length-1;l>=0;l--)(o=i[l])&&(a=(s<3?o(a):s>3?o(t,r,a):o(t,r))||a);return s>3&&a&&Object.defineProperty(t,r,a),a};let n=class extends(d(t)){constructor(){super(...arguments),this.width="auto",this.height="auto",this.alt="",this.previewable=!1,this.block=!1,this.currentSrc="",this.showPreview=!1,this.hasError=!1,this.defaultFallback="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KPHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNFRkYxRjMiLz4NCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMzMuMjUwMyAzOC40ODE2QzMzLjI2MDMgMzcuMDQ3MiAzNC40MTk5IDM1Ljg4NjQgMzUuODU0MyAzNS44NzVIODMuMTQ2M0M4NC41ODQ4IDM1Ljg3NSA4NS43NTAzIDM3LjA0MzEgODUuNzUwMyAzOC40ODE2VjgwLjUxODRDODUuNzQwMyA4MS45NTI4IDg0LjU4MDcgODMuMTEzNiA4My4xNDYzIDgzLjEyNUgzNS44NTQzQzM0LjQxNTggODMuMTIzNiAzMy4yNTAzIDgxLjk1NyAzMy4yNTAzIDgwLjUxODRWMzguNDgxNlpNODAuNTAwNiA0MS4xMjUxSDM4LjUwMDZWNzcuODc1MUw2Mi44OTIxIDUzLjQ3ODNDNjMuOTE3MiA1Mi40NTM2IDY1LjU3ODggNTIuNDUzNiA2Ni42MDM5IDUzLjQ3ODNMODAuNTAwNiA2Ny40MDEzVjQxLjEyNTFaTTQzLjc1IDUxLjYyNDlDNDMuNzUgNTQuNTI0NCA0Ni4xMDA1IDU2Ljg3NDkgNDkgNTYuODc0OUM1MS44OTk1IDU2Ljg3NDkgNTQuMjUgNTQuNTI0NCA1NC4yNSA1MS42MjQ5QzU0LjI1IDQ4LjcyNTQgNTEuODk5NSA0Ni4zNzQ5IDQ5IDQ2LjM3NDlDNDYuMTAwNSA0Ni4zNzQ5IDQzLjc1IDQ4LjcyNTQgNDMuNzUgNTEuNjI0OVoiIGZpbGw9IiM2ODc3ODciLz4NCjwvc3ZnPg=="}willUpdate(i){i.has("src")&&(this.currentSrc=this.src,this.hasError=!1)}handleError(){this.hasError=!0,this.dispatchEvent(new CustomEvent("nr-image-error",{bubbles:!0,composed:!0,detail:{error:`Error loading image: ${this.currentSrc}`,src:this.currentSrc}})),this.fallback&&this.currentSrc!==this.fallback&&this.currentSrc!==this.defaultFallback?this.currentSrc=this.fallback:this.currentSrc!==this.defaultFallback&&(this.currentSrc=this.defaultFallback)}handleLoad(){this.hasError=!1,this.dispatchEvent(new CustomEvent("nr-image-load",{bubbles:!0,composed:!0,detail:{src:this.currentSrc}}))}showPreviewModal(){this.previewable&&!this.hasError&&(this.showPreview=!0,this.dispatchEvent(new CustomEvent("nr-image-preview-open",{bubbles:!0,composed:!0,detail:{src:this.currentSrc}})))}closePreviewModal(){this.showPreview=!1,this.dispatchEvent(new CustomEvent("nr-image-preview-close",{bubbles:!0,composed:!0,detail:{src:this.currentSrc}}))}render(){const i={"image-container":!0,"image--previewable":this.previewable,"image--error":this.hasError},t={width:"number"==typeof this.width?`${this.width}px`:this.width,height:"number"==typeof this.height?`${this.height}px`:this.height};return this.fit&&(t["object-fit"]=this.fit),r`
|
|
82
|
+
<div class=${a(i)}>
|
|
83
|
+
<img
|
|
84
|
+
src=${this.currentSrc}
|
|
85
|
+
alt=${this.alt}
|
|
86
|
+
style=${l(t)}
|
|
87
|
+
@error=${this.handleError}
|
|
88
|
+
@load=${this.handleLoad}
|
|
89
|
+
@click=${this.showPreviewModal}
|
|
90
|
+
/>
|
|
91
|
+
${this.showPreview?r`
|
|
92
|
+
<div class="preview-modal" @click=${this.closePreviewModal}>
|
|
93
|
+
<button class="preview-close" @click=${this.closePreviewModal} aria-label="Close preview">×</button>
|
|
94
|
+
<img src="${this.currentSrc}" alt="${this.alt}" />
|
|
95
|
+
</div>
|
|
96
|
+
`:""}
|
|
97
|
+
</div>
|
|
98
|
+
`}};n.styles=g,c([e({type:String})],n.prototype,"src",void 0),c([e({type:String})],n.prototype,"fallback",void 0),c([e({type:String})],n.prototype,"width",void 0),c([e({type:String})],n.prototype,"height",void 0),c([e({type:String})],n.prototype,"alt",void 0),c([e({type:Boolean})],n.prototype,"previewable",void 0),c([e({type:String})],n.prototype,"fit",void 0),c([e({type:Boolean,reflect:!0})],n.prototype,"block",void 0),c([o()],n.prototype,"currentSrc",void 0),c([o()],n.prototype,"showPreview",void 0),c([o()],n.prototype,"hasError",void 0),n=c([s("nr-image")],n);export{n as NrImageElement};
|