elements-kit 0.9.1 → 0.10.1
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
CHANGED
|
@@ -227,20 +227,22 @@ customElements.define("x-counter", CounterElement);
|
|
|
227
227
|
|
|
228
228
|
### Typed JSX for custom elements
|
|
229
229
|
|
|
230
|
-
Register the tag and augment
|
|
230
|
+
Register the tag and augment `ElementsKit.CustomElementRegistry` in the global namespace — JSX infers the full prop shape (attributes, events, slots, children) from the class itself.
|
|
231
231
|
|
|
232
232
|
```ts
|
|
233
233
|
import { defineElement } from "elements-kit/custom-elements";
|
|
234
234
|
|
|
235
235
|
defineElement("x-counter", CounterElement);
|
|
236
236
|
|
|
237
|
-
declare
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
declare global {
|
|
238
|
+
namespace ElementsKit {
|
|
239
|
+
interface CustomElementRegistry {
|
|
240
|
+
"x-counter": typeof CounterElement;
|
|
241
|
+
}
|
|
240
242
|
}
|
|
241
243
|
}
|
|
242
244
|
|
|
243
|
-
// Now `<x-counter count={5} />` is fully typed
|
|
245
|
+
// Now `<x-counter count={5} />` is fully typed.
|
|
244
246
|
```
|
|
245
247
|
|
|
246
248
|
See [Types](docs/src/content/docs/elements/types.mdx) for the full set of prop-inference helpers.
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
.x-segmented-control {
|
|
2
|
+
vertical-align: top;
|
|
3
|
+
isolation: isolate;
|
|
4
|
+
min-width: max-content;
|
|
5
|
+
color: var(--base-color-12);
|
|
6
|
+
background-color: var(--color-surface);
|
|
7
|
+
background-image: linear-gradient(var(--base-color-a3),
|
|
8
|
+
var(--base-color-a3));
|
|
9
|
+
font-family: var(--default-font-family);
|
|
10
|
+
text-align: center;
|
|
11
|
+
--seg-inset: 1px;
|
|
12
|
+
--seg-transition-duration: .1s;
|
|
13
|
+
--seg-track-radius: max(var(--radius-2), var(--radius-pill));
|
|
14
|
+
--seg-indicator-radius: max(.5px,
|
|
15
|
+
calc(var(--seg-track-radius) - var(--seg-inset)));
|
|
16
|
+
--seg-indicator-bg: var(--color-background);
|
|
17
|
+
border-radius: var(--seg-track-radius);
|
|
18
|
+
border: 0;
|
|
19
|
+
grid-auto-columns: minmax(0, 1fr);
|
|
20
|
+
grid-auto-flow: column;
|
|
21
|
+
align-items: stretch;
|
|
22
|
+
margin: 0;
|
|
23
|
+
padding: 0;
|
|
24
|
+
font-style: normal;
|
|
25
|
+
display: inline-grid;
|
|
26
|
+
position: relative;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:is(.dark, .dark-theme) :where(.x-segmented-control:not(.light, .light-theme)), :is(.dark, .dark-theme):where(.x-segmented-control:not(.light, .light-theme)) {
|
|
30
|
+
--seg-indicator-bg: var(--base-color-a3);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.x-segmented-control > label {
|
|
34
|
+
justify-content: center;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: var(--space-1);
|
|
37
|
+
-webkit-user-select: none;
|
|
38
|
+
user-select: none;
|
|
39
|
+
cursor: var(--cursor-button);
|
|
40
|
+
color: var(--base-color-a11);
|
|
41
|
+
font-weight: var(--font-weight-regular);
|
|
42
|
+
letter-spacing: var(--tab-inactive-letter-spacing);
|
|
43
|
+
transition: color var(--seg-transition-duration);
|
|
44
|
+
display: flex;
|
|
45
|
+
position: relative;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.x-segmented-control > label:where(:first-child) {
|
|
49
|
+
border-top-left-radius: inherit;
|
|
50
|
+
border-bottom-left-radius: inherit;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.x-segmented-control > label:where(:last-child) {
|
|
54
|
+
border-top-right-radius: inherit;
|
|
55
|
+
border-bottom-right-radius: inherit;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.x-segmented-control :where(input[type="radio"]) {
|
|
59
|
+
white-space: nowrap;
|
|
60
|
+
clip-path: inset(50%);
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
appearance: none;
|
|
63
|
+
border: 0;
|
|
64
|
+
width: 1px;
|
|
65
|
+
height: 1px;
|
|
66
|
+
margin: -1px;
|
|
67
|
+
padding: 0;
|
|
68
|
+
position: absolute;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.x-segmented-control > label:where(:has(:checked)) {
|
|
73
|
+
color: var(--base-color-12);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.x-segmented-control > label:where(:has(:focus-visible)) {
|
|
77
|
+
outline: 2px solid var(--focus-8);
|
|
78
|
+
outline-offset: -1px;
|
|
79
|
+
border-radius: inherit;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@media (hover: hover) {
|
|
83
|
+
.x-segmented-control > label:where(:not(:has(:checked, :disabled)):hover) {
|
|
84
|
+
background-color: var(--base-color-a2);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.x-segmented-control > label + label:after {
|
|
89
|
+
content: "";
|
|
90
|
+
inset-inline-start: 0;
|
|
91
|
+
top: var(--seg-inset);
|
|
92
|
+
bottom: var(--seg-inset);
|
|
93
|
+
background-color: var(--base-color-a4);
|
|
94
|
+
z-index: -1;
|
|
95
|
+
width: 1px;
|
|
96
|
+
transition: opacity var(--seg-transition-duration) ease-out;
|
|
97
|
+
margin-inline-start: -.5px;
|
|
98
|
+
position: absolute;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.x-segmented-control > label:where(:has(:checked, :focus-visible)):after, .x-segmented-control > label:where(:has(:checked, :focus-visible)) + label:after {
|
|
102
|
+
opacity: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.x-segmented-control > label:before {
|
|
106
|
+
content: "";
|
|
107
|
+
inset: var(--seg-inset);
|
|
108
|
+
z-index: -1;
|
|
109
|
+
background-color: var(--seg-indicator-bg);
|
|
110
|
+
border-radius: var(--seg-indicator-radius);
|
|
111
|
+
box-shadow: 0 0 0 .5px var(--base-color-a3),
|
|
112
|
+
0 1px 2px var(--base-color-a4);
|
|
113
|
+
opacity: 0;
|
|
114
|
+
transition: opacity var(--seg-transition-duration) ease-out;
|
|
115
|
+
position: absolute;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.x-segmented-control > label:where(:has(:checked)):before {
|
|
119
|
+
opacity: 1;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@supports (anchor-name: --x) {
|
|
123
|
+
.x-segmented-control > label:before {
|
|
124
|
+
display: none;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.x-segmented-control > label:where(:has(:checked)) {
|
|
128
|
+
anchor-name: --x-seg-active;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.x-segmented-control:after {
|
|
132
|
+
content: "";
|
|
133
|
+
z-index: -1;
|
|
134
|
+
top: var(--seg-inset);
|
|
135
|
+
bottom: var(--seg-inset);
|
|
136
|
+
left: anchor(--x-seg-active left);
|
|
137
|
+
right: anchor(--x-seg-active right);
|
|
138
|
+
background-color: var(--seg-indicator-bg);
|
|
139
|
+
border-radius: var(--seg-indicator-radius);
|
|
140
|
+
width: auto;
|
|
141
|
+
box-shadow: 0 0 0 .5px var(--base-color-a3),
|
|
142
|
+
0 1px 2px var(--base-color-a4);
|
|
143
|
+
transition: left var(--seg-transition-duration) cubic-bezier(.45, .05, .55, .95),
|
|
144
|
+
right var(--seg-transition-duration) cubic-bezier(.45, .05, .55, .95);
|
|
145
|
+
position: absolute;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.x-segmented-control:not(:has(:checked)):after {
|
|
149
|
+
display: none;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.x-segmented-control:where(:disabled, [data-disabled]) {
|
|
154
|
+
color: var(--base-color-a8);
|
|
155
|
+
background-image: linear-gradient(var(--base-color-a2),
|
|
156
|
+
var(--base-color-a2));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.x-segmented-control:where(:disabled, [data-disabled]) > label, .x-segmented-control > label:where(:has(:disabled)) {
|
|
160
|
+
cursor: var(--cursor-disabled);
|
|
161
|
+
color: var(--base-color-a8);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.x-segmented-control:where(:disabled, [data-disabled]) > label:before, .x-segmented-control > label:where(:has(:disabled)):before {
|
|
165
|
+
background-color: var(--base-color-a3);
|
|
166
|
+
box-shadow: none;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@supports (anchor-name: --x) {
|
|
170
|
+
.x-segmented-control:where(:disabled, [data-disabled]):after, .x-segmented-control:where(:has( > label:where(:has(:disabled)):has(:checked))):after {
|
|
171
|
+
background-color: var(--base-color-a3);
|
|
172
|
+
box-shadow: none;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@media (prefers-reduced-motion: reduce) {
|
|
177
|
+
.x-segmented-control, .x-segmented-control > label, .x-segmented-control > label:before, .x-segmented-control > label + label:after, .x-segmented-control:after {
|
|
178
|
+
transition: none;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@media (forced-colors: active) {
|
|
183
|
+
.x-segmented-control {
|
|
184
|
+
background-image: none;
|
|
185
|
+
border: 1px solid buttontext;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.x-segmented-control > label {
|
|
189
|
+
color: buttontext;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.x-segmented-control > label:where(:has(:checked)) {
|
|
193
|
+
color: highlighttext;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.x-segmented-control > label:before, .x-segmented-control:after {
|
|
197
|
+
box-shadow: none;
|
|
198
|
+
background-color: highlight;
|
|
199
|
+
border: 1px solid highlighttext;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.x-segmented-control > label:where(:has(:focus-visible)) {
|
|
203
|
+
outline-color: highlight;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.x-segmented-control:where(:not([data-size])), .x-segmented-control:where([data-size="2"]) {
|
|
208
|
+
height: var(--space-6);
|
|
209
|
+
--seg-track-radius: max(var(--radius-2), var(--radius-pill));
|
|
210
|
+
font-size: var(--font-size-2);
|
|
211
|
+
line-height: var(--line-height-2);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
:is(.x-segmented-control:where(:not([data-size])), .x-segmented-control:where([data-size="2"])) > label {
|
|
215
|
+
padding-inline: var(--space-3);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.x-segmented-control:where([data-size="1"]) {
|
|
219
|
+
height: var(--space-5);
|
|
220
|
+
--seg-track-radius: max(var(--radius-1), var(--radius-pill));
|
|
221
|
+
font-size: var(--font-size-1);
|
|
222
|
+
line-height: var(--line-height-1);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.x-segmented-control:where([data-size="1"]) > label {
|
|
226
|
+
padding-inline: var(--space-2);
|
|
227
|
+
gap: var(--space-1);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.x-segmented-control:where([data-size="3"]) {
|
|
231
|
+
height: var(--space-7);
|
|
232
|
+
--seg-track-radius: max(var(--radius-3), var(--radius-pill));
|
|
233
|
+
font-size: var(--font-size-3);
|
|
234
|
+
line-height: var(--line-height-3);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.x-segmented-control:where([data-size="3"]) > label {
|
|
238
|
+
padding-inline: var(--space-4);
|
|
239
|
+
gap: var(--space-2);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.x-segmented-control:where([data-variant="soft"]) {
|
|
243
|
+
background-image: linear-gradient(var(--color-a3), var(--color-a3));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.x-segmented-control:where([data-variant="soft"]) > label {
|
|
247
|
+
color: var(--color-a11);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.x-segmented-control:where([data-variant="soft"]) > label:where(:has(:checked)) {
|
|
251
|
+
color: var(--color-a12, var(--color-12));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.x-segmented-control:where([data-variant="soft"]) > label + label:after {
|
|
255
|
+
background-color: var(--color-a4);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.x-segmented-control:where([data-high-contrast]) > label:where(:has(:checked)) {
|
|
259
|
+
color: var(--base-color-12);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.x-segmented-control:where([data-high-contrast][data-variant="soft"]) > label:where(:has(:checked)) {
|
|
263
|
+
color: var(--color-12);
|
|
264
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elements-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.1",
|
|
5
5
|
"description": "A lightweight reactive UI library that transforms native HTMLElements into reactive components with signals. Ideal for framework-agnostic applications and web components.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"webcomponents",
|