@lazhus/kg-ui 0.7.7 → 0.8.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.
@@ -2767,13 +2767,13 @@
2767
2767
  "text": "object"
2768
2768
  },
2769
2769
  "static": true,
2770
- "default": "{ src: { type: String }, alt: { type: String }, width: { type: String }, height: { type: String }, fit: { type: String }, // 'cover' | 'contain' | 'fill' | 'none' | 'scale-down' shape: { type: String }, // 'square' | 'circle' | 'rounded' lazy: { type: Boolean }, _error: { state: true } }"
2770
+ "default": "{ src: { type: String }, alt: { type: String }, width: { type: String }, height: { type: String }, fit: { type: String }, // 'cover' | 'contain' | 'fill' | 'none' | 'scale-down' shape: { type: String }, // 'square' | 'circle' | 'rounded' lazy: { type: Boolean }, preview: { type: Boolean }, _error: { state: true }, _previewOpen: { state: true } }"
2771
2771
  },
2772
2772
  {
2773
2773
  "kind": "field",
2774
2774
  "name": "styles",
2775
2775
  "static": true,
2776
- "default": "css` :host { display: inline-block; line-height: 0; overflow: hidden; background-color: var(--kg-bg-secondary); } :host([shape=\"circle\"]) { border-radius: 50%; } :host([shape=\"rounded\"]) { border-radius: var(--kg-radius, 8px); } :host([shape=\"square\"]) { border-radius: 0; } .img-wrapper { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; } img { display: block; width: 100%; height: 100%; } .fallback { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: var(--kg-text-muted); font-size: 0.8rem; } `"
2776
+ "default": "css` :host { display: inline-block; line-height: 0; overflow: hidden; background-color: var(--kg-bg-secondary); position: relative; } :host([shape=\"circle\"]) { border-radius: 50%; } :host([shape=\"rounded\"]) { border-radius: var(--kg-radius, 8px); } :host([shape=\"square\"]) { border-radius: 0; } :host([preview]) .img-wrapper { cursor: zoom-in; } .img-wrapper { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; } img { display: block; width: 100%; height: 100%; opacity: 1; transition: opacity 0.3s; } .fallback { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: var(--kg-text-muted); font-size: 0.8rem; } /* Preview Overlay */ .preview-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 2050; background-color: rgba(0, 0, 0, 0.9); display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.3s ease; backdrop-filter: blur(4px); } .preview-overlay.open { opacity: 1; visibility: visible; } .preview-image { max-width: 90vw; max-height: 90vh; width: auto; height: auto; object-fit: contain; transform: scale(0.9); transition: transform 0.3s ease; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5); } .preview-overlay.open .preview-image { transform: scale(1); } .preview-close { position: absolute; top: 20px; right: 20px; background: rgba(255, 255, 255, 0.2); border: none; color: white; cursor: pointer; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background 0.2s; z-index: 2060; } .preview-close:hover { background: rgba(255, 255, 255, 0.3); } `"
2777
2777
  },
2778
2778
  {
2779
2779
  "kind": "method",
@@ -2784,6 +2784,32 @@
2784
2784
  }
2785
2785
  ]
2786
2786
  },
2787
+ {
2788
+ "kind": "method",
2789
+ "name": "updated",
2790
+ "parameters": [
2791
+ {
2792
+ "name": "changedProperties"
2793
+ }
2794
+ ]
2795
+ },
2796
+ {
2797
+ "kind": "field",
2798
+ "name": "_handleKeyDown"
2799
+ },
2800
+ {
2801
+ "kind": "method",
2802
+ "name": "_handleImageClick"
2803
+ },
2804
+ {
2805
+ "kind": "method",
2806
+ "name": "_closePreview",
2807
+ "parameters": [
2808
+ {
2809
+ "name": "e"
2810
+ }
2811
+ ]
2812
+ },
2787
2813
  {
2788
2814
  "kind": "method",
2789
2815
  "name": "render"
@@ -2844,6 +2870,14 @@
2844
2870
  },
2845
2871
  "default": "false"
2846
2872
  },
2873
+ {
2874
+ "kind": "field",
2875
+ "name": "preview",
2876
+ "type": {
2877
+ "text": "boolean"
2878
+ },
2879
+ "default": "false"
2880
+ },
2847
2881
  {
2848
2882
  "kind": "field",
2849
2883
  "name": "_error",
@@ -2851,6 +2885,14 @@
2851
2885
  "text": "boolean"
2852
2886
  },
