@luckydraw/blex 0.1.2 → 0.1.4
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.
- package/dist/blex.min.global.js +67 -11
- package/dist/blex.min.global.js.map +1 -1
- package/dist/esm/{calendar-PNRNENA4.js → calendar-DOOC3ERV.js} +70 -2
- package/dist/esm/calendar-DOOC3ERV.js.map +1 -0
- package/dist/esm/{chunk-JEYTN6MT.js → chunk-RQXBRXSU.js} +345 -46
- package/dist/esm/chunk-RQXBRXSU.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/{kanban-FLEZGRIE.js → kanban-GPGDSK7N.js} +37 -17
- package/dist/esm/kanban-GPGDSK7N.js.map +1 -0
- package/dist/esm/react/index.js +1 -1
- package/dist/esm/renderers/calendar.d.ts +3 -0
- package/dist/esm/renderers/calendar.d.ts.map +1 -1
- package/dist/esm/renderers/code.d.ts.map +1 -1
- package/dist/esm/renderers/file-tree.d.ts.map +1 -1
- package/dist/esm/renderers/kanban.d.ts +4 -0
- package/dist/esm/renderers/kanban.d.ts.map +1 -1
- package/dist/esm/renderers/poll.d.ts +20 -3
- package/dist/esm/renderers/poll.d.ts.map +1 -1
- package/dist/esm/renderers/table.d.ts.map +1 -1
- package/dist/esm/theme.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/esm/calendar-PNRNENA4.js.map +0 -1
- package/dist/esm/chunk-JEYTN6MT.js.map +0 -1
- package/dist/esm/kanban-FLEZGRIE.js.map +0 -1
|
@@ -198,6 +198,39 @@ var DEFAULT_STYLES = `
|
|
|
198
198
|
.blex-poll__submit { background: var(--blex-accent); color: #fff; border-color: var(--blex-accent); }
|
|
199
199
|
.blex-poll__submit:hover { opacity: 0.9; background: var(--blex-accent); }
|
|
200
200
|
|
|
201
|
+
/* Poll carousel */
|
|
202
|
+
.blex-poll--carousel { position: relative; }
|
|
203
|
+
.blex-poll__carousel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
|
|
204
|
+
.blex-poll__dots { display: flex; gap: 6px; }
|
|
205
|
+
.blex-poll__dot {
|
|
206
|
+
width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--blex-border);
|
|
207
|
+
background: transparent; padding: 0; cursor: pointer; transition: all var(--blex-animation-duration);
|
|
208
|
+
}
|
|
209
|
+
.blex-poll__dot--answered { background: var(--blex-accent); border-color: var(--blex-accent); }
|
|
210
|
+
.blex-poll__dot--active { border-color: var(--blex-accent); box-shadow: 0 0 0 2px var(--blex-accent); }
|
|
211
|
+
.blex-poll__dot--active.blex-poll__dot--answered { background: var(--blex-accent); }
|
|
212
|
+
.blex-poll__counter { font-size: 12px; color: var(--blex-text); opacity: 0.6; }
|
|
213
|
+
.blex-poll__hint { font-weight: 400; opacity: 0.7; font-size: 12px; }
|
|
214
|
+
.blex-poll__nav { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
|
|
215
|
+
.blex-poll__nav-btn {
|
|
216
|
+
background: transparent; border: 1px solid var(--blex-border); border-radius: 4px;
|
|
217
|
+
padding: 6px 14px; cursor: pointer; font-size: 13px; color: var(--blex-text);
|
|
218
|
+
font-family: var(--blex-font-family);
|
|
219
|
+
}
|
|
220
|
+
.blex-poll__nav-btn:hover { background: var(--blex-border); }
|
|
221
|
+
|
|
222
|
+
/* Poll summary */
|
|
223
|
+
.blex-poll--summary .blex-poll__summary-heading { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
|
|
224
|
+
.blex-poll__summary-list { display: flex; flex-direction: column; gap: 4px; font-size: 13px; margin-bottom: 12px; }
|
|
225
|
+
.blex-poll__summary-item { padding: 4px 0; border-bottom: 1px solid var(--blex-border); }
|
|
226
|
+
.blex-poll__summary-item:last-child { border-bottom: none; }
|
|
227
|
+
.blex-poll__review-btn {
|
|
228
|
+
background: transparent; border: 1px solid var(--blex-border); border-radius: 4px;
|
|
229
|
+
padding: 6px 14px; cursor: pointer; font-size: 13px; color: var(--blex-text);
|
|
230
|
+
font-family: var(--blex-font-family);
|
|
231
|
+
}
|
|
232
|
+
.blex-poll__review-btn:hover { background: var(--blex-border); }
|
|
233
|
+
|
|
201
234
|
/* \u2500\u2500 status \u2500\u2500 */
|
|
202
235
|
.blex-status { padding: 8px 12px; }
|
|
203
236
|
.blex-status__entry {
|
|
@@ -466,6 +499,7 @@ var DEFAULT_STYLES = `
|
|
|
466
499
|
|
|
467
500
|
/* \u2500\u2500 calendar \u2500\u2500 */
|
|
468
501
|
.blex-calendar {
|
|
502
|
+
position: relative;
|
|
469
503
|
font-family: var(--blex-font-family); color: var(--blex-text);
|
|
470
504
|
border: 1px solid var(--blex-border); border-radius: 6px; padding: 12px;
|
|
471
505
|
background: var(--blex-bg);
|
|
@@ -501,6 +535,26 @@ var DEFAULT_STYLES = `
|
|
|
501
535
|
font-size: 11px; color: #fff; background: var(--blex-accent);
|
|
502
536
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
|
|
503
537
|
}
|
|
538
|
+
.blex-calendar__detail {
|
|
539
|
+
position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
|
|
540
|
+
display: flex; flex-direction: column; gap: 8px;
|
|
541
|
+
background: var(--blex-bg); border: 1px solid var(--blex-border);
|
|
542
|
+
border-radius: 8px; padding: 12px 16px; min-width: 220px; max-width: 320px;
|
|
543
|
+
box-shadow: 0 4px 16px rgba(0,0,0,0.12); z-index: 10;
|
|
544
|
+
font-family: var(--blex-font-family); color: var(--blex-text);
|
|
545
|
+
}
|
|
546
|
+
.blex-calendar__detail-color {
|
|
547
|
+
width: 100%; height: 4px; border-radius: 2px; background: var(--blex-accent);
|
|
548
|
+
}
|
|
549
|
+
.blex-calendar__detail-content { display: flex; flex-direction: column; gap: 4px; }
|
|
550
|
+
.blex-calendar__detail-title { font-weight: 600; font-size: 14px; }
|
|
551
|
+
.blex-calendar__detail-time { font-size: 12px; color: var(--blex-muted); }
|
|
552
|
+
.blex-calendar__detail-dismiss {
|
|
553
|
+
align-self: flex-end; padding: 4px 12px; border: 1px solid var(--blex-border);
|
|
554
|
+
border-radius: 4px; background: var(--blex-bg); color: var(--blex-text);
|
|
555
|
+
font-size: 12px; cursor: pointer;
|
|
556
|
+
}
|
|
557
|
+
.blex-calendar__detail-dismiss:hover { background: rgba(0,0,0,0.04); }
|
|
504
558
|
|
|
505
559
|
/* \u2500\u2500 gallery \u2500\u2500 */
|
|
506
560
|
.blex-gallery {
|
|
@@ -636,92 +690,336 @@ function createConfirmRenderer() {
|
|
|
636
690
|
var PollRenderer = class extends BaseRenderer {
|
|
637
691
|
constructor() {
|
|
638
692
|
super(...arguments);
|
|
639
|
-
this.
|
|
640
|
-
this.
|
|
693
|
+
this.questionStates = [];
|
|
694
|
+
this.currentIndex = 0;
|
|
695
|
+
this.normalizedQuestions = [];
|
|
696
|
+
this.submitted = false;
|
|
641
697
|
}
|
|
642
698
|
render(block, container) {
|
|
643
699
|
this.container = container;
|
|
700
|
+
this.normalizedQuestions = this._normalizeQuestions(block.data);
|
|
701
|
+
this.questionStates = this.normalizedQuestions.map(() => ({
|
|
702
|
+
selected: /* @__PURE__ */ new Set(),
|
|
703
|
+
writeInValue: ""
|
|
704
|
+
}));
|
|
705
|
+
this.currentIndex = 0;
|
|
706
|
+
this.submitted = false;
|
|
644
707
|
this._build(block);
|
|
645
708
|
container.setAttribute("data-blex-ready", "true");
|
|
646
709
|
}
|
|
647
710
|
update(block) {
|
|
648
711
|
if (!this.container) return;
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
if (
|
|
712
|
+
const newQuestions = this._normalizeQuestions(block.data);
|
|
713
|
+
const newStates = newQuestions.map((q, i) => {
|
|
714
|
+
if (i < this.questionStates.length) {
|
|
715
|
+
const existing = this.questionStates[i];
|
|
716
|
+
const filtered = /* @__PURE__ */ new Set();
|
|
717
|
+
for (const idx of existing.selected) {
|
|
718
|
+
if (idx < q.options.length) filtered.add(idx);
|
|
719
|
+
}
|
|
720
|
+
return { selected: filtered, writeInValue: existing.writeInValue };
|
|
721
|
+
}
|
|
722
|
+
return { selected: /* @__PURE__ */ new Set(), writeInValue: "" };
|
|
723
|
+
});
|
|
724
|
+
this.normalizedQuestions = newQuestions;
|
|
725
|
+
this.questionStates = newStates;
|
|
726
|
+
if (this.currentIndex >= newQuestions.length) {
|
|
727
|
+
this.currentIndex = Math.max(0, newQuestions.length - 1);
|
|
652
728
|
}
|
|
653
729
|
this.container.innerHTML = "";
|
|
654
730
|
this._build(block);
|
|
655
731
|
}
|
|
732
|
+
_normalizeQuestions(data) {
|
|
733
|
+
if (data.questions && data.questions.length > 0) {
|
|
734
|
+
return data.questions;
|
|
735
|
+
}
|
|
736
|
+
return [{
|
|
737
|
+
question: data.question || "",
|
|
738
|
+
options: data.options || [],
|
|
739
|
+
multiSelect: data.multiSelect,
|
|
740
|
+
writeIn: data.writeIn
|
|
741
|
+
}];
|
|
742
|
+
}
|
|
743
|
+
_isCarousel() {
|
|
744
|
+
return this.normalizedQuestions.length > 1;
|
|
745
|
+
}
|
|
656
746
|
_build(block) {
|
|
747
|
+
if (this.submitted) {
|
|
748
|
+
this._buildSummary(block);
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
if (this._isCarousel()) {
|
|
752
|
+
this._buildCarousel(block);
|
|
753
|
+
} else {
|
|
754
|
+
this._buildSingle(block);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
_buildSingle(block) {
|
|
657
758
|
const container = this.container;
|
|
658
|
-
const
|
|
759
|
+
const q = this.normalizedQuestions[0];
|
|
760
|
+
const state = this.questionStates[0];
|
|
659
761
|
const wrapper = document.createElement("div");
|
|
660
762
|
wrapper.className = "blex-poll";
|
|
661
763
|
wrapper.setAttribute("data-testid", `blex-poll-${block.id}`);
|
|
662
|
-
const
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
wrapper.appendChild(
|
|
764
|
+
const qEl = document.createElement("p");
|
|
765
|
+
qEl.className = "blex-poll__question";
|
|
766
|
+
qEl.textContent = q.question;
|
|
767
|
+
wrapper.appendChild(qEl);
|
|
768
|
+
this._buildOptions(wrapper, q, state, block.id, 0);
|
|
769
|
+
if (q.writeIn) {
|
|
770
|
+
this._buildWriteIn(wrapper, state, block.id, 0);
|
|
771
|
+
}
|
|
772
|
+
const submitBtn = document.createElement("button");
|
|
773
|
+
submitBtn.className = "blex-poll__submit";
|
|
774
|
+
submitBtn.textContent = "Submit";
|
|
775
|
+
submitBtn.setAttribute("data-testid", `blex-poll-submit-${block.id}`);
|
|
776
|
+
this.addListener(submitBtn, "click", () => {
|
|
777
|
+
this._emitSubmit(block);
|
|
778
|
+
});
|
|
779
|
+
wrapper.appendChild(submitBtn);
|
|
780
|
+
container.appendChild(wrapper);
|
|
781
|
+
}
|
|
782
|
+
_buildCarousel(block) {
|
|
783
|
+
const container = this.container;
|
|
784
|
+
const questions = this.normalizedQuestions;
|
|
785
|
+
const idx = this.currentIndex;
|
|
786
|
+
const q = questions[idx];
|
|
787
|
+
const state = this.questionStates[idx];
|
|
788
|
+
const total = questions.length;
|
|
789
|
+
const wrapper = document.createElement("div");
|
|
790
|
+
wrapper.className = "blex-poll blex-poll--carousel";
|
|
791
|
+
wrapper.setAttribute("data-testid", `blex-poll-${block.id}`);
|
|
792
|
+
const header = document.createElement("div");
|
|
793
|
+
header.className = "blex-poll__carousel-header";
|
|
794
|
+
header.setAttribute("data-testid", "blex-poll-carousel-header");
|
|
795
|
+
const dots = document.createElement("div");
|
|
796
|
+
dots.className = "blex-poll__dots";
|
|
797
|
+
dots.setAttribute("data-testid", "blex-poll-dots");
|
|
798
|
+
for (let i = 0; i < total; i++) {
|
|
799
|
+
const dot = document.createElement("button");
|
|
800
|
+
dot.className = "blex-poll__dot";
|
|
801
|
+
dot.setAttribute("data-testid", `blex-poll-dot-${i}`);
|
|
802
|
+
dot.setAttribute("aria-label", `Question ${i + 1}`);
|
|
803
|
+
if (i === idx) {
|
|
804
|
+
dot.classList.add("blex-poll__dot--active");
|
|
805
|
+
} else if (this.questionStates[i].selected.size > 0 || this.questionStates[i].writeInValue) {
|
|
806
|
+
dot.classList.add("blex-poll__dot--answered");
|
|
807
|
+
}
|
|
808
|
+
this.addListener(dot, "click", () => {
|
|
809
|
+
this.currentIndex = i;
|
|
810
|
+
this.container.innerHTML = "";
|
|
811
|
+
this._build(block);
|
|
812
|
+
});
|
|
813
|
+
dots.appendChild(dot);
|
|
814
|
+
}
|
|
815
|
+
header.appendChild(dots);
|
|
816
|
+
const counter = document.createElement("span");
|
|
817
|
+
counter.className = "blex-poll__counter";
|
|
818
|
+
counter.setAttribute("data-testid", "blex-poll-counter");
|
|
819
|
+
counter.textContent = `${idx + 1} of ${total}`;
|
|
820
|
+
header.appendChild(counter);
|
|
821
|
+
wrapper.appendChild(header);
|
|
822
|
+
const qEl = document.createElement("p");
|
|
823
|
+
qEl.className = "blex-poll__question";
|
|
824
|
+
qEl.textContent = q.question;
|
|
825
|
+
if (q.multiSelect) {
|
|
826
|
+
const hint = document.createElement("span");
|
|
827
|
+
hint.className = "blex-poll__hint";
|
|
828
|
+
hint.textContent = " (select all that apply)";
|
|
829
|
+
qEl.appendChild(hint);
|
|
830
|
+
}
|
|
831
|
+
wrapper.appendChild(qEl);
|
|
832
|
+
this._buildOptions(wrapper, q, state, block.id, idx);
|
|
833
|
+
if (q.writeIn) {
|
|
834
|
+
this._buildWriteIn(wrapper, state, block.id, idx);
|
|
835
|
+
}
|
|
836
|
+
const nav = document.createElement("div");
|
|
837
|
+
nav.className = "blex-poll__nav";
|
|
838
|
+
if (idx > 0) {
|
|
839
|
+
const backBtn = document.createElement("button");
|
|
840
|
+
backBtn.className = "blex-poll__nav-btn blex-poll__nav-btn--back";
|
|
841
|
+
backBtn.setAttribute("data-testid", "blex-poll-back");
|
|
842
|
+
backBtn.textContent = "\u2190 Back";
|
|
843
|
+
this.addListener(backBtn, "click", () => {
|
|
844
|
+
this.currentIndex = idx - 1;
|
|
845
|
+
this.container.innerHTML = "";
|
|
846
|
+
this._build(block);
|
|
847
|
+
});
|
|
848
|
+
nav.appendChild(backBtn);
|
|
849
|
+
} else {
|
|
850
|
+
const spacer = document.createElement("div");
|
|
851
|
+
nav.appendChild(spacer);
|
|
852
|
+
}
|
|
853
|
+
if (idx < total - 1) {
|
|
854
|
+
const nextBtn = document.createElement("button");
|
|
855
|
+
nextBtn.className = "blex-poll__nav-btn blex-poll__nav-btn--next";
|
|
856
|
+
nextBtn.setAttribute("data-testid", "blex-poll-next");
|
|
857
|
+
nextBtn.textContent = "Next \u2192";
|
|
858
|
+
this.addListener(nextBtn, "click", () => {
|
|
859
|
+
this.currentIndex = idx + 1;
|
|
860
|
+
this.container.innerHTML = "";
|
|
861
|
+
this._build(block);
|
|
862
|
+
});
|
|
863
|
+
nav.appendChild(nextBtn);
|
|
864
|
+
} else {
|
|
865
|
+
const submitBtn = document.createElement("button");
|
|
866
|
+
submitBtn.className = "blex-poll__submit";
|
|
867
|
+
submitBtn.setAttribute("data-testid", `blex-poll-submit-${block.id}`);
|
|
868
|
+
submitBtn.textContent = "Submit \u27A4";
|
|
869
|
+
this.addListener(submitBtn, "click", () => {
|
|
870
|
+
this._emitSubmit(block);
|
|
871
|
+
});
|
|
872
|
+
nav.appendChild(submitBtn);
|
|
873
|
+
}
|
|
874
|
+
wrapper.appendChild(nav);
|
|
875
|
+
container.appendChild(wrapper);
|
|
876
|
+
}
|
|
877
|
+
_buildOptions(wrapper, q, state, _blockId, questionIndex) {
|
|
666
878
|
const optionsList = document.createElement("div");
|
|
667
879
|
optionsList.className = "blex-poll__options";
|
|
668
|
-
options.forEach((opt, i) => {
|
|
880
|
+
q.options.forEach((opt, i) => {
|
|
669
881
|
const btn = document.createElement("button");
|
|
670
882
|
btn.className = "blex-poll__option";
|
|
671
|
-
if (
|
|
883
|
+
if (state.selected.has(i)) {
|
|
672
884
|
btn.classList.add("blex-poll__option--selected");
|
|
673
885
|
}
|
|
674
886
|
btn.setAttribute("data-testid", `blex-poll-option-${i}`);
|
|
675
887
|
btn.textContent = opt;
|
|
676
888
|
this.addListener(btn, "click", () => {
|
|
677
|
-
if (multiSelect) {
|
|
678
|
-
if (
|
|
679
|
-
|
|
889
|
+
if (q.multiSelect) {
|
|
890
|
+
if (state.selected.has(i)) {
|
|
891
|
+
state.selected.delete(i);
|
|
680
892
|
btn.classList.remove("blex-poll__option--selected");
|
|
681
893
|
} else {
|
|
682
|
-
|
|
894
|
+
state.selected.add(i);
|
|
683
895
|
btn.classList.add("blex-poll__option--selected");
|
|
684
896
|
}
|
|
685
897
|
} else {
|
|
686
898
|
const allOptionBtns = optionsList.querySelectorAll(".blex-poll__option");
|
|
687
899
|
allOptionBtns.forEach((b) => b.classList.remove("blex-poll__option--selected"));
|
|
688
|
-
|
|
689
|
-
|
|
900
|
+
state.selected.clear();
|
|
901
|
+
state.selected.add(i);
|
|
690
902
|
btn.classList.add("blex-poll__option--selected");
|
|
691
903
|
}
|
|
904
|
+
if (this._isCarousel()) {
|
|
905
|
+
const dot = this.container?.querySelector(`[data-testid="blex-poll-dot-${questionIndex}"]`);
|
|
906
|
+
if (dot) {
|
|
907
|
+
dot.classList.add("blex-poll__dot--answered");
|
|
908
|
+
}
|
|
909
|
+
}
|
|
692
910
|
});
|
|
693
911
|
optionsList.appendChild(btn);
|
|
694
912
|
});
|
|
695
913
|
wrapper.appendChild(optionsList);
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
914
|
+
}
|
|
915
|
+
_buildWriteIn(wrapper, state, blockId, questionIndex) {
|
|
916
|
+
const writeInInput = document.createElement("input");
|
|
917
|
+
writeInInput.type = "text";
|
|
918
|
+
writeInInput.className = "blex-poll__writein";
|
|
919
|
+
writeInInput.placeholder = "Other...";
|
|
920
|
+
writeInInput.setAttribute("data-testid", `blex-poll-writein-${blockId}`);
|
|
921
|
+
writeInInput.value = state.writeInValue;
|
|
922
|
+
this.addListener(writeInInput, "input", () => {
|
|
923
|
+
state.writeInValue = writeInInput.value;
|
|
924
|
+
if (this._isCarousel() && writeInInput.value) {
|
|
925
|
+
const dot = this.container?.querySelector(`[data-testid="blex-poll-dot-${questionIndex}"]`);
|
|
926
|
+
if (dot) {
|
|
927
|
+
dot.classList.add("blex-poll__dot--answered");
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
wrapper.appendChild(writeInInput);
|
|
932
|
+
}
|
|
933
|
+
_buildSummary(block) {
|
|
934
|
+
const container = this.container;
|
|
935
|
+
const questions = this.normalizedQuestions;
|
|
936
|
+
const wrapper = document.createElement("div");
|
|
937
|
+
wrapper.className = "blex-poll blex-poll--summary";
|
|
938
|
+
wrapper.setAttribute("data-testid", `blex-poll-${block.id}`);
|
|
939
|
+
const heading = document.createElement("div");
|
|
940
|
+
heading.className = "blex-poll__summary-heading";
|
|
941
|
+
heading.textContent = `\u{1F5F3} Survey complete (${questions.length} question${questions.length !== 1 ? "s" : ""})`;
|
|
942
|
+
wrapper.appendChild(heading);
|
|
943
|
+
const list = document.createElement("div");
|
|
944
|
+
list.className = "blex-poll__summary-list";
|
|
945
|
+
list.setAttribute("data-testid", "blex-poll-summary-list");
|
|
946
|
+
questions.forEach((q, i) => {
|
|
947
|
+
const state = this.questionStates[i];
|
|
948
|
+
const selectedLabels = Array.from(state.selected).sort((a, b) => a - b).map((si) => q.options[si]);
|
|
949
|
+
const item = document.createElement("div");
|
|
950
|
+
item.className = "blex-poll__summary-item";
|
|
951
|
+
let answerText = selectedLabels.join(", ") || "(no selection)";
|
|
952
|
+
if (state.writeInValue) {
|
|
953
|
+
answerText += answerText !== "(no selection)" ? `: "${state.writeInValue}"` : `"${state.writeInValue}"`;
|
|
954
|
+
}
|
|
955
|
+
item.textContent = `${i + 1}. ${q.question} \u2192 ${answerText}`;
|
|
956
|
+
list.appendChild(item);
|
|
957
|
+
});
|
|
958
|
+
wrapper.appendChild(list);
|
|
959
|
+
if (this._isCarousel()) {
|
|
960
|
+
const reviewBtn = document.createElement("button");
|
|
961
|
+
reviewBtn.className = "blex-poll__review-btn";
|
|
962
|
+
reviewBtn.setAttribute("data-testid", "blex-poll-review");
|
|
963
|
+
reviewBtn.textContent = "Review \u25BE";
|
|
964
|
+
this.addListener(reviewBtn, "click", () => {
|
|
965
|
+
this.submitted = false;
|
|
966
|
+
this.currentIndex = 0;
|
|
967
|
+
this.container.innerHTML = "";
|
|
968
|
+
this._build(block);
|
|
705
969
|
});
|
|
706
|
-
wrapper.appendChild(
|
|
970
|
+
wrapper.appendChild(reviewBtn);
|
|
707
971
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
this.
|
|
713
|
-
|
|
972
|
+
container.appendChild(wrapper);
|
|
973
|
+
}
|
|
974
|
+
_emitSubmit(block) {
|
|
975
|
+
const questions = this.normalizedQuestions;
|
|
976
|
+
const isCarousel = this._isCarousel();
|
|
977
|
+
if (isCarousel) {
|
|
978
|
+
const answers = [];
|
|
979
|
+
const lines = [`Survey response (${questions.length} questions):`];
|
|
980
|
+
questions.forEach((q, i) => {
|
|
981
|
+
const state = this.questionStates[i];
|
|
982
|
+
const selectedLabels = Array.from(state.selected).sort((a, b) => a - b).map((si) => q.options[si]);
|
|
983
|
+
const answer = {
|
|
984
|
+
question: q.question,
|
|
985
|
+
selected: selectedLabels
|
|
986
|
+
};
|
|
987
|
+
if (state.writeInValue) answer.writeIn = state.writeInValue;
|
|
988
|
+
answers.push(answer);
|
|
989
|
+
let line = `${i + 1}. ${q.question} \u2192 ${selectedLabels.join(", ") || "(no selection)"}`;
|
|
990
|
+
if (state.writeInValue) line += `
|
|
991
|
+
Write-in: ${state.writeInValue}`;
|
|
992
|
+
lines.push(line);
|
|
993
|
+
});
|
|
994
|
+
const answeredCount = answers.filter((a) => a.selected.length > 0 || a.writeIn).length;
|
|
995
|
+
const summary = `Survey: ${answeredCount}/${questions.length} answered`;
|
|
996
|
+
this.submitted = true;
|
|
997
|
+
this.container.innerHTML = "";
|
|
998
|
+
this._build(block);
|
|
999
|
+
this.emit({
|
|
1000
|
+
blockId: block.id,
|
|
1001
|
+
type: "submit",
|
|
1002
|
+
payload: { answers },
|
|
1003
|
+
serialized: lines.join("\n"),
|
|
1004
|
+
summary,
|
|
1005
|
+
icon: "\u{1F5F3}",
|
|
1006
|
+
immediate: true
|
|
1007
|
+
});
|
|
1008
|
+
} else {
|
|
1009
|
+
const q = questions[0];
|
|
1010
|
+
const state = this.questionStates[0];
|
|
1011
|
+
const selectedLabels = Array.from(state.selected).sort((a, b) => a - b).map((i) => q.options[i]);
|
|
714
1012
|
const payload = {
|
|
715
1013
|
selected: selectedLabels
|
|
716
1014
|
};
|
|
717
|
-
let serialized = `Poll response: ${question}
|
|
1015
|
+
let serialized = `Poll response: ${q.question}
|
|
718
1016
|
Selected: ${selectedLabels.join(", ")}`;
|
|
719
|
-
if (
|
|
720
|
-
payload.writeIn =
|
|
1017
|
+
if (state.writeInValue) {
|
|
1018
|
+
payload.writeIn = state.writeInValue;
|
|
721
1019
|
serialized += `
|
|
722
|
-
Write-in: ${
|
|
1020
|
+
Write-in: ${state.writeInValue}`;
|
|
723
1021
|
}
|
|
724
|
-
const summary = selectedLabels.length > 0 ? `Voted: ${selectedLabels.join(", ")}${
|
|
1022
|
+
const summary = selectedLabels.length > 0 ? `Voted: ${selectedLabels.join(", ")}${state.writeInValue ? ` + "${state.writeInValue}"` : ""}` : `Write-in: ${state.writeInValue}`;
|
|
725
1023
|
this.emit({
|
|
726
1024
|
blockId: block.id,
|
|
727
1025
|
type: "submit",
|
|
@@ -731,9 +1029,7 @@ Write-in: ${this.writeInValue}`;
|
|
|
731
1029
|
icon: "\u{1F5F3}",
|
|
732
1030
|
immediate: true
|
|
733
1031
|
});
|
|
734
|
-
}
|
|
735
|
-
wrapper.appendChild(submitBtn);
|
|
736
|
-
container.appendChild(wrapper);
|
|
1032
|
+
}
|
|
737
1033
|
}
|
|
738
1034
|
};
|
|
739
1035
|
function createPollRenderer() {
|
|
@@ -1105,6 +1401,7 @@ var TableRenderer = class extends BaseRenderer {
|
|
|
1105
1401
|
container.appendChild(wrapper);
|
|
1106
1402
|
}
|
|
1107
1403
|
_emitSelection(block) {
|
|
1404
|
+
if (this.selectedRows.size === 0) return;
|
|
1108
1405
|
const { columns, rows } = block.data;
|
|
1109
1406
|
const selectedIndices = Array.from(this.selectedRows).sort((a, b) => a - b);
|
|
1110
1407
|
const selectedRows = selectedIndices.map((i) => rows[i]);
|
|
@@ -1251,6 +1548,7 @@ var CodeRenderer = class extends BaseRenderer {
|
|
|
1251
1548
|
}
|
|
1252
1549
|
}
|
|
1253
1550
|
_emitSelection(block, lines) {
|
|
1551
|
+
if (this.selectedLines.size === 0) return;
|
|
1254
1552
|
const { language } = block.data;
|
|
1255
1553
|
const sortedLines = Array.from(this.selectedLines).sort((a, b) => a - b);
|
|
1256
1554
|
const selectedCode = sortedLines.map((lineNum) => lines[lineNum - 1]).join("\n");
|
|
@@ -1487,6 +1785,7 @@ var FileTreeRenderer = class extends BaseRenderer {
|
|
|
1487
1785
|
return li;
|
|
1488
1786
|
}
|
|
1489
1787
|
emitSelection(block) {
|
|
1788
|
+
if (this.selectedPaths.size === 0) return;
|
|
1490
1789
|
const paths = Array.from(this.selectedPaths).sort();
|
|
1491
1790
|
const count = paths.length;
|
|
1492
1791
|
const lastPath = paths[paths.length - 1] ?? "";
|
|
@@ -1986,11 +2285,11 @@ function registerDefaults() {
|
|
|
1986
2285
|
return createChartRenderer;
|
|
1987
2286
|
});
|
|
1988
2287
|
registerLazyBlockType("kanban", async () => {
|
|
1989
|
-
const { createKanbanRenderer } = await import('./kanban-
|
|
2288
|
+
const { createKanbanRenderer } = await import('./kanban-GPGDSK7N.js');
|
|
1990
2289
|
return createKanbanRenderer;
|
|
1991
2290
|
});
|
|
1992
2291
|
registerLazyBlockType("calendar", async () => {
|
|
1993
|
-
const { createCalendarRenderer } = await import('./calendar-
|
|
2292
|
+
const { createCalendarRenderer } = await import('./calendar-DOOC3ERV.js');
|
|
1994
2293
|
return createCalendarRenderer;
|
|
1995
2294
|
});
|
|
1996
2295
|
registerLazyBlockType("gallery", async () => {
|
|
@@ -2025,5 +2324,5 @@ function registerDefaults() {
|
|
|
2025
2324
|
}
|
|
2026
2325
|
|
|
2027
2326
|
export { getRegisteredTypes, hasBlockType, isBuiltIn, registerBlockType, registerDefaults, registerLazyBlockType, renderBlock, unregisterBlockType };
|
|
2028
|
-
//# sourceMappingURL=chunk-
|
|
2029
|
-
//# sourceMappingURL=chunk-
|
|
2327
|
+
//# sourceMappingURL=chunk-RQXBRXSU.js.map
|
|
2328
|
+
//# sourceMappingURL=chunk-RQXBRXSU.js.map
|