@sekiui/elements 0.0.28 → 0.0.29

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 (42) hide show
  1. package/dist/cjs/{index-B1pILoQg.js → index-dzrwTIbP.js} +96 -2
  2. package/dist/cjs/index.cjs.js +84 -0
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/seki-button.cjs.entry.js +2 -2
  5. package/dist/cjs/seki-input.cjs.entry.js +2 -2
  6. package/dist/cjs/seki-skeleton.cjs.entry.js +2 -2
  7. package/dist/cjs/seki-switch.cjs.entry.js +8 -0
  8. package/dist/cjs/sekiui.cjs.js +2 -2
  9. package/dist/collection/collection-manifest.json +1 -0
  10. package/dist/collection/components/button/seki-button.js +1 -1
  11. package/dist/collection/components/input/seki-input.js +1 -1
  12. package/dist/collection/components/skeleton/seki-skeleton.js +1 -1
  13. package/dist/collection/components/switch/seki-switch.css +94 -0
  14. package/dist/collection/components/switch/seki-switch.js +294 -0
  15. package/dist/collection/index.js +1 -1
  16. package/dist/components/index.js +104 -1185
  17. package/dist/components/p--oknAIA5.js +1274 -0
  18. package/dist/components/seki-button.js +2 -2
  19. package/dist/components/seki-input.js +2 -2
  20. package/dist/components/seki-skeleton.js +2 -2
  21. package/dist/components/seki-switch.d.ts +11 -0
  22. package/dist/components/seki-switch.js +6 -0
  23. package/dist/esm/{index-CLC2YwJ6.js → index-F_LoNrhC.js} +96 -3
  24. package/dist/esm/index.js +83 -0
  25. package/dist/esm/loader.js +3 -3
  26. package/dist/esm/seki-button.entry.js +2 -2
  27. package/dist/esm/seki-input.entry.js +2 -2
  28. package/dist/esm/seki-skeleton.entry.js +2 -2
  29. package/dist/esm/seki-switch.entry.js +2 -0
  30. package/dist/esm/sekiui.js +3 -3
  31. package/dist/sekiui/index.esm.js +1 -0
  32. package/dist/sekiui/{p-6573bc92.entry.js → p-23858479.entry.js} +1 -1
  33. package/dist/sekiui/p-3a4a98f8.entry.js +1 -0
  34. package/dist/sekiui/p-F_LoNrhC.js +2 -0
  35. package/dist/sekiui/{p-5d3011e0.entry.js → p-a22c9d08.entry.js} +1 -1
  36. package/dist/sekiui/{p-10c9b8b2.entry.js → p-b0298d88.entry.js} +1 -1
  37. package/dist/sekiui/sekiui.esm.js +1 -1
  38. package/dist/types/components/switch/seki-switch.d.ts +71 -0
  39. package/dist/types/components.d.ts +128 -0
  40. package/dist/types/index.d.ts +1 -0
  41. package/package.json +1 -1
  42. package/dist/sekiui/p-CLC2YwJ6.js +0 -2