2853
2887
  "default": "false"
2888
+ },
2889
+ {
2890
+ "kind": "field",
2891
+ "name": "_previewOpen",
2892
+ "type": {
2893
+ "text": "boolean"
2894
+ },
2895
+ "default": "false"
2854
2896
  }
2855
2897
  ],
2856
2898
  "superclass": {
@@ -1,4 +1,4 @@
1
- var e=Object.defineProperty,t=(t,i,r)=>((t,i,r)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[i]=r)(t,"symbol"!=typeof i?i+"":i,r);import{LitElement as i,css as r,html as s}from"lit";class h extends i{constructor(){super(),this.src="",this.alt="",this.width="100%",this.height="auto",this.fit="cover",this.shape="square",this.lazy=!1,this._error=!1}willUpdate(e){e.has("src")&&(this._error=!1)}render(){return this.width,this.height,s`
1
+ var e=Object.defineProperty,i=(i,t,r)=>((i,t,r)=>t in i?e(i,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[t]=r)(i,"symbol"!=typeof t?t+"":t,r);import{LitElement as t,css as r,html as o}from"lit";class s extends t{constructor(){super(),i(this,"_handleKeyDown",e=>{"Escape"===e.key&&this._closePreview(e)}),this.src="",this.alt="",this.width="100%",this.height="auto",this.fit="cover",this.shape="square",this.lazy=!1,this.preview=!1,this._error=!1,this._previewOpen=!1}willUpdate(e){e.has("src")&&(this._error=!1)}updated(e){e.has("_previewOpen")&&(this._previewOpen?(document.body.style.overflow="hidden",window.addEventListener("keydown",this._handleKeyDown)):(document.body.style.overflow="",window.removeEventListener("keydown",this._handleKeyDown)))}disconnectedCallback(){super.disconnectedCallback(),this._previewOpen&&(document.body.style.overflow="",window.removeEventListener("keydown",this._handleKeyDown))}_handleImageClick(){this.preview&&!this._error&&(this._previewOpen=!0)}_closePreview(e){e&&e.stopPropagation(),this._previewOpen=!1}render(){return this.width,this.height,o`
2
2
  <style>
3
3
  :host {
4
4
  width: ${this.width};
@@ -8,8 +8,9 @@ var e=Object.defineProperty,t=(t,i,r)=>((t,i,r)=>i in t?e(t,i,{enumerable:!0,con
8
8
  object-fit: ${this.fit};
9
9
  }
10
10
  </style>
11
- <div class="img-wrapper">
12
- ${this._error||!this.src?s`
11
+
12
+ <div class="img-wrapper" @click="${this._handleImageClick}">
13
+ ${this._error||!this.src?o`
13
14
  <div class="fallback">
14
15
  <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
15
16
  <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
@@ -17,7 +18,7 @@ var e=Object.defineProperty,t=(t,i,r)=>((t,i,r)=>i in t?e(t,i,{enumerable:!0,con
17
18
  <polyline points="21 15 16 10 5 21"></polyline>
18
19
  </svg>
19
20
  </div>
20
- `:s`
21
+ `:o`
21
22
  <img
22
23
  src="${this.src}"
23
24
  alt="${this.alt}"
@@ -26,12 +27,32 @@ var e=Object.defineProperty,t=(t,i,r)=>((t,i,r)=>i in t?e(t,i,{enumerable:!0,con
26
27
  />
27
28
  `}
28
29
  </div>
29
- `}}t(h,"properties",{src:{type:String},alt:{type:String},width:{type:String},height:{type:String},fit:{type:String},shape:{type:String},lazy:{type:Boolean},_error:{state:!0}}),t(h,"styles",r`
30
+
31
+ ${this.preview?o`
32
+ <div class="preview-overlay ${this._previewOpen?"open":""}" @click="${this._closePreview}">
33
+ ${this._previewOpen?o`
34
+ <button class="preview-close" @click="${this._closePreview}">
35
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
36
+ <line x1="18" y1="6" x2="6" y2="18"></line>
37
+ <line x1="6" y1="6" x2="18" y2="18"></line>
38
+ </svg>
39
+ </button>
40
+ <img
41
+ class="preview-image"
42
+ src="${this.src}"
43
+ alt="${this.alt}"
44
+ @click="${e=>e.stopPropagation()}"
45
+ />
46
+ `:""}
47
+ </div>
48
+ `:""}
49
+ `}}i(s,"properties",{src:{type:String},alt:{type:String},width:{type:String},height:{type:String},fit:{type:String},shape:{type:String},lazy:{type:Boolean},preview:{type:Boolean},_error:{state:!0},_previewOpen:{state:!0}}),i(s,"styles",r`
30
50
  :host {
31
51
  display: inline-block;
32
52
  line-height: 0;
33
53
  overflow: hidden;
34
54
  background-color: var(--kg-bg-secondary);
55
+ position: relative;
35
56
  }
36
57
 
37
58
  :host([shape="circle"]) {
@@ -46,6 +67,10 @@ var e=Object.defineProperty,t=(t,i,r)=>((t,i,r)=>i in t?e(t,i,{enumerable:!0,con
46
67
  border-radius: 0;
47
68
  }
48
69
 
70
+ :host([preview]) .img-wrapper {
71
+ cursor: zoom-in;
72
+ }
73
+
49
74
  .img-wrapper {
50
75
  width: 100%;
51
76
  height: 100%;
@@ -58,6 +83,8 @@ var e=Object.defineProperty,t=(t,i,r)=>((t,i,r)=>i in t?e(t,i,{enumerable:!0,con
58
83
  display: block;
59
84
  width: 100%;
60
85
  height: 100%;
86
+ opacity: 1;
87
+ transition: opacity 0.3s;
61
88
  }
62
89
 
63
90
  .fallback {
@@ -69,4 +96,64 @@ var e=Object.defineProperty,t=(t,i,r)=>((t,i,r)=>i in t?e(t,i,{enumerable:!0,con
69
96
  color: var(--kg-text-muted);
70
97
  font-size: 0.8rem;
71
98
  }
72
- `),"undefined"==typeof customElements||customElements.get("kg-image")||customElements.define("kg-image",h);export{h as kgimage};
99
+
100
+ /* Preview Overlay */
101
+ .preview-overlay {
102
+ position: fixed;
103
+ top: 0;
104
+ left: 0;
105
+ width: 100vw;
106
+ height: 100vh;
107
+ z-index: 2050;
108
+ background-color: rgba(0, 0, 0, 0.9);
109
+ display: flex;
110
+ align-items: center;
111
+ justify-content: center;
112
+ opacity: 0;
113
+ visibility: hidden;
114
+ transition: all 0.3s ease;
115
+ backdrop-filter: blur(4px);
116
+ }
117
+
118
+ .preview-overlay.open {
119
+ opacity: 1;
120
+ visibility: visible;
121
+ }
122
+
123
+ .preview-image {
124
+ max-width: 90vw;
125
+ max-height: 90vh;
126
+ width: auto;
127
+ height: auto;
128
+ object-fit: contain;
129
+ transform: scale(0.9);
130
+ transition: transform 0.3s ease;
131
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
132
+ }
133
+
134
+ .preview-overlay.open .preview-image {
135
+ transform: scale(1);
136
+ }
137
+
138
+ .preview-close {
139
+ position: absolute;
140
+ top: 20px;
141
+ right: 20px;
142
+ background: rgba(255, 255, 255, 0.2);
143
+ border: none;
144
+ color: white;
145
+ cursor: pointer;
146
+ width: 40px;
147
+ height: 40px;
148
+ border-radius: 50%;
149
+ display: flex;
150
+ align-items: center;
151
+ justify-content: center;
152
+ transition: background 0.2s;
153
+ z-index: 2060;
154
+ }
155
+
156
+ .preview-close:hover {
157
+ background: rgba(255, 255, 255, 0.3);
158
+ }
159
+ `),"undefined"==typeof customElements||customElements.get("kg-image")||customElements.define("kg-image",s);export{s as kgimage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazhus/kg-ui",
3
- "version": "0.7.7",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -16,6 +16,8 @@ export class kgimage extends LitElement {
16
16
  shape: string;
17
17
  /** */
18
18
  lazy: boolean;
19
+ /** */
20
+ preview: boolean;
19
21
  }
20
22
 
21
23
  declare global {
@@ -33,6 +35,7 @@ declare global {
33
35
  fit?: string;
34
36
  shape?: string;
35
37
  lazy?: boolean;
38
+ preview?: boolean;
36
39
  [key: string]: any;
37
40
  };
38
41
  }
package/types/index.d.ts CHANGED
@@ -239,6 +239,7 @@ declare global {
239
239
  fit?: string;
240
240
  shape?: string;
241
241
  lazy?: boolean;
242
+ preview?: boolean;
242
243
  [key: string]: any;
243
244
  };
244
245
  'kg-input': {