@sekiui/elements 0.0.28 → 0.0.31
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/dist/cjs/{index-B1pILoQg.js → index-dzrwTIbP.js} +96 -2
- package/dist/cjs/index.cjs.js +84 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/seki-button.cjs.entry.js +2 -2
- package/dist/cjs/seki-input.cjs.entry.js +2 -2
- package/dist/cjs/seki-skeleton.cjs.entry.js +2 -2
- package/dist/cjs/seki-switch.cjs.entry.js +8 -0
- package/dist/cjs/sekiui.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/button/seki-button.js +1 -1
- package/dist/collection/components/input/seki-input.js +1 -1
- package/dist/collection/components/skeleton/seki-skeleton.js +1 -1
- package/dist/collection/components/switch/seki-switch.css +94 -0
- package/dist/collection/components/switch/seki-switch.js +294 -0
- package/dist/collection/index.js +1 -1
- package/dist/components/index.js +104 -1185
- package/dist/components/p--oknAIA5.js +1274 -0
- package/dist/components/seki-button.js +2 -2
- package/dist/components/seki-input.js +2 -2
- package/dist/components/seki-skeleton.js +2 -2
- package/dist/components/seki-switch.d.ts +11 -0
- package/dist/components/seki-switch.js +6 -0
- package/dist/esm/{index-CLC2YwJ6.js → index-F_LoNrhC.js} +96 -3
- package/dist/esm/index.js +83 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/seki-button.entry.js +2 -2
- package/dist/esm/seki-input.entry.js +2 -2
- package/dist/esm/seki-skeleton.entry.js +2 -2
- package/dist/esm/seki-switch.entry.js +2 -0
- package/dist/esm/sekiui.js +3 -3
- package/dist/sekiui/index.esm.js +1 -0
- package/dist/sekiui/{p-6573bc92.entry.js → p-23858479.entry.js} +1 -1
- package/dist/sekiui/p-3a4a98f8.entry.js +1 -0
- package/dist/sekiui/p-F_LoNrhC.js +2 -0
- package/dist/sekiui/{p-5d3011e0.entry.js → p-a22c9d08.entry.js} +1 -1
- package/dist/sekiui/{p-10c9b8b2.entry.js → p-b0298d88.entry.js} +1 -1
- package/dist/sekiui/sekiui.esm.js +1 -1
- package/dist/types/components/switch/seki-switch.d.ts +71 -0
- package/dist/types/components.d.ts +128 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/sekiui/p-CLC2YwJ6.js +0 -2
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
/**
|
|
3
|
+
* @component seki-switch
|
|
4
|
+
* @description An accessible toggle control for binary on/off states with full keyboard navigation,
|
|
5
|
+
* ARIA support, form integration, and theme compatibility.
|
|
6
|
+
* @example
|
|
7
|
+
* <seki-switch></seki-switch>
|
|
8
|
+
* <seki-switch checked></seki-switch>
|
|
9
|
+
* <seki-switch disabled></seki-switch>
|
|
10
|
+
*/
|
|
11
|
+
export class SekiSwitch {
|
|
12
|
+
constructor() {
|
|
13
|
+
/**
|
|
14
|
+
* @description Initial checked state for uncontrolled mode. Ignored if checked prop is provided.
|
|
15
|
+
*/
|
|
16
|
+
this.defaultChecked = false;
|
|
17
|
+
/**
|
|
18
|
+
* @description Disables all interactions when true.
|
|
19
|
+
*/
|
|
20
|
+
this.disabled = false;
|
|
21
|
+
/**
|
|
22
|
+
* @description Marks switch as required for form validation.
|
|
23
|
+
*/
|
|
24
|
+
this.required = false;
|
|
25
|
+
/**
|
|
26
|
+
* @description Value sent in form data when switch is checked. Defaults to 'on'.
|
|
27
|
+
*/
|
|
28
|
+
this.value = 'on';
|
|
29
|
+
/**
|
|
30
|
+
* @description Internal checked state for uncontrolled mode.
|
|
31
|
+
*/
|
|
32
|
+
this.internalChecked = false;
|
|
33
|
+
/**
|
|
34
|
+
* Toggle switch state and emit event
|
|
35
|
+
*/
|
|
36
|
+
this.toggle = () => {
|
|
37
|
+
if (this.disabled) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const newCheckedState = !this.isChecked;
|
|
41
|
+
// Update internal state only in uncontrolled mode
|
|
42
|
+
if (this.checked === undefined) {
|
|
43
|
+
this.internalChecked = newCheckedState;
|
|
44
|
+
}
|
|
45
|
+
// Always emit event (for both controlled and uncontrolled)
|
|
46
|
+
this.sekiChange.emit({ checked: newCheckedState });
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Handle click events
|
|
50
|
+
*/
|
|
51
|
+
this.handleClick = () => {
|
|
52
|
+
this.toggle();
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Initialize internal checked state from defaultChecked
|
|
57
|
+
*/
|
|
58
|
+
componentWillLoad() {
|
|
59
|
+
this.internalChecked = this.defaultChecked;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get current checked state (controlled vs uncontrolled)
|
|
63
|
+
*/
|
|
64
|
+
get isChecked() {
|
|
65
|
+
return this.checked !== undefined ? this.checked : this.internalChecked;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Handle keyboard events (Space and Enter keys)
|
|
69
|
+
*/
|
|
70
|
+
handleKeyDown(event) {
|
|
71
|
+
if (this.disabled) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// Toggle on Space or Enter
|
|
75
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
76
|
+
event.preventDefault(); // Prevent page scroll on Space
|
|
77
|
+
this.toggle();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
render() {
|
|
81
|
+
const isChecked = this.isChecked;
|
|
82
|
+
const dataState = isChecked ? 'checked' : 'unchecked';
|
|
83
|
+
return (h(Host, { key: 'af5412cee9d097e57d8e626522619913b7459e4b', "data-state": dataState, "data-disabled": this.disabled ? '' : null }, h("div", { key: 'a2c15a3f6b33b4e98e215d82c14cba9dd47bd951', class: "switch", part: "switch", role: "switch", "aria-checked": isChecked ? 'true' : 'false', "aria-disabled": this.disabled ? 'true' : undefined, "aria-label": this.ariaLabel || undefined, "aria-required": this.required ? 'true' : undefined, tabindex: this.disabled ? -1 : 0, onClick: this.handleClick }, h("span", { key: '51fb815c2710b8fd5ac12bdc90b09c44a3bf9b24', class: "thumb", part: "thumb" })), this.name && (h("input", { key: '37f059d43e01b82c9fc3e6f1f1df5c894e8a6102', type: "checkbox", name: this.name, value: this.value, checked: isChecked, required: this.required, disabled: this.disabled, style: { display: 'none' }, tabindex: -1, "aria-hidden": "true" }))));
|
|
84
|
+
}
|
|
85
|
+
static get is() { return "seki-switch"; }
|
|
86
|
+
static get encapsulation() { return "shadow"; }
|
|
87
|
+
static get originalStyleUrls() {
|
|
88
|
+
return {
|
|
89
|
+
"$": ["seki-switch.css"]
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
static get styleUrls() {
|
|
93
|
+
return {
|
|
94
|
+
"$": ["seki-switch.css"]
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
static get properties() {
|
|
98
|
+
return {
|
|
99
|
+
"checked": {
|
|
100
|
+
"type": "boolean",
|
|
101
|
+
"mutable": false,
|
|
102
|
+
"complexType": {
|
|
103
|
+
"original": "boolean",
|
|
104
|
+
"resolved": "boolean | undefined",
|
|
105
|
+
"references": {}
|
|
106
|
+
},
|
|
107
|
+
"required": false,
|
|
108
|
+
"optional": true,
|
|
109
|
+
"docs": {
|
|
110
|
+
"tags": [{
|
|
111
|
+
"name": "description",
|
|
112
|
+
"text": "Controlled checked state. When provided, component operates in controlled mode."
|
|
113
|
+
}],
|
|
114
|
+
"text": ""
|
|
115
|
+
},
|
|
116
|
+
"getter": false,
|
|
117
|
+
"setter": false,
|
|
118
|
+
"reflect": false,
|
|
119
|
+
"attribute": "checked"
|
|
120
|
+
},
|
|
121
|
+
"defaultChecked": {
|
|
122
|
+
"type": "boolean",
|
|
123
|
+
"mutable": false,
|
|
124
|
+
"complexType": {
|
|
125
|
+
"original": "boolean",
|
|
126
|
+
"resolved": "boolean",
|
|
127
|
+
"references": {}
|
|
128
|
+
},
|
|
129
|
+
"required": false,
|
|
130
|
+
"optional": false,
|
|
131
|
+
"docs": {
|
|
132
|
+
"tags": [{
|
|
133
|
+
"name": "description",
|
|
134
|
+
"text": "Initial checked state for uncontrolled mode. Ignored if checked prop is provided."
|
|
135
|
+
}],
|
|
136
|
+
"text": ""
|
|
137
|
+
},
|
|
138
|
+
"getter": false,
|
|
139
|
+
"setter": false,
|
|
140
|
+
"reflect": false,
|
|
141
|
+
"attribute": "default-checked",
|
|
142
|
+
"defaultValue": "false"
|
|
143
|
+
},
|
|
144
|
+
"disabled": {
|
|
145
|
+
"type": "boolean",
|
|
146
|
+
"mutable": false,
|
|
147
|
+
"complexType": {
|
|
148
|
+
"original": "boolean",
|
|
149
|
+
"resolved": "boolean",
|
|
150
|
+
"references": {}
|
|
151
|
+
},
|
|
152
|
+
"required": false,
|
|
153
|
+
"optional": false,
|
|
154
|
+
"docs": {
|
|
155
|
+
"tags": [{
|
|
156
|
+
"name": "description",
|
|
157
|
+
"text": "Disables all interactions when true."
|
|
158
|
+
}],
|
|
159
|
+
"text": ""
|
|
160
|
+
},
|
|
161
|
+
"getter": false,
|
|
162
|
+
"setter": false,
|
|
163
|
+
"reflect": false,
|
|
164
|
+
"attribute": "disabled",
|
|
165
|
+
"defaultValue": "false"
|
|
166
|
+
},
|
|
167
|
+
"required": {
|
|
168
|
+
"type": "boolean",
|
|
169
|
+
"mutable": false,
|
|
170
|
+
"complexType": {
|
|
171
|
+
"original": "boolean",
|
|
172
|
+
"resolved": "boolean",
|
|
173
|
+
"references": {}
|
|
174
|
+
},
|
|
175
|
+
"required": false,
|
|
176
|
+
"optional": false,
|
|
177
|
+
"docs": {
|
|
178
|
+
"tags": [{
|
|
179
|
+
"name": "description",
|
|
180
|
+
"text": "Marks switch as required for form validation."
|
|
181
|
+
}],
|
|
182
|
+
"text": ""
|
|
183
|
+
},
|
|
184
|
+
"getter": false,
|
|
185
|
+
"setter": false,
|
|
186
|
+
"reflect": false,
|
|
187
|
+
"attribute": "required",
|
|
188
|
+
"defaultValue": "false"
|
|
189
|
+
},
|
|
190
|
+
"name": {
|
|
191
|
+
"type": "string",
|
|
192
|
+
"mutable": false,
|
|
193
|
+
"complexType": {
|
|
194
|
+
"original": "string",
|
|
195
|
+
"resolved": "string | undefined",
|
|
196
|
+
"references": {}
|
|
197
|
+
},
|
|
198
|
+
"required": false,
|
|
199
|
+
"optional": true,
|
|
200
|
+
"docs": {
|
|
201
|
+
"tags": [{
|
|
202
|
+
"name": "description",
|
|
203
|
+
"text": "Form field name for form integration."
|
|
204
|
+
}],
|
|
205
|
+
"text": ""
|
|
206
|
+
},
|
|
207
|
+
"getter": false,
|
|
208
|
+
"setter": false,
|
|
209
|
+
"reflect": false,
|
|
210
|
+
"attribute": "name"
|
|
211
|
+
},
|
|
212
|
+
"value": {
|
|
213
|
+
"type": "string",
|
|
214
|
+
"mutable": false,
|
|
215
|
+
"complexType": {
|
|
216
|
+
"original": "string",
|
|
217
|
+
"resolved": "string",
|
|
218
|
+
"references": {}
|
|
219
|
+
},
|
|
220
|
+
"required": false,
|
|
221
|
+
"optional": false,
|
|
222
|
+
"docs": {
|
|
223
|
+
"tags": [{
|
|
224
|
+
"name": "description",
|
|
225
|
+
"text": "Value sent in form data when switch is checked. Defaults to 'on'."
|
|
226
|
+
}],
|
|
227
|
+
"text": ""
|
|
228
|
+
},
|
|
229
|
+
"getter": false,
|
|
230
|
+
"setter": false,
|
|
231
|
+
"reflect": false,
|
|
232
|
+
"attribute": "value",
|
|
233
|
+
"defaultValue": "'on'"
|
|
234
|
+
},
|
|
235
|
+
"ariaLabel": {
|
|
236
|
+
"type": "string",
|
|
237
|
+
"mutable": false,
|
|
238
|
+
"complexType": {
|
|
239
|
+
"original": "string",
|
|
240
|
+
"resolved": "string | undefined",
|
|
241
|
+
"references": {}
|
|
242
|
+
},
|
|
243
|
+
"required": false,
|
|
244
|
+
"optional": true,
|
|
245
|
+
"docs": {
|
|
246
|
+
"tags": [{
|
|
247
|
+
"name": "description",
|
|
248
|
+
"text": "Accessible label for standalone switches without associated label elements."
|
|
249
|
+
}],
|
|
250
|
+
"text": ""
|
|
251
|
+
},
|
|
252
|
+
"getter": false,
|
|
253
|
+
"setter": false,
|
|
254
|
+
"reflect": false,
|
|
255
|
+
"attribute": "aria-label"
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
static get states() {
|
|
260
|
+
return {
|
|
261
|
+
"internalChecked": {}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
static get events() {
|
|
265
|
+
return [{
|
|
266
|
+
"method": "sekiChange",
|
|
267
|
+
"name": "sekiChange",
|
|
268
|
+
"bubbles": true,
|
|
269
|
+
"cancelable": true,
|
|
270
|
+
"composed": true,
|
|
271
|
+
"docs": {
|
|
272
|
+
"tags": [{
|
|
273
|
+
"name": "description",
|
|
274
|
+
"text": "Emitted when checked state changes (user interaction or programmatic)."
|
|
275
|
+
}],
|
|
276
|
+
"text": ""
|
|
277
|
+
},
|
|
278
|
+
"complexType": {
|
|
279
|
+
"original": "{ checked: boolean }",
|
|
280
|
+
"resolved": "{ checked: boolean; }",
|
|
281
|
+
"references": {}
|
|
282
|
+
}
|
|
283
|
+
}];
|
|
284
|
+
}
|
|
285
|
+
static get listeners() {
|
|
286
|
+
return [{
|
|
287
|
+
"name": "keydown",
|
|
288
|
+
"method": "handleKeyDown",
|
|
289
|
+
"target": undefined,
|
|
290
|
+
"capture": false,
|
|
291
|
+
"passive": false
|
|
292
|
+
}];
|
|
293
|
+
}
|
|
294
|
+
}
|
package/dist/collection/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { SekiSwitch } from './components/switch/seki-switch';
|