@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,117 @@
|
|
|
1
|
+
import { LitElement as e, css as t, html as o } from "lit";
|
|
2
|
+
import "lit/directives/class-map.js";
|
|
3
|
+
class r extends e {
|
|
4
|
+
static properties = {
|
|
5
|
+
title: { type: String },
|
|
6
|
+
open: { type: Boolean, reflect: !0 },
|
|
7
|
+
disabled: { type: Boolean }
|
|
8
|
+
};
|
|
9
|
+
static styles = t`
|
|
10
|
+
:host {
|
|
11
|
+
display: block;
|
|
12
|
+
border-bottom: 1px solid var(--kg-border);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:host(:last-child) {
|
|
16
|
+
border-bottom: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.accordion-header {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: space-between;
|
|
23
|
+
padding: 1rem 1.25rem;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
background: var(--kg-surface);
|
|
26
|
+
transition: all 0.2s ease;
|
|
27
|
+
user-select: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.accordion-header:hover {
|
|
31
|
+
background: var(--kg-bg-secondary, rgba(0,0,0,0.02));
|
|
32
|
+
color: var(--kg-primary);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.title {
|
|
36
|
+
font-weight: 600;
|
|
37
|
+
font-size: 1rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.chevron {
|
|
41
|
+
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
42
|
+
color: var(--kg-text-muted);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:host([open]) .chevron {
|
|
46
|
+
transform: rotate(180deg);
|
|
47
|
+
color: var(--kg-primary);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
:host([open]) .accordion-header {
|
|
51
|
+
color: var(--kg-primary);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.content-wrapper {
|
|
55
|
+
display: grid;
|
|
56
|
+
grid-template-rows: 0fr;
|
|
57
|
+
transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
background: var(--kg-bg);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
:host([open]) .content-wrapper {
|
|
63
|
+
grid-template-rows: 1fr;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.content {
|
|
67
|
+
min-height: 0;
|
|
68
|
+
padding: 0 1.25rem;
|
|
69
|
+
opacity: 0;
|
|
70
|
+
transform: translateY(-10px);
|
|
71
|
+
transition: all 0.3s ease;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
:host([open]) .content {
|
|
75
|
+
padding: 1.25rem;
|
|
76
|
+
opacity: 1;
|
|
77
|
+
transform: translateY(0);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.disabled {
|
|
81
|
+
opacity: 0.5;
|
|
82
|
+
cursor: not-allowed !important;
|
|
83
|
+
pointer-events: none;
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
constructor() {
|
|
87
|
+
super(), this.open = !1, this.disabled = !1;
|
|
88
|
+
}
|
|
89
|
+
_toggle() {
|
|
90
|
+
this.disabled || this.dispatchEvent(new CustomEvent("kg-accordion-toggle", {
|
|
91
|
+
detail: { open: !this.open },
|
|
92
|
+
bubbles: !0,
|
|
93
|
+
composed: !0
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
render() {
|
|
97
|
+
return o`
|
|
98
|
+
<div class="accordion-item ${this.disabled ? "disabled" : ""}">
|
|
99
|
+
<div class="accordion-header" @click="${this._toggle}">
|
|
100
|
+
<span class="title">${this.title}</span>
|
|
101
|
+
<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">
|
|
102
|
+
<polyline points="6 9 12 15 18 9"></polyline>
|
|
103
|
+
</svg>
|
|
104
|
+
</div>
|
|
105
|
+
<div class="content-wrapper">
|
|
106
|
+
<div class="content">
|
|
107
|
+
<slot></slot>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
customElements.define("kg-accordion-item", r);
|
|
115
|
+
export {
|
|
116
|
+
r as kgaccordionitem
|
|
117
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LitElement as s, css as i, html as l } from "lit";
|
|
2
|
+
class a extends s {
|
|
3
|
+
static properties = {
|
|
4
|
+
exclusive: { type: Boolean }
|
|
5
|
+
// If true, only one item can be open at a time
|
|
6
|
+
};
|
|
7
|
+
static styles = i`
|
|
8
|
+
:host {
|
|
9
|
+
display: block;
|
|
10
|
+
border: 1px solid var(--kg-border);
|
|
11
|
+
border-radius: var(--kg-radius-md, 8px);
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
background: var(--kg-bg);
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
constructor() {
|
|
17
|
+
super(), this.exclusive = !1, this.addEventListener("kg-accordion-toggle", this._handleToggle);
|
|
18
|
+
}
|
|
19
|
+
_handleToggle(e) {
|
|
20
|
+
const o = e.target, r = Array.from(this.querySelectorAll("kg-accordion-item"));
|
|
21
|
+
this.exclusive && e.detail.open && r.forEach((t) => {
|
|
22
|
+
t !== o && (t.open = !1);
|
|
23
|
+
}), o.open = e.detail.open;
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
return l`<slot></slot>`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
customElements.define("kg-accordion", a);
|
|
30
|
+
export {
|
|
31
|
+
a as kgaccordion
|
|
32
|
+
};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { LitElement as n, css as s, html as l } from "lit";
|
|
2
|
+
import { classMap as d } from "lit/directives/class-map.js";
|
|
3
|
+
class c extends n {
|
|
4
|
+
static properties = {
|
|
5
|
+
color: { type: String },
|
|
6
|
+
// primary, secondary, tertiary, red, green, etc.
|
|
7
|
+
size: { type: String },
|
|
8
|
+
// mini, tiny, small, medium, large, big, huge, massive
|
|
9
|
+
fullwidth: { type: Boolean },
|
|
10
|
+
circular: { type: Boolean },
|
|
11
|
+
square: { type: Boolean },
|
|
12
|
+
loading: { type: Boolean },
|
|
13
|
+
disabled: { type: Boolean },
|
|
14
|
+
basic: { type: Boolean },
|
|
15
|
+
inverted: { type: Boolean },
|
|
16
|
+
active: { type: Boolean },
|
|
17
|
+
text: { type: Boolean },
|
|
18
|
+
hasText: { type: Boolean, state: !0 },
|
|
19
|
+
hasLeft: { type: Boolean, state: !0 },
|
|
20
|
+
hasRight: { type: Boolean, state: !0 }
|
|
21
|
+
};
|
|
22
|
+
static styles = s`
|
|
23
|
+
:host {
|
|
24
|
+
display: inline-block;
|
|
25
|
+
vertical-align: middle;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:host([fullwidth]) {
|
|
29
|
+
display: block;
|
|
30
|
+
margin: 0 0 0.5em 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
button {
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
min-height: var(--kg-form-height);
|
|
39
|
+
height: var(--kg-form-height);
|
|
40
|
+
outline: none;
|
|
41
|
+
border: none;
|
|
42
|
+
vertical-align: top;
|
|
43
|
+
background: var(--kg-border);
|
|
44
|
+
color: var(--kg-text);
|
|
45
|
+
font-family: inherit;
|
|
46
|
+
margin: 0;
|
|
47
|
+
padding: 0 1.5em;
|
|
48
|
+
line-height: 1;
|
|
49
|
+
text-transform: none;
|
|
50
|
+
text-shadow: none;
|
|
51
|
+
font-weight: 700;
|
|
52
|
+
font-style: normal;
|
|
53
|
+
text-align: center;
|
|
54
|
+
text-decoration: none;
|
|
55
|
+
border-radius: 4px;
|
|
56
|
+
box-shadow: 0 0 0 1px transparent inset;
|
|
57
|
+
user-select: none;
|
|
58
|
+
transition: all 0.2s ease;
|
|
59
|
+
position: relative;
|
|
60
|
+
gap: 0.5em;
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Reset padding for icon-only buttons to ensure 1:1 aspect ratio */
|
|
65
|
+
button.icon-only {
|
|
66
|
+
padding: 0 !important;
|
|
67
|
+
width: var(--kg-form-height);
|
|
68
|
+
height: var(--kg-form-height);
|
|
69
|
+
gap: 0;
|
|
70
|
+
flex-shrink: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
button.icon-only.circular {
|
|
74
|
+
border-radius: 50%;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
button:hover {
|
|
78
|
+
filter: brightness(0.9);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
button:active {
|
|
82
|
+
filter: brightness(0.8);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Semantic Colors */
|
|
86
|
+
.primary { background-color: var(--kg-primary); color: #FFFFFF; }
|
|
87
|
+
.secondary { background-color: var(--kg-secondary); color: #FFFFFF; }
|
|
88
|
+
.tertiary { background-color: var(--kg-tertiary); color: #FFFFFF; }
|
|
89
|
+
.error { background-color: #DB2828; color: #FFFFFF; }
|
|
90
|
+
|
|
91
|
+
/* Custom Color Support */
|
|
92
|
+
.custom-color { background: var(--kg-custom-color) !important; color: #FFFFFF !important; border: none !important; }
|
|
93
|
+
|
|
94
|
+
/* Variations */
|
|
95
|
+
.fullwidth { width: 100%; }
|
|
96
|
+
.circular { border-radius: 10rem; }
|
|
97
|
+
.square {
|
|
98
|
+
padding: 0 !important;
|
|
99
|
+
width: var(--kg-form-height);
|
|
100
|
+
height: var(--kg-form-height);
|
|
101
|
+
min-width: var(--kg-form-height);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.basic {
|
|
105
|
+
background: transparent !important;
|
|
106
|
+
box-shadow: 0 0 0 1px var(--kg-border) inset !important;
|
|
107
|
+
color: var(--kg-text) !important;
|
|
108
|
+
}
|
|
109
|
+
.basic:hover {
|
|
110
|
+
background: var(--kg-surface) !important;
|
|
111
|
+
box-shadow: 0 0 0 1px var(--kg-text-muted) inset !important;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.basic.primary { color: var(--kg-primary) !important; box-shadow: 0 0 0 1px var(--kg-primary) inset !important; }
|
|
115
|
+
.basic.secondary { color: var(--kg-secondary) !important; box-shadow: 0 0 0 1px var(--kg-secondary) inset !important; }
|
|
116
|
+
.basic.tertiary { color: var(--kg-tertiary) !important; box-shadow: 0 0 0 1px var(--kg-tertiary) inset !important; }
|
|
117
|
+
.basic.error { color: #DB2828 !important; box-shadow: 0 0 0 1px #DB2828 inset !important; }
|
|
118
|
+
|
|
119
|
+
.text {
|
|
120
|
+
background: transparent !important;
|
|
121
|
+
border: none !important;
|
|
122
|
+
box-shadow: none !important;
|
|
123
|
+
color: var(--kg-text) !important;
|
|
124
|
+
padding-left: 0.5em !important;
|
|
125
|
+
padding-right: 0.5em !important;
|
|
126
|
+
}
|
|
127
|
+
.text:hover {
|
|
128
|
+
background: var(--kg-surface) !important;
|
|
129
|
+
color: var(--kg-primary) !important;
|
|
130
|
+
}
|
|
131
|
+
.text.primary { color: var(--kg-primary) !important; }
|
|
132
|
+
.text.secondary { color: var(--kg-secondary) !important; }
|
|
133
|
+
|
|
134
|
+
/* Sizes */
|
|
135
|
+
.mini { font-size: 0.7rem; padding: 0.4em 0.8em; }
|
|
136
|
+
.tiny { font-size: 0.8rem; padding: 0.5em 1em; }
|
|
137
|
+
.small { font-size: 0.9rem; padding: 0.6em 1.25em; }
|
|
138
|
+
.medium { font-size: 1rem; padding: 0.78em 1.5em; }
|
|
139
|
+
.large { font-size: 1.1rem; padding: 0.85em 1.75em; }
|
|
140
|
+
.big { font-size: 1.25rem; padding: 0.9em 2em; }
|
|
141
|
+
.huge { font-size: 1.4rem; padding: 1em 2.25em; }
|
|
142
|
+
.massive { font-size: 1.6rem; padding: 1.1em 2.5em; }
|
|
143
|
+
|
|
144
|
+
/* Loading */
|
|
145
|
+
.loading {
|
|
146
|
+
cursor: default !important;
|
|
147
|
+
pointer-events: none !important;
|
|
148
|
+
color: transparent !important;
|
|
149
|
+
}
|
|
150
|
+
.loading::after {
|
|
151
|
+
position: absolute;
|
|
152
|
+
content: '';
|
|
153
|
+
top: 50%;
|
|
154
|
+
left: 50%;
|
|
155
|
+
width: 1.15em;
|
|
156
|
+
height: 1.15em;
|
|
157
|
+
border-radius: 50%;
|
|
158
|
+
border: 0.2em solid rgba(0, 0, 0, 0.1);
|
|
159
|
+
border-top-color: var(--kg-text);
|
|
160
|
+
transform: translate(-50%, -50%);
|
|
161
|
+
animation: button-spin 0.6s linear infinite;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* Spinner colors for semantic/colored buttons */
|
|
165
|
+
.primary.loading::after,
|
|
166
|
+
.secondary.loading::after,
|
|
167
|
+
.tertiary.loading::after,
|
|
168
|
+
.error.loading::after,
|
|
169
|
+
.custom-color.loading::after {
|
|
170
|
+
border-color: rgba(255, 255, 255, 0.3);
|
|
171
|
+
border-top-color: #fff;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* Basic buttons should use their respective semantic colors for the spinner */
|
|
175
|
+
.basic.primary.loading::after { border-top-color: var(--kg-primary); }
|
|
176
|
+
.basic.secondary.loading::after { border-top-color: var(--kg-secondary); }
|
|
177
|
+
.basic.tertiary.loading::after { border-top-color: var(--kg-tertiary); }
|
|
178
|
+
.basic.error.loading::after { border-top-color: #DB2828; }
|
|
179
|
+
|
|
180
|
+
@keyframes button-spin {
|
|
181
|
+
from { transform: translate(-50%, -50%) rotate(0deg); }
|
|
182
|
+
to { transform: translate(-50%, -50%) rotate(360deg); }
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* Disabled */
|
|
186
|
+
button:disabled {
|
|
187
|
+
cursor: default !important;
|
|
188
|
+
opacity: 0.45 !important;
|
|
189
|
+
box-shadow: none !important;
|
|
190
|
+
pointer-events: none !important;
|
|
191
|
+
}
|
|
192
|
+
`;
|
|
193
|
+
constructor() {
|
|
194
|
+
super(), this.color = "", this.size = "medium", this.hasText = !1, this.hasLeft = !1, this.hasRight = !1;
|
|
195
|
+
}
|
|
196
|
+
_handleSlotChange(o) {
|
|
197
|
+
const t = o.target, r = t.assignedNodes({ flatten: !0 }).filter(
|
|
198
|
+
(e) => e.nodeType === Node.ELEMENT_NODE || e.nodeType === Node.TEXT_NODE && e.textContent.trim().length > 0
|
|
199
|
+
).length > 0;
|
|
200
|
+
t.name ? t.name === "left" ? this.hasLeft = r : t.name === "right" && (this.hasRight = r) : this.hasText = r;
|
|
201
|
+
}
|
|
202
|
+
render() {
|
|
203
|
+
const t = ["primary", "secondary", "tertiary", "error"].includes(this.color), a = this.color && !t, r = !this.hasText && (this.hasLeft || this.hasRight), e = {
|
|
204
|
+
[this.color]: t,
|
|
205
|
+
"custom-color": a,
|
|
206
|
+
[this.size]: !!this.size,
|
|
207
|
+
fullwidth: this.fullwidth,
|
|
208
|
+
circular: this.circular,
|
|
209
|
+
square: this.square,
|
|
210
|
+
loading: this.loading,
|
|
211
|
+
basic: this.basic,
|
|
212
|
+
text: this.text,
|
|
213
|
+
inverted: this.inverted,
|
|
214
|
+
disabled: this.disabled,
|
|
215
|
+
"icon-only": r
|
|
216
|
+
}, i = a ? `border: none; --kg-custom-color: ${this.color};` : "";
|
|
217
|
+
return l`
|
|
218
|
+
<button
|
|
219
|
+
class="${d(e)}"
|
|
220
|
+
style="${i}"
|
|
221
|
+
?disabled=${this.disabled}
|
|
222
|
+
@click=${this._handleClick}
|
|
223
|
+
>
|
|
224
|
+
<slot name="left" @slotchange=${this._handleSlotChange}></slot>
|
|
225
|
+
|
|
226
|
+
<span style="display: ${this.hasText ? "inline-block" : "none"}">
|
|
227
|
+
<slot @slotchange=${this._handleSlotChange}></slot>
|
|
228
|
+
</span>
|
|
229
|
+
|
|
230
|
+
<slot name="right" @slotchange=${this._handleSlotChange}></slot>
|
|
231
|
+
</button>
|
|
232
|
+
`;
|
|
233
|
+
}
|
|
234
|
+
_handleClick(o) {
|
|
235
|
+
(this.loading || this.disabled) && (o.preventDefault(), o.stopPropagation());
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
customElements.define("kg-button", c);
|
|
239
|
+
export {
|
|
240
|
+
c as kgbutton
|
|
241
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { LitElement as a, css as d, html as r } from "lit";
|
|
2
|
+
import { classMap as s } from "lit/directives/class-map.js";
|
|
3
|
+
class i extends a {
|
|
4
|
+
static properties = {
|
|
5
|
+
raised: { type: Boolean },
|
|
6
|
+
vertical: { type: Boolean },
|
|
7
|
+
inverted: { type: Boolean },
|
|
8
|
+
color: { type: String },
|
|
9
|
+
// primary, secondary, tertiary
|
|
10
|
+
basic: { type: Boolean },
|
|
11
|
+
padded: { type: Boolean }
|
|
12
|
+
};
|
|
13
|
+
static styles = d`
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
margin: 1rem 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.ui-card {
|
|
20
|
+
position: relative;
|
|
21
|
+
background: var(--kg-bg);
|
|
22
|
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
23
|
+
border-radius: var(--kg-radius-lg, 12px);
|
|
24
|
+
border: 1px solid var(--kg-border);
|
|
25
|
+
color: var(--kg-text);
|
|
26
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.card-header {
|
|
33
|
+
padding: 1rem 1.25rem;
|
|
34
|
+
background: var(--kg-surface);
|
|
35
|
+
border-bottom: 1px solid var(--kg-border);
|
|
36
|
+
font-weight: 700;
|
|
37
|
+
font-size: 1.1rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.card-content {
|
|
41
|
+
padding: 1.25rem;
|
|
42
|
+
flex: 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.card-footer {
|
|
46
|
+
padding: 0.75rem 1.25rem;
|
|
47
|
+
background: var(--kg-surface);
|
|
48
|
+
border-top: 1px solid var(--kg-border);
|
|
49
|
+
font-size: 0.9rem;
|
|
50
|
+
color: var(--kg-text-muted);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Variations */
|
|
54
|
+
.raised {
|
|
55
|
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.raised:hover {
|
|
59
|
+
transform: translateY(-4px);
|
|
60
|
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.basic {
|
|
64
|
+
background: transparent;
|
|
65
|
+
border: 1px dashed var(--kg-border);
|
|
66
|
+
box-shadow: none;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.padded .card-content { padding: 2.5rem; }
|
|
70
|
+
|
|
71
|
+
.inverted {
|
|
72
|
+
background: #1B1C1D !important;
|
|
73
|
+
color: #FFFFFF !important;
|
|
74
|
+
border-color: #3d3e3f !important;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.inverted .card-header,
|
|
78
|
+
.inverted .card-footer {
|
|
79
|
+
background: rgba(255, 255, 255, 0.05) !important;
|
|
80
|
+
border-color: rgba(255, 255, 255, 0.1) !important;
|
|
81
|
+
color: #FFFFFF !important;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.inverted .card-footer {
|
|
85
|
+
color: rgba(255, 255, 255, 0.6) !important;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* States / Colors */
|
|
89
|
+
.primary { border-top: 4px solid var(--kg-primary); }
|
|
90
|
+
.secondary { border-top: 4px solid var(--kg-secondary); }
|
|
91
|
+
.tertiary { border-top: 4px solid var(--kg-tertiary); }
|
|
92
|
+
`;
|
|
93
|
+
constructor() {
|
|
94
|
+
super(), this.raised = !1, this.inverted = !1, this.basic = !1, this.padded = !1;
|
|
95
|
+
}
|
|
96
|
+
render() {
|
|
97
|
+
const e = {
|
|
98
|
+
"ui-card": !0,
|
|
99
|
+
raised: this.raised,
|
|
100
|
+
inverted: this.inverted,
|
|
101
|
+
basic: this.basic,
|
|
102
|
+
padded: this.padded,
|
|
103
|
+
[this.color]: !!this.color
|
|
104
|
+
}, o = this.querySelector('[slot="header"]'), t = this.querySelector('[slot="footer"]');
|
|
105
|
+
return r`
|
|
106
|
+
<div class="${s(e)}">
|
|
107
|
+
${o ? r`
|
|
108
|
+
<div class="card-header">
|
|
109
|
+
<slot name="header" @slotchange=${() => this.requestUpdate()}></slot>
|
|
110
|
+
</div>
|
|
111
|
+
` : r`<slot name="header" @slotchange=${() => this.requestUpdate()} style="display:none"></slot>`}
|
|
112
|
+
|
|
113
|
+
<div class="card-content">
|
|
114
|
+
<slot></slot>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
${t ? r`
|
|
118
|
+
<div class="card-footer">
|
|
119
|
+
<slot name="footer" @slotchange=${() => this.requestUpdate()}></slot>
|
|
120
|
+
</div>
|
|
121
|
+
` : r`<slot name="footer" @slotchange=${() => this.requestUpdate()} style="display:none"></slot>`}
|
|
122
|
+
</div>
|
|
123
|
+
`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
customElements.define("kg-card", i);
|
|
127
|
+
export {
|
|
128
|
+
i as kgcard
|
|
129
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { LitElement as i, css as c, html as t } from "lit";
|
|
2
|
+
import { classMap as a } from "lit/directives/class-map.js";
|
|
3
|
+
class s extends i {
|
|
4
|
+
static properties = {
|
|
5
|
+
checked: { type: Boolean, reflect: !0 },
|
|
6
|
+
label: { type: String },
|
|
7
|
+
disabled: { type: Boolean },
|
|
8
|
+
color: { type: String },
|
|
9
|
+
indeterminate: { type: Boolean }
|
|
10
|
+
};
|
|
11
|
+
static styles = c`
|
|
12
|
+
:host {
|
|
13
|
+
display: inline-block;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
user-select: none;
|
|
16
|
+
font-family: inherit;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.kg-checkbox-container {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
gap: 10px;
|
|
23
|
+
position: relative;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.checkbox-box {
|
|
27
|
+
width: 20px;
|
|
28
|
+
height: 20px;
|
|
29
|
+
border: 2px solid var(--kg-border);
|
|
30
|
+
border-radius: 6px;
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
background: var(--kg-bg);
|
|
35
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
36
|
+
position: relative;
|
|
37
|
+
flex-shrink: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.kg-checkbox-container:hover .checkbox-box {
|
|
41
|
+
border-color: var(--checkbox-active-color, var(--kg-primary));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.kg-checkbox-container.checked .checkbox-box {
|
|
45
|
+
background: var(--checkbox-active-color, var(--kg-primary));
|
|
46
|
+
border-color: var(--checkbox-active-color, var(--kg-primary));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Checkmark Icon */
|
|
50
|
+
.checkmark {
|
|
51
|
+
width: 12px;
|
|
52
|
+
height: 12px;
|
|
53
|
+
color: white;
|
|
54
|
+
opacity: 0;
|
|
55
|
+
transform: scale(0.5) rotate(-45deg);
|
|
56
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.checked .checkmark {
|
|
60
|
+
opacity: 1;
|
|
61
|
+
transform: scale(1) rotate(0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Indeterminate state */
|
|
65
|
+
.checkbox-box::after {
|
|
66
|
+
content: '';
|
|
67
|
+
position: absolute;
|
|
68
|
+
width: 10px;
|
|
69
|
+
height: 2px;
|
|
70
|
+
background: white;
|
|
71
|
+
border-radius: 1px;
|
|
72
|
+
opacity: 0;
|
|
73
|
+
transform: scaleX(0.5);
|
|
74
|
+
transition: all 0.2s;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.kg-checkbox-container.indeterminate .checkbox-box {
|
|
78
|
+
background: var(--kg-primary);
|
|
79
|
+
border-color: var(--kg-primary);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.indeterminate .checkbox-box::after {
|
|
83
|
+
opacity: 1;
|
|
84
|
+
transform: scaleX(1);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.label-text {
|
|
88
|
+
font-size: 0.95rem;
|
|
89
|
+
color: var(--kg-text);
|
|
90
|
+
transition: color 0.2s;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* States */
|
|
94
|
+
.disabled {
|
|
95
|
+
opacity: 0.5;
|
|
96
|
+
cursor: not-allowed;
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
constructor() {
|
|
100
|
+
super(), this.checked = !1, this.disabled = !1, this.indeterminate = !1;
|
|
101
|
+
}
|
|
102
|
+
toggle() {
|
|
103
|
+
this.disabled || (this.checked = !this.checked, this.indeterminate = !1, this.dispatchEvent(new CustomEvent("change", {
|
|
104
|
+
detail: { checked: this.checked },
|
|
105
|
+
bubbles: !0,
|
|
106
|
+
composed: !0
|
|
107
|
+
})));
|
|
108
|
+
}
|
|
109
|
+
render() {
|
|
110
|
+
const r = {
|
|
111
|
+
"kg-checkbox-container": !0,
|
|
112
|
+
checked: this.checked,
|
|
113
|
+
disabled: this.disabled,
|
|
114
|
+
indeterminate: this.indeterminate
|
|
115
|
+
}, o = `--checkbox-active-color: ${((e) => e ? e.startsWith("#") || e.startsWith("rgb") || e.startsWith("hsl") ? e : {
|
|
116
|
+
primary: "var(--kg-primary)",
|
|
117
|
+
secondary: "var(--kg-secondary)",
|
|
118
|
+
tertiary: "var(--kg-tertiary)",
|
|
119
|
+
error: "#e74c3c",
|
|
120
|
+
red: "#e74c3c",
|
|
121
|
+
green: "#2ecc71",
|
|
122
|
+
blue: "#3498db",
|
|
123
|
+
orange: "#f39c12",
|
|
124
|
+
purple: "#9b59b6"
|
|
125
|
+
}[e] || `var(--kg-${e}, ${e})` : "var(--kg-primary)")(this.color)};`;
|
|
126
|
+
return t`
|
|
127
|
+
<div
|
|
128
|
+
class="${a(r)}"
|
|
129
|
+
style="${o}"
|
|
130
|
+
@click="${this.toggle}"
|
|
131
|
+
>
|
|
132
|
+
<div class="checkbox-box">
|
|
133
|
+
${this.indeterminate ? "" : t`
|
|
134
|
+
<svg class="checkmark" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round">
|
|
135
|
+
<polyline points="20 6 9 17 4 12"></polyline>
|
|
136
|
+
</svg>
|
|
137
|
+
`}
|
|
138
|
+
</div>
|
|
139
|
+
${this.label ? t`<span class="label-text">${this.label}</span>` : ""}
|
|
140
|
+
</div>
|
|
141
|
+
`;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
customElements.define("kg-checkbox", s);
|
|
145
|
+
export {
|
|
146
|
+
s as kgcheckbox
|
|
147
|
+
};
|