@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.
- package/README.md +128 -0
- package/custom-elements.json +3815 -0
- package/dist/components/kg-accordion-item.js +117 -0
- package/dist/components/kg-accordion.js +32 -0
- package/dist/components/kg-button.js +241 -0
- package/dist/components/kg-card.js +129 -0
- package/dist/components/kg-checkbox.js +147 -0
- package/dist/components/kg-colorpicker.js +240 -0
- package/dist/components/kg-column.js +48 -0
- package/dist/components/kg-datagrid.js +428 -0
- package/dist/components/kg-datepicker.js +650 -0
- package/dist/components/kg-divider.js +118 -0
- package/dist/components/kg-drawer.js +178 -0
- package/dist/components/kg-file-upload.js +274 -0
- package/dist/components/kg-grid.js +46 -0
- package/dist/components/kg-image.js +100 -0
- package/dist/components/kg-input.js +318 -0
- package/dist/components/kg-loader.js +175 -0
- package/dist/components/kg-modal.js +165 -0
- package/dist/components/kg-progress.js +82 -0
- package/dist/components/kg-radio-group.js +75 -0
- package/dist/components/kg-radio.js +121 -0
- package/dist/components/kg-row.js +42 -0
- package/dist/components/kg-select.js +331 -0
- package/dist/components/kg-skeleton.js +108 -0
- package/dist/components/kg-slider.js +196 -0
- package/dist/components/kg-spinner.js +79 -0
- package/dist/components/kg-stepper.js +214 -0
- package/dist/components/kg-switch.js +106 -0
- package/dist/components/kg-tab-panel.js +35 -0
- package/dist/components/kg-tabs.js +158 -0
- package/dist/components/kg-text.js +141 -0
- package/dist/components/kg-textarea.js +162 -0
- package/dist/components/kg-toast.js +200 -0
- package/dist/index.js +68 -0
- package/dist/kg-ui.css +1 -0
- package/package.json +57 -0
- package/types/components/kg-accordion-item.d.ts +25 -0
- package/types/components/kg-accordion.d.ts +22 -0
- package/types/components/kg-button.d.ts +34 -0
- package/types/components/kg-card.d.ts +31 -0
- package/types/components/kg-checkbox.d.ts +28 -0
- package/types/components/kg-colorpicker.d.ts +28 -0
- package/types/components/kg-column.d.ts +20 -0
- package/types/components/kg-datagrid.d.ts +55 -0
- package/types/components/kg-datepicker.d.ts +43 -0
- package/types/components/kg-divider.d.ts +34 -0
- package/types/components/kg-drawer.d.ts +31 -0
- package/types/components/kg-file-upload.d.ts +40 -0
- package/types/components/kg-grid.d.ts +20 -0
- package/types/components/kg-image.d.ts +40 -0
- package/types/components/kg-input.d.ts +34 -0
- package/types/components/kg-loader.d.ts +31 -0
- package/types/components/kg-modal.d.ts +31 -0
- package/types/components/kg-progress.d.ts +37 -0
- package/types/components/kg-radio-group.d.ts +25 -0
- package/types/components/kg-radio.d.ts +25 -0
- package/types/components/kg-row.d.ts +20 -0
- package/types/components/kg-select.d.ts +37 -0
- package/types/components/kg-skeleton.d.ts +34 -0
- package/types/components/kg-slider.d.ts +40 -0
- package/types/components/kg-spinner.d.ts +28 -0
- package/types/components/kg-stepper.d.ts +31 -0
- package/types/components/kg-switch.d.ts +28 -0
- package/types/components/kg-tab-panel.d.ts +28 -0
- package/types/components/kg-tabs.d.ts +25 -0
- package/types/components/kg-text.d.ts +31 -0
- package/types/components/kg-textarea.d.ts +43 -0
- package/types/components/kg-toast.d.ts +28 -0
- package/types/index.d.ts +335 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { LitElement as a, css as s, html as r } from "lit";
|
|
2
|
+
import { classMap as l } from "lit/directives/class-map.js";
|
|
3
|
+
class d extends a {
|
|
4
|
+
static properties = {
|
|
5
|
+
value: { type: String },
|
|
6
|
+
label: { type: String },
|
|
7
|
+
placeholder: { type: String },
|
|
8
|
+
type: { type: String },
|
|
9
|
+
size: { type: String },
|
|
10
|
+
disabled: { type: Boolean },
|
|
11
|
+
loading: { type: Boolean },
|
|
12
|
+
error: { type: Boolean },
|
|
13
|
+
fullwidth: { type: Boolean, reflect: !0 },
|
|
14
|
+
inverted: { type: Boolean, reflect: !0 },
|
|
15
|
+
hasLeft: { type: Boolean, state: !0 },
|
|
16
|
+
hasRight: { type: Boolean, state: !0 },
|
|
17
|
+
_showPassword: { type: Boolean, state: !0 },
|
|
18
|
+
positive: { type: Boolean, reflect: !0 },
|
|
19
|
+
integer: { type: Boolean, reflect: !0 }
|
|
20
|
+
};
|
|
21
|
+
static styles = s`
|
|
22
|
+
:host {
|
|
23
|
+
display: inline-block;
|
|
24
|
+
max-width: 100%;
|
|
25
|
+
vertical-align: top;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:host([fullwidth]) {
|
|
29
|
+
display: block;
|
|
30
|
+
width: 100%;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.kg-input-container {
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
gap: 0.5rem;
|
|
37
|
+
width: 100%;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.input-label {
|
|
41
|
+
font-size: 0.875rem;
|
|
42
|
+
font-weight: 600;
|
|
43
|
+
color: var(--kg-text);
|
|
44
|
+
opacity: 0.8;
|
|
45
|
+
margin-left: 2px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.ui-input {
|
|
49
|
+
display: inline-flex;
|
|
50
|
+
width: 100%;
|
|
51
|
+
color: var(--kg-text);
|
|
52
|
+
font-family: inherit;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.input-wrapper {
|
|
56
|
+
display: flex;
|
|
57
|
+
width: 100%;
|
|
58
|
+
align-items: stretch;
|
|
59
|
+
min-height: var(--kg-form-height);
|
|
60
|
+
background: var(--kg-surface);
|
|
61
|
+
border: 1px solid var(--kg-border);
|
|
62
|
+
border-radius: var(--kg-radius-md, 8px);
|
|
63
|
+
transition: all 0.2s ease;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
position: relative;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.input-wrapper:focus-within {
|
|
69
|
+
border-color: var(--kg-primary);
|
|
70
|
+
background: var(--kg-bg);
|
|
71
|
+
box-shadow: 0 0 0 2px rgba(65, 171, 52, 0.2);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
input {
|
|
75
|
+
margin: 0;
|
|
76
|
+
flex: 1 1 auto;
|
|
77
|
+
outline: none;
|
|
78
|
+
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
|
79
|
+
text-align: left;
|
|
80
|
+
line-height: var(--kg-form-height);
|
|
81
|
+
height: var(--kg-form-height);
|
|
82
|
+
font-family: inherit;
|
|
83
|
+
padding: 0 1rem;
|
|
84
|
+
background: transparent;
|
|
85
|
+
border: none;
|
|
86
|
+
color: inherit;
|
|
87
|
+
min-width: 0;
|
|
88
|
+
width: 100%;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
input::placeholder {
|
|
92
|
+
color: var(--kg-text-muted);
|
|
93
|
+
opacity: 0.6;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* Number input specific styling - hide spin buttons */
|
|
97
|
+
input[type="number"]::-webkit-inner-spin-button,
|
|
98
|
+
input[type="number"]::-webkit-outer-spin-button {
|
|
99
|
+
-webkit-appearance: none;
|
|
100
|
+
margin: 0;
|
|
101
|
+
}
|
|
102
|
+
input[type="number"] {
|
|
103
|
+
-moz-appearance: textfield;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.label-container {
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
justify-content: center;
|
|
110
|
+
background: var(--kg-bg-secondary, rgba(0,0,0,0.04));
|
|
111
|
+
padding: 0 0.8rem;
|
|
112
|
+
min-height: var(--kg-form-height);
|
|
113
|
+
color: var(--kg-text-muted);
|
|
114
|
+
font-size: 0.9em;
|
|
115
|
+
white-space: nowrap;
|
|
116
|
+
user-select: none;
|
|
117
|
+
transition: all 0.2s ease;
|
|
118
|
+
font-family: inherit;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* Secret Sauce: Hide container if it has no content but KEEP THE SLOT ACTIVE */
|
|
122
|
+
.label-container:not(.visible) {
|
|
123
|
+
display: none;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.label-container.left {
|
|
127
|
+
border-right: 1px solid var(--kg-border);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.label-container.right {
|
|
131
|
+
border-left: 1px solid var(--kg-border);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.reveal-btn {
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
justify-content: center;
|
|
138
|
+
padding: 0 0.8rem;
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
color: var(--kg-text-muted);
|
|
141
|
+
transition: color 0.2s;
|
|
142
|
+
user-select: none;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.reveal-btn:hover {
|
|
146
|
+
color: var(--kg-secondary);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* States */
|
|
150
|
+
.disabled { opacity: 0.45; pointer-events: none; }
|
|
151
|
+
|
|
152
|
+
.error .input-wrapper {
|
|
153
|
+
border-color: #DB2828;
|
|
154
|
+
background-color: rgba(219, 40, 40, 0.02);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.loading .input-wrapper::after {
|
|
158
|
+
position: absolute;
|
|
159
|
+
content: '';
|
|
160
|
+
top: 50%;
|
|
161
|
+
right: var(--loading-offset, 1rem);
|
|
162
|
+
margin-top: -0.5rem;
|
|
163
|
+
width: 1rem;
|
|
164
|
+
height: 1rem;
|
|
165
|
+
border: 2px solid rgba(0, 0, 0, 0.1);
|
|
166
|
+
border-top-color: var(--kg-secondary);
|
|
167
|
+
border-radius: 50%;
|
|
168
|
+
animation: input-spin 0.6s linear infinite;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@keyframes input-spin {
|
|
172
|
+
from { transform: rotate(0deg); }
|
|
173
|
+
to { transform: rotate(360deg); }
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* Sizes */
|
|
177
|
+
.mini input { font-size: 0.75rem; }
|
|
178
|
+
.small input { font-size: 0.85rem; }
|
|
179
|
+
.medium input { font-size: 1rem; }
|
|
180
|
+
.large input { font-size: 1.15rem; }
|
|
181
|
+
.massive input { font-size: 1.5rem; }
|
|
182
|
+
|
|
183
|
+
/* Variations */
|
|
184
|
+
.fullwidth { width: 100%; }
|
|
185
|
+
|
|
186
|
+
:host([inverted]) .input-label {
|
|
187
|
+
color: rgba(255, 255, 255, 0.9);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
:host([inverted]) .input-wrapper {
|
|
191
|
+
background: rgba(255, 255, 255, 0.08);
|
|
192
|
+
border-color: rgba(255, 255, 255, 0.15);
|
|
193
|
+
color: #FFFFFF;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
:host([inverted]) .input-wrapper:focus-within {
|
|
197
|
+
background: rgba(255, 255, 255, 0.12);
|
|
198
|
+
border-color: var(--kg-primary);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
:host([inverted]) .label-container {
|
|
202
|
+
background: rgba(255, 255, 255, 0.12);
|
|
203
|
+
border-color: rgba(255, 255, 255, 0.15);
|
|
204
|
+
color: rgba(255, 255, 255, 0.7);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
:host([inverted]) input::placeholder {
|
|
208
|
+
color: rgba(255, 255, 255, 0.5);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
:host([inverted]) .reveal-btn {
|
|
212
|
+
color: rgba(255, 255, 255, 0.6);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
:host([inverted]) .reveal-btn:hover {
|
|
216
|
+
color: var(--kg-secondary);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
* {
|
|
220
|
+
font-family: 'Century Gothic', 'Apple Gothic', 'CenturyGothic', sans-serif;
|
|
221
|
+
}
|
|
222
|
+
`;
|
|
223
|
+
constructor() {
|
|
224
|
+
super(), this.type = "text", this.value = "", this.placeholder = "", this.hasLeft = !1, this.hasRight = !1, this._showPassword = !1;
|
|
225
|
+
}
|
|
226
|
+
_handleKeyDown(t) {
|
|
227
|
+
if (this.type === "number") {
|
|
228
|
+
if (t.key === "e" || t.key === "E") {
|
|
229
|
+
t.preventDefault();
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (this.positive && (t.key === "-" || t.key === "_")) {
|
|
233
|
+
t.preventDefault();
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (this.integer && (t.key === "." || t.key === ",")) {
|
|
237
|
+
t.preventDefault();
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
_handleInput(t) {
|
|
243
|
+
let e = t.target.value;
|
|
244
|
+
this.type === "number" && (this.integer ? this.positive ? e = e.replace(/\D/g, "") : (e = e.replace(/[^\d-]/g, ""), e.indexOf("-") > 0 && (e = e.slice(0, e.indexOf("-")) + e.slice(e.indexOf("-") + 1))) : this.positive && (e = e.replace(/-/g, "")), t.target.value !== e && (t.target.value = e)), this.value = e, this.dispatchEvent(new CustomEvent("kg-input", {
|
|
245
|
+
detail: { value: this.value },
|
|
246
|
+
bubbles: !0,
|
|
247
|
+
composed: !0
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
_handleSlotChange(t) {
|
|
251
|
+
const e = t.target;
|
|
252
|
+
if (!e) return;
|
|
253
|
+
const n = e.assignedNodes({ flatten: !0 }).some(
|
|
254
|
+
(i) => i.nodeType === Node.ELEMENT_NODE || i.nodeType === Node.TEXT_NODE && i.textContent.trim().length > 0
|
|
255
|
+
);
|
|
256
|
+
e.name === "left" && (this.hasLeft = n), e.name === "right" && (this.hasRight = n);
|
|
257
|
+
}
|
|
258
|
+
_togglePassword() {
|
|
259
|
+
this._showPassword = !this._showPassword;
|
|
260
|
+
}
|
|
261
|
+
render() {
|
|
262
|
+
const t = {
|
|
263
|
+
"ui-input": !0,
|
|
264
|
+
[this.size]: !!this.size,
|
|
265
|
+
disabled: this.disabled,
|
|
266
|
+
loading: this.loading,
|
|
267
|
+
error: this.error,
|
|
268
|
+
fullwidth: this.fullwidth,
|
|
269
|
+
inverted: this.inverted
|
|
270
|
+
}, e = this.type === "number", o = this.type === "password" ? this._showPassword ? "text" : "password" : e ? "text" : this.type, n = this.type === "password" ? this.hasRight ? "5rem" : "3rem" : this.hasRight ? "3rem" : "1rem", i = e ? this.integer ? "numeric" : "decimal" : "";
|
|
271
|
+
return r`
|
|
272
|
+
<div class="kg-input-container" style="--loading-offset: ${n}">
|
|
273
|
+
${this.label ? r`<label class="input-label">${this.label}</label>` : ""}
|
|
274
|
+
<div class="${l(t)}">
|
|
275
|
+
<div class="input-wrapper">
|
|
276
|
+
<div class="label-container left ${this.hasLeft ? "visible" : ""}">
|
|
277
|
+
<slot name="left" @slotchange="${this._handleSlotChange}"></slot>
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
<input
|
|
281
|
+
type="${o}"
|
|
282
|
+
inputmode="${i}"
|
|
283
|
+
placeholder="${this.placeholder}"
|
|
284
|
+
.value="${this.value}"
|
|
285
|
+
?disabled="${this.disabled}"
|
|
286
|
+
@input="${this._handleInput}"
|
|
287
|
+
@keydown="${this._handleKeyDown}"
|
|
288
|
+
/>
|
|
289
|
+
|
|
290
|
+
${this.type === "password" ? r`
|
|
291
|
+
<div class="reveal-btn" @click="${this._togglePassword}">
|
|
292
|
+
${this._showPassword ? r`
|
|
293
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
294
|
+
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
|
|
295
|
+
<circle cx="12" cy="12" r="3"></circle>
|
|
296
|
+
</svg>
|
|
297
|
+
` : r`
|
|
298
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
299
|
+
<path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 1.06-2M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"></path>
|
|
300
|
+
<line x1="1" y1="1" x2="23" y2="23"></line>
|
|
301
|
+
</svg>
|
|
302
|
+
`}
|
|
303
|
+
</div>
|
|
304
|
+
` : ""}
|
|
305
|
+
|
|
306
|
+
<div class="label-container right ${this.hasRight ? "visible" : ""}">
|
|
307
|
+
<slot name="right" @slotchange="${this._handleSlotChange}"></slot>
|
|
308
|
+
</div>
|
|
309
|
+
</div>
|
|
310
|
+
</div>
|
|
311
|
+
</div>
|
|
312
|
+
`;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
customElements.define("kg-input", d);
|
|
316
|
+
export {
|
|
317
|
+
d as kginput
|
|
318
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { LitElement as i, css as r, html as e } from "lit";
|
|
2
|
+
class a extends i {
|
|
3
|
+
static properties = {
|
|
4
|
+
src: { type: String },
|
|
5
|
+
text: { type: String },
|
|
6
|
+
visible: { type: Boolean, reflect: !0 },
|
|
7
|
+
glass: { type: Boolean, reflect: !0 }
|
|
8
|
+
};
|
|
9
|
+
static styles = r`
|
|
10
|
+
:host {
|
|
11
|
+
position: fixed;
|
|
12
|
+
top: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
width: 100vw;
|
|
15
|
+
height: 100vh;
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
z-index: 999999;
|
|
21
|
+
background-color: var(--kg-bg, #ffffff);
|
|
22
|
+
visibility: hidden;
|
|
23
|
+
opacity: 0;
|
|
24
|
+
transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:host([visible]) {
|
|
29
|
+
visibility: visible;
|
|
30
|
+
opacity: 1;
|
|
31
|
+
pointer-events: auto;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host([glass]) {
|
|
35
|
+
background-color: rgba(255, 255, 255, 0.4);
|
|
36
|
+
backdrop-filter: blur(20px) saturate(180%);
|
|
37
|
+
-webkit-backdrop-filter: blur(20px) saturate(180%);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Dark Mode Support */
|
|
41
|
+
:host-context([data-theme='dark']) {
|
|
42
|
+
background-color: #0f172a;
|
|
43
|
+
}
|
|
44
|
+
:host-context([data-theme='dark']):host([glass]) {
|
|
45
|
+
background-color: rgba(15, 23, 42, 0.6);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.loader-container {
|
|
49
|
+
position: relative;
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Decorative Orbits */
|
|
57
|
+
.orbit {
|
|
58
|
+
position: absolute;
|
|
59
|
+
border: 2px solid var(--kg-primary);
|
|
60
|
+
border-radius: 50%;
|
|
61
|
+
opacity: 0.1;
|
|
62
|
+
pointer-events: none;
|
|
63
|
+
}
|
|
64
|
+
.orbit-1 { width: 140px; height: 140px; animation: rotate 3s linear infinite; border-top-color: transparent; }
|
|
65
|
+
.orbit-2 { width: 180px; height: 180px; animation: rotate 5s linear reverse infinite; border-right-color: transparent; }
|
|
66
|
+
|
|
67
|
+
@keyframes rotate {
|
|
68
|
+
from { transform: rotate(0deg); }
|
|
69
|
+
to { transform: rotate(360deg); }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.loader-content {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
align-items: center;
|
|
76
|
+
gap: 1rem;
|
|
77
|
+
text-align: center;
|
|
78
|
+
padding: 3rem;
|
|
79
|
+
z-index: 2;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.image-wrapper {
|
|
83
|
+
position: relative;
|
|
84
|
+
min-width: 140px;
|
|
85
|
+
min-height: 140px;
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
opacity: 0;
|
|
90
|
+
transform: scale(0.8);
|
|
91
|
+
transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
92
|
+
transition-delay: 0.1s;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
:host([visible]) .image-wrapper {
|
|
96
|
+
opacity: 1;
|
|
97
|
+
transform: scale(1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.loader-image {
|
|
101
|
+
max-width: 200px;
|
|
102
|
+
max-height: 140px;
|
|
103
|
+
object-fit: contain;
|
|
104
|
+
filter: drop-shadow(0 4px 12px rgba(0,0,0,0.1));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.loader-info {
|
|
108
|
+
display: flex;
|
|
109
|
+
flex-direction: column;
|
|
110
|
+
align-items: center;
|
|
111
|
+
gap: 1.5rem;
|
|
112
|
+
opacity: 0;
|
|
113
|
+
transform: translateY(10px);
|
|
114
|
+
transition: all 0.6s ease;
|
|
115
|
+
transition-delay: 0.3s;
|
|
116
|
+
width: 100%;
|
|
117
|
+
max-width: 240px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
:host([visible]) .loader-info {
|
|
121
|
+
opacity: 1;
|
|
122
|
+
transform: translateY(0);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.loader-text {
|
|
126
|
+
font-size: 1.25rem;
|
|
127
|
+
font-weight: 700;
|
|
128
|
+
color: var(--kg-text, #1e293b);
|
|
129
|
+
letter-spacing: -0.01em;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:host-context([data-theme='dark']) .loader-text { color: #f8fafc; }
|
|
133
|
+
`;
|
|
134
|
+
constructor() {
|
|
135
|
+
super(), this.src = "", this.text = "", this.visible = !1, this.glass = !1;
|
|
136
|
+
}
|
|
137
|
+
render() {
|
|
138
|
+
return e`
|
|
139
|
+
<div class="loader-container">
|
|
140
|
+
<div class="orbit orbit-1"></div>
|
|
141
|
+
<div class="orbit orbit-2"></div>
|
|
142
|
+
|
|
143
|
+
<div class="loader-content">
|
|
144
|
+
${this.src ? e`
|
|
145
|
+
<div class="image-wrapper">
|
|
146
|
+
<img class="loader-image" src="${this.src}" alt="Loading" />
|
|
147
|
+
</div>
|
|
148
|
+
` : ""}
|
|
149
|
+
|
|
150
|
+
${this.text ? e`
|
|
151
|
+
<div class="loader-info">
|
|
152
|
+
<div class="loader-text">${this.text}</div>
|
|
153
|
+
</div>
|
|
154
|
+
` : ""}
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
`;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
customElements.define("kg-loader", a);
|
|
161
|
+
const n = {
|
|
162
|
+
_instance: null,
|
|
163
|
+
show(t = {}) {
|
|
164
|
+
this._instance || (this._instance = document.createElement("kg-loader"), document.body.appendChild(this._instance)), this._instance.src = t.src !== void 0 ? t.src : "", this._instance.text = t.text !== void 0 ? t.text : "", this._instance.glass = t.glass !== void 0 ? t.glass : !0, requestAnimationFrame(() => {
|
|
165
|
+
this._instance.visible = !0;
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
hide() {
|
|
169
|
+
this._instance && (this._instance.visible = !1);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
export {
|
|
173
|
+
a as kgloader,
|
|
174
|
+
n as loader
|
|
175
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { LitElement as i, css as a, html as t } from "lit";
|
|
2
|
+
import { classMap as o } from "lit/directives/class-map.js";
|
|
3
|
+
class l extends i {
|
|
4
|
+
static properties = {
|
|
5
|
+
open: { type: Boolean, reflect: !0 },
|
|
6
|
+
size: { type: String },
|
|
7
|
+
// mini, tiny, small, large, fullscreen
|
|
8
|
+
closable: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
converter: (e) => e !== "false"
|
|
11
|
+
},
|
|
12
|
+
basic: { type: Boolean }
|
|
13
|
+
};
|
|
14
|
+
static styles = a`
|
|
15
|
+
:host {
|
|
16
|
+
display: block;
|
|
17
|
+
--kg-modal-z-index: 2000;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.kg-modal-dimmer {
|
|
21
|
+
position: fixed;
|
|
22
|
+
top: 0;
|
|
23
|
+
left: 0;
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 100%;
|
|
26
|
+
background: rgba(0, 0, 0, 0.6);
|
|
27
|
+
backdrop-filter: blur(5px);
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
z-index: var(--kg-modal-z-index);
|
|
32
|
+
opacity: 0;
|
|
33
|
+
visibility: hidden;
|
|
34
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
35
|
+
padding: var(--kg-space-md);
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.kg-modal-dimmer.open {
|
|
40
|
+
opacity: 1;
|
|
41
|
+
visibility: visible;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.kg-modal-content {
|
|
45
|
+
background: var(--kg-bg);
|
|
46
|
+
color: var(--kg-text);
|
|
47
|
+
border-radius: var(--kg-radius-lg);
|
|
48
|
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
|
49
|
+
width: 100%;
|
|
50
|
+
max-width: 600px;
|
|
51
|
+
transform: scale(0.95) translateY(10px);
|
|
52
|
+
transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
max-height: 90vh;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.kg-modal-dimmer.open .kg-modal-content {
|
|
60
|
+
transform: scale(1) translateY(0);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Sizes */
|
|
64
|
+
.size-mini { max-width: 350px; }
|
|
65
|
+
.size-tiny { max-width: 450px; }
|
|
66
|
+
.size-small { max-width: 550px; }
|
|
67
|
+
.size-large { max-width: 900px; }
|
|
68
|
+
.size-fullscreen {
|
|
69
|
+
max-width: 95vw;
|
|
70
|
+
height: 95vh;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Basic style */
|
|
74
|
+
:host([basic]) .kg-modal-content {
|
|
75
|
+
background: transparent;
|
|
76
|
+
box-shadow: none;
|
|
77
|
+
color: white;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.modal-header {
|
|
81
|
+
padding: var(--kg-space-lg);
|
|
82
|
+
font-size: 1.25rem;
|
|
83
|
+
font-weight: 700;
|
|
84
|
+
border-bottom: 1px solid var(--kg-border);
|
|
85
|
+
display: flex;
|
|
86
|
+
justify-content: space-between;
|
|
87
|
+
align-items: center;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.modal-body {
|
|
91
|
+
padding: var(--kg-space-lg);
|
|
92
|
+
overflow-y: auto;
|
|
93
|
+
flex: 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.modal-footer {
|
|
97
|
+
padding: var(--kg-space-md) var(--kg-space-lg);
|
|
98
|
+
border-top: 1px solid var(--kg-border);
|
|
99
|
+
background: var(--kg-surface);
|
|
100
|
+
display: flex;
|
|
101
|
+
justify-content: flex-end;
|
|
102
|
+
gap: 0.75rem;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.close-button {
|
|
106
|
+
background: none;
|
|
107
|
+
border: none;
|
|
108
|
+
color: var(--kg-text-muted);
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
font-size: 1.5rem;
|
|
111
|
+
padding: 0.5rem;
|
|
112
|
+
line-height: 1;
|
|
113
|
+
border-radius: var(--kg-radius-sm);
|
|
114
|
+
transition: all 0.2s;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.close-button:hover {
|
|
118
|
+
background: var(--kg-surface);
|
|
119
|
+
color: var(--kg-text);
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
constructor() {
|
|
123
|
+
super(), this.open = !1, this.size = "small", this.closable = !0, this.basic = !1;
|
|
124
|
+
}
|
|
125
|
+
close() {
|
|
126
|
+
this.open = !1, this.dispatchEvent(new CustomEvent("close", { bubbles: !0, composed: !0 }));
|
|
127
|
+
}
|
|
128
|
+
_handleDimmerClick(e) {
|
|
129
|
+
this.closable && e.target.classList.contains("kg-modal-dimmer") && this.close();
|
|
130
|
+
}
|
|
131
|
+
willUpdate(e) {
|
|
132
|
+
e.has("open") && (this.open ? document.body.style.overflow = "hidden" : document.body.style.overflow = "");
|
|
133
|
+
}
|
|
134
|
+
render() {
|
|
135
|
+
const e = {
|
|
136
|
+
"kg-modal-dimmer": !0,
|
|
137
|
+
open: this.open
|
|
138
|
+
}, s = {
|
|
139
|
+
"kg-modal-content": !0,
|
|
140
|
+
[`size-${this.size}`]: !0
|
|
141
|
+
};
|
|
142
|
+
return t`
|
|
143
|
+
<div class="${o(e)}" @click="${this._handleDimmerClick}">
|
|
144
|
+
<div class="${o(s)}">
|
|
145
|
+
<div class="modal-header">
|
|
146
|
+
<slot name="header"></slot>
|
|
147
|
+
${this.closable ? t`
|
|
148
|
+
<button class="close-button" @click="${this.close}">×</button>
|
|
149
|
+
` : ""}
|
|
150
|
+
</div>
|
|
151
|
+
<div class="modal-body">
|
|
152
|
+
<slot></slot>
|
|
153
|
+
</div>
|
|
154
|
+
<div class="modal-footer">
|
|
155
|
+
<slot name="footer"></slot>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
customElements.define("kg-modal", l);
|
|
163
|
+
export {
|
|
164
|
+
l as kgmodal
|
|
165
|
+
};
|