-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_ds_bundle.js
More file actions
2511 lines (2436 loc) · 90.7 KB
/
Copy path_ds_bundle.js
File metadata and controls
2511 lines (2436 loc) · 90.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* @ds-bundle: {"format":3,"namespace":"NLACEDesignSystem_c5a5c6","components":[{"name":"Alert","sourcePath":"src/components/Alert.jsx"},{"name":"Badge","sourcePath":"src/components/Badge.jsx"},{"name":"Button","sourcePath":"src/components/Button.jsx"},{"name":"Card","sourcePath":"src/components/Card.jsx"},{"name":"NL_CHART_PALETTE","sourcePath":"src/components/Charts.jsx"},{"name":"BarChart","sourcePath":"src/components/Charts.jsx"},{"name":"LineChart","sourcePath":"src/components/Charts.jsx"},{"name":"AreaChart","sourcePath":"src/components/Charts.jsx"},{"name":"PieChart","sourcePath":"src/components/Charts.jsx"},{"name":"DonutChart","sourcePath":"src/components/Charts.jsx"},{"name":"Dropdown","sourcePath":"src/components/Dropdown.jsx"},{"name":"Input","sourcePath":"src/components/Input.jsx"},{"name":"Spinner","sourcePath":"src/components/Loaders.jsx"},{"name":"Skeleton","sourcePath":"src/components/Loaders.jsx"},{"name":"Modal","sourcePath":"src/components/Modal.jsx"},{"name":"NlaceLogo","sourcePath":"src/components/NlaceLogo.jsx"},{"name":"NlaceAvatar","sourcePath":"src/components/NlaceLogo.jsx"},{"name":"Switch","sourcePath":"src/components/Switch.jsx"},{"name":"Table","sourcePath":"src/components/Table.jsx"},{"name":"Tabs","sourcePath":"src/components/Tabs.jsx"},{"name":"Tooltip","sourcePath":"src/components/Tooltip.jsx"}],"sourceHashes":{"decks/deck-stage.js":"522102a1c71e","src/components/Alert.jsx":"4af691c150f9","src/components/Badge.jsx":"9e58008f170a","src/components/Button.jsx":"df1b15804e10","src/components/Card.jsx":"f6c6a55578d7","src/components/Charts.jsx":"c88e0eaf56b3","src/components/Dropdown.jsx":"479d48572485","src/components/Input.jsx":"2757dee2921a","src/components/Loaders.jsx":"c3ad7372ff9e","src/components/Modal.jsx":"f5dc1a209218","src/components/NlaceLogo.jsx":"e5a358176c3e","src/components/Switch.jsx":"3d65706bfa34","src/components/Table.jsx":"4e67c8dcf9c2","src/components/Tabs.jsx":"3433cb81a979","src/components/Tooltip.jsx":"ba032e6be91e","src/index.js":"49832d40b588","src/tailwind-preset.js":"d8afe49dedd8","ui_kits/ai-studio/components.jsx":"c6f202dbe989","ui_kits/ai-studio/screens.jsx":"3dad7bee301c"},"inlinedExternals":[],"unexposedExports":[]} */
(() => {
const __ds_ns = (window.NLACEDesignSystem_c5a5c6 = window.NLACEDesignSystem_c5a5c6 || {});
const __ds_scope = {};
(__ds_ns.__errors = __ds_ns.__errors || []);
// decks/deck-stage.js
try { (() => {
/**
* <deck-stage> — reusable web component for HTML decks.
*
* Handles:
* (a) speaker notes — reads <script type="application/json" id="speaker-notes">
* and posts {slideIndexChanged: N} to the parent window on nav.
* (b) keyboard navigation — ←/→, PgUp/PgDn, Space, Home/End, number keys.
* (c) press R to reset to slide 0 (with a tasteful keyboard hint).
* (d) bottom-center overlay showing slide count + hints, fades out on idle.
* (e) auto-scaling — inner canvas is a fixed design size (default 1920×1080)
* scaled with `transform: scale()` to fit the viewport, letterboxed.
* Set the `noscale` attribute to render at authored size (1:1) — the
* PPTX exporter sets this so its DOM capture sees unscaled geometry.
* (f) print — `@media print` lays every slide out as its own page at the
* design size, so the browser's Print → Save as PDF produces a clean
* one-page-per-slide PDF with no extra setup.
*
* Slides are HIDDEN, not unmounted. Non-active slides stay in the DOM with
* `visibility: hidden` + `opacity: 0`, so their state (videos, iframes,
* form inputs, React trees) is preserved across navigation.
*
* Lifecycle event — the component dispatches a `slidechange` CustomEvent on
* itself whenever the active slide changes (including the initial mount).
* The event bubbles and composes out of shadow DOM, so you can listen on
* the <deck-stage> element or on document:
*
* document.querySelector('deck-stage').addEventListener('slidechange', (e) => {
* e.detail.index // new 0-based index
* e.detail.previousIndex // previous index, or -1 on init
* e.detail.total // total slide count
* e.detail.slide // the new active slide element
* e.detail.previousSlide // the prior slide element, or null on init
* e.detail.reason // 'init' | 'keyboard' | 'click' | 'tap' | 'api'
* });
*
* Persistence: current slide index is saved to localStorage keyed by the
* document path, so refresh returns you to the same place.
*
* Usage:
* <deck-stage width="1920" height="1080">
* <section data-label="Title">...</section>
* <section data-label="Agenda">...</section>
* </deck-stage>
*
* Slides are the direct element children of <deck-stage>. Each slide is
* automatically tagged with:
* - data-screen-label="NN Label" (1-indexed, for comment flow)
* - data-om-validate="no_overflowing_text,no_overlapping_text,slide_sized_text"
*/
(() => {
const DESIGN_W_DEFAULT = 1920;
const DESIGN_H_DEFAULT = 1080;
const STORAGE_PREFIX = 'deck-stage:slide:';
const OVERLAY_HIDE_MS = 1800;
const VALIDATE_ATTR = 'no_overflowing_text,no_overlapping_text,slide_sized_text';
const pad2 = n => String(n).padStart(2, '0');
const stylesheet = `
:host {
position: fixed;
inset: 0;
display: block;
background: #000;
color: #fff;
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
overflow: hidden;
}
.stage {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
}
.canvas {
position: relative;
transform-origin: center center;
flex-shrink: 0;
background: #fff;
will-change: transform;
}
/* Slides live in light DOM (via <slot>) so authored CSS still applies.
We absolutely position each slotted child to stack them. */
::slotted(*) {
position: absolute !important;
inset: 0 !important;
width: 100% !important;
height: 100% !important;
box-sizing: border-box !important;
overflow: hidden;
opacity: 0;
pointer-events: none;
visibility: hidden;
}
::slotted([data-deck-active]) {
opacity: 1;
pointer-events: auto;
visibility: visible;
}
/* Tap zones for mobile — back/forward thirds like Stories.
Transparent, no visible UI, don't block the overlay. */
.tapzones {
position: fixed;
inset: 0;
display: flex;
z-index: 2147482000;
pointer-events: none;
}
.tapzone {
flex: 1;
pointer-events: auto;
-webkit-tap-highlight-color: transparent;
}
/* Only activate tap zones on coarse pointers (touch devices). */
@media (hover: hover) and (pointer: fine) {
.tapzones { display: none; }
}
.overlay {
position: fixed;
left: 50%;
bottom: 22px;
transform: translate(-50%, 6px) scale(0.92);
filter: blur(6px);
display: flex;
align-items: center;
gap: 4px;
padding: 4px;
background: #000;
color: #fff;
border-radius: 999px;
font-size: 12px;
font-feature-settings: "tnum" 1;
letter-spacing: 0.01em;
opacity: 0;
pointer-events: none;
transition: opacity 260ms ease, transform 260ms cubic-bezier(.2,.8,.2,1), filter 260ms ease;
transform-origin: center bottom;
z-index: 2147483000;
user-select: none;
}
.overlay[data-visible] {
opacity: 1;
pointer-events: auto;
transform: translate(-50%, 0) scale(1);
filter: blur(0);
}
.btn {
appearance: none;
-webkit-appearance: none;
background: transparent;
border: 0;
margin: 0;
padding: 0;
color: inherit;
font: inherit;
cursor: default;
display: inline-flex;
align-items: center;
justify-content: center;
height: 28px;
min-width: 28px;
border-radius: 999px;
color: rgba(255,255,255,0.72);
transition: background 140ms ease, color 140ms ease;
-webkit-tap-highlight-color: transparent;
}
.btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.btn:active { background: rgba(255,255,255,0.18); }
.btn:focus { outline: none; }
.btn:focus-visible { outline: none; }
.btn::-moz-focus-inner { border: 0; }
.btn svg { width: 14px; height: 14px; display: block; }
.btn.reset {
font-size: 11px;
font-weight: 500;
letter-spacing: 0.02em;
padding: 0 10px 0 12px;
gap: 6px;
color: rgba(255,255,255,0.72);
}
.btn.reset .kbd {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 16px;
height: 16px;
padding: 0 4px;
font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
font-size: 10px;
line-height: 1;
color: rgba(255,255,255,0.88);
background: rgba(255,255,255,0.12);
border-radius: 4px;
}
.count {
font-variant-numeric: tabular-nums;
color: #fff;
font-weight: 500;
padding: 0 8px;
min-width: 42px;
text-align: center;
font-size: 12px;
}
.count .sep { color: rgba(255,255,255,0.45); margin: 0 3px; font-weight: 400; }
.count .total { color: rgba(255,255,255,0.55); }
.divider {
width: 1px;
height: 14px;
background: rgba(255,255,255,0.18);
margin: 0 2px;
}
/* ── Print: one page per slide, no chrome ────────────────────────────
The screen layout stacks every slide at inset:0 inside a scaled
canvas; for print we want them in document flow at the authored
design size so the browser paginates one slide per sheet. The
@page size is set from the width/height attributes via the inline
<style id="deck-stage-print-page"> that connectedCallback injects
into <head> (the @page at-rule has no effect inside shadow DOM). */
@media print {
:host {
position: static;
inset: auto;
background: none;
overflow: visible;
color: inherit;
}
.stage { position: static; display: block; }
.canvas {
transform: none !important;
width: auto !important;
height: auto !important;
background: none;
will-change: auto;
}
::slotted(*) {
position: relative !important;
inset: auto !important;
width: var(--deck-design-w) !important;
height: var(--deck-design-h) !important;
box-sizing: border-box !important;
opacity: 1 !important;
visibility: visible !important;
pointer-events: auto;
break-after: page;
page-break-after: always;
break-inside: avoid;
overflow: hidden;
}
::slotted(*:last-child) {
break-after: auto;
page-break-after: auto;
}
.overlay, .tapzones { display: none !important; }
}
`;
class DeckStage extends HTMLElement {
static get observedAttributes() {
return ['width', 'height', 'noscale'];
}
constructor() {
super();
this._root = this.attachShadow({
mode: 'open'
});
this._index = 0;
this._slides = [];
this._notes = [];
this._hideTimer = null;
this._mouseIdleTimer = null;
this._storageKey = STORAGE_PREFIX + (location.pathname || '/');
this._onKey = this._onKey.bind(this);
this._onResize = this._onResize.bind(this);
this._onSlotChange = this._onSlotChange.bind(this);
this._onMouseMove = this._onMouseMove.bind(this);
this._onTapBack = this._onTapBack.bind(this);
this._onTapForward = this._onTapForward.bind(this);
}
get designWidth() {
return parseInt(this.getAttribute('width'), 10) || DESIGN_W_DEFAULT;
}
get designHeight() {
return parseInt(this.getAttribute('height'), 10) || DESIGN_H_DEFAULT;
}
connectedCallback() {
this._render();
this._loadNotes();
this._syncPrintPageRule();
window.addEventListener('keydown', this._onKey);
window.addEventListener('resize', this._onResize);
window.addEventListener('mousemove', this._onMouseMove, {
passive: true
});
// Initial collection + layout happens via slotchange, which fires on mount.
}
disconnectedCallback() {
window.removeEventListener('keydown', this._onKey);
window.removeEventListener('resize', this._onResize);
window.removeEventListener('mousemove', this._onMouseMove);
if (this._hideTimer) clearTimeout(this._hideTimer);
if (this._mouseIdleTimer) clearTimeout(this._mouseIdleTimer);
}
attributeChangedCallback() {
if (this._canvas) {
this._canvas.style.width = this.designWidth + 'px';
this._canvas.style.height = this.designHeight + 'px';
this._canvas.style.setProperty('--deck-design-w', this.designWidth + 'px');
this._canvas.style.setProperty('--deck-design-h', this.designHeight + 'px');
this._fit();
this._syncPrintPageRule();
}
}
_render() {
const style = document.createElement('style');
style.textContent = stylesheet;
const stage = document.createElement('div');
stage.className = 'stage';
const canvas = document.createElement('div');
canvas.className = 'canvas';
canvas.style.width = this.designWidth + 'px';
canvas.style.height = this.designHeight + 'px';
canvas.style.setProperty('--deck-design-w', this.designWidth + 'px');
canvas.style.setProperty('--deck-design-h', this.designHeight + 'px');
const slot = document.createElement('slot');
slot.addEventListener('slotchange', this._onSlotChange);
canvas.appendChild(slot);
stage.appendChild(canvas);
// Tap zones (mobile): left third = back, right third = forward.
const tapzones = document.createElement('div');
tapzones.className = 'tapzones export-hidden';
tapzones.setAttribute('aria-hidden', 'true');
const tzBack = document.createElement('div');
tzBack.className = 'tapzone tapzone--back';
const tzMid = document.createElement('div');
tzMid.className = 'tapzone tapzone--mid';
tzMid.style.pointerEvents = 'none';
const tzFwd = document.createElement('div');
tzFwd.className = 'tapzone tapzone--fwd';
tzBack.addEventListener('click', this._onTapBack);
tzFwd.addEventListener('click', this._onTapForward);
tapzones.append(tzBack, tzMid, tzFwd);
// Overlay: compact, solid black, with clickable controls.
const overlay = document.createElement('div');
overlay.className = 'overlay export-hidden';
overlay.setAttribute('role', 'toolbar');
overlay.setAttribute('aria-label', 'Deck controls');
overlay.innerHTML = `
<button class="btn prev" type="button" aria-label="Previous slide" title="Previous (←)">
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3L5 8l5 5"/></svg>
</button>
<span class="count" aria-live="polite"><span class="current">1</span><span class="sep">/</span><span class="total">1</span></span>
<button class="btn next" type="button" aria-label="Next slide" title="Next (→)">
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 3l5 5-5 5"/></svg>
</button>
<span class="divider"></span>
<button class="btn reset" type="button" aria-label="Reset to first slide" title="Reset (R)">Reset<span class="kbd">R</span></button>
`;
overlay.querySelector('.prev').addEventListener('click', () => this._go(this._index - 1, 'click'));
overlay.querySelector('.next').addEventListener('click', () => this._go(this._index + 1, 'click'));
overlay.querySelector('.reset').addEventListener('click', () => this._go(0, 'click'));
this._root.append(style, stage, tapzones, overlay);
this._canvas = canvas;
this._slot = slot;
this._overlay = overlay;
this._countEl = overlay.querySelector('.current');
this._totalEl = overlay.querySelector('.total');
}
/** @page must live in the document stylesheet — it's a no-op inside
* shadow DOM. Inject/update a single <head> style tag so the print
* sheet matches the design size and Save-as-PDF yields one slide per
* page with no margins. */
_syncPrintPageRule() {
const id = 'deck-stage-print-page';
let tag = document.getElementById(id);
if (!tag) {
tag = document.createElement('style');
tag.id = id;
document.head.appendChild(tag);
}
tag.textContent = '@page { size: ' + this.designWidth + 'px ' + this.designHeight + 'px; margin: 0; } ' + '@media print { html, body { margin: 0 !important; padding: 0 !important; background: none !important; overflow: visible !important; height: auto !important; } ' + '* { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }';
}
_onSlotChange() {
this._collectSlides();
this._restoreIndex();
this._applyIndex({
showOverlay: false,
broadcast: true,
reason: 'init'
});
this._fit();
}
_collectSlides() {
const assigned = this._slot.assignedElements({
flatten: true
});
this._slides = assigned.filter(el => {
// Skip template/style/script nodes even if someone slots them.
const tag = el.tagName;
return tag !== 'TEMPLATE' && tag !== 'SCRIPT' && tag !== 'STYLE';
});
this._slides.forEach((slide, i) => {
const n = i + 1;
// Determine a label for comment flow: prefer explicit data-label,
// then an existing data-screen-label, then first heading, else "Slide".
let label = slide.getAttribute('data-label');
if (!label) {
const existing = slide.getAttribute('data-screen-label');
if (existing) {
// Strip any leading number the author may have included.
label = existing.replace(/^\s*\d+\s*/, '').trim() || existing;
}
}
if (!label) {
const h = slide.querySelector('h1, h2, h3, [data-title]');
if (h) label = (h.textContent || '').trim().slice(0, 40);
}
if (!label) label = 'Slide';
slide.setAttribute('data-screen-label', `${pad2(n)} ${label}`);
// Validation attribute for comment flow / auto-checks.
if (!slide.hasAttribute('data-om-validate')) {
slide.setAttribute('data-om-validate', VALIDATE_ATTR);
}
slide.setAttribute('data-deck-slide', String(i));
});
if (this._totalEl) this._totalEl.textContent = String(this._slides.length || 1);
if (this._index >= this._slides.length) this._index = Math.max(0, this._slides.length - 1);
}
_loadNotes() {
const tag = document.getElementById('speaker-notes');
if (!tag) {
this._notes = [];
return;
}
try {
const parsed = JSON.parse(tag.textContent || '[]');
if (Array.isArray(parsed)) this._notes = parsed;
} catch (e) {
console.warn('[deck-stage] Failed to parse #speaker-notes JSON:', e);
this._notes = [];
}
}
_restoreIndex() {
try {
const raw = localStorage.getItem(this._storageKey);
if (raw != null) {
const n = parseInt(raw, 10);
if (Number.isFinite(n) && n >= 0 && n < this._slides.length) {
this._index = n;
}
}
} catch (e) {/* ignore */}
}
_persistIndex() {
try {
localStorage.setItem(this._storageKey, String(this._index));
} catch (e) {/* ignore */}
}
_applyIndex({
showOverlay = true,
broadcast = true,
reason = 'init'
} = {}) {
if (!this._slides.length) return;
const prev = this._prevIndex == null ? -1 : this._prevIndex;
const curr = this._index;
this._slides.forEach((s, i) => {
if (i === curr) s.setAttribute('data-deck-active', '');else s.removeAttribute('data-deck-active');
});
if (this._countEl) this._countEl.textContent = String(curr + 1);
this._persistIndex();
if (broadcast) {
// (1) Legacy: host-window postMessage for speaker-notes renderers.
try {
window.postMessage({
slideIndexChanged: curr
}, '*');
} catch (e) {}
// (2) In-page CustomEvent on the <deck-stage> element itself.
// Bubbles and composes out of shadow DOM so slide code can listen:
// document.querySelector('deck-stage').addEventListener('slidechange', e => {
// e.detail.index, e.detail.previousIndex, e.detail.total, e.detail.slide, e.detail.reason
// });
const detail = {
index: curr,
previousIndex: prev,
total: this._slides.length,
slide: this._slides[curr] || null,
previousSlide: prev >= 0 ? this._slides[prev] || null : null,
reason: reason // 'init' | 'keyboard' | 'click' | 'tap' | 'api'
};
this.dispatchEvent(new CustomEvent('slidechange', {
detail,
bubbles: true,
composed: true
}));
}
this._prevIndex = curr;
if (showOverlay) this._flashOverlay();
}
_flashOverlay() {
if (!this._overlay) return;
this._overlay.setAttribute('data-visible', '');
if (this._hideTimer) clearTimeout(this._hideTimer);
this._hideTimer = setTimeout(() => {
this._overlay.removeAttribute('data-visible');
}, OVERLAY_HIDE_MS);
}
_fit() {
if (!this._canvas) return;
// PPTX export sets noscale so the DOM capture sees authored-size
// geometry — the scaled canvas is in shadow DOM, so the exporter's
// resetTransformSelector can't reach .canvas.style.transform directly.
if (this.hasAttribute('noscale')) {
this._canvas.style.transform = 'none';
return;
}
const vw = window.innerWidth;
const vh = window.innerHeight;
const s = Math.min(vw / this.designWidth, vh / this.designHeight);
this._canvas.style.transform = `scale(${s})`;
}
_onResize() {
this._fit();
}
_onMouseMove() {
// Keep overlay visible while mouse moves; hide after idle.
this._flashOverlay();
}
_onTapBack(e) {
e.preventDefault();
this._go(this._index - 1, 'tap');
}
_onTapForward(e) {
e.preventDefault();
this._go(this._index + 1, 'tap');
}
_onKey(e) {
// Ignore when the user is typing.
const t = e.target;
if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) return;
if (e.metaKey || e.ctrlKey || e.altKey) return;
const key = e.key;
let handled = true;
if (key === 'ArrowRight' || key === 'PageDown' || key === ' ' || key === 'Spacebar') {
this._go(this._index + 1, 'keyboard');
} else if (key === 'ArrowLeft' || key === 'PageUp') {
this._go(this._index - 1, 'keyboard');
} else if (key === 'Home') {
this._go(0, 'keyboard');
} else if (key === 'End') {
this._go(this._slides.length - 1, 'keyboard');
} else if (key === 'r' || key === 'R') {
this._go(0, 'keyboard');
} else if (/^[0-9]$/.test(key)) {
// 1..9 jump to that slide; 0 jumps to 10.
const n = key === '0' ? 9 : parseInt(key, 10) - 1;
if (n < this._slides.length) this._go(n, 'keyboard');
} else {
handled = false;
}
if (handled) {
e.preventDefault();
this._flashOverlay();
}
}
_go(i, reason = 'api') {
if (!this._slides.length) return;
const clamped = Math.max(0, Math.min(this._slides.length - 1, i));
if (clamped === this._index) {
this._flashOverlay();
return;
}
this._index = clamped;
this._applyIndex({
showOverlay: true,
broadcast: true,
reason
});
}
// Public API ------------------------------------------------------------
/** Current slide index (0-based). */
get index() {
return this._index;
}
/** Total slide count. */
get length() {
return this._slides.length;
}
/** Programmatically navigate. */
goTo(i) {
this._go(i, 'api');
}
next() {
this._go(this._index + 1, 'api');
}
prev() {
this._go(this._index - 1, 'api');
}
reset() {
this._go(0, 'api');
}
}
if (!customElements.get('deck-stage')) {
customElements.define('deck-stage', DeckStage);
}
})();
})(); } catch (e) { __ds_ns.__errors.push({ path: "decks/deck-stage.js", error: String((e && e.message) || e) }); }
// src/components/Alert.jsx
try { (() => {
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const variants = {
info: 'bg-nl-primary/8 border-l-[3px] border-nl-primary',
success: 'bg-nl-success-bg border-l-[3px] border-nl-success-dark',
warning: 'bg-yellow-50 border-l-[3px] border-yellow-400',
error: 'bg-nl-danger/7 border-l-[3px] border-nl-danger'
};
const icons = {
info: 'ℹ',
success: '✓',
warning: '⚠',
error: '✕'
};
const textColors = {
info: 'text-nl-primary',
success: 'text-nl-success-text',
warning: 'text-yellow-700',
error: 'text-nl-danger'
};
function Alert({
variant = 'info',
title,
className = '',
children,
...props
}) {
return /*#__PURE__*/React.createElement("div", _extends({
role: "alert",
className: ['flex gap-3.5 rounded-[14px] p-4', variants[variant] ?? variants.info, className].join(' ')
}, props), /*#__PURE__*/React.createElement("span", {
className: `text-base mt-0.5 ${textColors[variant]}`
}, icons[variant]), /*#__PURE__*/React.createElement("div", {
className: "flex flex-col gap-0.5"
}, title && /*#__PURE__*/React.createElement("p", {
className: `text-[0.88rem] font-semibold font-body ${textColors[variant]}`
}, title), /*#__PURE__*/React.createElement("p", {
className: "text-[0.85rem] font-body text-nl-700"
}, children)));
}
Object.assign(__ds_scope, { Alert });
})(); } catch (e) { __ds_ns.__errors.push({ path: "src/components/Alert.jsx", error: String((e && e.message) || e) }); }
// src/components/Badge.jsx
try { (() => {
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const variants = {
primary: 'bg-nl-primary/10 text-nl-primary',
accent: 'bg-nl-accent/10 text-[#d64f2a]',
success: 'bg-nl-success/20 text-nl-success-text',
danger: 'bg-nl-danger/8 text-nl-danger',
neutral: 'bg-nl-400/15 text-nl-700',
solidPrimary: 'bg-nl-primary text-white',
solidAccent: 'bg-nl-accent text-white',
solidDark: 'bg-nl-900 text-white'
};
function Badge({
variant = 'primary',
className = '',
children,
...props
}) {
return /*#__PURE__*/React.createElement("span", _extends({
className: ['inline-flex items-center gap-1.5 px-3 py-1', 'rounded-pill text-[0.78rem] font-semibold font-body', variants[variant] ?? variants.primary, className].join(' ')
}, props), children);
}
Object.assign(__ds_scope, { Badge });
})(); } catch (e) { __ds_ns.__errors.push({ path: "src/components/Badge.jsx", error: String((e && e.message) || e) }); }
// src/components/Button.jsx
try { (() => {
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const variants = {
accent: 'bg-nl-accent text-white hover:-translate-y-0.5',
primary: 'bg-nl-primary text-white hover:-translate-y-0.5',
secondary: 'bg-white text-nl-text border border-nl-border-ui hover:-translate-y-0.5',
success: 'bg-nl-success text-nl-success-text hover:-translate-y-0.5',
outlineLight: 'bg-transparent text-white border border-white/50 hover:-translate-y-0.5',
danger: 'bg-nl-danger text-white hover:-translate-y-0.5'
};
const sizes = {
sm: 'px-4 py-1.5 text-[0.82rem]',
md: 'px-[22px] py-[11px] text-[0.9rem]',
lg: 'px-[30px] py-[15px] text-base'
};
function Button({
variant = 'primary',
size = 'md',
disabled = false,
className = '',
children,
...props
}) {
return /*#__PURE__*/React.createElement("button", _extends({
disabled: disabled,
className: ['inline-flex items-center justify-center gap-2', 'rounded-pill font-semibold font-body', 'transition-all duration-ui ease-nl shadow-none', 'hover:shadow-hover', 'focus:outline-none focus:ring-4 focus:ring-nl-primary/20', 'disabled:opacity-40 disabled:translate-y-0 disabled:shadow-none disabled:cursor-not-allowed', variants[variant] ?? variants.primary, sizes[size] ?? sizes.md, className].join(' ')
}, props), children);
}
Object.assign(__ds_scope, { Button });
})(); } catch (e) { __ds_ns.__errors.push({ path: "src/components/Button.jsx", error: String((e && e.message) || e) }); }
// src/components/Card.jsx
try { (() => {
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function Card({
accent = false,
hover = true,
padding = 'p-6',
className = '',
children,
...props
}) {
return /*#__PURE__*/React.createElement("div", _extends({
className: ['rounded-card border', accent ? 'bg-nl-primary text-white border-transparent' : 'bg-white border-nl-border-soft shadow-card', hover && !accent ? 'transition-all duration-ui ease-nl hover:-translate-y-[3px] hover:shadow-hover' : '', padding, className].join(' ')
}, props), children);
}
Object.assign(__ds_scope, { Card });
})(); } catch (e) { __ds_ns.__errors.push({ path: "src/components/Card.jsx", error: String((e && e.message) || e) }); }
// src/components/Charts.jsx
try { (() => {
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
/* NLACE — Charts
Gráficos SVG sin dependencias, con la paleta de marca.
API uniforme:
· BarChart / LineChart / AreaChart → { labels:string[], series:[{name,color,values:number[]}] }
· PieChart / DonutChart → { data:[{label,value,color?}] }
Todos heredan tipografía y colores del sistema. Listos para PDF (sin animación). */
const NL_CHART_PALETTE = ['#5869f7',
// primary
'#fc624b',
// accent
'#42cf8a',
// success
'#b717af',
// magenta
'#ff8c42',
// accent-warm
'#f76dee',
// pink
'#2d3bc4',
// primary-dark
'#a5f3fc' // cyan
];
const FONT_BODY = 'Inter, system-ui, sans-serif';
const FONT_DISPLAY = '"Space Grotesk", sans-serif';
const C_GRID = '#dbdcd7';
const C_AXIS = '#a1a1aa';
const C_LABEL = '#71717a';
const C_VALUE = '#0f1011';
function niceMax(v) {
if (v <= 0) return 1;
const pow = Math.pow(10, Math.floor(Math.log10(v)));
const n = v / pow;
let nice;
if (n <= 1) nice = 1;else if (n <= 2) nice = 2;else if (n <= 2.5) nice = 2.5;else if (n <= 5) nice = 5;else nice = 10;
return nice * pow;
}
function fmtTick(v) {
if (Math.abs(v) >= 1000000) return (v / 1000000).toFixed(v % 1000000 ? 1 : 0) + 'M';
if (Math.abs(v) >= 1000) return (v / 1000).toFixed(v % 1000 ? 1 : 0) + 'k';
return String(Math.round(v * 100) / 100);
}
/* ── Leyenda compartida ─────────────────────────────── */
function Legend({
items,
style
}) {
if (!items || items.length < 2) return null;
return /*#__PURE__*/React.createElement("div", {
style: {
display: 'flex',
flexWrap: 'wrap',
gap: '8px 18px',
...style
}
}, items.map((it, i) => /*#__PURE__*/React.createElement("div", {
key: i,
style: {
display: 'flex',
alignItems: 'center',
gap: 7
}
}, /*#__PURE__*/React.createElement("span", {
style: {
width: 10,
height: 10,
borderRadius: 3,
background: it.color,
flex: 'none'
}
}), /*#__PURE__*/React.createElement("span", {
style: {
fontFamily: FONT_BODY,
fontSize: 12.5,
color: C_LABEL
}
}, it.name))));
}
/* ── BarChart ───────────────────────────────────────── */
function BarChart({
labels = [],
series = [],
height = 240,
stacked = false,
showValues = true,
legend = true,
className = '',
...props
}) {
const W = 580;
const H = height;
const pad = {
top: 18,
right: 14,
bottom: 30,
left: 38
};
const iw = W - pad.left - pad.right;
const ih = H - pad.top - pad.bottom;
const colors = series.map((s, i) => s.color || NL_CHART_PALETTE[i % NL_CHART_PALETTE.length]);
let max;
if (stacked) {
max = niceMax(Math.max(1, ...labels.map((_, gi) => series.reduce((a, s) => a + (s.values[gi] || 0), 0))));
} else {
max = niceMax(Math.max(1, ...series.flatMap(s => s.values)));
}
const ticks = [0, max / 2, max];
const step = iw / Math.max(1, labels.length);
const single = series.length === 1;
return /*#__PURE__*/React.createElement("div", _extends({
className: className
}, props), /*#__PURE__*/React.createElement("svg", {
viewBox: `0 0 ${W} ${H}`,
width: "100%",
style: {
display: 'block',
height: 'auto',
overflow: 'visible'
},
role: "img"
}, ticks.map((t, i) => {
const y = pad.top + ih - t / max * ih;
return /*#__PURE__*/React.createElement("g", {
key: i
}, /*#__PURE__*/React.createElement("line", {
x1: pad.left,
y1: y,
x2: W - pad.right,
y2: y,
stroke: C_GRID,
strokeWidth: "1",
strokeDasharray: i === 0 ? '0' : '3 4'
}), /*#__PURE__*/React.createElement("text", {
x: pad.left - 8,
y: y + 4,
textAnchor: "end",
fontFamily: FONT_BODY,
fontSize: "11",
fill: C_AXIS
}, fmtTick(t)));
}), labels.map((lab, gi) => {
const gx = pad.left + step * gi;
const inner = single ? step * 0.5 : step * 0.66;
const bw = inner / (single ? 1 : series.length);
const startX = gx + (step - inner) / 2;
let stackTop = pad.top + ih;
return /*#__PURE__*/React.createElement("g", {
key: gi
}, series.map((s, si) => {
const v = s.values[gi] || 0;
const h = v / max * ih;
let x, y;
if (stacked) {
x = gx + (step - step * 0.5) / 2;
y = stackTop - h;
stackTop = y;
return /*#__PURE__*/React.createElement("rect", {
key: si,
x: x,
y: y,
width: step * 0.5,
height: Math.max(0, h),
rx: "3",
fill: colors[si]
});
}
x = startX + bw * si;
y = pad.top + ih - h;
return /*#__PURE__*/React.createElement("g", {
key: si
}, /*#__PURE__*/React.createElement("rect", {
x: x,
y: y,
width: Math.max(1, bw - 3),
height: Math.max(0, h),
rx: "4",
fill: colors[si]
}), showValues && single && /*#__PURE__*/React.createElement("text", {
x: x + (bw - 3) / 2,
y: y - 6,
textAnchor: "middle",
fontFamily: FONT_DISPLAY,
fontSize: "12",
fontWeight: "600",
fill: C_VALUE
}, fmtTick(v)));
}), /*#__PURE__*/React.createElement("text", {
x: gx + step / 2,
y: H - pad.bottom + 18,
textAnchor: "middle",
fontFamily: FONT_BODY,
fontSize: "11.5",
fill: C_LABEL
}, lab));
})), legend && /*#__PURE__*/React.createElement(Legend, {
items: series.map((s, i) => ({
name: s.name,
color: colors[i]
})),
style: {
marginTop: 12,
paddingLeft: 4
}
}));
}
/* ── LineChart / AreaChart ──────────────────────────── */
function LineChart({
labels = [],
series = [],
height = 240,
area = false,
showDots = true,
legend = true,
className = '',
...props
}) {
const W = 580;
const H = height;
const pad = {
top: 18,
right: 16,
bottom: 30,
left: 38
};
const iw = W - pad.left - pad.right;
const ih = H - pad.top - pad.bottom;
const colors = series.map((s, i) => s.color || NL_CHART_PALETTE[i % NL_CHART_PALETTE.length]);
const max = niceMax(Math.max(1, ...series.flatMap(s => s.values)));
const ticks = [0, max / 2, max];
const n = labels.length;
const xAt = i => pad.left + (n <= 1 ? iw / 2 : iw * i / (n - 1));
const yAt = v => pad.top + ih - v / max * ih;
const gid = React.useId ? React.useId().replace(/:/g, '') : 'g' + Math.random().toString(36).slice(2, 8);
return /*#__PURE__*/React.createElement("div", _extends({
className: className
}, props), /*#__PURE__*/React.createElement("svg", {
viewBox: `0 0 ${W} ${H}`,
width: "100%",
style: {