@@ -1,1193 +1,112 @@
1
- const NAMESPACE = 'sekiui';
2
- const BUILD = /* sekiui */ { hydratedSelectorName: "hydrated", lazyLoad: false, propChangeCallback: false, updatable: true};
3
-
4
- /*
5
- Stencil Client Platform v4.38.0 | MIT Licensed | https://stenciljs.com
6
- */
7
- var __defProp = Object.defineProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
-
13
- // src/client/client-host-ref.ts
14
- var getHostRef = (ref) => {
15
- if (ref.__stencil__getHostRef) {
16
- return ref.__stencil__getHostRef();
17
- }
18
- return void 0;
19
- };
20
- var registerHost = (hostElement, cmpMeta) => {
21
- const hostRef = {
22
- $flags$: 0,
23
- $hostElement$: hostElement,
24
- $cmpMeta$: cmpMeta,
25
- $instanceValues$: /* @__PURE__ */ new Map(),
26
- $serializerValues$: /* @__PURE__ */ new Map()
27
- };
28
- {
29
- hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
30
- hostElement["s-p"] = [];
31
- hostElement["s-rc"] = [];
32
- }
33
- const ref = hostRef;
34
- hostElement.__stencil__getHostRef = () => ref;
35
- return ref;
36
- };
37
- var isMemberInElement = (elm, memberName) => memberName in elm;
38
- var consoleError = (e, el) => (0, console.error)(e, el);
39
-
40
- // src/client/client-style.ts
41
- var styles = /* @__PURE__ */ new Map();
42
- var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
43
- var win = typeof window !== "undefined" ? window : {};
44
- var H = win.HTMLElement || class {
45
- };
46
- var plt = {
47
- $flags$: 0,
48
- $resourcesUrl$: "",
49
- jmp: (h2) => h2(),
50
- raf: (h2) => requestAnimationFrame(h2),
51
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
52
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
53
- ce: (eventName, opts) => new CustomEvent(eventName, opts)
54
- };
55
- var promiseResolve = (v) => Promise.resolve(v);
56
- var supportsConstructableStylesheets = /* @__PURE__ */ (() => {
57
- try {
58
- new CSSStyleSheet();
59
- return typeof new CSSStyleSheet().replaceSync === "function";
60
- } catch (e) {
61
- }
62
- return false;
63
- })() ;
64
- var supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? /* @__PURE__ */ (() => !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable)() : false;
65
- var queuePending = false;
66
- var queueDomReads = [];
67
- var queueDomWrites = [];
68
- var queueTask = (queue, write) => (cb) => {
69
- queue.push(cb);
70
- if (!queuePending) {
71
- queuePending = true;
72
- if (write && plt.$flags$ & 4 /* queueSync */) {
73
- nextTick(flush);
74
- } else {
75
- plt.raf(flush);
76
- }
77
- }
78
- };
79
- var consume = (queue) => {
80
- for (let i2 = 0; i2 < queue.length; i2++) {
81
- try {
82
- queue[i2](performance.now());
83
- } catch (e) {
84
- consoleError(e);
85
- }
86
- }
87
- queue.length = 0;
88
- };
89
- var flush = () => {
90
- consume(queueDomReads);
91
- {
92
- consume(queueDomWrites);
93
- if (queuePending = queueDomReads.length > 0) {
94
- plt.raf(flush);
95
- }
96
- }
97
- };
98
- var nextTick = (cb) => promiseResolve().then(cb);
99
- var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
100
-
101
- // src/runtime/asset-path.ts
102
- var getAssetPath = (path) => {
103
- const assetUrl = new URL(path, plt.$resourcesUrl$);
104
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
105
- };
106
- var setAssetPath = (path) => plt.$resourcesUrl$ = path;
107
- var isComplexType = (o) => {
108
- o = typeof o;
109
- return o === "object" || o === "function";
110
- };
111
-
112
- // src/utils/query-nonce-meta-tag-content.ts
113
- function queryNonceMetaTagContent(doc) {
114
- var _a, _b, _c;
115
- return (_c = (_b = (_a = doc.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
116
- }
117
-
118
- // src/utils/regular-expression.ts
119
- var escapeRegExpSpecialCharacters = (text) => {
120
- return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
121
- };
122
-
123
- // src/utils/result.ts
124
- var result_exports = {};
125
- __export(result_exports, {
126
- err: () => err,
127
- map: () => map,
128
- ok: () => ok,
129
- unwrap: () => unwrap,
130
- unwrapErr: () => unwrapErr
131
- });
132
- var ok = (value) => ({
133
- isOk: true,
134
- isErr: false,
135
- value
136
- });
137
- var err = (value) => ({
138
- isOk: false,
139
- isErr: true,
140
- value
141
- });
142
- function map(result, fn) {
143
- if (result.isOk) {
144
- const val = fn(result.value);
145
- if (val instanceof Promise) {
146
- return val.then((newVal) => ok(newVal));
147
- } else {
148
- return ok(val);
149
- }
150
- }
151
- if (result.isErr) {
152
- const value = result.value;
153
- return err(value);
154
- }
155
- throw "should never get here";
156
- }
157
- var unwrap = (result) => {
158
- if (result.isOk) {
159
- return result.value;
160
- } else {
161
- throw result.value;
162
- }
163
- };
164
- var unwrapErr = (result) => {
165
- if (result.isErr) {
166
- return result.value;
167
- } else {
168
- throw result.value;
169
- }
170
- };
171
-
172
- // src/utils/style.ts
173
- function createStyleSheetIfNeededAndSupported(styles2) {
174
- return void 0;
175
- }
176
-
177
- // src/utils/shadow-root.ts
178
- var globalStyleSheet;
179
- function createShadowRoot(cmpMeta) {
180
- var _a;
181
- const shadowRoot = this.attachShadow({ mode: "open" });
182
- if (globalStyleSheet === void 0) globalStyleSheet = (_a = createStyleSheetIfNeededAndSupported()) != null ? _a : null;
183
- if (globalStyleSheet) {
184
- if (supportsMutableAdoptedStyleSheets) {
185
- shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
186
- } else {
187
- shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
188
- }
189
- }
190
- }
191
- var createTime = (fnName, tagName = "") => {
192
- {
193
- return () => {
194
- return;
195
- };
196
- }
197
- };
198
- var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
199
- var registerStyle = (scopeId2, cssText, allowCS) => {
200
- let style = styles.get(scopeId2);
201
- if (supportsConstructableStylesheets && allowCS) {
202
- style = style || new CSSStyleSheet();
203
- if (typeof style === "string") {
204
- style = cssText;
205
- } else {
206
- style.replaceSync(cssText);
207
- }
208
- } else {
209
- style = cssText;
210
- }
211
- styles.set(scopeId2, style);
212
- };
213
- var addStyle = (styleContainerNode, cmpMeta, mode) => {
214
- var _a;
215
- const scopeId2 = getScopeId(cmpMeta);
216
- const style = styles.get(scopeId2);
217
- if (!win.document) {
218
- return scopeId2;
219
- }
220
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : win.document;
221
- if (style) {
222
- if (typeof style === "string") {
223
- styleContainerNode = styleContainerNode.head || styleContainerNode;
224
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
225
- let styleElm;
226
- if (!appliedStyles) {
227
- rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
228
- }
229
- if (!appliedStyles.has(scopeId2)) {
230
- {
231
- styleElm = win.document.createElement("style");
232
- styleElm.innerHTML = style;
233
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
234
- if (nonce != null) {
235
- styleElm.setAttribute("nonce", nonce);
236
- }
237
- if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
238
- if (styleContainerNode.nodeName === "HEAD") {
239
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
240
- const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
241
- styleContainerNode.insertBefore(
242
- styleElm,
243
- (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
244
- );
245
- } else if ("host" in styleContainerNode) {
246
- if (supportsConstructableStylesheets) {
247
- const stylesheet = new CSSStyleSheet();
248
- stylesheet.replaceSync(style);
249
- if (supportsMutableAdoptedStyleSheets) {
250
- styleContainerNode.adoptedStyleSheets.unshift(stylesheet);
251
- } else {
252
- styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
253
- }
254
- } else {
255
- const existingStyleContainer = styleContainerNode.querySelector("style");
256
- if (existingStyleContainer) {
257
- existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
258
- } else {
259
- styleContainerNode.prepend(styleElm);
260
- }
261
- }
262
- } else {
263
- styleContainerNode.append(styleElm);
1
+ import { p as proxyCustomElement, H, c as createEvent, h, a as Host } from './p--oknAIA5.js';
2
+ export { g as getAssetPath, r as render, s as setAssetPath, b as setNonce, d as setPlatformOptions } from './p--oknAIA5.js';
3
+
4
+ const sekiSwitchCss = ":host{display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px}.switch{width:var(--seki-switch-width, 2.75rem);height:var(--seki-switch-height, 1.5rem);position:relative;display:inline-flex;align-items:center;flex-shrink:0;background-color:var(--seki-switch-bg-unchecked, hsl(var(--muted, 240 4.8% 95.9%)));border-radius:9999px;cursor:pointer;transition:background-color var(--seki-switch-transition-duration, 150ms) ease-out;outline:none}.switch:focus-visible{outline:2px solid var(--seki-switch-focus-ring, hsl(var(--ring, 240 5% 64.9%)));outline-offset:2px}:host([data-state=\"checked\"]) .switch{background-color:var(--seki-switch-bg-checked, hsl(var(--primary, 240 5.9% 10%)))}:host([data-disabled]) .switch{background-color:var(--seki-switch-bg-disabled, hsl(var(--muted, 240 4.8% 95.9%) / 0.5));cursor:not-allowed;opacity:0.5}.thumb{width:var(--seki-switch-thumb-size, 1.25rem);height:var(--seki-switch-thumb-size, 1.25rem);background-color:var(--seki-switch-thumb-bg, hsl(var(--background, 0 0% 100%)));position:absolute;left:0.125rem;border-radius:50%;box-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);transition:transform var(--seki-switch-transition-duration, 150ms) ease-out;pointer-events:none}:host([data-state=\"checked\"]) .thumb{transform:translateX(calc(var(--seki-switch-width, 2.75rem) - var(--seki-switch-thumb-size, 1.25rem) - 0.25rem))}@media (prefers-color-scheme: dark){.switch{--seki-switch-bg-unchecked:hsl(var(--muted, 240 3.7% 15.9%))}.thumb{--seki-switch-thumb-bg:hsl(var(--background, 240 10% 3.9%))}}";
5
+
6
+ const SekiSwitch = /*@__PURE__*/ proxyCustomElement(class SekiSwitch extends H {
7
+ constructor(registerHost) {
8
+ super();
9
+ if (registerHost !== false) {
10
+ this.__registerHost();
11
+ }
12
+ this.__attachShadow();
13
+ this.sekiChange = createEvent(this, "sekiChange");
14
+ /**
15
+ * @description Initial checked state for uncontrolled mode. Ignored if checked prop is provided.
16
+ */
17
+ this.defaultChecked = false;
18
+ /**
19
+ * @description Disables all interactions when true.
20
+ */
21
+ this.disabled = false;
22
+ /**
23
+ * @description Marks switch as required for form validation.
24
+ */
25
+ this.required = false;
26
+ /**
27
+ * @description Value sent in form data when switch is checked. Defaults to 'on'.
28
+ */
29
+ this.value = 'on';
30
+ /**
31
+ * @description Internal checked state for uncontrolled mode.
32
+ */
33
+ this.internalChecked = false;
34
+ /**
35
+ * Toggle switch state and emit event
36
+ */
37
+ this.toggle = () => {
38
+ if (this.disabled) {
39
+ return;
264
40
  }
265
- }
266
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
267
- styleContainerNode.insertBefore(styleElm, null);
268
- }
269
- }
270
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
271
- styleElm.innerHTML += SLOT_FB_CSS;
272
- }
273
- if (appliedStyles) {
274
- appliedStyles.add(scopeId2);
275
- }
276
- }
277
- } else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
278
- if (supportsMutableAdoptedStyleSheets) {
279
- styleContainerNode.adoptedStyleSheets.push(style);
280
- } else {
281
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
282
- }
283
- }
284
- }
285
- return scopeId2;
286
- };
287
- var attachStyles = (hostRef) => {
288
- const cmpMeta = hostRef.$cmpMeta$;
289
- const elm = hostRef.$hostElement$;
290
- const flags = cmpMeta.$flags$;
291
- const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
292
- const scopeId2 = addStyle(
293
- elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
294
- cmpMeta);
295
- if (flags & 10 /* needsScopedEncapsulation */) {
296
- elm["s-sc"] = scopeId2;
297
- elm.classList.add(scopeId2 + "-h");
298
- }
299
- endAttachStyles();
300
- };
301
- var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
302
- var h = (nodeName, vnodeData, ...children) => {
303
- let child = null;
304
- let key = null;
305
- let simple = false;
306
- let lastSimple = false;
307
- const vNodeChildren = [];
308
- const walk = (c) => {
309
- for (let i2 = 0; i2 < c.length; i2++) {
310
- child = c[i2];
311
- if (Array.isArray(child)) {
312
- walk(child);
313
- } else if (child != null && typeof child !== "boolean") {
314
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
315
- child = String(child);
316
- }
317
- if (simple && lastSimple) {
318
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
319
- } else {
320
- vNodeChildren.push(simple ? newVNode(null, child) : child);
321
- }
322
- lastSimple = simple;
323
- }
324
- }
325
- };
326
- walk(children);
327
- if (vnodeData) {
328
- if (vnodeData.key) {
329
- key = vnodeData.key;
330
- }
331
- {
332
- const classData = vnodeData.className || vnodeData.class;
333
- if (classData) {
334
- vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
335
- }
336
- }
337
- }
338
- const vnode = newVNode(nodeName, null);
339
- vnode.$attrs$ = vnodeData;
340
- if (vNodeChildren.length > 0) {
341
- vnode.$children$ = vNodeChildren;
342
- }
343
- {
344
- vnode.$key$ = key;
345
- }
346
- return vnode;
347
- };
348
- var newVNode = (tag, text) => {
349
- const vnode = {
350
- $flags$: 0,
351
- $tag$: tag,
352
- $text$: text,
353
- $elm$: null,
354
- $children$: null
355
- };
356
- {
357
- vnode.$attrs$ = null;
358
- }
359
- {
360
- vnode.$key$ = null;
361
- }
362
- return vnode;
363
- };
364
- var Host = {};
365
- var isHost = (node) => node && node.$tag$ === Host;
366
- var createSupportsRuleRe = (selector) => {
367
- const safeSelector2 = escapeRegExpSpecialCharacters(selector);
368
- return new RegExp(
369
- // First capture group: match any context before the selector that's not inside @supports selector()
370
- // Using negative lookahead to avoid matching inside @supports selector(...) condition
371
- `(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${safeSelector2}))(${safeSelector2}\\b)`,
372
- "g"
373
- );
374
- };
375
- createSupportsRuleRe("::slotted");
376
- createSupportsRuleRe(":host");
377
- createSupportsRuleRe(":host-context");
378
- var parsePropertyValue = (propValue, propType, isFormAssociated) => {
379
- if (propValue != null && !isComplexType(propValue)) {
380
- if (propType & 4 /* Boolean */) {
381
- {
382
- return propValue === "false" ? false : propValue === "" || !!propValue;
383
- }
384
- }
385
- if (propType & 2 /* Number */) {
386
- return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
387
- }
388
- if (propType & 1 /* String */) {
389
- return String(propValue);
390
- }
391
- return propValue;
392
- }
393
- return propValue;
394
- };
395
- var getElement = (ref) => {
396
- return ref;
397
- };
398
-
399
- // src/runtime/event-emitter.ts
400
- var createEvent = (ref, name, flags) => {
401
- const elm = getElement(ref);
402
- return {
403
- emit: (detail) => {
404
- return emitEvent(elm, name, {
405
- bubbles: true,
406
- composed: true,
407
- cancelable: true,
408
- detail
409
- });
410
- }
411
- };
412
- };
413
- var emitEvent = (elm, name, opts) => {
414
- const ev = plt.ce(name, opts);
415
- elm.dispatchEvent(ev);
416
- return ev;
417
- };
418
- var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
419
- if (oldValue === newValue) {
420
- return;
421
- }
422
- let isProp = isMemberInElement(elm, memberName);
423
- let ln = memberName.toLowerCase();
424
- if (memberName === "class") {
425
- const classList = elm.classList;
426
- const oldClasses = parseClassList(oldValue);
427
- let newClasses = parseClassList(newValue);
428
- {
429
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
430
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
431
- }
432
- } else if (memberName === "key") ; else if ((!elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
433
- if (memberName[2] === "-") {
434
- memberName = memberName.slice(3);
435
- } else if (isMemberInElement(win, ln)) {
436
- memberName = ln.slice(2);
437
- } else {
438
- memberName = ln[2] + memberName.slice(3);
439
- }
440
- if (oldValue || newValue) {
441
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
442
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
443
- if (oldValue) {
444
- plt.rel(elm, memberName, oldValue, capture);
445
- }
446
- if (newValue) {
447
- plt.ael(elm, memberName, newValue, capture);
448
- }
449
- }
450
- } else {
451
- const isComplex = isComplexType(newValue);
452
- if ((isProp || isComplex && newValue !== null) && true) {
453
- try {
454
- if (!elm.tagName.includes("-")) {
455
- const n = newValue == null ? "" : newValue;
456
- if (memberName === "list") {
457
- isProp = false;
458
- } else if (oldValue == null || elm[memberName] != n) {
459
- if (typeof elm.__lookupSetter__(memberName) === "function") {
460
- elm[memberName] = n;
461
- } else {
462
- elm.setAttribute(memberName, n);
41
+ const newCheckedState = !this.isChecked;
42
+ // Update internal state only in uncontrolled mode
43
+ if (this.checked === undefined) {
44
+ this.internalChecked = newCheckedState;
463
45
  }
464
- }
465
- } else if (elm[memberName] !== newValue) {
466
- elm[memberName] = newValue;
467
- }
468
- } catch (e) {
469
- }
470
- }
471
- if (newValue == null || newValue === false) {
472
- if (newValue !== false || elm.getAttribute(memberName) === "") {
473
- {
474
- elm.removeAttribute(memberName);
475
- }
476
- }
477
- } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex && elm.nodeType === 1 /* ElementNode */) {
478
- newValue = newValue === true ? "" : newValue;
479
- {
480
- elm.setAttribute(memberName, newValue);
481
- }
482
- }
483
- }
484
- };
485
- var parseClassListRegex = /\s/;
486
- var parseClassList = (value) => {
487
- if (typeof value === "object" && value && "baseVal" in value) {
488
- value = value.baseVal;
489
- }
490
- if (!value || typeof value !== "string") {
491
- return [];
492
- }
493
- return value.split(parseClassListRegex);
494
- };
495
- var CAPTURE_EVENT_SUFFIX = "Capture";
496
- var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
497
-
498
- // src/runtime/vdom/update-element.ts
499
- var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
500
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
501
- const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
502
- const newVnodeAttrs = newVnode.$attrs$ || {};
503
- {
504
- for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
505
- if (!(memberName in newVnodeAttrs)) {
506
- setAccessor(
507
- elm,
508
- memberName,
509
- oldVnodeAttrs[memberName],
510
- void 0,
511
- isSvgMode2,
512
- newVnode.$flags$);
513
- }
514
- }
515
- }
516
- for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
517
- setAccessor(
518
- elm,
519
- memberName,
520
- oldVnodeAttrs[memberName],
521
- newVnodeAttrs[memberName],
522
- isSvgMode2,
523
- newVnode.$flags$);
524
- }
525
- };
526
- function sortedAttrNames(attrNames) {
527
- return attrNames.includes("ref") ? (
528
- // we need to sort these to ensure that `'ref'` is the last attr
529
- [...attrNames.filter((attr) => attr !== "ref"), "ref"]
530
- ) : (
531
- // no need to sort, return the original array
532
- attrNames
533
- );
534
- }
535
- var hostTagName;
536
- var isSvgMode = false;
537
- var createElm = (oldParentVNode, newParentVNode, childIndex) => {
538
- const newVNode2 = newParentVNode.$children$[childIndex];
539
- let i2 = 0;
540
- let elm;
541
- let childNode;
542
- {
543
- if (!win.document) {
544
- throw new Error(
545
- "You are trying to render a Stencil component in an environment that doesn't support the DOM. Make sure to populate the [`window`](https://developer.mozilla.org/en-US/docs/Web/API/Window/window) object before rendering a component."
546
- );
547
- }
548
- elm = newVNode2.$elm$ = win.document.createElement(
549
- newVNode2.$tag$
550
- );
551
- {
552
- updateElement(null, newVNode2, isSvgMode);
553
- }
554
- if (newVNode2.$children$) {
555
- for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
556
- childNode = createElm(oldParentVNode, newVNode2, i2);
557
- if (childNode) {
558
- elm.appendChild(childNode);
559
- }
560
- }
561
- }
562
- }
563
- elm["s-hn"] = hostTagName;
564
- return elm;
565
- };
566
- var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
567
- let containerElm = parentElm;
568
- let childNode;
569
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
570
- containerElm = containerElm.shadowRoot;
571
- }
572
- for (; startIdx <= endIdx; ++startIdx) {
573
- if (vnodes[startIdx]) {
574
- childNode = createElm(null, parentVNode, startIdx);
575
- if (childNode) {
576
- vnodes[startIdx].$elm$ = childNode;
577
- insertBefore(containerElm, childNode, before);
578
- }
579
- }
580
- }
581
- };
582
- var removeVnodes = (vnodes, startIdx, endIdx) => {
583
- for (let index = startIdx; index <= endIdx; ++index) {
584
- const vnode = vnodes[index];
585
- if (vnode) {
586
- const elm = vnode.$elm$;
587
- if (elm) {
588
- elm.remove();
589
- }
590
- }
591
- }
592
- };
593
- var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
594
- let oldStartIdx = 0;
595
- let newStartIdx = 0;
596
- let idxInOld = 0;
597
- let i2 = 0;
598
- let oldEndIdx = oldCh.length - 1;
599
- let oldStartVnode = oldCh[0];
600
- let oldEndVnode = oldCh[oldEndIdx];
601
- let newEndIdx = newCh.length - 1;
602
- let newStartVnode = newCh[0];
603
- let newEndVnode = newCh[newEndIdx];
604
- let node;
605
- let elmToMove;
606
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
607
- if (oldStartVnode == null) {
608
- oldStartVnode = oldCh[++oldStartIdx];
609
- } else if (oldEndVnode == null) {
610
- oldEndVnode = oldCh[--oldEndIdx];
611
- } else if (newStartVnode == null) {
612
- newStartVnode = newCh[++newStartIdx];
613
- } else if (newEndVnode == null) {
614
- newEndVnode = newCh[--newEndIdx];
615
- } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
616
- patch(oldStartVnode, newStartVnode, isInitialRender);
617
- oldStartVnode = oldCh[++oldStartIdx];
618
- newStartVnode = newCh[++newStartIdx];
619
- } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
620
- patch(oldEndVnode, newEndVnode, isInitialRender);
621
- oldEndVnode = oldCh[--oldEndIdx];
622
- newEndVnode = newCh[--newEndIdx];
623
- } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
624
- patch(oldStartVnode, newEndVnode, isInitialRender);
625
- insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
626
- oldStartVnode = oldCh[++oldStartIdx];
627
- newEndVnode = newCh[--newEndIdx];
628
- } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
629
- patch(oldEndVnode, newStartVnode, isInitialRender);
630
- insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
631
- oldEndVnode = oldCh[--oldEndIdx];
632
- newStartVnode = newCh[++newStartIdx];
633
- } else {
634
- idxInOld = -1;
635
- {
636
- for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
637
- if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
638
- idxInOld = i2;
639
- break;
640
- }
641
- }
642
- }
643
- if (idxInOld >= 0) {
644
- elmToMove = oldCh[idxInOld];
645
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
646
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
647
- } else {
648
- patch(elmToMove, newStartVnode, isInitialRender);
649
- oldCh[idxInOld] = void 0;
650
- node = elmToMove.$elm$;
651
- }
652
- newStartVnode = newCh[++newStartIdx];
653
- } else {
654
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
655
- newStartVnode = newCh[++newStartIdx];
656
- }
657
- if (node) {
658
- {
659
- insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
660
- }
661
- }
662
- }
663
- }
664
- if (oldStartIdx > oldEndIdx) {
665
- addVnodes(
666
- parentElm,
667
- newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
668
- newVNode2,
669
- newCh,
670
- newStartIdx,
671
- newEndIdx
672
- );
673
- } else if (newStartIdx > newEndIdx) {
674
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
675
- }
676
- };
677
- var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
678
- if (leftVNode.$tag$ === rightVNode.$tag$) {
679
- if (!isInitialRender) {
680
- return leftVNode.$key$ === rightVNode.$key$;
681
- }
682
- if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
683
- leftVNode.$key$ = rightVNode.$key$;
684
- }
685
- return true;
686
- }
687
- return false;
688
- };
689
- var patch = (oldVNode, newVNode2, isInitialRender = false) => {
690
- const elm = newVNode2.$elm$ = oldVNode.$elm$;
691
- const oldChildren = oldVNode.$children$;
692
- const newChildren = newVNode2.$children$;
693
- {
694
- {
695
- updateElement(oldVNode, newVNode2, isSvgMode);
696
- }
697
- if (oldChildren !== null && newChildren !== null) {
698
- updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
699
- } else if (newChildren !== null) {
700
- addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
701
- } else if (
702
- // don't do this on initial render as it can cause non-hydrated content to be removed
703
- !isInitialRender && BUILD.updatable && oldChildren !== null
704
- ) {
705
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
706
- } else ;
707
- }
708
- };
709
- var insertBefore = (parent, newNode, reference) => {
710
- {
711
- return parent == null ? void 0 : parent.insertBefore(newNode, reference);
712
- }
713
- };
714
- var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
715
- const hostElm = hostRef.$hostElement$;
716
- const cmpMeta = hostRef.$cmpMeta$;
717
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
718
- const isHostElement = isHost(renderFnResults);
719
- const rootVnode = isHostElement ? renderFnResults : h(null, null, renderFnResults);
720
- hostTagName = hostElm.tagName;
721
- if (cmpMeta.$attrsToReflect$) {
722
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
723
- cmpMeta.$attrsToReflect$.forEach(([propName, attribute]) => {
724
- {
725
- rootVnode.$attrs$[attribute] = hostElm[propName];
726
- }
727
- });
728
- }
729
- if (isInitialLoad && rootVnode.$attrs$) {
730
- for (const key of Object.keys(rootVnode.$attrs$)) {
731
- if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
732
- rootVnode.$attrs$[key] = hostElm[key];
733
- }
734
- }
735
- }
736
- rootVnode.$tag$ = null;
737
- rootVnode.$flags$ |= 4 /* isHost */;
738
- hostRef.$vnode$ = rootVnode;
739
- rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm ;
740
- patch(oldVNode, rootVnode, isInitialLoad);
741
- };
742
-
743
- // src/runtime/update-component.ts
744
- var attachToAncestor = (hostRef, ancestorComponent) => {
745
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
746
- const index = ancestorComponent["s-p"].push(
747
- new Promise(
748
- (r) => hostRef.$onRenderResolve$ = () => {
749
- ancestorComponent["s-p"].splice(index - 1, 1);
750
- r();
751
- }
752
- )
753
- );
754
- }
755
- };
756
- var scheduleUpdate = (hostRef, isInitialLoad) => {
757
- {
758
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
759
- }
760
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
761
- hostRef.$flags$ |= 512 /* needsRerender */;
762
- return;
763
- }
764
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
765
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
766
- if (isInitialLoad) {
767
- queueMicrotask(() => {
768
- dispatch();
769
- });
770
- return;
771
- }
772
- return writeTask(dispatch) ;
773
- };
774
- var dispatchHooks = (hostRef, isInitialLoad) => {
775
- const elm = hostRef.$hostElement$;
776
- const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
777
- const instance = elm;
778
- if (!instance) {
779
- throw new Error(
780
- `Can't render component <${elm.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`
781
- );
782
- }
783
- let maybePromise;
784
- if (isInitialLoad) {
785
- maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
786
- } else {
787
- maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
788
- }
789
- maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
790
- endSchedule();
791
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
792
- };
793
- var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err2) => {
794
- console.error(err2);
795
- fn();
796
- }) : fn();
797
- var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
798
- var updateComponent = async (hostRef, instance, isInitialLoad) => {
799
- var _a;
800
- const elm = hostRef.$hostElement$;
801
- const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$);
802
- const rc = elm["s-rc"];
803
- if (isInitialLoad) {
804
- attachStyles(hostRef);
805
- }
806
- const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$);
807
- {
808
- callRender(hostRef, instance, elm, isInitialLoad);
809
- }
810
- if (rc) {
811
- rc.map((cb) => cb());
812
- elm["s-rc"] = void 0;
813
- }
814
- endRender();
815
- endUpdate();
816
- {
817
- const childrenPromises = (_a = elm["s-p"]) != null ? _a : [];
818
- const postUpdate = () => postUpdateComponent(hostRef);
819
- if (childrenPromises.length === 0) {
820
- postUpdate();
821
- } else {
822
- Promise.all(childrenPromises).then(postUpdate);
823
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
824
- childrenPromises.length = 0;
825
- }
826
- }
827
- };
828
- var callRender = (hostRef, instance, elm, isInitialLoad) => {
829
- try {
830
- instance = instance.render() ;
831
- {
832
- hostRef.$flags$ &= -17 /* isQueuedForUpdate */;
833
- }
834
- {
835
- hostRef.$flags$ |= 2 /* hasRendered */;
836
- }
837
- {
838
- {
839
- {
840
- renderVdom(hostRef, instance, isInitialLoad);
841
- }
842
- }
843
- }
844
- } catch (e) {
845
- consoleError(e, hostRef.$hostElement$);
846
- }
847
- return null;
848
- };
849
- var postUpdateComponent = (hostRef) => {
850
- const tagName = hostRef.$cmpMeta$.$tagName$;
851
- const elm = hostRef.$hostElement$;
852
- const endPostUpdate = createTime("postUpdate", tagName);
853
- const instance = elm;
854
- const ancestorComponent = hostRef.$ancestorComponent$;
855
- safeCall(instance, "componentDidRender", void 0, elm);
856
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
857
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
858
- {
859
- addHydratedFlag(elm);
860
- }
861
- safeCall(instance, "componentDidLoad", void 0, elm);
862
- endPostUpdate();
863
- {
864
- hostRef.$onReadyResolve$(elm);
865
- if (!ancestorComponent) {
866
- appDidLoad();
867
- }
868
- }
869
- } else {
870
- safeCall(instance, "componentDidUpdate", void 0, elm);
871
- endPostUpdate();
872
- }
873
- {
874
- if (hostRef.$onRenderResolve$) {
875
- hostRef.$onRenderResolve$();
876
- hostRef.$onRenderResolve$ = void 0;
877
- }
878
- if (hostRef.$flags$ & 512 /* needsRerender */) {
879
- nextTick(() => scheduleUpdate(hostRef, false));
880
- }
881
- hostRef.$flags$ &= -517;
882
- }
883
- };
884
- var appDidLoad = (who) => {
885
- nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
886
- };
887
- var safeCall = (instance, method, arg, elm) => {
888
- if (instance && instance[method]) {
889
- try {
890
- return instance[method](arg);
891
- } catch (e) {
892
- consoleError(e, elm);
893
- }
894
- }
895
- return void 0;
896
- };
897
- var addHydratedFlag = (elm) => {
898
- var _a;
899
- return elm.classList.add((_a = BUILD.hydratedSelectorName) != null ? _a : "hydrated") ;
900
- };
901
-
902
- // src/runtime/set-value.ts
903
- var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
904
- var setValue = (ref, propName, newVal, cmpMeta) => {
905
- const hostRef = getHostRef(ref);
906
- if (!hostRef) {
907
- return;
908
- }
909
- const elm = ref;
910
- const oldVal = hostRef.$instanceValues$.get(propName);
911
- const flags = hostRef.$flags$;
912
- const instance = elm;
913
- newVal = parsePropertyValue(
914
- newVal,
915
- cmpMeta.$members$[propName][0]);
916
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
917
- const didValueChange = newVal !== oldVal && !areBothNaN;
918
- if (didValueChange) {
919
- hostRef.$instanceValues$.set(propName, newVal);
920
- {
921
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
922
- if (instance.componentShouldUpdate) {
923
- if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
46
+ // Always emit event (for both controlled and uncontrolled)
47
+ this.sekiChange.emit({ checked: newCheckedState });
48
+ };
49
+ /**
50
+ * Handle click events
51
+ */
52
+ this.handleClick = () => {
53
+ this.toggle();
54
+ };
55
+ }
56
+ /**
57
+ * Initialize internal checked state from defaultChecked
58
+ */
59
+ componentWillLoad() {
60
+ this.internalChecked = this.defaultChecked;
61
+ }
62
+ /**
63
+ * Get current checked state (controlled vs uncontrolled)
64
+ */
65
+ get isChecked() {
66
+ return this.checked !== undefined ? this.checked : this.internalChecked;
67
+ }
68
+ /**
69
+ * Handle keyboard events (Space and Enter keys)
70
+ */
71
+ handleKeyDown(event) {
72
+ if (this.disabled) {
924
73
  return;
925
- }
926
74
  }
927
- scheduleUpdate(hostRef, false);
928
- }
929
- }
930
- }
931
- };
932
-
933
- // src/runtime/proxy-component.ts
934
- var proxyComponent = (Cstr, cmpMeta, flags) => {
935
- var _a, _b;
936
- const prototype = Cstr.prototype;
937
- if (cmpMeta.$members$ || BUILD.propChangeCallback) {
938
- const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
939
- members.map(([memberName, [memberFlags]]) => {
940
- if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
941
- const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
942
- if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
943
- if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
944
- {
945
- Object.defineProperty(prototype, memberName, {
946
- get() {
947
- {
948
- return origGetter ? origGetter.apply(this) : getValue(this, memberName);
949
- }
950
- },
951
- configurable: true,
952
- enumerable: true
953
- });
954
- }
955
- Object.defineProperty(prototype, memberName, {
956
- set(newValue) {
957
- const ref = getHostRef(this);
958
- if (!ref) {
959
- return;
960
- }
961
- if (origSetter) {
962
- const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
963
- if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
964
- newValue = ref.$instanceValues$.get(memberName);
965
- }
966
- origSetter.apply(this, [
967
- parsePropertyValue(
968
- newValue,
969
- memberFlags)
970
- ]);
971
- newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
972
- setValue(this, memberName, newValue, cmpMeta);
973
- return;
974
- }
975
- {
976
- setValue(this, memberName, newValue, cmpMeta);
977
- return;
978
- }
979
- }
980
- });
981
- }
982
- });
983
- {
984
- const attrNameToPropName = /* @__PURE__ */ new Map();
985
- prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
986
- plt.jmp(() => {
987
- var _a2;
988
- const propName = attrNameToPropName.get(attrName);
989
- const hostRef = getHostRef(this);
990
- if (this.hasOwnProperty(propName) && BUILD.lazyLoad) ;
991
- if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
992
- this[propName] == newValue) {
993
- return;
994
- } else if (propName == null) {
995
- const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
996
- if (hostRef && flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
997
- const elm = this;
998
- const instance = elm;
999
- const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
1000
- entry == null ? void 0 : entry.forEach((callbackName) => {
1001
- if (instance[callbackName] != null) {
1002
- instance[callbackName].call(instance, newValue, oldValue, attrName);
1003
- }
1004
- });
1005
- }
1006
- return;
1007
- }
1008
- const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
1009
- newValue = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
1010
- if (newValue != this[propName] && (!propDesc.get || !!propDesc.set)) {
1011
- this[propName] = newValue;
1012
- }
1013
- });
1014
- };
1015
- Cstr.observedAttributes = Array.from(
1016
- /* @__PURE__ */ new Set([
1017
- ...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
1018
- ...members.filter(([_, m]) => m[0] & 31 /* HasAttribute */).map(([propName, m]) => {
1019
- var _a2;
1020
- const attrName = m[1] || propName;
1021
- attrNameToPropName.set(attrName, propName);
1022
- if (m[0] & 512 /* ReflectAttr */) {
1023
- (_a2 = cmpMeta.$attrsToReflect$) == null ? void 0 : _a2.push([propName, attrName]);
75
+ // Toggle on Space or Enter
76
+ if (event.key === ' ' || event.key === 'Enter') {
77
+ event.preventDefault(); // Prevent page scroll on Space
78
+ this.toggle();
79
+ }
80
+ }
81
+ render() {
82
+ const isChecked = this.isChecked;
83
+ const dataState = isChecked ? 'checked' : 'unchecked';
84
+ 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" }))));
85
+ }
86
+ static get style() { return sekiSwitchCss; }
87
+ }, [257, "seki-switch", {
88
+ "checked": [4],
89
+ "defaultChecked": [4, "default-checked"],
90
+ "disabled": [4],
91
+ "required": [4],
92
+ "name": [1],
93
+ "value": [1],
94
+ "ariaLabel": [1, "aria-label"],
95
+ "internalChecked": [32]
96
+ }, [[0, "keydown", "handleKeyDown"]]]);
97
+ function defineCustomElement() {
98
+ if (typeof customElements === "undefined") {
99
+ return;
100
+ }
101
+ const components = ["seki-switch"];
102
+ components.forEach(tagName => { switch (tagName) {
103
+ case "seki-switch":
104
+ if (!customElements.get(tagName)) {
105
+ customElements.define(tagName, SekiSwitch);
1024
106
  }
1025
- return attrName;
1026
- })
1027
- ])
1028
- );
1029
- }
1030
- }
1031
- return Cstr;
1032
- };
1033
-
1034
- // src/runtime/initialize-component.ts
1035
- var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1036
- let Cstr;
1037
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1038
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1039
- {
1040
- Cstr = elm.constructor;
1041
- const cmpTag = elm.localName;
1042
- customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
1043
- }
1044
- if (Cstr && Cstr.style) {
1045
- let style;
1046
- if (typeof Cstr.style === "string") {
1047
- style = Cstr.style;
1048
- }
1049
- const scopeId2 = getScopeId(cmpMeta);
1050
- if (!styles.has(scopeId2)) {
1051
- const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
1052
- registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1053
- endRegisterStyles();
1054
- }
1055
- }
1056
- }
1057
- const ancestorComponent = hostRef.$ancestorComponent$;
1058
- const schedule = () => scheduleUpdate(hostRef, true);
1059
- if (ancestorComponent && ancestorComponent["s-rc"]) {
1060
- ancestorComponent["s-rc"].push(schedule);
1061
- } else {
1062
- schedule();
1063
- }
1064
- };
1065
- var fireConnectedCallback = (instance, elm) => {
1066
- };
1067
-
1068
- // src/runtime/connected-callback.ts
1069
- var connectedCallback = (elm) => {
1070
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1071
- const hostRef = getHostRef(elm);
1072
- if (!hostRef) {
1073
- return;
1074
- }
1075
- const cmpMeta = hostRef.$cmpMeta$;
1076
- const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
1077
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1078
- hostRef.$flags$ |= 1 /* hasConnected */;
1079
- {
1080
- let ancestorComponent = elm;
1081
- while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
1082
- if (ancestorComponent["s-p"]) {
1083
- attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
1084
107
  break;
1085
- }
1086
- }
1087
- }
1088
- if (cmpMeta.$members$) {
1089
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1090
- if (memberFlags & 31 /* Prop */ && memberName in elm && elm[memberName] !== Object.prototype[memberName]) {
1091
- const value = elm[memberName];
1092
- delete elm[memberName];
1093
- elm[memberName] = value;
1094
- }
1095
- });
1096
- }
1097
- {
1098
- initializeComponent(elm, hostRef, cmpMeta);
1099
- }
1100
- } else {
1101
- if (hostRef == null ? void 0 : hostRef.$lazyInstance$) ; else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
1102
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback());
1103
- }
1104
- }
1105
- endConnected();
1106
- }
1107
- };
1108
- var disconnectedCallback = async (elm) => {
1109
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1110
- getHostRef(elm);
1111
- }
1112
- if (rootAppliedStyles.has(elm)) {
1113
- rootAppliedStyles.delete(elm);
1114
- }
1115
- if (elm.shadowRoot && rootAppliedStyles.has(elm.shadowRoot)) {
1116
- rootAppliedStyles.delete(elm.shadowRoot);
1117
- }
1118
- };
1119
- var proxyCustomElement = (Cstr, compactMeta) => {
1120
- const cmpMeta = {
1121
- $flags$: compactMeta[0],
1122
- $tagName$: compactMeta[1]
1123
- };
1124
- {
1125
- cmpMeta.$members$ = compactMeta[2];
1126
- }
1127
- {
1128
- cmpMeta.$attrsToReflect$ = [];
1129
- }
1130
- const originalConnectedCallback = Cstr.prototype.connectedCallback;
1131
- const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
1132
- Object.assign(Cstr.prototype, {
1133
- __hasHostListenerAttached: false,
1134
- __registerHost() {
1135
- registerHost(this, cmpMeta);
1136
- },
1137
- connectedCallback() {
1138
- if (!this.__hasHostListenerAttached) {
1139
- const hostRef = getHostRef(this);
1140
- if (!hostRef) {
1141
- return;
1142
- }
1143
- this.__hasHostListenerAttached = true;
1144
- }
1145
- connectedCallback(this);
1146
- if (originalConnectedCallback) {
1147
- originalConnectedCallback.call(this);
1148
- }
1149
- },
1150
- disconnectedCallback() {
1151
- disconnectedCallback(this);
1152
- if (originalDisconnectedCallback) {
1153
- originalDisconnectedCallback.call(this);
1154
- }
1155
- },
1156
- __attachShadow() {
1157
- {
1158
- if (!this.shadowRoot) {
1159
- createShadowRoot.call(this, cmpMeta);
1160
- } else {
1161
- if (this.shadowRoot.mode !== "open") {
1162
- throw new Error(
1163
- `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`
1164
- );
1165
- }
1166
- }
1167
- }
1168
- }
1169
- });
1170
- Cstr.is = cmpMeta.$tagName$;
1171
- return proxyComponent(Cstr, cmpMeta);
1172
- };
1173
-
1174
- // src/runtime/nonce.ts
1175
- var setNonce = (nonce) => plt.$nonce$ = nonce;
1176
-
1177
- // src/runtime/platform-options.ts
1178
- var setPlatformOptions = (opts) => Object.assign(plt, opts);
1179
-
1180
- // src/runtime/render.ts
1181
- function render(vnode, container) {
1182
- const cmpMeta = {
1183
- $flags$: 0,
1184
- $tagName$: container.tagName
1185
- };
1186
- const ref = {
1187
- $cmpMeta$: cmpMeta,
1188
- $hostElement$: container
1189
- };
1190
- renderVdom(ref, vnode);
108
+ } });
1191
109
  }
110
+ defineCustomElement();
1192
111
 
1193
- export { H, createEvent as c, getAssetPath, h, proxyCustomElement as p, render, setAssetPath, setNonce, setPlatformOptions };
112
+ export { SekiSwitch, defineCustomElement as d };