@lazhus/kg-ui 0.2.2

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.
Files changed (70) hide show
  1. package/README.md +128 -0
  2. package/custom-elements.json +3815 -0
  3. package/dist/components/kg-accordion-item.js +117 -0
  4. package/dist/components/kg-accordion.js +32 -0
  5. package/dist/components/kg-button.js +241 -0
  6. package/dist/components/kg-card.js +129 -0
  7. package/dist/components/kg-checkbox.js +147 -0
  8. package/dist/components/kg-colorpicker.js +240 -0
  9. package/dist/components/kg-column.js +48 -0
  10. package/dist/components/kg-datagrid.js +428 -0
  11. package/dist/components/kg-datepicker.js +650 -0
  12. package/dist/components/kg-divider.js +118 -0
  13. package/dist/components/kg-drawer.js +178 -0
  14. package/dist/components/kg-file-upload.js +274 -0
  15. package/dist/components/kg-grid.js +46 -0
  16. package/dist/components/kg-image.js +100 -0
  17. package/dist/components/kg-input.js +318 -0
  18. package/dist/components/kg-loader.js +175 -0
  19. package/dist/components/kg-modal.js +165 -0
  20. package/dist/components/kg-progress.js +82 -0
  21. package/dist/components/kg-radio-group.js +75 -0
  22. package/dist/components/kg-radio.js +121 -0
  23. package/dist/components/kg-row.js +42 -0
  24. package/dist/components/kg-select.js +331 -0
  25. package/dist/components/kg-skeleton.js +108 -0
  26. package/dist/components/kg-slider.js +196 -0
  27. package/dist/components/kg-spinner.js +79 -0
  28. package/dist/components/kg-stepper.js +214 -0
  29. package/dist/components/kg-switch.js +106 -0
  30. package/dist/components/kg-tab-panel.js +35 -0
  31. package/dist/components/kg-tabs.js +158 -0
  32. package/dist/components/kg-text.js +141 -0
  33. package/dist/components/kg-textarea.js +162 -0
  34. package/dist/components/kg-toast.js +200 -0
  35. package/dist/index.js +68 -0
  36. package/dist/kg-ui.css +1 -0
  37. package/package.json +57 -0
  38. package/types/components/kg-accordion-item.d.ts +25 -0
  39. package/types/components/kg-accordion.d.ts +22 -0
  40. package/types/components/kg-button.d.ts +34 -0
  41. package/types/components/kg-card.d.ts +31 -0
  42. package/types/components/kg-checkbox.d.ts +28 -0
  43. package/types/components/kg-colorpicker.d.ts +28 -0
  44. package/types/components/kg-column.d.ts +20 -0
  45. package/types/components/kg-datagrid.d.ts +55 -0
  46. package/types/components/kg-datepicker.d.ts +43 -0
  47. package/types/components/kg-divider.d.ts +34 -0
  48. package/types/components/kg-drawer.d.ts +31 -0
  49. package/types/components/kg-file-upload.d.ts +40 -0
  50. package/types/components/kg-grid.d.ts +20 -0
  51. package/types/components/kg-image.d.ts +40 -0
  52. package/types/components/kg-input.d.ts +34 -0
  53. package/types/components/kg-loader.d.ts +31 -0
  54. package/types/components/kg-modal.d.ts +31 -0
  55. package/types/components/kg-progress.d.ts +37 -0
  56. package/types/components/kg-radio-group.d.ts +25 -0
  57. package/types/components/kg-radio.d.ts +25 -0
  58. package/types/components/kg-row.d.ts +20 -0
  59. package/types/components/kg-select.d.ts +37 -0
  60. package/types/components/kg-skeleton.d.ts +34 -0
  61. package/types/components/kg-slider.d.ts +40 -0
  62. package/types/components/kg-spinner.d.ts +28 -0
  63. package/types/components/kg-stepper.d.ts +31 -0
  64. package/types/components/kg-switch.d.ts +28 -0
  65. package/types/components/kg-tab-panel.d.ts +28 -0
  66. package/types/components/kg-tabs.d.ts +25 -0
  67. package/types/components/kg-text.d.ts +31 -0
  68. package/types/components/kg-textarea.d.ts +43 -0
  69. package/types/components/kg-toast.d.ts +28 -0
  70. package/types/index.d.ts +335 -0
