@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,108 @@
1
+ import { LitElement as e, css as i, html as r } from "lit";
2
+ import { styleMap as a } from "lit/directives/style-map.js";
3
+ class s extends e {
4
+ static properties = {
5
+ variant: { type: String },
6
+ // text, circle, rect
7
+ animation: { type: String },
8
+ // pulse, wave, none
9
+ width: { type: String },
10
+ height: { type: String },
11
+ borderRadius: { type: String, attribute: "border-radius" }
12
+ };
13
+ static styles = i`
14
+ :host {
15
+ display: inline-block;
16
+ vertical-align: middle;
17
+ width: 100%;
18
+ line-height: 0;
19
+ }
20
+
21
+ /* Circle ve Rect için width: fit-content olmalı */
22
+ :host([variant="circle"]),
23
+ :host([variant="rect"]) {
24
+ width: fit-content;
25
+ }
26
+
27
+ .skeleton {
28
+ /* Light mode: Biraz daha belirgin, şık bir gri */
29
+ background-color: #ebebeb;
30
+ position: relative;
31
+ overflow: hidden;
32
+ display: block;
33
+ width: var(--skeleton-width, 100%);
34
+ height: var(--skeleton-height, 1.2em);
35
+ box-sizing: border-box;
36
+ }
37
+
38
+ /* Sadece Dark Mode seçiliyse renkleri değiştir */
39
+ :host-context([data-theme='dark']) .skeleton,
40
+ [data-theme='dark'] .skeleton {
41
+ background-color: rgba(255, 255, 255, 0.1);
42
+ }
43
+
44
+ /* Variants */
45
+ .skeleton.text {
46
+ margin: 0.3em 0;
47
+ height: 0.9em;
48
+ border-radius: 4px;
49
+ }
50
+
51
+ .skeleton.circle {
52
+ border-radius: 50%;
53
+ }
54
+
55
+ .skeleton.rect {
56
+ border-radius: 8px;
57
+ }
58
+
59
+ /* Animations */
60
+ .skeleton.pulse {
61
+ animation: pulse 1.5s ease-in-out infinite;
62
+ }
63
+
64
+ .skeleton.wave::after {
65
+ content: "";
66
+ position: absolute;
67
+ top: 0;
68
+ right: 0;
69
+ bottom: 0;
70
+ left: 0;
71
+ transform: translateX(-100%);
72
+ /* Yumuşak parlayan dalga */
73
+ background-image: linear-gradient(
74
+ 90deg,
75
+ rgba(255, 255, 255, 0) 0,
76
+ rgba(255, 255, 255, 0.6) 50%,
77
+ rgba(255, 255, 255, 0) 100%
78
+ );
79
+ animation: wave 1.5s infinite;
80
+ }
81
+
82
+ @keyframes pulse {
83
+ 0% { opacity: 1; }
84
+ 50% { opacity: 0.4; }
85
+ 100% { opacity: 1; }
86
+ }
87
+
88
+ @keyframes wave {
89
+ 100% { transform: translateX(100%); }
90
+ }
91
+ `;
92
+ constructor() {
93
+ super(), this.variant = "text", this.animation = "pulse", this.width = "", this.height = "", this.borderRadius = "";
94
+ }
95
+ render() {
96
+ const t = {};
97
+ return this.width && (t["--skeleton-width"] = this.width), this.height && (t["--skeleton-height"] = this.height), this.borderRadius && (t["border-radius"] = this.borderRadius), r`
98
+ <span
99
+ class="skeleton ${this.variant} ${this.animation}"
100
+ style="${a(t)}"
101
+ ></span>
102
+ `;
103
+ }
104
+ }
105
+ customElements.define("kg-skeleton", s);
106
+ export {
107
+ s as kgskeleton
108
+ };
@@ -0,0 +1,196 @@
1
+ import { LitElement as a, css as s, html as t } from "lit";
2
+ import "lit/directives/class-map.js";
3
+ class n extends a {
4
+ static properties = {
5
+ value: { type: Number, reflect: !0 },
6
+ min: { type: Number },
7
+ max: { type: Number },
8
+ step: { type: Number },
9
+ label: { type: String },
10
+ color: { type: String },
11
+ disabled: { type: Boolean, reflect: !0 },
12
+ hideValue: { type: Boolean, reflect: !0, attribute: "hide-value" },
13
+ showPins: { type: Boolean, attribute: "show-pins" }
14
+ };
15
+ static styles = s`
16
+ :host {
17
+ display: block;
18
+ margin: 1rem 0;
19
+ font-family: inherit;
20
+ }
21
+
22
+ .kg-slider-container {
23
+ display: flex;
24
+ flex-direction: column;
25
+ gap: 0.5rem;
26
+ width: 100%;
27
+ }
28
+
29
+ .slider-header {
30
+ display: flex;
31
+ justify-content: space-between;
32
+ align-items: center;
33
+ }
34
+
35
+ .slider-label {
36
+ font-size: 0.875rem;
37
+ font-weight: 600;
38
+ color: var(--kg-text);
39
+ opacity: 0.8;
40
+ }
41
+
42
+ .current-value {
43
+ font-size: 0.875rem;
44
+ font-weight: 700;
45
+ color: var(--slider-active-color, var(--kg-primary));
46
+ background: var(--kg-bg-secondary, rgba(0,0,0,0.04));
47
+ padding: 2px 8px;
48
+ border-radius: 4px;
49
+ min-width: 2.5rem;
50
+ text-align: center;
51
+ }
52
+
53
+ .slider-wrapper {
54
+ position: relative;
55
+ display: flex;
56
+ align-items: center;
57
+ height: 24px;
58
+ }
59
+
60
+ input[type="range"] {
61
+ -webkit-appearance: none;
62
+ width: 100%;
63
+ background: transparent;
64
+ margin: 0;
65
+ cursor: pointer;
66
+ }
67
+
68
+ input[type="range"]:focus {
69
+ outline: none;
70
+ }
71
+
72
+ /* Track Styles */
73
+ input[type="range"]::-webkit-slider-runnable-track {
74
+ width: 100%;
75
+ height: 6px;
76
+ background: var(--kg-border);
77
+ border-radius: 3px;
78
+ transition: background 0.2s;
79
+ }
80
+
81
+ .checked-track {
82
+ position: absolute;
83
+ height: 6px;
84
+ background: var(--slider-active-color, var(--kg-primary));
85
+ border-radius: 3px;
86
+ pointer-events: none;
87
+ left: 0;
88
+ }
89
+
90
+ /* Thumb Styles */
91
+ input[type="range"]::-webkit-slider-thumb {
92
+ -webkit-appearance: none;
93
+ height: 20px;
94
+ width: 20px;
95
+ border-radius: 50%;
96
+ background: white;
97
+ border: 2px solid var(--slider-active-color, var(--kg-primary));
98
+ margin-top: -7px; /* Centers thumb on track */
99
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
100
+ transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
101
+ position: relative;
102
+ z-index: 2;
103
+ }
104
+
105
+ input[type="range"]:not(:disabled):::-webkit-slider-thumb:hover {
106
+ transform: scale(1.2);
107
+ box-shadow: 0 0 0 6px rgba(var(--kg-primary-rgb, 19, 103, 255), 0.1);
108
+ }
109
+
110
+ input[type="range"]:active::-webkit-slider-thumb {
111
+ transform: scale(0.9);
112
+ background: var(--slider-active-color, var(--kg-primary));
113
+ }
114
+
115
+ /* Disabled State */
116
+ .disabled {
117
+ opacity: 0.5;
118
+ cursor: not-allowed;
119
+ }
120
+
121
+ .disabled input[type="range"] {
122
+ cursor: not-allowed;
123
+ }
124
+
125
+ .pins-container {
126
+ position: absolute;
127
+ width: 100%;
128
+ height: 100%;
129
+ display: flex;
130
+ justify-content: space-between;
131
+ align-items: center;
132
+ pointer-events: none;
133
+ z-index: 0;
134
+ }
135
+
136
+ .pin {
137
+ width: 4px;
138
+ height: 4px;
139
+ background-color: var(--kg-text);
140
+ opacity: 0.3;
141
+ border-radius: 50%;
142
+ }
143
+ `;
144
+ constructor() {
145
+ super(), this.value = 50, this.min = 0, this.max = 100, this.step = 1, this.disabled = !1, this.hideValue = !1, this.showPins = !1;
146
+ }
147
+ _handleInput(r) {
148
+ this.value = Number(r.target.value), this.dispatchEvent(new CustomEvent("kg-input", {
149
+ detail: { value: this.value },
150
+ bubbles: !0,
151
+ composed: !0
152
+ }));
153
+ }
154
+ render() {
155
+ const r = (this.value - this.min) / (this.max - this.min) * 100, i = `--slider-active-color: ${((e) => e ? e.startsWith("#") || e.startsWith("rgb") || e.startsWith("hsl") ? e : {
156
+ primary: "var(--kg-primary)",
157
+ secondary: "var(--kg-secondary)",
158
+ tertiary: "var(--kg-tertiary)",
159
+ error: "#e74c3c",
160
+ red: "#e74c3c",
161
+ green: "#2ecc71",
162
+ blue: "#3498db",
163
+ orange: "#f39c12",
164
+ purple: "#9b59b6"
165
+ }[e] || `var(--kg-${e}, ${e})` : "var(--kg-primary)")(this.color)};`;
166
+ return t`
167
+ <div class="kg-slider-container ${this.disabled ? "disabled" : ""}" style="${i}">
168
+ <div class="slider-header">
169
+ ${this.label ? t`<label class="slider-label">${this.label}</label>` : ""}
170
+ ${this.hideValue ? "" : t`<span class="current-value">${this.value}</span>`}
171
+ </div>
172
+ <div class="slider-wrapper">
173
+ ${this.showPins ? t`
174
+ <div class="pins-container">
175
+ ${[...Array(5)].map(() => t`<div class="pin"></div>`)}
176
+ </div>
177
+ ` : ""}
178
+ <div class="checked-track" style="width: ${r}%"></div>
179
+ <input
180
+ type="range"
181
+ .min="${this.min}"
182
+ .max="${this.max}"
183
+ .step="${this.step}"
184
+ .value="${this.value}"
185
+ ?disabled="${this.disabled}"
186
+ @input="${this._handleInput}"
187
+ />
188
+ </div>
189
+ </div>
190
+ `;
191
+ }
192
+ }
193
+ customElements.define("kg-slider", n);
194
+ export {
195
+ n as kgslider
196
+ };
@@ -0,0 +1,79 @@
1
+ import { LitElement as r, css as s, html as t } from "lit";
2
+ class i extends r {
3
+ static properties = {
4
+ size: { type: String, reflect: !0 },
5
+ // 'small', 'medium', 'large' or custom px
6
+ color: { type: String, reflect: !0 },
7
+ thickness: { type: Number }
8
+ };
9
+ static styles = s`
10
+ :host {
11
+ display: inline-flex;
12
+ align-items: center;
13
+ justify-content: center;
14
+ line-height: 0;
15
+ }
16
+
17
+ .spinner {
18
+ animation: rotate 1.5s linear infinite;
19
+ transform-origin: center center;
20
+ }
21
+
22
+ circle {
23
+ stroke: var(--spinner-color, var(--kg-primary));
24
+ stroke-dasharray: 1, 200;
25
+ stroke-dashoffset: 0;
26
+ animation: dash 1.5s ease-in-out infinite;
27
+ stroke-linecap: round;
28
+ fill: none;
29
+ }
30
+
31
+ @keyframes rotate {
32
+ 100% { transform: rotate(360deg); }
33
+ }
34
+
35
+ @keyframes dash {
36
+ 0% {
37
+ stroke-dasharray: 1, 200;
38
+ stroke-dashoffset: 0;
39
+ }
40
+ 50% {
41
+ stroke-dasharray: 89, 200;
42
+ stroke-dashoffset: -35px;
43
+ }
44
+ 100% {
45
+ stroke-dasharray: 89, 200;
46
+ stroke-dashoffset: -124px;
47
+ }
48
+ }
49
+
50
+ /* Sizes */
51
+ :host([size="small"]) .spinner { width: 16px; height: 16px; }
52
+ :host([size="medium"]) .spinner { width: 32px; height: 32px; }
53
+ :host([size="large"]) .spinner { width: 48px; height: 48px; }
54
+
55
+ /* Colors */
56
+ :host([color="primary"]) { --spinner-color: var(--kg-primary); }
57
+ :host([color="secondary"]) { --spinner-color: var(--kg-secondary); }
58
+ :host([color="tertiary"]) { --spinner-color: var(--kg-tertiary); }
59
+ :host([color="error"]) { --spinner-color: #DB2828; }
60
+ :host([color="white"]) { --spinner-color: white; }
61
+ `;
62
+ constructor() {
63
+ super(), this.size = "medium", this.color = "primary", this.thickness = 4;
64
+ }
65
+ render() {
66
+ let e = "";
67
+ return ["small", "medium", "large"].includes(this.size) || (e = `width: ${this.size}; height: ${this.size};`), t`
68
+ <svg class="spinner" viewBox="25 25 50 50" style="${e}">
69
+ <circle cx="50" cy="50" r="20"
70
+ stroke-width="${this.thickness}">
71
+ </circle>
72
+ </svg>
73
+ `;
74
+ }
75
+ }
76
+ customElements.define("kg-spinner", i);
77
+ export {
78
+ i as kgspinner
79
+ };
@@ -0,0 +1,214 @@
1
+ import { LitElement as l, css as n, html as t } from "lit";
2
+ import { classMap as a } from "lit/directives/class-map.js";
3
+ import { unsafeHTML as p } from "lit/directives/unsafe-html.js";
4
+ class d extends l {
5
+ static properties = {
6
+ steps: { type: Array },
7
+ activeStep: { type: Number },
8
+ vertical: { type: Boolean },
9
+ clickable: { type: Boolean }
10
+ };
11
+ static styles = n`
12
+ :host {
13
+ display: block;
14
+ width: 100%;
15
+ font-family: inherit;
16
+ }
17
+
18
+ .stepper-container {
19
+ display: flex;
20
+ width: 100%;
21
+ padding: 1rem 0;
22
+ }
23
+
24
+ .stepper-container.horizontal {
25
+ flex-direction: row;
26
+ align-items: flex-start;
27
+ justify-content: space-between;
28
+ }
29
+
30
+ .stepper-container.vertical {
31
+ flex-direction: column;
32
+ gap: 0.5rem;
33
+ }
34
+
35
+ .step-item {
36
+ display: flex;
37
+ position: relative;
38
+ flex: 1;
39
+ }
40
+
41
+ .horizontal .step-item {
42
+ flex-direction: column;
43
+ align-items: center;
44
+ text-align: center;
45
+ }
46
+
47
+ .vertical .step-item {
48
+ flex-direction: row;
49
+ align-items: center;
50
+ gap: 1rem;
51
+ min-height: 60px;
52
+ }
53
+
54
+ /* Connection Lines */
55
+ .step-line {
56
+ position: absolute;
57
+ background: var(--kg-border);
58
+ transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
59
+ z-index: 1;
60
+ }
61
+
62
+ .horizontal .step-line {
63
+ top: 16px;
64
+ left: calc(50% + 20px);
65
+ right: calc(-50% + 20px);
66
+ height: 2px;
67
+ }
68
+
69
+ .vertical .step-line {
70
+ left: 16px;
71
+ top: 36px;
72
+ bottom: -4px;
73
+ width: 2px;
74
+ }
75
+
76
+ .step-item:last-child .step-line {
77
+ display: none;
78
+ }
79
+
80
+ .step-line.active {
81
+ background: var(--kg-primary);
82
+ }
83
+
84
+ /* Step Circle */
85
+ .step-circle {
86
+ width: 34px;
87
+ height: 34px;
88
+ border-radius: 50%;
89
+ background: var(--kg-bg);
90
+ border: 2px solid var(--kg-border);
91
+ display: flex;
92
+ align-items: center;
93
+ justify-content: center;
94
+ font-weight: 700;
95
+ font-size: 0.9rem;
96
+ color: var(--kg-text-muted);
97
+ z-index: 2;
98
+ transition: all 0.3s ease;
99
+ cursor: default;
100
+ }
101
+
102
+ .step-item.clickable .step-circle {
103
+ cursor: pointer;
104
+ }
105
+
106
+ .step-item.active .step-circle {
107
+ border-color: var(--kg-primary);
108
+ color: var(--kg-primary);
109
+ box-shadow: 0 0 0 4px rgba(65, 171, 52, 0.1);
110
+ }
111
+
112
+ .step-item.completed .step-circle {
113
+ background: var(--kg-primary);
114
+ border-color: var(--kg-primary);
115
+ color: white;
116
+ }
117
+
118
+ /* Content */
119
+ .step-content {
120
+ margin-top: 0.75rem;
121
+ z-index: 2;
122
+ }
123
+
124
+ .vertical .step-content {
125
+ margin-top: 0;
126
+ text-align: left;
127
+ }
128
+
129
+ .step-title {
130
+ display: block;
131
+ font-weight: 600;
132
+ font-size: 0.95rem;
133
+ color: var(--kg-text);
134
+ transition: color 0.3s ease;
135
+ }
136
+
137
+ .step-item.active .step-title {
138
+ color: var(--kg-primary);
139
+ }
140
+
141
+ .step-desc {
142
+ display: block;
143
+ font-size: 0.8rem;
144
+ color: var(--kg-text-muted);
145
+ margin-top: 2px;
146
+ }
147
+
148
+ /* Icons */
149
+ .check-icon {
150
+ width: 18px;
151
+ height: 18px;
152
+ }
153
+
154
+ .custom-icon-wrapper {
155
+ display: flex;
156
+ align-items: center;
157
+ justify-content: center;
158
+ width: 18px;
159
+ height: 18px;
160
+ }
161
+
162
+ .custom-icon-wrapper svg {
163
+ width: 100%;
164
+ height: 100%;
165
+ }
166
+ `;
167
+ constructor() {
168
+ super(), this.steps = [], this.activeStep = 0, this.vertical = !1, this.clickable = !1;
169
+ }
170
+ _handleStepClick(i) {
171
+ this.clickable && this.dispatchEvent(new CustomEvent("kg-step-change", {
172
+ detail: { step: i },
173
+ bubbles: !0,
174
+ composed: !0
175
+ }));
176
+ }
177
+ render() {
178
+ const i = Array.isArray(this.steps) ? this.steps : [];
179
+ return i.length === 0 ? t`<div style="padding: 1rem; color: var(--kg-text-muted); text-align: center;">Henüz adım eklenmedi.</div>` : t`
180
+ <div class="stepper-container ${this.vertical ? "vertical" : "horizontal"}">
181
+ ${i.map((e, r) => {
182
+ const s = r < this.activeStep, c = r === this.activeStep, o = {
183
+ "step-item": !0,
184
+ completed: s,
185
+ active: c,
186
+ clickable: this.clickable
187
+ };
188
+ return t`
189
+ <div class="${a(o)}" @click="${() => this._handleStepClick(r)}">
190
+ <div class="step-line ${s ? "active" : ""}"></div>
191
+
192
+ <div class="step-circle">
193
+ ${s ? t`
194
+ <svg class="check-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
195
+ <polyline points="20 6 9 17 4 12"></polyline>
196
+ </svg>
197
+ ` : e.icon ? t`<div class="custom-icon-wrapper">${p(e.icon)}</div>` : r + 1}
198
+ </div>
199
+
200
+ <div class="step-content">
201
+ <span class="step-title">${typeof e == "string" ? e : e.title}</span>
202
+ ${e.description ? t`<span class="step-desc">${e.description}</span>` : ""}
203
+ </div>
204
+ </div>
205
+ `;
206
+ })}
207
+ </div>
208
+ `;
209
+ }
210
+ }
211
+ customElements.define("kg-stepper", d);
212
+ export {
213
+ d as kgstepper
214
+ };
@@ -0,0 +1,106 @@
1
+ import { LitElement as s, css as a, html as e } from "lit";
2
+ import "lit/directives/class-map.js";
3
+ class c extends s {
4
+ static properties = {
5
+ checked: { type: Boolean, reflect: !0 },
6
+ disabled: { type: Boolean },
7
+ label: { type: String },
8
+ color: { type: String }
9
+ // primary, secondary, tertiary
10
+ };
11
+ static styles = a`
12
+ :host {
13
+ display: inline-block;
14
+ vertical-align: middle;
15
+ cursor: pointer;
16
+ user-select: none;
17
+ font-family: inherit;
18
+ }
19
+
20
+ :host([disabled]) {
21
+ cursor: not-allowed;
22
+ opacity: 0.5;
23
+ }
24
+
25
+ .kg-switch-wrapper {
26
+ display: flex;
27
+ align-items: center;
28
+ gap: 0.75rem;
29
+ }
30
+
31
+ .kg-switch-track {
32
+ position: relative;
33
+ width: 44px;
34
+ height: 24px;
35
+ background: var(--kg-border);
36
+ border-radius: 24px;
37
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
38
+ box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
39
+ }
40
+
41
+ .kg-switch-thumb {
42
+ position: absolute;
43
+ top: 2px;
44
+ left: 2px;
45
+ width: 20px;
46
+ height: 20px;
47
+ background: white;
48
+ border-radius: 50%;
49
+ box-shadow: 0 2px 4px rgba(0,0,0,0.2);
50
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
51
+ }
52
+
53
+ /* Checked State */
54
+ :host([checked]) .kg-switch-track {
55
+ background: var(--switch-active-color, var(--kg-primary));
56
+ }
57
+
58
+ :host([checked]) .kg-switch-thumb {
59
+ transform: translateX(20px);
60
+ }
61
+
62
+ .label {
63
+ font-size: 0.95rem;
64
+ font-weight: 500;
65
+ color: var(--kg-text);
66
+ }
67
+ `;
68
+ constructor() {
69
+ super(), this.checked = !1, this.disabled = !1, this.color = "primary";
70
+ }
71
+ _toggle() {
72
+ this.disabled || (this.checked = !this.checked, this.dispatchEvent(new CustomEvent("change", {
73
+ detail: { checked: this.checked },
74
+ bubbles: !0,
75
+ composed: !0
76
+ })));
77
+ }
78
+ render() {
79
+ const r = ((t) => !t || t === "primary" ? "var(--kg-primary)" : t.startsWith("#") || t.startsWith("rgb") || t.startsWith("hsl") ? t : {
80
+ secondary: "var(--kg-secondary)",
81
+ tertiary: "var(--kg-tertiary)",
82
+ error: "#e74c3c",
83
+ red: "#e74c3c",
84
+ green: "#2ecc71",
85
+ blue: "#3498db",
86
+ orange: "#f39c12",
87
+ purple: "#9b59b6"
88
+ }[t] || `var(--kg-${t}, ${t})`)(this.color), i = this.checked ? `--switch-active-color: ${r};` : "";
89
+ return e`
90
+ <div
91
+ class="kg-switch-wrapper"
92
+ style="${i}"
93
+ @click="${this._toggle}"
94
+ >
95
+ <div class="kg-switch-track">
96
+ <div class="kg-switch-thumb"></div>
97
+ </div>
98
+ ${this.label ? e`<span class="label">${this.label}</span>` : ""}
99
+ </div>
100
+ `;
101
+ }
102
+ }
103
+ customElements.define("kg-switch", c);
104
+ export {
105
+ c as kgswitch
106
+ };