@vibe-flags/core 0.1.4 → 0.1.6

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,23 +1,10 @@
1
- import { LitElement as g, html as a, nothing as x, css as k } from "lit";
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;
7
- };
8
- let F = class extends g {
9
- render() {
10
- return a`<slot></slot>`;
11
- }
12
- };
13
- F = O([
14
- h("vibe-flags")
15
- ], F);
1
+ import { LitElement as y, nothing as u, html as a, css as k } from "lit";
2
+ import { property as c, state as g, customElement as m } from "lit/decorators.js";
16
3
  const f = "vibe-flags:";
17
4
  function w(t) {
18
5
  return t.type === "boolean" ? !1 : t.options[0] || "";
19
6
  }
20
- class _ extends EventTarget {
7
+ class $ extends EventTarget {
21
8
  constructor() {
22
9
  super(...arguments), this.configs = /* @__PURE__ */ new Map(), this.state = {}, this.listening = !1, this.onStorageEvent = (e) => {
23
10
  if (!e.key?.startsWith(f)) return;
@@ -32,8 +19,8 @@ class _ extends EventTarget {
32
19
  }
33
20
  register(e) {
34
21
  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);
22
+ const r = w(e), o = this.readFromStorage(e.key), s = o !== null && (e.type === "boolean" && typeof o == "boolean" || e.type === "select" && typeof o == "string" && e.options.includes(o));
23
+ this.state[e.key] = s ? o : r, this.listening || (this.listening = !0, typeof window < "u" && window.addEventListener("storage", this.onStorageEvent)), this.dispatch(e.key);
37
24
  }
38
25
  unregister(e) {
39
26
  this.configs.delete(e), delete this.state[e], this.dispatch();
@@ -90,17 +77,17 @@ class _ extends EventTarget {
90
77
  this.dispatchEvent(o), typeof window < "u" && window.dispatchEvent(new CustomEvent("vibe-flags-changed", { detail: r }));
91
78
  }
92
79
  }
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--)
80
+ const l = new $();
81
+ var M = Object.defineProperty, O = Object.getOwnPropertyDescriptor, h = (t, e, r, o) => {
82
+ for (var s = o > 1 ? void 0 : o ? O(e, r) : e, n = t.length - 1, i; n >= 0; n--)
96
83
  (i = t[n]) && (s = (o ? i(e, r, s) : i(s)) || s);
97
- return o && s && E(e, r, s), s;
84
+ return o && s && M(e, r, s), s;
98
85
  };
99
86
  if (typeof document < "u" && !document.getElementById("vibe-flag-fouc")) {
100
87
  const t = document.createElement("style");
101
88
  t.id = "vibe-flag-fouc", t.textContent = "vibe-flag-boolean:not(:defined),vibe-flag-boolean:defined,vibe-flag-select:not(:defined),vibe-flag-select:defined,vibe-flag-option:not(:defined),vibe-flag-option:defined{display:none}", document.head.appendChild(t);
102
89
  }
103
- let p = class extends g {
90
+ let p = class extends y {
104
91
  constructor() {
105
92
  super(...arguments), this.name = "", this.description = "", this.value = "", this.isMatch = !1, this.onFlagChange = () => {
106
93
  this.evaluate();
@@ -130,30 +117,30 @@ let p = class extends g {
130
117
  t === void 0 ? this.isMatch = !1 : this.value === "" ? this.isMatch = !0 : this.isMatch = String(t) === this.value, this.isMatch ? this.setAttribute("active", "") : this.removeAttribute("active");
131
118
  }
132
119
  render() {
133
- return this.isMatch ? a`<slot></slot>` : x;
120
+ return this.isMatch ? a`<slot></slot>` : u;
134
121
  }
135
122
  };
136
- u([
123
+ h([
137
124
  c({ type: String })
138
125
  ], p.prototype, "name", 2);
139
- u([
126
+ h([
140
127
  c({ type: String })
141
128
  ], p.prototype, "description", 2);
142
- u([
129
+ h([
143
130
  c({ type: String })
144
131
  ], p.prototype, "value", 2);
145
- u([
146
- v()
132
+ h([
133
+ g()
147
134
  ], p.prototype, "isMatch", 2);
148
- p = u([
149
- h("vibe-flag-boolean")
135
+ p = h([
136
+ m("vibe-flag-boolean")
150
137
  ], 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--)
138
+ var _ = Object.defineProperty, E = Object.getOwnPropertyDescriptor, S = (t, e, r, o) => {
139
+ for (var s = o > 1 ? void 0 : o ? E(e, r) : e, n = t.length - 1, i; n >= 0; n--)
153
140
  (i = t[n]) && (s = (o ? i(e, r, s) : i(s)) || s);
154
- return o && s && T(e, r, s), s;
141
+ return o && s && _(e, r, s), s;
155
142
  };
156
- let y = class extends g {
143
+ let b = class extends y {
157
144
  constructor() {
158
145
  super(...arguments), this.name = "", this.description = "", this.onFlagChange = () => {
159
146
  this.syncOptions();
@@ -195,36 +182,39 @@ let y = class extends g {
195
182
  };
196
183
  S([
197
184
  c({ type: String })
198
- ], y.prototype, "name", 2);
185
+ ], b.prototype, "name", 2);
199
186
  S([
200
187
  c({ type: String })
201
- ], y.prototype, "description", 2);
202
- y = S([
203
- h("vibe-flag-select")
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--)
188
+ ], b.prototype, "description", 2);
189
+ b = S([
190
+ m("vibe-flag-select")
191
+ ], b);
192
+ var T = Object.defineProperty, I = Object.getOwnPropertyDescriptor, C = (t, e, r, o) => {
193
+ for (var s = o > 1 ? void 0 : o ? I(e, r) : e, n = t.length - 1, i; n >= 0; n--)
207
194
  (i = t[n]) && (s = (o ? i(e, r, s) : i(s)) || s);
208
- return o && s && I(e, r, s), s;
195
+ return o && s && T(e, r, s), s;
209
196
  };
210
- let m = class extends g {
197
+ let x = class extends y {
211
198
  constructor() {
212
199
  super(...arguments), this.value = "", this.active = !1;
213
200
  }
201
+ firstUpdated() {
202
+ this.style.display = "contents";
203
+ }
214
204
  render() {
215
- return this.active ? a`<slot></slot>` : x;
205
+ return this.active ? a`<slot></slot>` : u;
216
206
  }
217
207
  };
218
208
  C([
219
209
  c({ type: String })
220
- ], m.prototype, "value", 2);
210
+ ], x.prototype, "value", 2);
221
211
  C([
222
212
  c({ type: Boolean, reflect: !0 })
223
- ], m.prototype, "active", 2);
224
- m = C([
225
- h("vibe-flag-option")
226
- ], m);
227
- const A = k`
213
+ ], x.prototype, "active", 2);
214
+ x = C([
215
+ m("vibe-flag-option")
216
+ ], x);
217
+ const j = k`
228
218
  :host {
229
219
  --vf-bg: #0a0a0a;
230
220
  --vf-bg-muted: #171717;
@@ -248,7 +238,7 @@ const A = k`
248
238
  --vf-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6),
249
239
  0 8px 10px -6px rgba(0, 0, 0, 0.6);
250
240
  }
251
- `, B = k`
241
+ `, P = k`
252
242
  :host {
253
243
  --vf-bg: #ffffff;
254
244
  --vf-bg-muted: #f5f5f5;
@@ -273,13 +263,13 @@ const A = k`
273
263
  0 8px 10px -6px rgba(0, 0, 0, 0.1);
274
264
  }
275
265
  `;
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--)
266
+ var z = Object.defineProperty, A = Object.getOwnPropertyDescriptor, v = (t, e, r, o) => {
267
+ for (var s = o > 1 ? void 0 : o ? A(e, r) : e, n = t.length - 1, i; n >= 0; n--)
278
268
  (i = t[n]) && (s = (o ? i(e, r, s) : i(s)) || s);
279
- return o && s && D(e, r, s), s;
269
+ return o && s && z(e, r, s), s;
280
270
  };
281
- const $ = "vibeFlagsTheme";
282
- let d = class extends g {
271
+ const F = "vibeFlagsTheme";
272
+ let d = class extends y {
283
273
  constructor() {
284
274
  super(...arguments), this.open = !1, this.flags = {}, this.configs = [], this.darkMode = !0, this.onFlagChange = () => {
285
275
  this.syncFromStore();
@@ -293,14 +283,14 @@ let d = class extends g {
293
283
  }
294
284
  loadTheme() {
295
285
  if (typeof window > "u") return;
296
- const t = localStorage.getItem($);
286
+ const t = localStorage.getItem(F);
297
287
  this.darkMode = t ? t === "dark" : !0, this.applyTheme();
298
288
  }
299
289
  toggleTheme() {
300
- this.darkMode = !this.darkMode, localStorage.setItem($, this.darkMode ? "dark" : "light"), this.applyTheme();
290
+ this.darkMode = !this.darkMode, localStorage.setItem(F, this.darkMode ? "dark" : "light"), this.applyTheme();
301
291
  }
302
292
  applyTheme() {
303
- const t = this.darkMode ? A : B, e = new CSSStyleSheet();
293
+ const t = this.darkMode ? j : P, e = new CSSStyleSheet();
304
294
  e.replaceSync(t.cssText), this.shadowRoot.adoptedStyleSheets = [
305
295
  ...d.elementStyles.map((r) => r.styleSheet),
306
296
  e
@@ -309,12 +299,9 @@ let d = class extends g {
309
299
  syncFromStore() {
310
300
  this.configs = l.getConfig(), this.flags = l.getAll();
311
301
  }
312
- toggleSidebar() {
302
+ toggle() {
313
303
  this.open = !this.open;
314
304
  }
315
- closeSidebar() {
316
- this.open = !1;
317
- }
318
305
  onToggle(t) {
319
306
  const e = this.flags[t];
320
307
  l.set(t, !e);
@@ -364,7 +351,7 @@ let d = class extends g {
364
351
  `;
365
352
  }
366
353
  renderSelectFlag(t) {
367
- if (t.type !== "select") return x;
354
+ if (t.type !== "select") return u;
368
355
  const e = this.flags[t.key];
369
356
  return a`
370
357
  <div class="flag-item">
@@ -393,15 +380,13 @@ let d = class extends g {
393
380
  }
394
381
  render() {
395
382
  return a`
396
- ${this.open ? x : a`
397
- <button class="fab" @click=${this.toggleSidebar} aria-label="Toggle feature flags">
383
+ ${this.open ? u : a`
384
+ <button class="fab" @click=${this.toggle} aria-label="Toggle feature flags">
398
385
  ${this.renderFlagIcon()}
399
386
  </button>
400
387
  `}
401
388
 
402
- <div class="backdrop ${this.open ? "open" : ""}" @click=${this.closeSidebar}></div>
403
-
404
- <div class="sidebar ${this.open ? "open" : ""}">
389
+ <div class="card ${this.open ? "open" : ""}">
405
390
  <div class="header">
406
391
  <h2>
407
392
  ${this.renderFlagIcon()}
@@ -412,7 +397,7 @@ let d = class extends g {
412
397
  <button class="icon-btn" @click=${this.toggleTheme} aria-label="Toggle theme" title="${this.darkMode ? "Switch to light theme" : "Switch to dark theme"}">
413
398
  ${this.darkMode ? this.renderSunIcon() : this.renderMoonIcon()}
414
399
  </button>
415
- <button class="icon-btn" @click=${this.closeSidebar} aria-label="Close">
400
+ <button class="icon-btn" @click=${this.toggle} aria-label="Close">
416
401
  ${this.renderCloseIcon()}
417
402
  </button>
418
403
  </div>
@@ -443,15 +428,13 @@ d.styles = [
443
428
 
444
429
  .fab {
445
430
  position: fixed;
446
- right: 0;
447
- top: 50%;
448
- transform: translateY(-50%);
431
+ right: 16px;
432
+ bottom: 16px;
449
433
  z-index: 99999;
450
- width: 40px;
451
- height: 44px;
434
+ width: 42px;
435
+ height: 42px;
452
436
  border: 1px solid var(--vf-border);
453
- border-right: none;
454
- border-radius: var(--vf-radius-lg) 0 0 var(--vf-radius-lg);
437
+ border-radius: 12px;
455
438
  background: var(--vf-bg);
456
439
  color: var(--vf-text);
457
440
  cursor: pointer;
@@ -464,94 +447,80 @@ d.styles = [
464
447
  }
465
448
 
466
449
  .fab:hover {
467
- width: 46px;
468
450
  background: var(--vf-bg-muted);
451
+ box-shadow: var(--vf-shadow-xl);
452
+ transform: translateY(-1px);
469
453
  }
470
454
 
471
455
  .fab svg {
472
- width: 20px;
473
- height: 20px;
456
+ width: 18px;
457
+ height: 18px;
474
458
  flex-shrink: 0;
475
459
  }
476
460
 
477
- .backdrop {
461
+ .card {
478
462
  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;
463
+ right: 16px;
464
+ bottom: 16px;
497
465
  z-index: 100001;
498
- width: 340px;
499
- max-width: 90vw;
466
+ width: 300px;
467
+ max-width: calc(100vw - 32px);
468
+ max-height: calc(100vh - 32px);
500
469
  background: var(--vf-bg);
501
- border-left: 1px solid var(--vf-border);
470
+ border: 1px solid var(--vf-border);
471
+ border-radius: 14px;
502
472
  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
473
  font-family: var(--vf-font);
508
474
  color: var(--vf-text);
475
+ overflow: hidden;
476
+ display: flex;
477
+ flex-direction: column;
478
+ opacity: 0;
479
+ transform: translateY(8px) scale(0.96);
480
+ pointer-events: none;
481
+ transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
509
482
  }
510
483
 
511
- .sidebar.open {
512
- transform: translateX(0);
484
+ .card.open {
485
+ opacity: 1;
486
+ transform: translateY(0) scale(1);
487
+ pointer-events: auto;
513
488
  }
514
489
 
515
490
  .header {
516
491
  display: flex;
517
492
  align-items: center;
518
493
  justify-content: space-between;
519
- padding: 16px 20px;
494
+ padding: 12px 14px;
520
495
  border-bottom: 1px solid var(--vf-border);
521
496
  flex-shrink: 0;
522
497
  }
523
498
 
524
- .header-left {
525
- display: flex;
526
- align-items: center;
527
- gap: 8px;
528
- }
529
-
530
499
  .header h2 {
531
- font-size: 16px;
500
+ font-size: 13px;
532
501
  font-weight: 600;
533
- letter-spacing: -0.025em;
502
+ letter-spacing: -0.01em;
534
503
  display: flex;
535
504
  align-items: center;
536
- gap: 8px;
505
+ gap: 7px;
537
506
  }
538
507
 
539
508
  .header h2 svg {
540
- width: 18px;
541
- height: 18px;
509
+ width: 15px;
510
+ height: 15px;
542
511
  color: var(--vf-accent);
543
512
  }
544
513
 
545
514
  .header-actions {
546
515
  display: flex;
547
516
  align-items: center;
548
- gap: 4px;
517
+ gap: 2px;
549
518
  }
550
519
 
551
520
  .badge {
552
- font-size: 11px;
521
+ font-size: 10px;
553
522
  font-weight: 500;
554
- padding: 2px 7px;
523
+ padding: 1px 6px;
555
524
  border-radius: 9999px;
556
525
  background: var(--vf-bg-muted);
557
526
  color: var(--vf-text-muted);
@@ -559,8 +528,8 @@ d.styles = [
559
528
  }
560
529
 
561
530
  .icon-btn {
562
- width: 32px;
563
- height: 32px;
531
+ width: 28px;
532
+ height: 28px;
564
533
  border: none;
565
534
  border-radius: var(--vf-radius);
566
535
  background: transparent;
@@ -578,18 +547,17 @@ d.styles = [
578
547
  }
579
548
 
580
549
  .icon-btn svg {
581
- width: 16px;
582
- height: 16px;
550
+ width: 14px;
551
+ height: 14px;
583
552
  }
584
553
 
585
554
  .flags {
586
- flex: 1;
587
555
  overflow-y: auto;
588
- padding: 8px 0;
556
+ flex: 1;
589
557
  }
590
558
 
591
559
  .flag-item {
592
- padding: 12px 20px;
560
+ padding: 10px 14px;
593
561
  transition: background 0.1s ease;
594
562
  }
595
563
 
@@ -602,13 +570,13 @@ d.styles = [
602
570
  }
603
571
 
604
572
  .flag-label {
605
- font-size: 13px;
573
+ font-size: 12px;
606
574
  font-weight: 500;
607
- margin-bottom: 2px;
575
+ margin-bottom: 1px;
608
576
  }
609
577
 
610
578
  .flag-key {
611
- font-size: 11px;
579
+ font-size: 10px;
612
580
  color: var(--vf-text-muted);
613
581
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas,
614
582
  monospace;
@@ -618,7 +586,7 @@ d.styles = [
618
586
  display: flex;
619
587
  align-items: center;
620
588
  justify-content: space-between;
621
- gap: 12px;
589
+ gap: 10px;
622
590
  }
623
591
 
624
592
  .flag-info {
@@ -629,8 +597,8 @@ d.styles = [
629
597
  /* Toggle switch */
630
598
  .toggle {
631
599
  position: relative;
632
- width: 40px;
633
- height: 22px;
600
+ width: 36px;
601
+ height: 20px;
634
602
  flex-shrink: 0;
635
603
  }
636
604
 
@@ -644,7 +612,7 @@ d.styles = [
644
612
  .toggle-track {
645
613
  position: absolute;
646
614
  inset: 0;
647
- border-radius: 11px;
615
+ border-radius: 10px;
648
616
  background: var(--vf-border);
649
617
  cursor: pointer;
650
618
  transition: background 0.2s ease;
@@ -658,8 +626,8 @@ d.styles = [
658
626
  position: absolute;
659
627
  top: 2px;
660
628
  left: 2px;
661
- width: 18px;
662
- height: 18px;
629
+ width: 16px;
630
+ height: 16px;
663
631
  border-radius: 50%;
664
632
  background: white;
665
633
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
@@ -668,7 +636,7 @@ d.styles = [
668
636
  }
669
637
 
670
638
  .toggle input:checked ~ .toggle-thumb {
671
- transform: translateX(18px);
639
+ transform: translateX(16px);
672
640
  }
673
641
 
674
642
  /* Select dropdown */
@@ -680,16 +648,16 @@ d.styles = [
680
648
  .select {
681
649
  appearance: none;
682
650
  -webkit-appearance: none;
683
- font-size: 13px;
651
+ font-size: 12px;
684
652
  font-family: var(--vf-font);
685
- padding: 6px 30px 6px 10px;
653
+ padding: 5px 26px 5px 8px;
686
654
  border: 1px solid var(--vf-border);
687
655
  border-radius: var(--vf-radius);
688
656
  background: var(--vf-bg);
689
657
  color: var(--vf-text);
690
658
  cursor: pointer;
691
659
  outline: none;
692
- min-width: 100px;
660
+ min-width: 80px;
693
661
  transition: border-color 0.15s ease;
694
662
  }
695
663
 
@@ -704,7 +672,7 @@ d.styles = [
704
672
 
705
673
  .select-chevron {
706
674
  position: absolute;
707
- right: 8px;
675
+ right: 6px;
708
676
  top: 50%;
709
677
  transform: translateY(-50%);
710
678
  pointer-events: none;
@@ -712,21 +680,21 @@ d.styles = [
712
680
  }
713
681
 
714
682
  .select-chevron svg {
715
- width: 14px;
716
- height: 14px;
683
+ width: 12px;
684
+ height: 12px;
717
685
  }
718
686
 
719
687
  /* Footer */
720
688
  .footer {
721
- padding: 12px 20px;
689
+ padding: 10px 14px;
722
690
  border-top: 1px solid var(--vf-border);
723
691
  flex-shrink: 0;
724
692
  }
725
693
 
726
694
  .reset-btn {
727
695
  width: 100%;
728
- padding: 8px 16px;
729
- font-size: 13px;
696
+ padding: 6px 12px;
697
+ font-size: 12px;
730
698
  font-weight: 500;
731
699
  font-family: var(--vf-font);
732
700
  border: 1px solid var(--vf-border);
@@ -743,33 +711,32 @@ d.styles = [
743
711
  }
744
712
 
745
713
  .empty {
746
- padding: 40px 20px;
714
+ padding: 24px 14px;
747
715
  text-align: center;
748
716
  color: var(--vf-text-muted);
749
- font-size: 13px;
717
+ font-size: 12px;
750
718
  }
751
719
  `
752
720
  ];
753
- b([
754
- v()
721
+ v([
722
+ g()
755
723
  ], d.prototype, "open", 2);
756
- b([
757
- v()
724
+ v([
725
+ g()
758
726
  ], d.prototype, "flags", 2);
759
- b([
760
- v()
727
+ v([
728
+ g()
761
729
  ], d.prototype, "configs", 2);
762
- b([
763
- v()
730
+ v([
731
+ g()
764
732
  ], d.prototype, "darkMode", 2);
765
- d = b([
766
- h("vibe-toolbar")
733
+ d = v([
734
+ m("vibe-toolbar")
767
735
  ], d);
768
736
  export {
769
737
  p as VibeFlagBoolean,
770
- m as VibeFlagOption,
771
- y as VibeFlagSelect,
772
- F as VibeFlags,
738
+ x as VibeFlagOption,
739
+ b as VibeFlagSelect,
773
740
  d as VibeToolbar,
774
741
  l as flagStore
775
742
  };
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.6",
4
4
  "type": "module",
5
5
  "main": "./dist/vibe-flags.js",
6
6
  "module": "./dist/vibe-flags.js",