@@ -0,0 +1,118 @@
1
+ import { LitElement as t, css as r, html as e } from "lit";
2
+ import { classMap as l } from "lit/directives/class-map.js";
3
+ class a extends t {
4
+ static properties = {
5
+ vertical: { type: Boolean },
6
+ dashed: { type: Boolean },
7
+ fitted: { type: Boolean },
8
+ inverted: { type: Boolean },
9
+ label: { type: String }
10
+ };
11
+ static styles = r`
12
+ :host {
13
+ display: block;
14
+ width: 100%;
15
+ }
16
+
17
+ :host([vertical]) {
18
+ display: inline-flex;
19
+ vertical-align: middle;
20
+ height: 1.5rem;
21
+ width: auto;
22
+ align-self: center;
23
+ }
24
+
25
+ .divider-container {
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: center;
29
+ width: 100%;
30
+ height: 100%;
31
+ }
32
+
33
+ .divider-container.horizontal {
34
+ flex-direction: row;
35
+ margin: 1.5rem 0;
36
+ }
37
+
38
+ .divider-container.vertical {
39
+ flex-direction: column;
40
+ margin: 0 1rem;
41
+ height: 100%;
42
+ width: auto;
43
+ }
44
+
45
+ .line {
46
+ flex: 1;
47
+ border: 0;
48
+ }
49
+
50
+ .divider-container.horizontal .line {
51
+ border-top: 1px solid var(--kg-border);
52
+ height: 0;
53
+ }
54
+
55
+ .divider-container.vertical .line {
56
+ border-left: 1px solid var(--kg-border);
57
+ width: 0;
58
+ height: 100%;
59
+ }
60
+
61
+ /* Dashed State */
62
+ .divider-container.dashed.horizontal .line {
63
+ border-top-style: dashed;
64
+ }
65
+
66
+ .divider-container.dashed.vertical .line {
67
+ border-left-style: dashed;
68
+ }
69
+
70
+ .label {
71
+ padding: 0 1rem;
72
+ font-size: 0.85rem;
73
+ font-weight: 700;
74
+ color: var(--kg-text-muted);
75
+ white-space: nowrap;
76
+ text-transform: uppercase;
77
+ letter-spacing: 0.1em;
78
+ flex-shrink: 0;
79
+ }
80
+
81
+ .divider-container.vertical .label {
82
+ padding: 0.5rem 0;
83
+ writing-mode: vertical-lr;
84
+ }
85
+
86
+ .fitted { margin: 0 !important; }
87
+
88
+ .inverted .line { border-color: rgba(255, 255, 255, 0.2); }
89
+ .inverted .label { color: rgba(255, 255, 255, 0.6); }
90
+
91
+ .no-label .label { display: none; }
92
+ `;
93
+ constructor() {
94
+ super(), this.vertical = !1, this.dashed = !1, this.fitted = !1, this.inverted = !1, this.label = "";
95
+ }
96
+ render() {
97
+ const i = {
98
+ "divider-container": !0,
99
+ horizontal: !this.vertical,
100
+ vertical: this.vertical,
101
+ dashed: this.dashed,
102
+ fitted: this.fitted,
103
+ inverted: this.inverted,
104
+ "no-label": !this.label
105
+ };
106
+ return e`
107
+ <div class="${l(i)}">
108
+ <div class="line"></div>
109
+ ${this.label ? e`<span class="label">${this.label}</span>` : ""}
110
+ <div class="line"></div>
111
+ </div>
112
+ `;
113
+ }
114
+ }
115
+ customElements.define("kg-divider", a);
116
+ export {
117
+ a as kgdivider
118
+ };
@@ -0,0 +1,178 @@
1
+ import { LitElement as o, css as i, html as t } from "lit";
2
+ import { classMap as r } from "lit/directives/class-map.js";
3
+ class s extends o {
4
+ static properties = {
5
+ open: { type: Boolean, reflect: !0 },
6
+ placement: { type: String },
7
+ // left, right, top, bottom
8
+ size: { type: String },
9
+ // small, medium, large, full
10
+ noOverlay: { type: Boolean },
11
+ closable: {
12
+ type: Boolean,
13
+ converter: (e) => e !== "false"
14
+ }
15
+ };
16
+ static styles = i`
17
+ :host {
18
+ display: block;
19
+ --kg-drawer-width: 350px;
20
+ --kg-drawer-height: 350px;
21
+ --kg-drawer-z-index: 1000;
22
+ }
23
+
24
+ .kg-drawer-overlay {
25
+ position: fixed;
26
+ top: 0;
27
+ left: 0;
28
+ width: 100%;
29
+ height: 100%;
30
+ background: rgba(0, 0, 0, 0.4);
31
+ backdrop-filter: blur(4px);
32
+ z-index: var(--kg-drawer-z-index);
33
+ opacity: 0;
34
+ visibility: hidden;
35
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
36
+ }
37
+
38
+ .kg-drawer-overlay.open {
39
+ opacity: 1;
40
+ visibility: visible;
41
+ }
42
+
43
+ .kg-drawer-content {
44
+ position: fixed;
45
+ background: var(--kg-bg);
46
+ color: var(--kg-text);
47
+ z-index: calc(var(--kg-drawer-z-index) + 1);
48
+ box-shadow: var(--kg-shadow);
49
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
50
+ display: flex;
51
+ flex-direction: column;
52
+ box-sizing: border-box;
53
+ }
54
+
55
+ /* Placements */
56
+ .placement-right {
57
+ top: 0;
58
+ right: 0;
59
+ width: var(--kg-drawer-width);
60
+ height: 100%;
61
+ transform: translateX(100%);
62
+ }
63
+
64
+ .placement-left {
65
+ top: 0;
66
+ left: 0;
67
+ width: var(--kg-drawer-width);
68
+ height: 100%;
69
+ transform: translateX(-100%);
70
+ }
71
+
72
+ .placement-top {
73
+ top: 0;
74
+ left: 0;
75
+ width: 100%;
76
+ height: var(--kg-drawer-height);
77
+ transform: translateY(-100%);
78
+ }
79
+
80
+ .placement-bottom {
81
+ bottom: 0;
82
+ left: 0;
83
+ width: 100%;
84
+ height: var(--kg-drawer-height);
85
+ transform: translateY(100%);
86
+ }
87
+
88
+ /* Open States */
89
+ .open.placement-right, .open.placement-left { transform: translateX(0); }
90
+ .open.placement-top, .open.placement-bottom { transform: translateY(0); }
91
+
92
+ /* Sizes */
93
+ .size-small { --kg-drawer-width: 260px; --kg-drawer-height: 260px; }
94
+ .size-medium { --kg-drawer-width: 400px; --kg-drawer-height: 400px; }
95
+ .size-large { --kg-drawer-width: 600px; --kg-drawer-height: 600px; }
96
+ .size-full { --kg-drawer-width: 100%; --kg-drawer-height: 100%; }
97
+
98
+ .drawer-header {
99
+ padding: var(--kg-space-md) var(--kg-space-lg);
100
+ border-bottom: 1px solid var(--kg-border);
101
+ display: flex;
102
+ justify-content: space-between;
103
+ align-items: center;
104
+ }
105
+
106
+ .drawer-body {
107
+ padding: var(--kg-space-lg);
108
+ flex: 1;
109
+ overflow-y: auto;
110
+ }
111
+
112
+ .drawer-footer {
113
+ padding: var(--kg-space-md) var(--kg-space-lg);
114
+ border-top: 1px solid var(--kg-border);
115
+ }
116
+
117
+ .close-button {
118
+ background: none;
119
+ border: none;
120
+ color: var(--kg-text-muted);
121
+ cursor: pointer;
122
+ font-size: 1.5rem;
123
+ padding: 0.5rem;
124
+ line-height: 1;
125
+ border-radius: var(--kg-radius-sm);
126
+ transition: all 0.2s;
127
+ }
128
+
129
+ .close-button:hover {
130
+ background: var(--kg-surface);
131
+ color: var(--kg-text);
132
+ }
133
+ `;
134
+ constructor() {
135
+ super(), this.open = !1, this.placement = "right", this.size = "medium", this.closable = !0;
136
+ }
137
+ close() {
138
+ this.open = !1, this.dispatchEvent(new CustomEvent("close", { bubbles: !0, composed: !0 }));
139
+ }
140
+ _handleOverlayClick() {
141
+ this.closable && this.close();
142
+ }
143
+ willUpdate(e) {
144
+ e.has("open") && (this.open ? document.body.style.overflow = "hidden" : document.body.style.overflow = "");
145
+ }
146
+ render() {
147
+ const e = {
148
+ "kg-drawer-overlay": !0,
149
+ open: this.open && !this.noOverlay
150
+ }, a = {
151
+ "kg-drawer-content": !0,
152
+ open: this.open,
153
+ [`placement-${this.placement}`]: !0,
154
+ [`size-${this.size}`]: !0
155
+ };
156
+ return t`
157
+ <div class="${r(e)}" @click="${this._handleOverlayClick}"></div>
158
+ <div class="${r(a)}">
159
+ <div class="drawer-header">
160
+ <slot name="header"></slot>
161
+ ${this.closable ? t`
162
+ <button class="close-button" @click="${this.close}">&times;</button>
163
+ ` : ""}
164
+ </div>
165
+ <div class="drawer-body">
166
+ <slot></slot>
167
+ </div>
168
+ <div class="drawer-footer">
169
+ <slot name="footer"></slot>
170
+ </div>
171
+ </div>
172
+ `;
173
+ }
174
+ }
175
+ customElements.define("kg-drawer", s);
176
+ export {
177
+ s as kgdrawer
178
+ };
@@ -0,0 +1,274 @@
1
+ import { LitElement as l, css as o, html as t } from "lit";
2
+ class d extends l {
3
+ static properties = {
4
+ label: { type: String },
5
+ placeholder: { type: String },
6
+ accept: { type: String },
7
+ multiple: { type: Boolean },
8
+ disabled: { type: Boolean },
9
+ hideChips: { type: Boolean, attribute: "hide-chips" },
10
+ files: { type: Array, state: !0 },
11
+ _previews: { state: !0 }
12
+ };
13
+ static styles = o`
14
+ :host {
15
+ display: block;
16
+ width: 100%;
17
+ font-family: inherit;
18
+ }
19
+
20
+ .container {
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: 0.5rem;
24
+ }
25
+
26
+ .label {
27
+ font-size: 0.85rem;
28
+ font-weight: 600;
29
+ color: var(--kg-text);
30
+ }
31
+
32
+ .upload-wrapper {
33
+ display: flex;
34
+ align-items: stretch;
35
+ border: 2px solid var(--kg-border);
36
+ border-radius: 10px;
37
+ overflow: hidden;
38
+ background: var(--kg-bg-primary);
39
+ transition: all 0.2s ease;
40
+ height: var(--kg-form-height);
41
+ cursor: pointer;
42
+ }
43
+
44
+ .upload-wrapper:hover:not(.disabled) {
45
+ border-color: var(--kg-primary);
46
+ }
47
+
48
+ .upload-wrapper.active {
49
+ border-color: var(--kg-primary);
50
+ box-shadow: 0 0 0 3px rgba(65, 171, 52, 0.1);
51
+ }
52
+
53
+ .upload-wrapper.disabled {
54
+ opacity: 0.6;
55
+ cursor: not-allowed;
56
+ background: var(--kg-bg-secondary);
57
+ }
58
+
59
+ .file-display {
60
+ flex: 1;
61
+ display: flex;
62
+ align-items: center;
63
+ padding: 0 1rem;
64
+ font-size: 0.9rem;
65
+ color: var(--kg-text-muted);
66
+ min-width: 0;
67
+ white-space: nowrap;
68
+ overflow: hidden;
69
+ text-overflow: ellipsis;
70
+ }
71
+
72
+ .file-display.has-file {
73
+ color: var(--kg-text);
74
+ font-weight: 500;
75
+ }
76
+
77
+ .divider {
78
+ width: 1px;
79
+ background: var(--kg-border);
80
+ margin: 8px 0;
81
+ transition: background 0.2s ease;
82
+ }
83
+
84
+ .upload-wrapper:hover .divider {
85
+ background: var(--kg-primary);
86
+ opacity: 0.3;
87
+ }
88
+
89
+ .upload-btn {
90
+ width: 48px;
91
+ display: flex;
92
+ align-items: center;
93
+ justify-content: center;
94
+ color: var(--kg-primary);
95
+ background: transparent;
96
+ transition: all 0.2s ease;
97
+ }
98
+
99
+ .upload-wrapper:hover .upload-btn {
100
+ background: rgba(65, 171, 52, 0.05);
101
+ }
102
+
103
+ input[type="file"] {
104
+ display: none;
105
+ }
106
+
107
+ /* File Chips below for multiple */
108
+ .file-chips {
109
+ display: flex;
110
+ flex-wrap: wrap;
111
+ gap: 0.5rem;
112
+ margin-top: 0.75rem;
113
+ }
114
+
115
+ .chip {
116
+ display: inline-flex;
117
+ align-items: center;
118
+ gap: 0.5rem;
119
+ padding: 0.4rem 0.75rem;
120
+ background: var(--kg-bg-secondary);
121
+ border: 1px solid var(--kg-border);
122
+ border-radius: 20px;
123
+ font-size: 0.8rem;
124
+ animation: slideIn 0.2s ease;
125
+ }
126
+
127
+ .chip-name {
128
+ max-width: 150px;
129
+ overflow: hidden;
130
+ text-overflow: ellipsis;
131
+ white-space: nowrap;
132
+ }
133
+
134
+ .chip-remove {
135
+ cursor: pointer;
136
+ color: var(--kg-text-muted);
137
+ display: flex;
138
+ align-items: center;
139
+ }
140
+
141
+ .chip-remove:hover {
142
+ color: #e74c3c;
143
+ }
144
+
145
+ @keyframes slideIn {
146
+ from { opacity: 0; transform: scale(0.95); }
147
+ to { opacity: 1; transform: scale(1); }
148
+ }
149
+
150
+ .preview-thumb {
151
+ width: 24px;
152
+ height: 24px;
153
+ object-fit: cover;
154
+ border-radius: 4px;
155
+ margin-right: 8px;
156
+ border: 1px solid var(--kg-border);
157
+ }
158
+
159
+ .chip .preview-thumb {
160
+ width: 20px;
161
+ height: 20px;
162
+ margin-right: 6px;
163
+ }
164
+ `;
165
+ constructor() {
166
+ super(), this.label = "", this.placeholder = "Dosya seçin...", this.accept = "*", this.multiple = !1, this.disabled = !1, this.hideChips = !1, this.files = [], this._previews = /* @__PURE__ */ new Map();
167
+ }
168
+ disconnectedCallback() {
169
+ super.disconnectedCallback(), this._revokePreviews();
170
+ }
171
+ updated(e) {
172
+ e.has("files") && this._updatePreviews();
173
+ }
174
+ _revokePreviews() {
175
+ this._previews.forEach((e) => URL.revokeObjectURL(e)), this._previews.clear();
176
+ }
177
+ _updatePreviews() {
178
+ this._revokePreviews();
179
+ const e = /* @__PURE__ */ new Map();
180
+ this.files.forEach((i) => {
181
+ i.type.startsWith("image/") && e.set(i, URL.createObjectURL(i));
182
+ }), this._previews = e, this.requestUpdate();
183
+ }
184
+ _handleFileChange(e) {
185
+ const i = Array.from(e.target.files);
186
+ this._addFiles(i), e.target.value = "";
187
+ }
188
+ _addFiles(e) {
189
+ this.disabled || e.length === 0 || (this.files = this.multiple ? e : [e[0]], this._emitChange());
190
+ }
191
+ _removeFile(e) {
192
+ this.files = this.files.filter((i, r) => r !== e), this._emitChange();
193
+ }
194
+ _emitChange() {
195
+ this.dispatchEvent(new CustomEvent("kg-change", {
196
+ detail: { files: this.files },
197
+ bubbles: !0,
198
+ composed: !0
199
+ }));
200
+ }
201
+ _triggerUpload() {
202
+ this.disabled || this.shadowRoot.querySelector("input").click();
203
+ }
204
+ // Drag & Drop
205
+ _onDragOver(e) {
206
+ e.preventDefault(), !this.disabled && this.shadowRoot.querySelector(".upload-wrapper").classList.add("active");
207
+ }
208
+ _onDragLeave() {
209
+ this.shadowRoot.querySelector(".upload-wrapper").classList.remove("active");
210
+ }
211
+ _onDrop(e) {
212
+ if (e.preventDefault(), this._onDragLeave(), this.disabled) return;
213
+ const i = Array.from(e.dataTransfer.files);
214
+ this._addFiles(i);
215
+ }
216
+ render() {
217
+ const e = this.files.length > 0, i = e ? this.multiple ? `${this.files.length} Dosya Seçildi` : this.files[0].name : this.placeholder;
218
+ return t`
219
+ <div class="container">
220
+ ${this.label ? t`<label class="label">${this.label}</label>` : ""}
221
+
222
+ <div
223
+ class="upload-wrapper ${this.disabled ? "disabled" : ""}"
224
+ @click="${this._triggerUpload}"
225
+ @dragover="${this._onDragOver}"
226
+ @dragleave="${this._onDragLeave}"
227
+ @drop="${this._onDrop}"
228
+ >
229
+ <div class="file-display ${e ? "has-file" : ""}">
230
+ ${e && !this.multiple && this._previews.get(this.files[0]) ? t`<img src="${this._previews.get(this.files[0])}" class="preview-thumb" alt="Preview" />` : ""}
231
+ ${i}
232
+ </div>
233
+
234
+ <div class="divider"></div>
235
+
236
+ <div class="upload-btn">
237
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
238
+ <line x1="12" y1="5" x2="12" y2="19"></line>
239
+ <line x1="5" y1="12" x2="19" y2="12"></line>
240
+ </svg>
241
+ </div>
242
+
243
+ <input
244
+ type="file"
245
+ ?multiple="${this.multiple}"
246
+ accept="${this.accept}"
247
+ ?disabled="${this.disabled}"
248
+ @change="${this._handleFileChange}"
249
+ >
250
+ </div>
251
+
252
+ ${this.multiple && !this.hideChips && this.files.length > 0 ? t`
253
+ <div class="file-chips">
254
+ ${this.files.map((r, s) => t`
255
+ <div class="chip">
256
+ ${this._previews.get(r) ? t`<img src="${this._previews.get(r)}" class="preview-thumb" alt="Preview" />` : ""}
257
+ <span class="chip-name">${r.name}</span>
258
+ <div class="chip-remove" @click="${(a) => {
259
+ a.stopPropagation(), this._removeFile(s);
260
+ }}">
261
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
262
+ </div>
263
+ </div>
264
+ `)}
265
+ </div>
266
+ ` : ""}
267
+ </div>
268
+ `;
269
+ }
270
+ }
271
+ customElements.define("kg-file-upload", d);
272
+ export {
273
+ d as kgfileupload
274
+ };
@@ -0,0 +1,46 @@
1
+ import { LitElement as e, css as t, html as d } from "lit";
2
+ class i extends e {
3
+ static properties = {
4
+ container: { type: Boolean },
5
+ // if true, acts as a centered container
6
+ padded: { type: Boolean },
7
+ relaxed: { type: Boolean },
8
+ doubling: { type: Boolean },
9
+ stackable: { type: Boolean }
10
+ };
11
+ static styles = t`
12
+ :host {
13
+ display: block;
14
+ width: 100%;
15
+ box-sizing: border-box;
16
+ }
17
+
18
+ :host([container]) {
19
+ max-width: 1200px;
20
+ margin: 0 auto;
21
+ padding-left: var(--kg-space-md);
22
+ padding-right: var(--kg-space-md);
23
+ }
24
+
25
+ .ui-grid {
26
+ display: flex;
27
+ flex-direction: column;
28
+ width: 100%;
29
+ }
30
+
31
+ :host([padded]) {
32
+ padding: var(--kg-space-md) 0;
33
+ }
34
+ `;
35
+ render() {
36
+ return d`
37
+ <div class="ui-grid">
38
+ <slot></slot>
39
+ </div>
40
+ `;
41
+ }
42
+ }
43
+ customElements.define("kg-grid", i);
44
+ export {
45
+ i as kggrid
46
+ };
@@ -0,0 +1,100 @@
1
+ import { LitElement as i, css as r, html as t } from "lit";
2
+ class s extends i {
3
+ static properties = {
4
+ src: { type: String },
5
+ alt: { type: String },
6
+ width: { type: String },
7
+ height: { type: String },
8
+ fit: { type: String },
9
+ // 'cover' | 'contain' | 'fill' | 'none' | 'scale-down'
10
+ shape: { type: String },
11
+ // 'square' | 'circle' | 'rounded'
12
+ lazy: { type: Boolean },
13
+ _error: { state: !0 }
14
+ };
15
+ static styles = r`
16
+ :host {
17
+ display: inline-block;
18
+ line-height: 0;
19
+ overflow: hidden;
20
+ background-color: var(--kg-bg-secondary);
21
+ }
22
+
23
+ :host([shape="circle"]) {
24
+ border-radius: 50%;
25
+ }
26
+
27
+ :host([shape="rounded"]) {
28
+ border-radius: var(--kg-radius, 8px);
29
+ }
30
+
31
+ :host([shape="square"]) {
32
+ border-radius: 0;
33
+ }
34
+
35
+ .img-wrapper {
36
+ width: 100%;
37
+ height: 100%;
38
+ display: flex;
39
+ align-items: center;
40
+ justify-content: center;
41
+ }
42
+
43
+ img {
44
+ display: block;
45
+ width: 100%;
46
+ height: 100%;
47
+ }
48
+
49
+ .fallback {
50
+ display: flex;
51
+ align-items: center;
52
+ justify-content: center;
53
+ width: 100%;
54
+ height: 100%;
55
+ color: var(--kg-text-muted);
56
+ font-size: 0.8rem;
57
+ }
58
+ `;
59
+ constructor() {
60
+ super(), this.src = "", this.alt = "", this.width = "100%", this.height = "auto", this.fit = "cover", this.shape = "square", this.lazy = !1, this._error = !1;
61
+ }
62
+ willUpdate(e) {
63
+ e.has("src") && (this._error = !1);
64
+ }
65
+ render() {
66
+ return `${this.width}${this.height}`, t`
67
+ <style>
68
+ :host {
69
+ width: ${this.width};
70
+ height: ${this.height};
71
+ }
72
+ img {
73
+ object-fit: ${this.fit};
74
+ }
75
+ </style>
76
+ <div class="img-wrapper">
77
+ ${this._error || !this.src ? t`
78
+ <div class="fallback">
79
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
80
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
81
+ <circle cx="8.5" cy="8.5" r="1.5"></circle>
82
+ <polyline points="21 15 16 10 5 21"></polyline>
83
+ </svg>
84
+ </div>
85
+ ` : t`
86
+ <img
87
+ src="${this.src}"
88
+ alt="${this.alt}"
89
+ loading="${this.lazy ? "lazy" : "eager"}"
90
+ @error="${() => this._error = !0}"
91
+ />
92
+ `}
93
+ </div>
94
+ `;
95
+ }
96
+ }
97
+ customElements.define("kg-image", s);
98
+ export {
99
+ s as kgimage
100
+ };