@vibe-flags/core 0.1.4 → 0.1.5

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.
@@ -1,9 +1,9 @@
1
1
  import { LitElement as g, html as a, nothing as x, css as k } from "lit";
2
2
  import { customElement as h, property as c, state as v } from "lit/decorators.js";
3
- var M = Object.getOwnPropertyDescriptor, O = (t, e, r, o) => {
4
- for (var s = o > 1 ? void 0 : o ? M(e, r) : e, n = t.length - 1, i; n >= 0; n--)
5
- (i = t[n]) && (s = i(s) || s);
6
- return s;
3
+ var M = Object.getOwnPropertyDescriptor, O = (t, e, r, s) => {
4
+ for (var o = s > 1 ? void 0 : s ? M(e, r) : e, n = t.length - 1, i; n >= 0; n--)
5
+ (i = t[n]) && (o = i(o) || o);
6
+ return o;
7
7
  };
8
8
  let F = class extends g {
9
9
  render() {
@@ -21,19 +21,19 @@ class _ extends EventTarget {
21
21
  constructor() {
22
22
  super(...arguments), this.configs = /* @__PURE__ */ new Map(), this.state = {}, this.listening = !1, this.onStorageEvent = (e) => {
23
23
  if (!e.key?.startsWith(f)) return;
24
- const r = e.key.slice(f.length), o = this.configs.get(r);
25
- if (o)
24
+ const r = e.key.slice(f.length), s = this.configs.get(r);
25
+ if (s)
26
26
  try {
27
- const s = e.newValue ? JSON.parse(e.newValue) : w(o);
28
- this.state[r] = s, this.dispatch(r);
27
+ const o = e.newValue ? JSON.parse(e.newValue) : w(s);
28
+ this.state[r] = o, this.dispatch(r);
29
29
  } catch {
30
30
  }
31
31
  };
32
32
  }
33
33
  register(e) {
34
34
  this.configs.set(e.key, e);
35
- const r = this.readFromStorage(e.key);
36
- this.state[e.key] = r ?? w(e), this.listening || (this.listening = !0, typeof window < "u" && window.addEventListener("storage", this.onStorageEvent)), this.dispatch(e.key);
35
+ const r = w(e), s = this.readFromStorage(e.key), o = s !== null && (e.type === "boolean" && typeof s == "boolean" || e.type === "select" && typeof s == "string" && e.options.includes(s));
36
+ this.state[e.key] = o ? s : r, this.listening || (this.listening = !0, typeof window < "u" && window.addEventListener("storage", this.onStorageEvent)), this.dispatch(e.key);
37
37
  }
38
38
  unregister(e) {
39
39
  this.configs.delete(e), delete this.state[e], this.dispatch();
@@ -42,8 +42,8 @@ class _ extends EventTarget {
42
42
  return this.state[e];
43
43
  }
44
44
  set(e, r) {
45
- const o = this.configs.get(e);
46
- o && (o.type === "boolean" && typeof r != "boolean" || o.type === "select" && (typeof r != "string" || !o.options.includes(r)) || (this.state[e] = r, this.writeToStorage(e, r), this.dispatch(e)));
45
+ const s = this.configs.get(e);
46
+ s && (s.type === "boolean" && typeof r != "boolean" || s.type === "select" && (typeof r != "string" || !s.options.includes(r)) || (this.state[e] = r, this.writeToStorage(e, r), this.dispatch(e)));
47
47
  }
48
48
  getAll() {
49
49
  return { ...this.state };
@@ -83,18 +83,18 @@ class _ extends EventTarget {
83
83
  }
84
84
  }
85
85
  dispatch(e) {
86
- const r = { key: e, state: this.getAll() }, o = new CustomEvent("vibe-flags-changed", {
86
+ const r = { key: e, state: this.getAll() }, s = new CustomEvent("vibe-flags-changed", {
87
87
  detail: r,
88
88
  bubbles: !0
89
89
  });
90
- this.dispatchEvent(o), typeof window < "u" && window.dispatchEvent(new CustomEvent("vibe-flags-changed", { detail: r }));
90
+ this.dispatchEvent(s), typeof window < "u" && window.dispatchEvent(new CustomEvent("vibe-flags-changed", { detail: r }));
91
91
  }
92
92
  }
93
93
  const l = new _();
94
- var E = Object.defineProperty, P = Object.getOwnPropertyDescriptor, u = (t, e, r, o) => {
95
- for (var s = o > 1 ? void 0 : o ? P(e, r) : e, n = t.length - 1, i; n >= 0; n--)
96
- (i = t[n]) && (s = (o ? i(e, r, s) : i(s)) || s);
97
- return o && s && E(e, r, s), s;
94
+ var E = Object.defineProperty, P = Object.getOwnPropertyDescriptor, u = (t, e, r, s) => {
95
+ for (var o = s > 1 ? void 0 : s ? P(e, r) : e, n = t.length - 1, i; n >= 0; n--)
96
+ (i = t[n]) && (o = (s ? i(e, r, o) : i(o)) || o);
97
+ return s && o && E(e, r, o), o;
98
98
  };
99
99
  if (typeof document < "u" && !document.getElementById("vibe-flag-fouc")) {
100
100
  const t = document.createElement("style");
@@ -148,10 +148,10 @@ u([
148
148
  p = u([
149
149
  h("vibe-flag-boolean")
150
150
  ], p);
151
- var T = Object.defineProperty, j = Object.getOwnPropertyDescriptor, S = (t, e, r, o) => {
152
- for (var s = o > 1 ? void 0 : o ? j(e, r) : e, n = t.length - 1, i; n >= 0; n--)
153
- (i = t[n]) && (s = (o ? i(e, r, s) : i(s)) || s);
154
- return o && s && T(e, r, s), s;
151
+ var T = Object.defineProperty, j = Object.getOwnPropertyDescriptor, S = (t, e, r, s) => {
152
+ for (var o = s > 1 ? void 0 : s ? j(e, r) : e, n = t.length - 1, i; n >= 0; n--)
153
+ (i = t[n]) && (o = (s ? i(e, r, o) : i(o)) || o);
154
+ return s && o && T(e, r, o), o;
155
155
  };
156
156
  let y = class extends g {
157
157
  constructor() {
@@ -202,15 +202,18 @@ S([
202
202
  y = S([
203
203
  h("vibe-flag-select")
204
204
  ], y);
205
- var I = Object.defineProperty, z = Object.getOwnPropertyDescriptor, C = (t, e, r, o) => {
206
- for (var s = o > 1 ? void 0 : o ? z(e, r) : e, n = t.length - 1, i; n >= 0; n--)
207
- (i = t[n]) && (s = (o ? i(e, r, s) : i(s)) || s);
208
- return o && s && I(e, r, s), s;
205
+ var I = Object.defineProperty, z = Object.getOwnPropertyDescriptor, C = (t, e, r, s) => {
206
+ for (var o = s > 1 ? void 0 : s ? z(e, r) : e, n = t.length - 1, i; n >= 0; n--)
207
+ (i = t[n]) && (o = (s ? i(e, r, o) : i(o)) || o);
208
+ return s && o && I(e, r, o), o;
209
209
  };
210
210
  let m = class extends g {
211
211
  constructor() {
212
212
  super(...arguments), this.value = "", this.active = !1;
213
213
  }
214
+ firstUpdated() {
215
+ this.style.display = "contents";
216
+ }
214
217
  render() {
215
218
  return this.active ? a`<slot></slot>` : x;
216
219
  }
@@ -273,10 +276,10 @@ const A = k`
273
276
  0 8px 10px -6px rgba(0, 0, 0, 0.1);
274
277
  }
275
278
  `;
276
- var D = Object.defineProperty, V = Object.getOwnPropertyDescriptor, b = (t, e, r, o) => {
277
- for (var s = o > 1 ? void 0 : o ? V(e, r) : e, n = t.length - 1, i; n >= 0; n--)
278
- (i = t[n]) && (s = (o ? i(e, r, s) : i(s)) || s);
279
- return o && s && D(e, r, s), s;
279
+ var D = Object.defineProperty, V = Object.getOwnPropertyDescriptor, b = (t, e, r, s) => {
280
+ for (var o = s > 1 ? void 0 : s ? V(e, r) : e, n = t.length - 1, i; n >= 0; n--)
281
+ (i = t[n]) && (o = (s ? i(e, r, o) : i(o)) || o);
282
+ return s && o && D(e, r, o), o;
280
283
  };
281
284
  const $ = "vibeFlagsTheme";
282
285
  let d = class extends g {
@@ -309,12 +312,9 @@ let d = class extends g {
309
312
  syncFromStore() {
310
313
  this.configs = l.getConfig(), this.flags = l.getAll();
311
314
  }
312
- toggleSidebar() {
315
+ toggle() {
313
316
  this.open = !this.open;
314
317
  }
315
- closeSidebar() {
316
- this.open = !1;
317
- }
318
318
  onToggle(t) {
319
319
  const e = this.flags[t];
320
320
  l.set(t, !e);
@@ -394,14 +394,12 @@ let d = class extends g {
394
394
  render() {
395
395
  return a`
396
396
  ${this.open ? x : a`
397
- <button class="fab" @click=${this.toggleSidebar} aria-label="Toggle feature flags">
397
+ <button class="fab" @click=${this.toggle} aria-label="Toggle feature flags">
398
398
  ${this.renderFlagIcon()}
399
399
  </button>
400
400
  `}
401
401
 
402
- <div class="backdrop ${this.open ? "open" : ""}" @click=${this.closeSidebar}></div>
403
-
404
- <div class="sidebar ${this.open ? "open" : ""}">
402
+ <div class="card ${this.open ? "open" : ""}">
405
403
  <div class="header">
406
404
  <h2>
407
405
  ${this.renderFlagIcon()}
@@ -412,7 +410,7 @@ let d = class extends g {
412
410
  <button class="icon-btn" @click=${this.toggleTheme} aria-label="Toggle theme" title="${this.darkMode ? "Switch to light theme" : "Switch to dark theme"}">
413
411
  ${this.darkMode ? this.renderSunIcon() : this.renderMoonIcon()}
414
412
  </button>
415
- <button class="icon-btn" @click=${this.closeSidebar} aria-label="Close">
413
+ <button class="icon-btn" @click=${this.toggle} aria-label="Close">
416
414
  ${this.renderCloseIcon()}
417
415
  </button>
418
416
  </div>
@@ -443,15 +441,13 @@ d.styles = [
443
441
 
444
442
  .fab {
445
443
  position: fixed;
446
- right: 0;
447
- top: 50%;
448
- transform: translateY(-50%);
444
+ right: 16px;
445
+ bottom: 16px;
449
446
  z-index: 99999;
450
- width: 40px;
451
- height: 44px;
447
+ width: 42px;
448
+ height: 42px;
452
449
  border: 1px solid var(--vf-border);
453
- border-right: none;
454
- border-radius: var(--vf-radius-lg) 0 0 var(--vf-radius-lg);
450
+ border-radius: 12px;
455
451
  background: var(--vf-bg);
456
452
  color: var(--vf-text);
457
453
  cursor: pointer;
@@ -464,94 +460,80 @@ d.styles = [
464
460
  }
465
461
 
466
462
  .fab:hover {
467
- width: 46px;
468
463
  background: var(--vf-bg-muted);
464
+ box-shadow: var(--vf-shadow-xl);
465
+ transform: translateY(-1px);
469
466
  }
470
467
 
471
468
  .fab svg {
472
- width: 20px;
473
- height: 20px;
469
+ width: 18px;
470
+ height: 18px;
474
471
  flex-shrink: 0;
475
472
  }
476
473
 
477
- .backdrop {
474
+ .card {
478
475
  position: fixed;
479
- inset: 0;
480
- z-index: 100000;
481
- background: rgba(0, 0, 0, 0.4);
482
- opacity: 0;
483
- transition: opacity 0.3s ease;
484
- pointer-events: none;
485
- }
486
-
487
- .backdrop.open {
488
- opacity: 1;
489
- pointer-events: auto;
490
- }
491
-
492
- .sidebar {
493
- position: fixed;
494
- top: 0;
495
- right: 0;
496
- bottom: 0;
476
+ right: 16px;
477
+ bottom: 16px;
497
478
  z-index: 100001;
498
- width: 340px;
499
- max-width: 90vw;
479
+ width: 300px;
480
+ max-width: calc(100vw - 32px);
481
+ max-height: calc(100vh - 32px);
500
482
  background: var(--vf-bg);
501
- border-left: 1px solid var(--vf-border);
483
+ border: 1px solid var(--vf-border);
484
+ border-radius: 14px;
502
485
  box-shadow: var(--vf-shadow-xl);
503
- transform: translateX(100%);
504
- transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
505
- display: flex;
506
- flex-direction: column;
507
486
  font-family: var(--vf-font);
508
487
  color: var(--vf-text);
488
+ overflow: hidden;
489
+ display: flex;
490
+ flex-direction: column;
491
+ opacity: 0;
492
+ transform: translateY(8px) scale(0.96);
493
+ pointer-events: none;
494
+ transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
509
495
  }
510
496
 
511
- .sidebar.open {
512
- transform: translateX(0);
497
+ .card.open {
498
+ opacity: 1;
499
+ transform: translateY(0) scale(1);
500
+ pointer-events: auto;
513
501
  }
514
502
 
515
503
  .header {
516
504
  display: flex;
517
505
  align-items: center;
518
506
  justify-content: space-between;
519
- padding: 16px 20px;
507
+ padding: 12px 14px;
520
508
  border-bottom: 1px solid var(--vf-border);
521
509
  flex-shrink: 0;
522
510
  }
523
511
 
524
- .header-left {
525
- display: flex;
526
- align-items: center;
527
- gap: 8px;
528
- }
529
-
530
512
  .header h2 {
531
- font-size: 16px;
513
+ font-size: 13px;
532
514
  font-weight: 600;
533
- letter-spacing: -0.025em;
515
+ letter-spacing: -0.01em;
534
516
  display: flex;
535
517
  align-items: center;
536
- gap: 8px;
518
+ gap: 7px;
537
519
  }
538
520
 
539
521
  .header h2 svg {
540
- width: 18px;
541
- height: 18px;
522
+ width: 15px;
523
+ height: 15px;
542
524
  color: var(--vf-accent);
543
525
  }
544
526
 
545
527
  .header-actions {
546
528
  display: flex;
547
529
  align-items: center;
548
- gap: 4px;
530
+ gap: 2px;
549
531
  }
550
532
 
551
533
  .badge {
552
- font-size: 11px;
534
+ font-size: 10px;
553
535
  font-weight: 500;
554
- padding: 2px 7px;
536
+ padding: 1px 6px;
555
537
  border-radius: 9999px;
556
538
  background: var(--vf-bg-muted);
557
539
  color: var(--vf-text-muted);
@@ -559,8 +541,8 @@ d.styles = [
559
541
  }
560
542
 
561
543
  .icon-btn {
562
- width: 32px;
563
- height: 32px;
544
+ width: 28px;
545
+ height: 28px;
564
546
  border: none;
565
547
  border-radius: var(--vf-radius);
566
548
  background: transparent;
@@ -578,18 +560,17 @@ d.styles = [
578
560
  }
579
561
 
580
562
  .icon-btn svg {
581
- width: 16px;
582
- height: 16px;
563
+ width: 14px;
564
+ height: 14px;
583
565
  }
584
566
 
585
567
  .flags {
586
- flex: 1;
587
568
  overflow-y: auto;
588
- padding: 8px 0;
569
+ flex: 1;
589
570
  }
590
571
 
591
572
  .flag-item {
592
- padding: 12px 20px;
573
+ padding: 10px 14px;
593
574
  transition: background 0.1s ease;
594
575
  }
595
576
 
@@ -602,13 +583,13 @@ d.styles = [
602
583
  }
603
584
 
604
585
  .flag-label {
605
- font-size: 13px;
586
+ font-size: 12px;
606
587
  font-weight: 500;
607
- margin-bottom: 2px;
588
+ margin-bottom: 1px;
608
589
  }
609
590
 
610
591
  .flag-key {
611
- font-size: 11px;
592
+ font-size: 10px;
612
593
  color: var(--vf-text-muted);
613
594
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas,
614
595
  monospace;
@@ -618,7 +599,7 @@ d.styles = [
618
599
  display: flex;
619
600
  align-items: center;
620
601
  justify-content: space-between;
621
- gap: 12px;
602
+ gap: 10px;
622
603
  }
623
604
 
624
605
  .flag-info {
@@ -629,8 +610,8 @@ d.styles = [
629
610
  /* Toggle switch */
630
611
  .toggle {
631
612
  position: relative;
632
- width: 40px;
633
- height: 22px;
613
+ width: 36px;
614
+ height: 20px;
634
615
  flex-shrink: 0;
635
616
  }
636
617
 
@@ -644,7 +625,7 @@ d.styles = [
644
625
  .toggle-track {
645
626
  position: absolute;
646
627
  inset: 0;
647
- border-radius: 11px;
628
+ border-radius: 10px;
648
629
  background: var(--vf-border);
649
630
  cursor: pointer;
650
631
  transition: background 0.2s ease;
@@ -658,8 +639,8 @@ d.styles = [
658
639
  position: absolute;
659
640
  top: 2px;
660
641
  left: 2px;
661
- width: 18px;
662
- height: 18px;
642
+ width: 16px;
643
+ height: 16px;
663
644
  border-radius: 50%;
664
645
  background: white;
665
646
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
@@ -668,7 +649,7 @@ d.styles = [
668
649
  }
669
650
 
670
651
  .toggle input:checked ~ .toggle-thumb {
671
- transform: translateX(18px);
652
+ transform: translateX(16px);
672
653
  }
673
654
 
674
655
  /* Select dropdown */
@@ -680,16 +661,16 @@ d.styles = [
680
661
  .select {
681
662
  appearance: none;
682
663
  -webkit-appearance: none;
683
- font-size: 13px;
664
+ font-size: 12px;
684
665
  font-family: var(--vf-font);
685
- padding: 6px 30px 6px 10px;
666
+ padding: 5px 26px 5px 8px;
686
667
  border: 1px solid var(--vf-border);
687
668
  border-radius: var(--vf-radius);
688
669
  background: var(--vf-bg);
689
670
  color: var(--vf-text);
690
671
  cursor: pointer;
691
672
  outline: none;
692
- min-width: 100px;
673
+ min-width: 80px;
693
674
  transition: border-color 0.15s ease;
694
675
  }
695
676
 
@@ -704,7 +685,7 @@ d.styles = [
704
685
 
705
686
  .select-chevron {
706
687
  position: absolute;
707
- right: 8px;
688
+ right: 6px;
708
689
  top: 50%;
709
690
  transform: translateY(-50%);
710
691
  pointer-events: none;
@@ -712,21 +693,21 @@ d.styles = [
712
693
  }
713
694
 
714
695
  .select-chevron svg {
715
- width: 14px;
716
- height: 14px;
696
+ width: 12px;
697
+ height: 12px;
717
698
  }
718
699
 
719
700
  /* Footer */
720
701
  .footer {
721
- padding: 12px 20px;
702
+ padding: 10px 14px;
722
703
  border-top: 1px solid var(--vf-border);
723
704
  flex-shrink: 0;
724
705
  }
725
706
 
726
707
  .reset-btn {
727
708
  width: 100%;
728
- padding: 8px 16px;
729
- font-size: 13px;
709
+ padding: 6px 12px;
710
+ font-size: 12px;
730
711
  font-weight: 500;
731
712
  font-family: var(--vf-font);
732
713
  border: 1px solid var(--vf-border);
@@ -743,10 +724,10 @@ d.styles = [
743
724
  }
744
725
 
745
726
  .empty {
746
- padding: 40px 20px;
727
+ padding: 24px 14px;
747
728
  text-align: center;
748
729
  color: var(--vf-text-muted);
749
- font-size: 13px;
730
+ font-size: 12px;
750
731
  }
751
732
  `
752
733
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-flags/core",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "./dist/vibe-flags.js",
6
6
  "module": "./dist/vibe-flags.js",