@duskmoon-dev/el-base 0.6.0

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.
@@ -0,0 +1,958 @@
1
+ // src/styles.ts
2
+ var styleSheetCache = new WeakMap;
3
+ function css(strings, ...values) {
4
+ const cached = styleSheetCache.get(strings);
5
+ if (cached && values.length === 0) {
6
+ return cached;
7
+ }
8
+ let cssText = strings[0];
9
+ for (let i = 0;i < values.length; i++) {
10
+ cssText += String(values[i]) + strings[i + 1];
11
+ }
12
+ const sheet = new CSSStyleSheet;
13
+ sheet.replaceSync(cssText);
14
+ if (values.length === 0) {
15
+ styleSheetCache.set(strings, sheet);
16
+ }
17
+ return sheet;
18
+ }
19
+ function combineStyles(...sheets) {
20
+ return sheets;
21
+ }
22
+ function cssVars(vars) {
23
+ return Object.entries(vars).map(([key, value]) => `--${key}: ${value}`).join("; ");
24
+ }
25
+ var defaultTheme = css`
26
+ :host {
27
+ /* Typography - safe to set defaults */
28
+ --font-family: system-ui, -apple-system, sans-serif;
29
+ --font-size-xs: 0.75rem;
30
+ --font-size-sm: 0.875rem;
31
+ --font-size-md: 1rem;
32
+ --font-size-lg: 1.125rem;
33
+ --font-size-xl: 1.25rem;
34
+ --font-weight-normal: 400;
35
+ --font-weight-medium: 500;
36
+ --font-weight-semibold: 600;
37
+ --font-weight-bold: 700;
38
+
39
+ /* Spacing - safe to set defaults */
40
+ --spacing-xs: 0.25rem;
41
+ --spacing-sm: 0.5rem;
42
+ --spacing-md: 1rem;
43
+ --spacing-lg: 1.5rem;
44
+ --spacing-xl: 2rem;
45
+
46
+ /* Border Radius - safe to set defaults */
47
+ --radius-sm: 0.25rem;
48
+ --radius-md: 0.5rem;
49
+ --radius-lg: 0.75rem;
50
+ --radius-xl: 1rem;
51
+ --radius-full: 9999px;
52
+
53
+ /* Transitions - safe to set defaults */
54
+ --transition-fast: 150ms ease;
55
+ --transition-normal: 200ms ease;
56
+ --transition-slow: 300ms ease;
57
+ }
58
+ `;
59
+ var lightThemeColors = `
60
+ /* Primary colors */
61
+ --color-primary: oklch(60% 0.15 250);
62
+ --color-primary-content: white;
63
+ --color-on-primary: white;
64
+
65
+ /* Secondary colors */
66
+ --color-secondary: oklch(55% 0.1 250);
67
+ --color-secondary-content: white;
68
+ --color-on-secondary: white;
69
+
70
+ /* Tertiary colors */
71
+ --color-tertiary: oklch(50% 0.12 300);
72
+ --color-tertiary-content: white;
73
+ --color-on-tertiary: white;
74
+
75
+ /* Surface colors */
76
+ --color-surface: white;
77
+ --color-surface-container: oklch(97% 0.01 250);
78
+ --color-surface-container-low: oklch(98% 0.005 250);
79
+ --color-surface-container-high: oklch(94% 0.01 250);
80
+ --color-on-surface: oklch(25% 0.02 250);
81
+ --color-on-surface-variant: oklch(45% 0.02 250);
82
+
83
+ /* Outline colors */
84
+ --color-outline: oklch(75% 0.02 250);
85
+ --color-outline-variant: oklch(85% 0.01 250);
86
+
87
+ /* Semantic colors */
88
+ --color-success: oklch(60% 0.15 145);
89
+ --color-warning: oklch(75% 0.15 85);
90
+ --color-error: oklch(55% 0.2 25);
91
+ --color-info: oklch(60% 0.15 250);
92
+
93
+ /* Shadows */
94
+ --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
95
+ --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
96
+ --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
97
+ --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
98
+ --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
99
+
100
+ /* Focus */
101
+ --focus-ring: 0 0 0 2px var(--color-primary);
102
+ --focus-ring-offset: 0 0 0 2px white, 0 0 0 4px var(--color-primary);
103
+ `;
104
+ var resetStyles = css`
105
+ *,
106
+ *::before,
107
+ *::after {
108
+ box-sizing: border-box;
109
+ }
110
+
111
+ :host {
112
+ font-family: var(--font-family, system-ui, -apple-system, sans-serif);
113
+ }
114
+
115
+ :host([hidden]) {
116
+ display: none !important;
117
+ }
118
+ `;
119
+
120
+ // src/base-element.ts
121
+ class BaseElement extends HTMLElement {
122
+ static properties = {};
123
+ static get observedAttributes() {
124
+ return Object.entries(this.properties).filter(([, def]) => def.attribute !== false).map(([name, def]) => def.attribute || toKebabCase(name));
125
+ }
126
+ _styles = [];
127
+ _isConnected = false;
128
+ _preUpgradeValues;
129
+ _pendingUpdate = false;
130
+ _propertyValues = new Map;
131
+ constructor() {
132
+ super();
133
+ this.attachShadow({ mode: "open" });
134
+ this._styles = [resetStyles, defaultTheme];
135
+ this.shadowRoot.adoptedStyleSheets = [...this._styles];
136
+ this._initializeProperties();
137
+ }
138
+ _initializeProperties() {
139
+ const ctor = this.constructor;
140
+ const properties = ctor.properties;
141
+ for (const [name, def] of Object.entries(properties)) {
142
+ if (Object.prototype.hasOwnProperty.call(this, name)) {
143
+ const preValue = this[name];
144
+ delete this[name];
145
+ if (preValue !== undefined) {
146
+ if (!this._preUpgradeValues)
147
+ this._preUpgradeValues = new Map;
148
+ this._preUpgradeValues.set(name, preValue);
149
+ }
150
+ }
151
+ if (def.default !== undefined) {
152
+ this._propertyValues.set(name, def.default);
153
+ }
154
+ Object.defineProperty(this, name, {
155
+ get: () => this._propertyValues.get(name),
156
+ set: (value) => {
157
+ const oldValue = this._propertyValues.get(name);
158
+ if (oldValue === value)
159
+ return;
160
+ this._propertyValues.set(name, value);
161
+ if (def.reflect && def.attribute !== false) {
162
+ const attrName = def.attribute || toKebabCase(name);
163
+ this._reflectToAttribute(attrName, value, def.type);
164
+ }
165
+ this._scheduleUpdate();
166
+ },
167
+ enumerable: true,
168
+ configurable: true
169
+ });
170
+ }
171
+ }
172
+ _reflectToAttribute(attrName, value, type) {
173
+ if (value === null || value === undefined) {
174
+ this.removeAttribute(attrName);
175
+ return;
176
+ }
177
+ if (type === Boolean) {
178
+ if (value) {
179
+ this.setAttribute(attrName, "");
180
+ } else {
181
+ this.removeAttribute(attrName);
182
+ }
183
+ return;
184
+ }
185
+ if (type === Object || type === Array) {
186
+ this.setAttribute(attrName, JSON.stringify(value));
187
+ return;
188
+ }
189
+ this.setAttribute(attrName, String(value));
190
+ }
191
+ _attributeToProperty(value, type) {
192
+ if (value === null) {
193
+ return type === Boolean ? false : undefined;
194
+ }
195
+ switch (type) {
196
+ case Boolean:
197
+ return true;
198
+ case Number:
199
+ return Number(value);
200
+ case Object:
201
+ case Array:
202
+ try {
203
+ return JSON.parse(value);
204
+ } catch {
205
+ return;
206
+ }
207
+ default:
208
+ return value;
209
+ }
210
+ }
211
+ _scheduleUpdate() {
212
+ if (this._pendingUpdate)
213
+ return;
214
+ this._pendingUpdate = true;
215
+ queueMicrotask(() => {
216
+ this._pendingUpdate = false;
217
+ if (this._isConnected) {
218
+ this.update();
219
+ }
220
+ });
221
+ }
222
+ attachStyles(styles) {
223
+ const sheets = Array.isArray(styles) ? styles : [styles];
224
+ this._styles = [...this._styles, ...sheets];
225
+ this.shadowRoot.adoptedStyleSheets = [...this._styles];
226
+ }
227
+ connectedCallback() {
228
+ this._isConnected = true;
229
+ if (this._preUpgradeValues) {
230
+ for (const [name, value] of this._preUpgradeValues) {
231
+ this[name] = value;
232
+ }
233
+ this._preUpgradeValues = undefined;
234
+ }
235
+ this.update();
236
+ }
237
+ disconnectedCallback() {
238
+ this._isConnected = false;
239
+ }
240
+ attributeChangedCallback(name, oldValue, newValue) {
241
+ if (oldValue === newValue)
242
+ return;
243
+ const ctor = this.constructor;
244
+ const properties = ctor.properties;
245
+ for (const [propName, def] of Object.entries(properties)) {
246
+ const attrName = def.attribute || toKebabCase(propName);
247
+ if (attrName === name) {
248
+ const value = this._attributeToProperty(newValue, def.type);
249
+ this._propertyValues.set(propName, value);
250
+ this._scheduleUpdate();
251
+ break;
252
+ }
253
+ }
254
+ }
255
+ update() {
256
+ const content = this.render();
257
+ if (content !== undefined) {
258
+ this.shadowRoot.innerHTML = content;
259
+ }
260
+ }
261
+ render() {
262
+ return;
263
+ }
264
+ emit(name, detail, options) {
265
+ const event = new CustomEvent(name, {
266
+ bubbles: true,
267
+ composed: true,
268
+ cancelable: true,
269
+ ...options,
270
+ detail
271
+ });
272
+ return this.dispatchEvent(event);
273
+ }
274
+ query(selector) {
275
+ return this.shadowRoot.querySelector(selector);
276
+ }
277
+ queryAll(selector) {
278
+ return this.shadowRoot.querySelectorAll(selector);
279
+ }
280
+ }
281
+ function toKebabCase(str) {
282
+ return str.replace(/([A-Z])/g, "-$1").toLowerCase();
283
+ }
284
+ // src/animations.ts
285
+ var durations = {
286
+ fast: "150ms",
287
+ normal: "200ms",
288
+ slow: "300ms",
289
+ slower: "500ms"
290
+ };
291
+ var easings = {
292
+ ease: "ease",
293
+ easeIn: "cubic-bezier(0.4, 0, 1, 1)",
294
+ easeOut: "cubic-bezier(0, 0, 0.2, 1)",
295
+ easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)",
296
+ spring: "cubic-bezier(0.175, 0.885, 0.32, 1.275)"
297
+ };
298
+ var animationStyles = css`
299
+ @keyframes dm-fade-in {
300
+ from {
301
+ opacity: 0;
302
+ }
303
+ to {
304
+ opacity: 1;
305
+ }
306
+ }
307
+
308
+ @keyframes dm-fade-out {
309
+ from {
310
+ opacity: 1;
311
+ }
312
+ to {
313
+ opacity: 0;
314
+ }
315
+ }
316
+
317
+ @keyframes dm-scale-in {
318
+ from {
319
+ opacity: 0;
320
+ transform: scale(0.95);
321
+ }
322
+ to {
323
+ opacity: 1;
324
+ transform: scale(1);
325
+ }
326
+ }
327
+
328
+ @keyframes dm-scale-out {
329
+ from {
330
+ opacity: 1;
331
+ transform: scale(1);
332
+ }
333
+ to {
334
+ opacity: 0;
335
+ transform: scale(0.95);
336
+ }
337
+ }
338
+
339
+ @keyframes dm-slide-in-up {
340
+ from {
341
+ opacity: 0;
342
+ transform: translateY(0.5rem);
343
+ }
344
+ to {
345
+ opacity: 1;
346
+ transform: translateY(0);
347
+ }
348
+ }
349
+
350
+ @keyframes dm-slide-in-down {
351
+ from {
352
+ opacity: 0;
353
+ transform: translateY(-0.5rem);
354
+ }
355
+ to {
356
+ opacity: 1;
357
+ transform: translateY(0);
358
+ }
359
+ }
360
+
361
+ @keyframes dm-slide-in-left {
362
+ from {
363
+ opacity: 0;
364
+ transform: translateX(0.5rem);
365
+ }
366
+ to {
367
+ opacity: 1;
368
+ transform: translateX(0);
369
+ }
370
+ }
371
+
372
+ @keyframes dm-slide-in-right {
373
+ from {
374
+ opacity: 0;
375
+ transform: translateX(-0.5rem);
376
+ }
377
+ to {
378
+ opacity: 1;
379
+ transform: translateX(0);
380
+ }
381
+ }
382
+
383
+ @keyframes dm-shake {
384
+ 0%,
385
+ 100% {
386
+ transform: translateX(0);
387
+ }
388
+ 10%,
389
+ 30%,
390
+ 50%,
391
+ 70%,
392
+ 90% {
393
+ transform: translateX(-0.25rem);
394
+ }
395
+ 20%,
396
+ 40%,
397
+ 60%,
398
+ 80% {
399
+ transform: translateX(0.25rem);
400
+ }
401
+ }
402
+
403
+ @keyframes dm-spin {
404
+ from {
405
+ transform: rotate(0deg);
406
+ }
407
+ to {
408
+ transform: rotate(360deg);
409
+ }
410
+ }
411
+
412
+ @keyframes dm-pulse {
413
+ 0%,
414
+ 100% {
415
+ opacity: 1;
416
+ }
417
+ 50% {
418
+ opacity: 0.5;
419
+ }
420
+ }
421
+
422
+ /* Reduced motion: disable all animations */
423
+ @media (prefers-reduced-motion: reduce) {
424
+ *,
425
+ *::before,
426
+ *::after {
427
+ animation-duration: 0.01ms !important;
428
+ animation-iteration-count: 1 !important;
429
+ transition-duration: 0.01ms !important;
430
+ }
431
+ }
432
+ `;
433
+ function animation(name, duration = "normal", easing = "easeOut", fillMode = "both") {
434
+ return `${name} ${durations[duration]} ${easings[easing]} ${fillMode}`;
435
+ }
436
+ function transition(properties, duration = "normal", easing = "ease") {
437
+ return properties.map((prop) => `${prop} ${durations[duration]} ${easings[easing]}`).join(", ");
438
+ }
439
+ // src/themes.ts
440
+ var sunshineTheme = `
441
+ /* Primary */
442
+ --color-primary: oklch(60% 0.15 250);
443
+ --color-primary-content: white;
444
+ --color-on-primary: white;
445
+
446
+ /* Secondary */
447
+ --color-secondary: oklch(55% 0.1 250);
448
+ --color-secondary-content: white;
449
+ --color-on-secondary: white;
450
+
451
+ /* Tertiary */
452
+ --color-tertiary: oklch(50% 0.12 300);
453
+ --color-tertiary-content: white;
454
+ --color-on-tertiary: white;
455
+
456
+ /* Surface */
457
+ --color-surface: white;
458
+ --color-surface-container: oklch(97% 0.01 250);
459
+ --color-surface-container-low: oklch(98% 0.005 250);
460
+ --color-surface-container-high: oklch(94% 0.01 250);
461
+ --color-surface-variant: oklch(92% 0.01 250);
462
+ --color-on-surface: oklch(25% 0.02 250);
463
+ --color-on-surface-variant: oklch(45% 0.02 250);
464
+ --color-inverse-surface: oklch(25% 0.02 250);
465
+ --color-inverse-on-surface: oklch(95% 0.01 250);
466
+
467
+ /* Outline */
468
+ --color-outline: oklch(75% 0.02 250);
469
+ --color-outline-variant: oklch(85% 0.01 250);
470
+
471
+ /* Semantic */
472
+ --color-success: oklch(60% 0.15 145);
473
+ --color-on-success: white;
474
+ --color-warning: oklch(75% 0.15 85);
475
+ --color-on-warning: oklch(25% 0.05 85);
476
+ --color-error: oklch(55% 0.2 25);
477
+ --color-on-error: white;
478
+ --color-info: oklch(60% 0.15 250);
479
+ --color-on-info: white;
480
+
481
+ /* Shadows */
482
+ --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
483
+ --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
484
+ --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
485
+ --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
486
+ --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
487
+
488
+ /* Focus */
489
+ --focus-ring: 0 0 0 2px var(--color-primary);
490
+ --focus-ring-offset: 0 0 0 2px white, 0 0 0 4px var(--color-primary);
491
+ `;
492
+ var moonlightTheme = `
493
+ /* Primary */
494
+ --color-primary: oklch(72% 0.15 250);
495
+ --color-primary-content: oklch(20% 0.05 250);
496
+ --color-on-primary: oklch(20% 0.05 250);
497
+
498
+ /* Secondary */
499
+ --color-secondary: oklch(68% 0.1 250);
500
+ --color-secondary-content: oklch(20% 0.05 250);
501
+ --color-on-secondary: oklch(20% 0.05 250);
502
+
503
+ /* Tertiary */
504
+ --color-tertiary: oklch(70% 0.12 300);
505
+ --color-tertiary-content: oklch(20% 0.05 300);
506
+ --color-on-tertiary: oklch(20% 0.05 300);
507
+
508
+ /* Surface */
509
+ --color-surface: oklch(18% 0.02 250);
510
+ --color-surface-container: oklch(22% 0.02 250);
511
+ --color-surface-container-low: oklch(20% 0.02 250);
512
+ --color-surface-container-high: oklch(26% 0.02 250);
513
+ --color-surface-variant: oklch(30% 0.02 250);
514
+ --color-on-surface: oklch(92% 0.01 250);
515
+ --color-on-surface-variant: oklch(75% 0.02 250);
516
+ --color-inverse-surface: oklch(92% 0.01 250);
517
+ --color-inverse-on-surface: oklch(25% 0.02 250);
518
+
519
+ /* Outline */
520
+ --color-outline: oklch(45% 0.02 250);
521
+ --color-outline-variant: oklch(35% 0.02 250);
522
+
523
+ /* Semantic */
524
+ --color-success: oklch(70% 0.15 145);
525
+ --color-on-success: oklch(20% 0.05 145);
526
+ --color-warning: oklch(80% 0.12 85);
527
+ --color-on-warning: oklch(20% 0.05 85);
528
+ --color-error: oklch(65% 0.2 25);
529
+ --color-on-error: oklch(20% 0.05 25);
530
+ --color-info: oklch(70% 0.15 250);
531
+ --color-on-info: oklch(20% 0.05 250);
532
+
533
+ /* Shadows */
534
+ --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
535
+ --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
536
+ --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
537
+ --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.4);
538
+ --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.5);
539
+
540
+ /* Focus */
541
+ --focus-ring: 0 0 0 2px var(--color-primary);
542
+ --focus-ring-offset: 0 0 0 2px oklch(18% 0.02 250), 0 0 0 4px var(--color-primary);
543
+ `;
544
+ var oceanTheme = `
545
+ /* Primary */
546
+ --color-primary: oklch(58% 0.12 210);
547
+ --color-primary-content: white;
548
+ --color-on-primary: white;
549
+
550
+ /* Secondary */
551
+ --color-secondary: oklch(55% 0.08 185);
552
+ --color-secondary-content: white;
553
+ --color-on-secondary: white;
554
+
555
+ /* Tertiary */
556
+ --color-tertiary: oklch(60% 0.1 170);
557
+ --color-tertiary-content: white;
558
+ --color-on-tertiary: white;
559
+
560
+ /* Surface */
561
+ --color-surface: oklch(98% 0.005 210);
562
+ --color-surface-container: oklch(96% 0.01 210);
563
+ --color-surface-container-low: oklch(97% 0.005 210);
564
+ --color-surface-container-high: oklch(93% 0.01 210);
565
+ --color-surface-variant: oklch(91% 0.01 210);
566
+ --color-on-surface: oklch(22% 0.02 210);
567
+ --color-on-surface-variant: oklch(40% 0.02 210);
568
+ --color-inverse-surface: oklch(22% 0.02 210);
569
+ --color-inverse-on-surface: oklch(95% 0.01 210);
570
+
571
+ /* Outline */
572
+ --color-outline: oklch(72% 0.02 210);
573
+ --color-outline-variant: oklch(82% 0.01 210);
574
+
575
+ /* Semantic */
576
+ --color-success: oklch(62% 0.14 155);
577
+ --color-on-success: white;
578
+ --color-warning: oklch(76% 0.14 80);
579
+ --color-on-warning: oklch(25% 0.05 80);
580
+ --color-error: oklch(56% 0.18 20);
581
+ --color-on-error: white;
582
+ --color-info: oklch(58% 0.12 210);
583
+ --color-on-info: white;
584
+
585
+ /* Shadows */
586
+ --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.06);
587
+ --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08);
588
+ --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
589
+ --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
590
+ --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
591
+
592
+ /* Focus */
593
+ --focus-ring: 0 0 0 2px var(--color-primary);
594
+ --focus-ring-offset: 0 0 0 2px oklch(98% 0.005 210), 0 0 0 4px var(--color-primary);
595
+ `;
596
+ var forestTheme = `
597
+ /* Primary */
598
+ --color-primary: oklch(52% 0.12 155);
599
+ --color-primary-content: white;
600
+ --color-on-primary: white;
601
+
602
+ /* Secondary */
603
+ --color-secondary: oklch(50% 0.08 70);
604
+ --color-secondary-content: white;
605
+ --color-on-secondary: white;
606
+
607
+ /* Tertiary */
608
+ --color-tertiary: oklch(55% 0.1 120);
609
+ --color-tertiary-content: white;
610
+ --color-on-tertiary: white;
611
+
612
+ /* Surface */
613
+ --color-surface: oklch(97% 0.005 90);
614
+ --color-surface-container: oklch(95% 0.01 90);
615
+ --color-surface-container-low: oklch(96% 0.005 90);
616
+ --color-surface-container-high: oklch(92% 0.01 90);
617
+ --color-surface-variant: oklch(90% 0.01 90);
618
+ --color-on-surface: oklch(22% 0.03 90);
619
+ --color-on-surface-variant: oklch(40% 0.03 90);
620
+ --color-inverse-surface: oklch(22% 0.03 90);
621
+ --color-inverse-on-surface: oklch(95% 0.01 90);
622
+
623
+ /* Outline */
624
+ --color-outline: oklch(70% 0.03 90);
625
+ --color-outline-variant: oklch(82% 0.01 90);
626
+
627
+ /* Semantic */
628
+ --color-success: oklch(58% 0.14 145);
629
+ --color-on-success: white;
630
+ --color-warning: oklch(74% 0.14 85);
631
+ --color-on-warning: oklch(25% 0.05 85);
632
+ --color-error: oklch(54% 0.18 25);
633
+ --color-on-error: white;
634
+ --color-info: oklch(55% 0.12 230);
635
+ --color-on-info: white;
636
+
637
+ /* Shadows */
638
+ --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
639
+ --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08);
640
+ --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
641
+ --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
642
+ --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
643
+
644
+ /* Focus */
645
+ --focus-ring: 0 0 0 2px var(--color-primary);
646
+ --focus-ring-offset: 0 0 0 2px oklch(97% 0.005 90), 0 0 0 4px var(--color-primary);
647
+ `;
648
+ var roseTheme = `
649
+ /* Primary */
650
+ --color-primary: oklch(60% 0.16 350);
651
+ --color-primary-content: white;
652
+ --color-on-primary: white;
653
+
654
+ /* Secondary */
655
+ --color-secondary: oklch(55% 0.1 330);
656
+ --color-secondary-content: white;
657
+ --color-on-secondary: white;
658
+
659
+ /* Tertiary */
660
+ --color-tertiary: oklch(58% 0.12 15);
661
+ --color-tertiary-content: white;
662
+ --color-on-tertiary: white;
663
+
664
+ /* Surface */
665
+ --color-surface: oklch(98% 0.005 350);
666
+ --color-surface-container: oklch(96% 0.01 350);
667
+ --color-surface-container-low: oklch(97% 0.005 350);
668
+ --color-surface-container-high: oklch(93% 0.01 350);
669
+ --color-surface-variant: oklch(91% 0.01 350);
670
+ --color-on-surface: oklch(22% 0.02 350);
671
+ --color-on-surface-variant: oklch(42% 0.02 350);
672
+ --color-inverse-surface: oklch(22% 0.02 350);
673
+ --color-inverse-on-surface: oklch(95% 0.005 350);
674
+
675
+ /* Outline */
676
+ --color-outline: oklch(72% 0.02 350);
677
+ --color-outline-variant: oklch(84% 0.01 350);
678
+
679
+ /* Semantic */
680
+ --color-success: oklch(62% 0.14 148);
681
+ --color-on-success: white;
682
+ --color-warning: oklch(76% 0.14 82);
683
+ --color-on-warning: oklch(25% 0.05 82);
684
+ --color-error: oklch(55% 0.2 22);
685
+ --color-on-error: white;
686
+ --color-info: oklch(58% 0.14 245);
687
+ --color-on-info: white;
688
+
689
+ /* Shadows */
690
+ --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.04);
691
+ --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07);
692
+ --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
693
+ --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
694
+ --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
695
+
696
+ /* Focus */
697
+ --focus-ring: 0 0 0 2px var(--color-primary);
698
+ --focus-ring-offset: 0 0 0 2px oklch(98% 0.005 350), 0 0 0 4px var(--color-primary);
699
+ `;
700
+ var themes = {
701
+ sunshine: sunshineTheme,
702
+ moonlight: moonlightTheme,
703
+ ocean: oceanTheme,
704
+ forest: forestTheme,
705
+ rose: roseTheme
706
+ };
707
+ function applyTheme(element, theme) {
708
+ const css2 = typeof theme === "string" && theme in themes ? themes[theme] : theme;
709
+ const props = css2.match(/--[\w-]+:\s*[^;]+/g);
710
+ if (props) {
711
+ for (const prop of props) {
712
+ const [name, ...valueParts] = prop.split(":");
713
+ const value = valueParts.join(":").trim();
714
+ element.style.setProperty(name.trim(), value);
715
+ }
716
+ }
717
+ }
718
+ // src/mixins.ts
719
+ function FocusableMixin(Base) {
720
+ class FocusableElement extends Base {
721
+ static properties = {
722
+ ...Base.properties,
723
+ focused: { type: Boolean, reflect: true, default: false }
724
+ };
725
+ #handleFocus = () => {
726
+ this.focused = true;
727
+ };
728
+ #handleBlur = () => {
729
+ this.focused = false;
730
+ };
731
+ connectedCallback() {
732
+ super.connectedCallback();
733
+ if (!this.hasAttribute("tabindex")) {
734
+ this.setAttribute("tabindex", "0");
735
+ }
736
+ this.addEventListener("focus", this.#handleFocus);
737
+ this.addEventListener("blur", this.#handleBlur);
738
+ }
739
+ disconnectedCallback() {
740
+ super.disconnectedCallback();
741
+ this.removeEventListener("focus", this.#handleFocus);
742
+ this.removeEventListener("blur", this.#handleBlur);
743
+ }
744
+ }
745
+ return FocusableElement;
746
+ }
747
+ function FormMixin(Base) {
748
+
749
+ class FormElement extends Base {
750
+ static properties = {
751
+ ...Base.properties,
752
+ name: { type: String, reflect: true, default: "" },
753
+ value: { type: String, reflect: true, default: "" },
754
+ disabled: { type: Boolean, reflect: true, default: false },
755
+ required: { type: Boolean, reflect: true, default: false }
756
+ };
757
+ get form() {
758
+ return this.closest("form");
759
+ }
760
+ }
761
+ return FormElement;
762
+ }
763
+ function EventListenerMixin(Base) {
764
+
765
+ class EventListenerElement extends Base {
766
+ #listeners = [];
767
+ addListener(target, type, handler, options) {
768
+ target.addEventListener(type, handler, options);
769
+ this.#listeners.push({ target, type, handler, options });
770
+ }
771
+ disconnectedCallback() {
772
+ super.disconnectedCallback();
773
+ for (const { target, type, handler, options } of this.#listeners) {
774
+ target.removeEventListener(type, handler, options);
775
+ }
776
+ this.#listeners = [];
777
+ }
778
+ }
779
+ return EventListenerElement;
780
+ }
781
+ function SlotObserverMixin(Base) {
782
+
783
+ class SlotObserverElement extends Base {
784
+ #slotObservers = new Map;
785
+ observeSlot(slotName, handler) {
786
+ this.#slotObservers.set(slotName, handler);
787
+ }
788
+ connectedCallback() {
789
+ super.connectedCallback();
790
+ requestAnimationFrame(() => this.#attachSlotListeners());
791
+ }
792
+ #attachSlotListeners() {
793
+ const slots = this.shadowRoot.querySelectorAll("slot");
794
+ for (const slot of slots) {
795
+ const name = slot.name || "";
796
+ const handler = this.#slotObservers.get(name);
797
+ if (handler) {
798
+ slot.addEventListener("slotchange", () => {
799
+ const elements2 = slot.assignedElements();
800
+ handler(elements2);
801
+ });
802
+ const elements = slot.assignedElements();
803
+ handler(elements);
804
+ }
805
+ }
806
+ }
807
+ disconnectedCallback() {
808
+ super.disconnectedCallback();
809
+ this.#slotObservers.clear();
810
+ }
811
+ }
812
+ return SlotObserverElement;
813
+ }
814
+ // src/validation.ts
815
+ function validate(value, rules) {
816
+ for (const rule of rules) {
817
+ const message = rule(value);
818
+ if (message) {
819
+ return { state: "invalid", message };
820
+ }
821
+ }
822
+ return { state: "valid", message: undefined };
823
+ }
824
+ async function validateAsync(value, rules, asyncRule) {
825
+ const syncResult = validate(value, rules);
826
+ if (syncResult.state === "invalid") {
827
+ return syncResult;
828
+ }
829
+ const message = await asyncRule(value);
830
+ if (message) {
831
+ return { state: "invalid", message };
832
+ }
833
+ return { state: "valid", message: undefined };
834
+ }
835
+ var validators = {
836
+ required(message = "This field is required") {
837
+ return (value) => !value || value.trim().length === 0 ? message : undefined;
838
+ },
839
+ minLength(min, message) {
840
+ return (value) => value && value.length < min ? message ?? `Must be at least ${min} characters` : undefined;
841
+ },
842
+ maxLength(max, message) {
843
+ return (value) => value && value.length > max ? message ?? `Must be at most ${max} characters` : undefined;
844
+ },
845
+ pattern(regex, message = "Invalid format") {
846
+ return (value) => value && !regex.test(value) ? message : undefined;
847
+ },
848
+ email(message = "Must be a valid email address") {
849
+ const emailRe = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
850
+ return (value) => value && !emailRe.test(value) ? message : undefined;
851
+ },
852
+ range(min, max, message) {
853
+ return (value) => {
854
+ if (!value)
855
+ return;
856
+ const num = Number(value);
857
+ if (isNaN(num) || num < min || num > max) {
858
+ return message ?? `Must be between ${min} and ${max}`;
859
+ }
860
+ return;
861
+ };
862
+ },
863
+ custom(predicate, message) {
864
+ return (value) => !predicate(value) ? message : undefined;
865
+ }
866
+ };
867
+ // src/performance.ts
868
+ function debounce(fn, delay) {
869
+ let timeoutId;
870
+ const debounced = function(...args) {
871
+ if (timeoutId !== undefined) {
872
+ clearTimeout(timeoutId);
873
+ }
874
+ timeoutId = setTimeout(() => {
875
+ timeoutId = undefined;
876
+ fn.apply(this, args);
877
+ }, delay);
878
+ };
879
+ debounced.cancel = () => {
880
+ if (timeoutId !== undefined) {
881
+ clearTimeout(timeoutId);
882
+ timeoutId = undefined;
883
+ }
884
+ };
885
+ return debounced;
886
+ }
887
+ function throttle(fn, interval) {
888
+ let lastCall = 0;
889
+ let timeoutId;
890
+ const throttled = function(...args) {
891
+ const now = Date.now();
892
+ const remaining = interval - (now - lastCall);
893
+ if (remaining <= 0) {
894
+ if (timeoutId !== undefined) {
895
+ clearTimeout(timeoutId);
896
+ timeoutId = undefined;
897
+ }
898
+ lastCall = now;
899
+ fn.apply(this, args);
900
+ } else if (timeoutId === undefined) {
901
+ timeoutId = setTimeout(() => {
902
+ lastCall = Date.now();
903
+ timeoutId = undefined;
904
+ fn.apply(this, args);
905
+ }, remaining);
906
+ }
907
+ };
908
+ throttled.cancel = () => {
909
+ if (timeoutId !== undefined) {
910
+ clearTimeout(timeoutId);
911
+ timeoutId = undefined;
912
+ }
913
+ lastCall = 0;
914
+ };
915
+ return throttled;
916
+ }
917
+ function scheduleIdle(callback, options) {
918
+ if (typeof requestIdleCallback === "function") {
919
+ const id2 = requestIdleCallback(callback, options);
920
+ return () => cancelIdleCallback(id2);
921
+ }
922
+ const id = setTimeout(callback, options?.timeout ?? 50);
923
+ return () => clearTimeout(id);
924
+ }
925
+ export {
926
+ validators,
927
+ validateAsync,
928
+ validate,
929
+ transition,
930
+ throttle,
931
+ themes,
932
+ sunshineTheme,
933
+ scheduleIdle,
934
+ roseTheme,
935
+ resetStyles,
936
+ oceanTheme,
937
+ moonlightTheme,
938
+ lightThemeColors,
939
+ forestTheme,
940
+ easings,
941
+ durations,
942
+ defaultTheme,
943
+ debounce,
944
+ cssVars,
945
+ css,
946
+ combineStyles,
947
+ applyTheme,
948
+ animationStyles,
949
+ animation,
950
+ SlotObserverMixin,
951
+ FormMixin,
952
+ FocusableMixin,
953
+ EventListenerMixin,
954
+ BaseElement
955
+ };
956
+
957
+ //# debugId=68AFD94A846D93BF64756E2164756E21
958
+ //# sourceMappingURL=index.js.map