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