@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,82 @@
|
|
|
1
|
+
import { LitElement as t, css as s, html as r } from "lit";
|
|
2
|
+
class o extends t {
|
|
3
|
+
static properties = {
|
|
4
|
+
value: { type: Number },
|
|
5
|
+
max: { type: Number },
|
|
6
|
+
color: { type: String, reflect: !0 },
|
|
7
|
+
height: { type: String },
|
|
8
|
+
showValue: { type: Boolean },
|
|
9
|
+
indeterminate: { type: Boolean, reflect: !0 }
|
|
10
|
+
};
|
|
11
|
+
static styles = s`
|
|
12
|
+
:host {
|
|
13
|
+
display: block;
|
|
14
|
+
width: 100%;
|
|
15
|
+
margin: 0.5rem 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.progress-wrapper {
|
|
19
|
+
width: 100%;
|
|
20
|
+
background-color: var(--kg-bg-secondary, #eee);
|
|
21
|
+
border-radius: 4px;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
position: relative;
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.progress-bar {
|
|
29
|
+
height: 100%;
|
|
30
|
+
background-color: var(--progress-color, var(--kg-primary));
|
|
31
|
+
border-radius: 4px;
|
|
32
|
+
transition: width 0.3s ease;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.progress-label {
|
|
36
|
+
position: absolute;
|
|
37
|
+
left: 50%;
|
|
38
|
+
top: 50%;
|
|
39
|
+
transform: translate(-50%, -50%);
|
|
40
|
+
font-size: 0.7rem;
|
|
41
|
+
font-weight: 700;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
z-index: 1;
|
|
44
|
+
color: white;
|
|
45
|
+
text-shadow: 0 0 2px rgba(0,0,0,0.8);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Colors */
|
|
49
|
+
:host([color="primary"]) { --progress-color: var(--kg-primary); }
|
|
50
|
+
:host([color="secondary"]) { --progress-color: var(--kg-secondary); }
|
|
51
|
+
:host([color="tertiary"]) { --progress-color: var(--kg-tertiary); }
|
|
52
|
+
:host([color="error"]) { --progress-color: #DB2828; }
|
|
53
|
+
|
|
54
|
+
/* Indeterminate Animation */
|
|
55
|
+
:host([indeterminate]) .progress-bar {
|
|
56
|
+
width: 30% !important;
|
|
57
|
+
animation: indeterminate 1.5s infinite linear;
|
|
58
|
+
position: absolute;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@keyframes indeterminate {
|
|
62
|
+
0% { left: -30%; }
|
|
63
|
+
100% { left: 100%; }
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
constructor() {
|
|
67
|
+
super(), this.value = 0, this.max = 100, this.color = "primary", this.height = "12px", this.showValue = !1, this.indeterminate = !1;
|
|
68
|
+
}
|
|
69
|
+
render() {
|
|
70
|
+
const e = Math.min(100, Math.max(0, this.value / this.max * 100));
|
|
71
|
+
return r`
|
|
72
|
+
<div class="progress-wrapper" style="height: ${this.height};">
|
|
73
|
+
${this.showValue && !this.indeterminate ? r`<span class="progress-label">${Math.round(e)}%</span>` : ""}
|
|
74
|
+
<div class="progress-bar" style="width: ${this.indeterminate ? "30%" : e + "%"};"></div>
|
|
75
|
+
</div>
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
customElements.define("kg-progress", o);
|
|
80
|
+
export {
|
|
81
|
+
o as kgprogress
|
|
82
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { LitElement as r, css as a, html as i } from "lit";
|
|
2
|
+
class l extends r {
|
|
3
|
+
static properties = {
|
|
4
|
+
value: { type: String, reflect: !0 },
|
|
5
|
+
direction: { type: String },
|
|
6
|
+
// horizontal, vertical
|
|
7
|
+
label: { type: String }
|
|
8
|
+
};
|
|
9
|
+
static styles = a`
|
|
10
|
+
:host {
|
|
11
|
+
display: block;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.kg-radio-group-container {
|
|
15
|
+
display: flex;
|
|
16
|
+
gap: 16px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.kg-radio-group-container.vertical {
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: 12px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.kg-radio-group-container.horizontal {
|
|
25
|
+
flex-direction: row;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.group-label {
|
|
30
|
+
font-size: 0.875rem;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
color: var(--kg-text-muted);
|
|
33
|
+
margin-bottom: 0.75rem;
|
|
34
|
+
display: block;
|
|
35
|
+
text-transform: uppercase;
|
|
36
|
+
letter-spacing: 0.05em;
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
constructor() {
|
|
40
|
+
super(), this.direction = "vertical", this.value = "", this.addEventListener("kg-radio-select", this._handleRadioSelect);
|
|
41
|
+
}
|
|
42
|
+
_handleRadioSelect(e) {
|
|
43
|
+
const t = e.detail.value;
|
|
44
|
+
this.value = t, this._updateChildren(), this.dispatchEvent(new CustomEvent("change", {
|
|
45
|
+
detail: { value: this.value },
|
|
46
|
+
bubbles: !0,
|
|
47
|
+
composed: !0
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
_updateChildren() {
|
|
51
|
+
this.querySelectorAll("kg-radio").forEach((t) => {
|
|
52
|
+
t.checked = t.value === this.value;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
firstUpdated() {
|
|
56
|
+
this._updateChildren();
|
|
57
|
+
}
|
|
58
|
+
updated(e) {
|
|
59
|
+
e.has("value") && this._updateChildren();
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
return i`
|
|
63
|
+
<div class="kg-radio-group">
|
|
64
|
+
${this.label ? i`<span class="group-label">${this.label}</span>` : ""}
|
|
65
|
+
<div class="kg-radio-group-container ${this.direction}">
|
|
66
|
+
<slot></slot>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
customElements.define("kg-radio-group", l);
|
|
73
|
+
export {
|
|
74
|
+
l as kgradiogroup
|
|
75
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { LitElement as o, css as s, html as e } from "lit";
|
|
2
|
+
import { classMap as c } from "lit/directives/class-map.js";
|
|
3
|
+
class l extends o {
|
|
4
|
+
static properties = {
|
|
5
|
+
checked: { type: Boolean, reflect: !0 },
|
|
6
|
+
label: { type: String },
|
|
7
|
+
name: { type: String },
|
|
8
|
+
value: { type: String },
|
|
9
|
+
disabled: { type: Boolean },
|
|
10
|
+
color: { type: String }
|
|
11
|
+
};
|
|
12
|
+
static styles = s`
|
|
13
|
+
:host {
|
|
14
|
+
display: inline-block;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
user-select: none;
|
|
17
|
+
font-family: inherit;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.kg-radio-container {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: 10px;
|
|
24
|
+
position: relative;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.radio-circle {
|
|
28
|
+
width: 20px;
|
|
29
|
+
height: 20px;
|
|
30
|
+
border: 2px solid var(--kg-border);
|
|
31
|
+
border-radius: 50%;
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
background: var(--kg-bg);
|
|
36
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
37
|
+
position: relative;
|
|
38
|
+
flex-shrink: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.kg-radio-container:hover .radio-circle {
|
|
42
|
+
border-color: var(--radio-active-color, var(--kg-primary));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.kg-radio-container.checked .radio-circle {
|
|
46
|
+
border-color: var(--radio-active-color, var(--kg-primary));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Inner Dot */
|
|
50
|
+
.radio-circle::after {
|
|
51
|
+
content: '';
|
|
52
|
+
width: 10px;
|
|
53
|
+
height: 10px;
|
|
54
|
+
background: var(--radio-active-color, var(--kg-primary));
|
|
55
|
+
border-radius: 50%;
|
|
56
|
+
transform: scale(0);
|
|
57
|
+
transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.checked .radio-circle::after {
|
|
61
|
+
transform: scale(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.label-text {
|
|
65
|
+
font-size: 0.95rem;
|
|
66
|
+
color: var(--kg-text);
|
|
67
|
+
transition: color 0.2s;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* States */
|
|
71
|
+
.disabled {
|
|
72
|
+
opacity: 0.5;
|
|
73
|
+
cursor: not-allowed;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.disabled .radio-circle {
|
|
77
|
+
background: var(--kg-surface);
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
constructor() {
|
|
81
|
+
super(), this.checked = !1, this.disabled = !1;
|
|
82
|
+
}
|
|
83
|
+
_handleClick() {
|
|
84
|
+
this.disabled || this.checked || this.dispatchEvent(new CustomEvent("kg-radio-select", {
|
|
85
|
+
detail: { value: this.value },
|
|
86
|
+
bubbles: !0,
|
|
87
|
+
composed: !0
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
render() {
|
|
91
|
+
const t = {
|
|
92
|
+
"kg-radio-container": !0,
|
|
93
|
+
checked: this.checked,
|
|
94
|
+
disabled: this.disabled
|
|
95
|
+
}, i = (r) => r ? r.startsWith("#") || r.startsWith("rgb") || r.startsWith("hsl") ? r : {
|
|
96
|
+
primary: "var(--kg-primary)",
|
|
97
|
+
secondary: "var(--kg-secondary)",
|
|
98
|
+
tertiary: "var(--kg-tertiary)",
|
|
99
|
+
error: "#e74c3c",
|
|
100
|
+
red: "#e74c3c",
|
|
101
|
+
green: "#2ecc71",
|
|
102
|
+
blue: "#3498db",
|
|
103
|
+
orange: "#f39c12",
|
|
104
|
+
purple: "#9b59b6"
|
|
105
|
+
}[r] || `var(--kg-${r}, ${r})` : "var(--kg-primary)", a = this.color ? `--radio-active-color: ${i(this.color)}` : "";
|
|
106
|
+
return e`
|
|
107
|
+
<div
|
|
108
|
+
class="${c(t)}"
|
|
109
|
+
style="${a}"
|
|
110
|
+
@click="${this._handleClick}"
|
|
111
|
+
>
|
|
112
|
+
<div class="radio-circle"></div>
|
|
113
|
+
${this.label ? e`<span class="label-text">${this.label}</span>` : ""}
|
|
114
|
+
</div>
|
|
115
|
+
`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
customElements.define("kg-radio", l);
|
|
119
|
+
export {
|
|
120
|
+
l as kgradio
|
|
121
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LitElement as e, css as t, html as s } from "lit";
|
|
2
|
+
class n extends e {
|
|
3
|
+
static properties = {
|
|
4
|
+
columns: { type: Number },
|
|
5
|
+
// can force children to share columns
|
|
6
|
+
stretched: { type: Boolean },
|
|
7
|
+
centered: { type: Boolean },
|
|
8
|
+
justify: { type: String }
|
|
9
|
+
// start, center, end, space-between
|
|
10
|
+
};
|
|
11
|
+
static styles = t`
|
|
12
|
+
:host {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
margin: 0 calc(var(--kg-space-md) * -1);
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host([centered]) {
|
|
20
|
+
justify-content: center;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host([justify="space-between"]) { justify-content: space-between; }
|
|
24
|
+
:host([justify="end"]) { justify-content: flex-end; }
|
|
25
|
+
|
|
26
|
+
:host([stretched]) {
|
|
27
|
+
align-items: stretch;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* Handle nesting if needed */
|
|
31
|
+
::slotted(kg-column) {
|
|
32
|
+
padding: var(--kg-space-md);
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
render() {
|
|
36
|
+
return s`<slot></slot>`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
customElements.define("kg-row", n);
|
|
40
|
+
export {
|
|
41
|
+
n as kgrow
|
|
42
|
+
};
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { LitElement as n, css as c, html as s } from "lit";
|
|
2
|
+
import "lit/directives/class-map.js";
|
|
3
|
+
import "lit/directives/live.js";
|
|
4
|
+
class d extends n {
|
|
5
|
+
static properties = {
|
|
6
|
+
options: { type: Array },
|
|
7
|
+
value: { type: Object },
|
|
8
|
+
// Can be string or array
|
|
9
|
+
placeholder: { type: String },
|
|
10
|
+
label: { type: String },
|
|
11
|
+
multiple: { type: Boolean },
|
|
12
|
+
disabled: { type: Boolean },
|
|
13
|
+
searchable: { type: Boolean },
|
|
14
|
+
_open: { type: Boolean, state: !0 },
|
|
15
|
+
_searchQuery: { type: String, state: !0 }
|
|
16
|
+
};
|
|
17
|
+
static styles = c`
|
|
18
|
+
:host {
|
|
19
|
+
display: inline-block;
|
|
20
|
+
width: 100%;
|
|
21
|
+
position: relative;
|
|
22
|
+
font-family: inherit;
|
|
23
|
+
user-select: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.kg-select-container {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
gap: 0.5rem;
|
|
30
|
+
width: 100%;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.select-label {
|
|
34
|
+
font-size: 0.875rem;
|
|
35
|
+
font-weight: 600;
|
|
36
|
+
color: var(--kg-text);
|
|
37
|
+
opacity: 0.8;
|
|
38
|
+
margin-left: 2px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
* {
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.select-trigger {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: space-between;
|
|
49
|
+
height: var(--kg-form-height);
|
|
50
|
+
padding: 0 1rem;
|
|
51
|
+
background: var(--kg-surface);
|
|
52
|
+
border: 1px solid var(--kg-border);
|
|
53
|
+
border-radius: var(--kg-radius-md, 8px);
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
transition: all 0.2s ease;
|
|
56
|
+
gap: 8px;
|
|
57
|
+
flex-wrap: nowrap;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.select-trigger:hover {
|
|
62
|
+
border-color: var(--kg-primary);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.select-trigger.open {
|
|
66
|
+
border-color: var(--kg-primary);
|
|
67
|
+
box-shadow: 0 0 0 2px rgba(65, 171, 52, 0.2);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.select-trigger.disabled {
|
|
71
|
+
opacity: 0.5;
|
|
72
|
+
cursor: not-allowed;
|
|
73
|
+
background: var(--kg-bg-secondary);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.placeholder {
|
|
77
|
+
color: var(--kg-text-muted);
|
|
78
|
+
opacity: 0.6;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.selected-text {
|
|
82
|
+
color: var(--kg-text);
|
|
83
|
+
flex: 1;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.tags-container {
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-wrap: wrap;
|
|
89
|
+
gap: 4px;
|
|
90
|
+
flex: 1;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.tag {
|
|
94
|
+
background: var(--kg-primary);
|
|
95
|
+
color: white;
|
|
96
|
+
padding: 2px 8px;
|
|
97
|
+
border-radius: 4px;
|
|
98
|
+
font-size: 0.8rem;
|
|
99
|
+
display: flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
gap: 4px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.tag-remove {
|
|
105
|
+
cursor: pointer;
|
|
106
|
+
opacity: 0.8;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.tag-remove:hover {
|
|
110
|
+
opacity: 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.chevron {
|
|
114
|
+
transition: transform 0.2s ease;
|
|
115
|
+
color: var(--kg-text-muted);
|
|
116
|
+
flex-shrink: 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.open .chevron {
|
|
120
|
+
transform: rotate(180deg);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* Dropdown */
|
|
124
|
+
.select-dropdown {
|
|
125
|
+
position: absolute;
|
|
126
|
+
top: calc(100% + 5px);
|
|
127
|
+
left: 0;
|
|
128
|
+
width: 100%;
|
|
129
|
+
background: var(--kg-surface);
|
|
130
|
+
border: 1px solid var(--kg-border);
|
|
131
|
+
border-radius: var(--kg-radius-md, 8px);
|
|
132
|
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
|
133
|
+
z-index: 1000;
|
|
134
|
+
max-height: 300px;
|
|
135
|
+
overflow-y: auto;
|
|
136
|
+
display: none;
|
|
137
|
+
animation: slideDown 0.2s ease-out;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.select-dropdown.visible {
|
|
141
|
+
display: block;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@keyframes slideDown {
|
|
145
|
+
from { opacity: 0; transform: translateY(-10px); }
|
|
146
|
+
to { opacity: 1; transform: translateY(0); }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.search-container {
|
|
150
|
+
padding: 8px;
|
|
151
|
+
border-bottom: 1px solid var(--kg-border);
|
|
152
|
+
position: sticky;
|
|
153
|
+
top: 0;
|
|
154
|
+
background: var(--kg-surface);
|
|
155
|
+
z-index: 10;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.search-input {
|
|
159
|
+
width: 100%;
|
|
160
|
+
padding: 6px 10px;
|
|
161
|
+
border: 1px solid var(--kg-border);
|
|
162
|
+
border-radius: 4px;
|
|
163
|
+
outline: none;
|
|
164
|
+
font-family: inherit;
|
|
165
|
+
font-size: 0.9rem;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.search-input:focus {
|
|
169
|
+
border-color: var(--kg-primary);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.option-item {
|
|
173
|
+
padding: 10px 16px;
|
|
174
|
+
cursor: pointer;
|
|
175
|
+
display: flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
justify-content: space-between;
|
|
178
|
+
transition: background 0.15s;
|
|
179
|
+
color: var(--kg-text);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.option-item:hover {
|
|
183
|
+
background: var(--kg-bg-secondary, rgba(0,0,0,0.04));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.option-item.selected {
|
|
187
|
+
background: rgba(var(--kg-primary-rgb, 19, 103, 255), 0.08);
|
|
188
|
+
color: var(--kg-primary);
|
|
189
|
+
font-weight: 600;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.no-results {
|
|
193
|
+
padding: 16px;
|
|
194
|
+
text-align: center;
|
|
195
|
+
color: var(--kg-text-muted);
|
|
196
|
+
font-size: 0.9rem;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.check-icon {
|
|
200
|
+
width: 16px;
|
|
201
|
+
height: 16px;
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
constructor() {
|
|
205
|
+
super(), this.options = [], this.value = null, this.placeholder = "Seçiniz...", this.multiple = !1, this.disabled = !1, this.searchable = !1, this._open = !1, this._searchQuery = "", this._handleOutsideClick = this._handleOutsideClick.bind(this);
|
|
206
|
+
}
|
|
207
|
+
connectedCallback() {
|
|
208
|
+
super.connectedCallback(), document.addEventListener("click", this._handleOutsideClick);
|
|
209
|
+
}
|
|
210
|
+
disconnectedCallback() {
|
|
211
|
+
super.disconnectedCallback(), document.removeEventListener("click", this._handleOutsideClick);
|
|
212
|
+
}
|
|
213
|
+
_handleOutsideClick(t) {
|
|
214
|
+
if (!this._open) return;
|
|
215
|
+
t.composedPath().includes(this) || this._closeDropdown();
|
|
216
|
+
}
|
|
217
|
+
_toggleDropdown(t) {
|
|
218
|
+
this.disabled || (this._open = !this._open, this._open && (this._searchQuery = "", setTimeout(() => {
|
|
219
|
+
const r = this.shadowRoot.querySelector(".search-input");
|
|
220
|
+
r && r.focus();
|
|
221
|
+
}, 100)));
|
|
222
|
+
}
|
|
223
|
+
_closeDropdown() {
|
|
224
|
+
this._open = !1;
|
|
225
|
+
}
|
|
226
|
+
_selectOption(t, r) {
|
|
227
|
+
if (r.stopPropagation(), this.multiple) {
|
|
228
|
+
let i = Array.isArray(this.value) ? [...this.value] : [];
|
|
229
|
+
const o = i.indexOf(t.value);
|
|
230
|
+
o > -1 ? i.splice(o, 1) : i.push(t.value), this.value = i;
|
|
231
|
+
} else
|
|
232
|
+
this.value = t.value, this._closeDropdown();
|
|
233
|
+
this._dispatchChange();
|
|
234
|
+
}
|
|
235
|
+
_dispatchChange() {
|
|
236
|
+
this.dispatchEvent(new CustomEvent("change", {
|
|
237
|
+
detail: { value: this.value },
|
|
238
|
+
bubbles: !0,
|
|
239
|
+
composed: !0
|
|
240
|
+
}));
|
|
241
|
+
}
|
|
242
|
+
_handleSearch(t) {
|
|
243
|
+
this._searchQuery = t.target.value.toLowerCase();
|
|
244
|
+
}
|
|
245
|
+
_removeTag(t, r) {
|
|
246
|
+
r.stopPropagation();
|
|
247
|
+
let i = [...this.value];
|
|
248
|
+
const o = i.indexOf(t);
|
|
249
|
+
o > -1 && (i.splice(o, 1), this.value = i, this._dispatchChange());
|
|
250
|
+
}
|
|
251
|
+
render() {
|
|
252
|
+
const t = (e) => this.multiple && Array.isArray(this.value) ? this.value.includes(e) : this.value === e, i = (() => {
|
|
253
|
+
if (!this.value) return null;
|
|
254
|
+
if (this.multiple && Array.isArray(this.value))
|
|
255
|
+
return this.options.filter((a) => this.value.includes(a.value));
|
|
256
|
+
const e = this.options.find((a) => a.value === this.value);
|
|
257
|
+
return e ? e.label : null;
|
|
258
|
+
})(), l = (this.options || []).filter(
|
|
259
|
+
(e) => e.label.toLowerCase().includes(this._searchQuery || "")
|
|
260
|
+
);
|
|
261
|
+
return s`
|
|
262
|
+
<div class="kg-select-container">
|
|
263
|
+
${this.label ? s`<label class="select-label">${this.label}</label>` : ""}
|
|
264
|
+
|
|
265
|
+
<div
|
|
266
|
+
class="select-trigger ${this._open ? "open" : ""} ${this.disabled ? "disabled" : ""}"
|
|
267
|
+
@click="${this._toggleDropdown}"
|
|
268
|
+
>
|
|
269
|
+
${!this.value || this.multiple && this.value.length === 0 ? s`
|
|
270
|
+
<span class="placeholder">${this.placeholder}</span>
|
|
271
|
+
` : this.multiple ? s`
|
|
272
|
+
<div class="tags-container">
|
|
273
|
+
${i.slice(0, 2).map((e) => s`
|
|
274
|
+
<div class="tag">
|
|
275
|
+
${e.label}
|
|
276
|
+
<span class="tag-remove" @click="${(a) => this._removeTag(e.value, a)}">×</span>
|
|
277
|
+
</div>
|
|
278
|
+
`)}
|
|
279
|
+
${i.length > 2 ? s`
|
|
280
|
+
<div class="tag" style="background: var(--kg-secondary); cursor: default;">
|
|
281
|
+
+${i.length - 2}
|
|
282
|
+
</div>
|
|
283
|
+
` : ""}
|
|
284
|
+
</div>
|
|
285
|
+
` : s`
|
|
286
|
+
<span class="selected-text">${i}</span>
|
|
287
|
+
`}
|
|
288
|
+
|
|
289
|
+
<svg class="chevron" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
290
|
+
<polyline points="6 9 12 15 18 9"></polyline>
|
|
291
|
+
</svg>
|
|
292
|
+
</div>
|
|
293
|
+
|
|
294
|
+
<div class="select-dropdown ${this._open ? "visible" : ""}">
|
|
295
|
+
${this.searchable ? s`
|
|
296
|
+
<div class="search-container">
|
|
297
|
+
<input
|
|
298
|
+
type="text"
|
|
299
|
+
class="search-input"
|
|
300
|
+
placeholder="Ara..."
|
|
301
|
+
.value="${this._searchQuery}"
|
|
302
|
+
@input="${this._handleSearch}"
|
|
303
|
+
@click="${(e) => e.stopPropagation()}"
|
|
304
|
+
/>
|
|
305
|
+
</div>
|
|
306
|
+
` : ""}
|
|
307
|
+
|
|
308
|
+
${l.length > 0 ? l.map((e) => s`
|
|
309
|
+
<div
|
|
310
|
+
class="option-item ${t(e.value) ? "selected" : ""}"
|
|
311
|
+
@click="${(a) => this._selectOption(e, a)}"
|
|
312
|
+
>
|
|
313
|
+
<span>${e.label}</span>
|
|
314
|
+
${t(e.value) ? s`
|
|
315
|
+
<svg class="check-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
|
|
316
|
+
<polyline points="20 6 9 17 4 12"></polyline>
|
|
317
|
+
</svg>
|
|
318
|
+
` : ""}
|
|
319
|
+
</div>
|
|
320
|
+
`) : s`
|
|
321
|
+
<div class="no-results">Sonuç bulunamadı</div>
|
|
322
|
+
`}
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
`;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
customElements.define("kg-select", d);
|
|
329
|
+
export {
|
|
330
|
+
d as kgselect
|
|
331
|
+
};
|