@explorer02/cfm-survey-sdk 0.3.9 → 0.4.1

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.
Files changed (31) hide show
  1. package/dist/cli/index.js +64 -64
  2. package/dist/cli/index.mjs +63 -63
  3. package/package.json +1 -1
  4. package/templates/docs/templates/CsatMatrixScale.tsx +105 -36
  5. package/templates/docs/templates/CustomSliderTrack.tsx +2 -2
  6. package/templates/docs/templates/Footer.tsx +3 -2
  7. package/templates/docs/templates/Header.tsx +14 -14
  8. package/templates/docs/templates/LikertMatrixScale.tsx +2 -2
  9. package/templates/docs/templates/Question.tsx +30 -23
  10. package/templates/docs/templates/RankOrderScale.tsx +10 -2
  11. package/templates/docs/templates/SliderMatrixScale.tsx +1 -1
  12. package/templates/docs/templates/labelStyles.ts +27 -0
  13. package/templates/docs/templates/uiConfig.ts +100 -0
  14. package/templates/preview-harness/preview-bridge.inline.js +55 -17
  15. package/templates/preview-harness/previewPages.js +2 -2
  16. package/templates/preview-harness/previewPages.ts +1 -1
  17. package/templates/preview-harness/vite-app/src/PreviewConfigContext.tsx +60 -7
  18. package/templates/preview-harness/vite-app/src/QuestionPreview.tsx +17 -96
  19. package/templates/preview-harness/vite-app/src/SurveyPagePreview.tsx +32 -8
  20. package/templates/preview-harness/vite-app/src/fixtures/questions.ts +53 -25
  21. package/templates/preview-harness/vite-app/src/globals.css +6 -0
  22. package/templates/preview-harness/vite-app/src/mergePreviewQuestion.ts +233 -0
  23. package/templates/preview-harness/vite-app/src/preview-live-overrides.css +30 -0
  24. package/templates/previewBridge.ts +61 -18
  25. package/templates/survey-theme.css +16 -0
  26. package/templates/wizard-dist/assets/{PreviewMock-CS4WqhDB.js → PreviewMock-MsONyaq9.js} +1 -1
  27. package/templates/wizard-dist/assets/TypePanel-D24BxbHk.js +1 -0
  28. package/templates/wizard-dist/assets/index-C7RSJr09.js +34 -0
  29. package/templates/wizard-dist/index.html +1 -1
  30. package/templates/wizard-dist/assets/TypePanel-BgTW2c74.js +0 -1
  31. package/templates/wizard-dist/assets/index-hjm-fxWO.js +0 -34
@@ -0,0 +1,233 @@
1
+ import type { SurveyQuestion } from '@explorer02/cfm-survey-sdk';
2
+ import type { PreviewStatePatch } from './PreviewConfigContext';
3
+ import {
4
+ BIPOLAR_ROWS_MULTI,
5
+ BIPOLAR_ROWS_SINGLE,
6
+ MATRIX_ROWS_MULTI,
7
+ MATRIX_ROW_SINGLE,
8
+ SLIDER_ROWS_MULTI,
9
+ SLIDER_ROWS_SINGLE,
10
+ } from './fixtures/questions';
11
+
12
+ function mapNpsButtonStyle(style: string | undefined): SurveyQuestion['buttonStyle'] {
13
+ if (style === 'numbered' || style === 'pill' || style === 'emoji' || style === 'standard') {
14
+ return style;
15
+ }
16
+ return 'numbered';
17
+ }
18
+
19
+ /** Survey page always shows multi-row matrix for zebra styling. */
20
+ export function normalizeSurveyPagePreviewState(previewState: PreviewStatePatch): PreviewStatePatch {
21
+ return {
22
+ ...previewState,
23
+ activePreviewKey: 'survey_page',
24
+ multiStatement: true,
25
+ };
26
+ }
27
+
28
+ type MatrixRowCapable = SurveyQuestion & {
29
+ statementRows?: { id: string; statementText: string; oppositeStatementText?: string }[];
30
+ statementLayout?: string;
31
+ };
32
+
33
+ const MULTI_STATEMENT_MATRIX_TYPES = new Set([
34
+ 'CFM_MATRIX',
35
+ 'CSAT_MATRIX',
36
+ 'RATING_MATRIX',
37
+ 'SLIDER_MATRIX',
38
+ ]);
39
+
40
+ /** Each preview iframe loads one fixture — infer its format tab from fixture shape. */
41
+ function inferPreviewKeyFromQuestion(q: SurveyQuestion): string | null {
42
+ if (q.type === 'CFM_MATRIX') {
43
+ if (q.statementLayout === 'bipolar') return 'CFM_bipolar';
44
+ if (q.transposeTable) return 'CFM_transpose';
45
+ if (q.gridLayout === 'carousel') return 'CFM_carousel';
46
+ if (q.gridLayout === 'dropdown') return 'CFM_dropdown';
47
+ return 'CFM_likert';
48
+ }
49
+ if (q.type === 'RANK_ORDER') {
50
+ const mode = (q as { interactionMode?: string }).interactionMode;
51
+ if (mode === 'dropdown') return 'RANK_dropdown';
52
+ return 'RANK_drag';
53
+ }
54
+ return null;
55
+ }
56
+
57
+ function resolvePreviewKey(
58
+ previewState: PreviewStatePatch,
59
+ question: SurveyQuestion,
60
+ ): string {
61
+ if (previewState.activePreviewKey === 'survey_page') return 'survey_page';
62
+ const inferred = inferPreviewKeyFromQuestion(question);
63
+ if (inferred) return inferred;
64
+ return previewState.activePreviewKey ?? '';
65
+ }
66
+
67
+ function resolveMultiStatementFlag(
68
+ previewState: PreviewStatePatch,
69
+ ): boolean | undefined {
70
+ if (previewState.multiStatement !== undefined) return previewState.multiStatement;
71
+ if (typeof document === 'undefined') return undefined;
72
+ const css = getComputedStyle(document.documentElement)
73
+ .getPropertyValue('--cfm-matrix-multi-statement')
74
+ .trim();
75
+ if (css === '1') return true;
76
+ if (css === '0') return false;
77
+ return undefined;
78
+ }
79
+
80
+ export function applyMatrixRowCount<T extends MatrixRowCapable>(
81
+ q: T,
82
+ multiStatement: boolean | undefined,
83
+ options?: { preserveSurveyPageRows?: boolean },
84
+ ): T {
85
+ if (!MULTI_STATEMENT_MATRIX_TYPES.has(q.type)) return q;
86
+ if (!('statementRows' in q) || !Array.isArray(q.statementRows)) return q;
87
+
88
+ const isBipolar = q.type === 'CFM_MATRIX' && q.statementLayout === 'bipolar';
89
+ const isSlider = q.type === 'SLIDER_MATRIX';
90
+
91
+ if (options?.preserveSurveyPageRows && q.statementRows.length >= 2) return q;
92
+
93
+ if (multiStatement === true) {
94
+ if (isBipolar) {
95
+ return {
96
+ ...q,
97
+ statementRows: BIPOLAR_ROWS_MULTI,
98
+ showColumnHeaders: false,
99
+ statementLayout: 'bipolar',
100
+ } as T;
101
+ }
102
+ if (isSlider) {
103
+ return { ...q, statementRows: SLIDER_ROWS_MULTI } as T;
104
+ }
105
+ return { ...q, statementRows: MATRIX_ROWS_MULTI } as T;
106
+ }
107
+
108
+ if (multiStatement === false) {
109
+ if (isBipolar) {
110
+ return {
111
+ ...q,
112
+ statementRows: BIPOLAR_ROWS_SINGLE,
113
+ showColumnHeaders: false,
114
+ statementLayout: 'bipolar',
115
+ } as T;
116
+ }
117
+ if (isSlider) {
118
+ return { ...q, statementRows: SLIDER_ROWS_SINGLE } as T;
119
+ }
120
+ return { ...q, statementRows: [...MATRIX_ROW_SINGLE] } as T;
121
+ }
122
+
123
+ return q;
124
+ }
125
+
126
+ function applyCfmMatrixLayout(
127
+ q: SurveyQuestion & {
128
+ statementLayout?: string;
129
+ gridLayout?: string;
130
+ transposeTable?: boolean;
131
+ showColumnHeaders?: boolean;
132
+ },
133
+ previewKey: string,
134
+ ): SurveyQuestion {
135
+ if (previewKey === 'survey_page') {
136
+ return {
137
+ ...q,
138
+ statementLayout: 'likert',
139
+ gridLayout: 'standard',
140
+ transposeTable: false,
141
+ showColumnHeaders: true,
142
+ } as SurveyQuestion;
143
+ }
144
+ if (!previewKey) {
145
+ return q as SurveyQuestion;
146
+ }
147
+ if (previewKey === 'CFM_likert' || !previewKey.startsWith('CFM_')) {
148
+ return {
149
+ ...q,
150
+ statementLayout: 'likert',
151
+ gridLayout: 'standard',
152
+ transposeTable: false,
153
+ showColumnHeaders: true,
154
+ } as SurveyQuestion;
155
+ }
156
+ if (previewKey === 'CFM_bipolar') {
157
+ return {
158
+ ...q,
159
+ statementLayout: 'bipolar',
160
+ showColumnHeaders: false,
161
+ gridLayout: 'standard',
162
+ transposeTable: false,
163
+ } as SurveyQuestion;
164
+ }
165
+ if (previewKey === 'CFM_transpose') {
166
+ return { ...q, statementLayout: 'likert', transposeTable: true, gridLayout: 'standard' } as SurveyQuestion;
167
+ }
168
+ if (previewKey === 'CFM_carousel') {
169
+ return { ...q, statementLayout: 'likert', gridLayout: 'carousel', transposeTable: false } as SurveyQuestion;
170
+ }
171
+ if (previewKey === 'CFM_dropdown') {
172
+ return { ...q, statementLayout: 'likert', gridLayout: 'dropdown', transposeTable: false } as SurveyQuestion;
173
+ }
174
+ return { ...q, statementLayout: 'likert', gridLayout: 'standard', transposeTable: false } as SurveyQuestion;
175
+ }
176
+
177
+ /** Apply wizard bridge previewState onto a fixture question. */
178
+ export function mergePreviewQuestion(
179
+ question: SurveyQuestion,
180
+ previewState: PreviewStatePatch,
181
+ ): SurveyQuestion {
182
+ let q = { ...question } as SurveyQuestion;
183
+ const previewKey = resolvePreviewKey(previewState, question);
184
+ const isSurveyPage = previewKey === 'survey_page';
185
+
186
+ if (previewState.textfieldPlaceholder && q.type === 'TEXTFIELD') {
187
+ q = { ...q, placeholder: previewState.textfieldPlaceholder };
188
+ }
189
+
190
+ if (q.type === 'NPS_SCALE') {
191
+ q = {
192
+ ...q,
193
+ buttonStyle: mapNpsButtonStyle(previewState.npsButtonStyle ?? q.buttonStyle ?? 'numbered'),
194
+ minLabel: previewState.hintMinText ?? q.minLabel,
195
+ maxLabel: previewState.hintMaxText ?? q.maxLabel,
196
+ };
197
+ } else if (previewState.hintMinText !== undefined || previewState.hintMaxText !== undefined) {
198
+ if (q.type === 'SLIDER_MATRIX') {
199
+ q = {
200
+ ...q,
201
+ scaleAnchorLabels: [
202
+ previewState.hintMinText ?? q.scaleAnchorLabels?.[0] ?? '',
203
+ previewState.hintMaxText ?? q.scaleAnchorLabels?.[1] ?? '',
204
+ ],
205
+ };
206
+ }
207
+ }
208
+
209
+ if (q.type === 'CFM_MATRIX') {
210
+ q = applyCfmMatrixLayout(q, isSurveyPage ? 'survey_page' : previewKey);
211
+ }
212
+
213
+ if (q.type === 'RANK_ORDER') {
214
+ if (previewState.rankVariant === 'drag' || previewKey === 'RANK_drag') {
215
+ q = { ...q, interactionMode: 'dragAndDrop', optionDisplay: 'textAndImage' };
216
+ }
217
+ if (previewState.rankVariant === 'dropdown' || previewKey === 'RANK_dropdown') {
218
+ q = { ...q, interactionMode: 'dropdown', optionDisplay: 'textAndImage' };
219
+ }
220
+ }
221
+
222
+ return applyMatrixRowCount(q, resolveMultiStatementFlag(previewState), {
223
+ preserveSurveyPageRows: isSurveyPage,
224
+ });
225
+ }
226
+
227
+ /** Survey page layout — each question reflects its type-tab customization mapping. */
228
+ export function mergeSurveyPageQuestion(
229
+ question: SurveyQuestion,
230
+ previewState: PreviewStatePatch,
231
+ ): SurveyQuestion {
232
+ return mergePreviewQuestion(question, normalizeSurveyPagePreviewState(previewState));
233
+ }
@@ -90,6 +90,14 @@ html.cfm-live-edit .cfm-footer-inner {
90
90
  flex-direction: var(--cfm-footer-flex-direction, row) !important;
91
91
  }
92
92
 
93
+ html.cfm-live-edit [data-cfm-footer-logo] {
94
+ object-fit: contain !important;
95
+ object-position: left center !important;
96
+ height: var(--cfm-footer-logo-height, 32px) !important;
97
+ max-width: var(--cfm-footer-logo-width, 120px) !important;
98
+ width: auto !important;
99
+ }
100
+
93
101
  html.cfm-live-edit .rounded-xl,
94
102
  html.cfm-live-edit .rounded-md,
95
103
  html.cfm-live-edit .rounded-lg {
@@ -106,3 +114,25 @@ html.cfm-live-edit input[data-cfm-textfield]::placeholder {
106
114
  color: var(--cfm-input-placeholder, #9ca3af) !important;
107
115
  opacity: 1;
108
116
  }
117
+
118
+ /* Keep every question-type preview inside the wizard iframe without horizontal bleed */
119
+ html.cfm-live-edit,
120
+ html.cfm-live-edit body,
121
+ html.cfm-live-edit #root {
122
+ max-width: 100%;
123
+ overflow-x: hidden;
124
+ box-sizing: border-box;
125
+ }
126
+
127
+ html.cfm-live-edit [data-cfm-question-area],
128
+ html.cfm-live-edit .cfm-question-card {
129
+ max-width: 100%;
130
+ min-width: 0;
131
+ overflow-x: auto;
132
+ box-sizing: border-box;
133
+ }
134
+
135
+ html.cfm-live-edit [data-cfm-nps-area] {
136
+ max-width: 100%;
137
+ overflow-x: auto;
138
+ }
@@ -43,6 +43,8 @@ function flushCssVars(): void {
43
43
  delete pendingVars[key];
44
44
  }
45
45
  applyThemeSideEffects();
46
+ syncCompanyNameVisibility();
47
+ syncQuestionChromeVisibility();
46
48
  }
47
49
 
48
50
  function queueCssVars(vars: Record<string, string>): void {
@@ -58,6 +60,8 @@ function applyCssVarsImmediate(vars: Record<string, string>): void {
58
60
  root.style.setProperty(key, value);
59
61
  }
60
62
  applyThemeSideEffects();
63
+ syncCompanyNameVisibility();
64
+ syncQuestionChromeVisibility();
61
65
  }
62
66
 
63
67
  function setDisplay(selector: string, visible: boolean): void {
@@ -66,6 +70,58 @@ function setDisplay(selector: string, visible: boolean): void {
66
70
  });
67
71
  }
68
72
 
73
+ function readCssVar(name: string, fallback: string): string {
74
+ return getComputedStyle(document.documentElement).getPropertyValue(name).trim() || fallback;
75
+ }
76
+
77
+ function isHeaderLogoVisible(): boolean {
78
+ const logoImg = document.querySelector(
79
+ 'header [data-cfm-logo], .cfm-header [data-cfm-logo]',
80
+ ) as HTMLImageElement | null;
81
+ return Boolean(
82
+ logoImg &&
83
+ logoImg.style.display !== 'none' &&
84
+ Boolean(logoImg.getAttribute('src')),
85
+ );
86
+ }
87
+
88
+ /** Keep [data-cfm-company] beside logo when toggle, name, and logo are all present. */
89
+ function syncCompanyNameVisibility(layoutShowCompany?: boolean): void {
90
+ const showFromCss = readCssVar('--cfm-header-show-company', '1') !== '0';
91
+ const showToggle =
92
+ layoutShowCompany !== undefined ? Boolean(layoutShowCompany) : showFromCss;
93
+
94
+ document.querySelectorAll('[data-cfm-company]').forEach((el) => {
95
+ const htmlEl = el as HTMLElement;
96
+ const hasName = Boolean(htmlEl.textContent?.trim());
97
+ const show = showToggle && hasName && isHeaderLogoVisible();
98
+ htmlEl.style.display = show ? '' : 'none';
99
+ });
100
+ }
101
+
102
+ function syncQuestionChromeVisibility(
103
+ layoutShowNumbers?: boolean,
104
+ layoutShowRequired?: boolean,
105
+ ): void {
106
+ const showNumbers =
107
+ layoutShowNumbers !== undefined
108
+ ? Boolean(layoutShowNumbers)
109
+ : readCssVar('--cfm-show-question-numbers', '1') !== '0';
110
+ const showRequired =
111
+ layoutShowRequired !== undefined
112
+ ? Boolean(layoutShowRequired)
113
+ : readCssVar('--cfm-show-required-asterisk', '1') !== '0';
114
+
115
+ document.querySelectorAll('[data-cfm-question-number]').forEach((el) => {
116
+ const htmlEl = el as HTMLElement;
117
+ const hasNumber = Boolean(htmlEl.textContent?.trim());
118
+ htmlEl.style.display = showNumbers && hasNumber ? '' : 'none';
119
+ });
120
+ document.querySelectorAll('[data-cfm-required]').forEach((el) => {
121
+ (el as HTMLElement).style.display = showRequired ? '' : 'none';
122
+ });
123
+ }
124
+
69
125
  function applyContentPatch(patch: ContentPatch): void {
70
126
  if (patch.logoUrl !== undefined) {
71
127
  document.querySelectorAll('[data-cfm-logo], header img, footer img').forEach((el) => {
@@ -88,23 +144,12 @@ function applyContentPatch(patch: ContentPatch): void {
88
144
  htmlEl.classList.remove('hidden');
89
145
  }
90
146
  });
91
- document.querySelectorAll('[data-cfm-company]').forEach((el) => {
92
- const htmlEl = el as HTMLElement;
93
- if (patch.logoUrl) {
94
- if (!htmlEl.textContent?.trim()) {
95
- htmlEl.style.display = 'none';
96
- }
97
- }
98
- });
99
147
  }
100
148
 
101
149
  if (patch.companyName !== undefined) {
102
150
  const name = patch.companyName ?? '';
103
151
  document.querySelectorAll('[data-cfm-company]').forEach((el) => {
104
152
  (el as HTMLElement).textContent = name;
105
- if (!name) {
106
- (el as HTMLElement).style.display = 'none';
107
- }
108
153
  });
109
154
  document.querySelectorAll('[data-cfm-logo-text]').forEach((el) => {
110
155
  const logoImg = document.querySelector('[data-cfm-logo]') as HTMLImageElement | null;
@@ -167,7 +212,7 @@ function applyContentPatch(patch: ContentPatch): void {
167
212
  if (patch.layoutFlags) {
168
213
  const flags = patch.layoutFlags;
169
214
  if (flags.showCompanyName !== undefined) {
170
- setDisplay('[data-cfm-company]', Boolean(flags.showCompanyName));
215
+ syncCompanyNameVisibility(Boolean(flags.showCompanyName));
171
216
  }
172
217
  if (flags.showHeader !== undefined) {
173
218
  setDisplay('.cfm-header, header.cfm-header', Boolean(flags.showHeader));
@@ -188,10 +233,10 @@ function applyContentPatch(patch: ContentPatch): void {
188
233
  setDisplay('[data-cfm-btn-back]', Boolean(flags.showBackButton));
189
234
  }
190
235
  if (flags.showQuestionNumbers !== undefined) {
191
- setDisplay('[data-cfm-question-number]', Boolean(flags.showQuestionNumbers));
236
+ syncQuestionChromeVisibility(Boolean(flags.showQuestionNumbers), undefined);
192
237
  }
193
238
  if (flags.showRequiredAsterisk !== undefined) {
194
- setDisplay('[data-cfm-required]', Boolean(flags.showRequiredAsterisk));
239
+ syncQuestionChromeVisibility(undefined, Boolean(flags.showRequiredAsterisk));
195
240
  }
196
241
  if (flags.showFooterLogo !== undefined) {
197
242
  setDisplay('[data-cfm-footer-logo]', Boolean(flags.showFooterLogo));
@@ -229,15 +274,13 @@ function applyContentPatch(patch: ContentPatch): void {
229
274
  (el as HTMLElement).style.display = show ? '' : 'none';
230
275
  });
231
276
  }
277
+ syncCompanyNameVisibility();
278
+ syncQuestionChromeVisibility();
232
279
  applyThemeSideEffects();
233
280
  }
234
281
 
235
282
  const TRAFFIC_BADGE = ['#ef4444', '#f97316', '#eab308', '#84cc16', '#22c55e', '#14b8a6', '#06b6d4', '#3b82f6', '#6366f1', '#8b5cf6', '#a855f7'];
236
283
 
237
- function readCssVar(name: string, fallback: string): string {
238
- return getComputedStyle(document.documentElement).getPropertyValue(name).trim() || fallback;
239
- }
240
-
241
284
  function applyThemeSideEffects(): void {
242
285
  const mode = readCssVar('--cfm-number-label-mode', 'traffic');
243
286
  const mono = readCssVar('--cfm-number-mono-color', '#9ca3af');
@@ -14,6 +14,8 @@
14
14
  --cfm-font-family: Inter, sans-serif;
15
15
  --cfm-heading-weight: 700;
16
16
  --cfm-motion-duration: 200ms;
17
+ --cfm-show-question-numbers: 1;
18
+ --cfm-show-required-asterisk: 1;
17
19
 
18
20
  --cfm-header-height: 120px;
19
21
  --cfm-header-logo-width: 120px;
@@ -126,6 +128,7 @@
126
128
  --cfm-heatmap-pin-size: 12px;
127
129
 
128
130
  --cfm-rank-item-bg: #ffffff;
131
+ --cfm-rank-dropdown-hover-bg: #f3f4f6;
129
132
  --cfm-rank-badge-bg: var(--cfm-mcq-selected-bg);
130
133
  --cfm-rank-badge-text: var(--cfm-mcq-selected-accent);
131
134
  --cfm-rank-badge: var(--cfm-primary);
@@ -225,6 +228,19 @@ body {
225
228
  grid-row: 1;
226
229
  justify-self: var(--cfm-footer-logo-justify, start);
227
230
  align-self: end;
231
+ display: flex;
232
+ justify-content: flex-start;
233
+ width: 100%;
234
+ max-width: 100%;
235
+ }
236
+
237
+ .cfm-footer-logo-slot img,
238
+ [data-cfm-footer-logo] {
239
+ object-fit: contain;
240
+ object-position: left center;
241
+ height: var(--cfm-footer-logo-height, 32px);
242
+ max-width: var(--cfm-footer-logo-width, 120px);
243
+ width: auto;
228
244
  }
229
245
 
230
246
  .cfm-footer-links {
@@ -1 +1 @@
1
- import{u as x,j as e}from"./index-hjm-fxWO.js";import{b as t}from"./vendor-BwkXDkd3.js";function p(d=150){const l=x(r=>r.config),[a,s]=t.useState(l);return t.useEffect(()=>{const r=window.setTimeout(()=>s(l),d);return()=>window.clearTimeout(r)},[l,d]),a}const h=t.memo(function(){const l=p(150),a=x(n=>n.logoPreviewDataUrl),{global:s}=l,{layout:r,colorScheme:o,buttons:c}=s,m=t.useMemo(()=>r.borderStyle==="sharp"?"rounded-none":r.borderStyle==="pill"?"rounded-[32px]":"rounded-2xl",[r.borderStyle]),i=t.useMemo(()=>r.fontStyle==="serif"?"Georgia, serif":r.fontStyle==="system"?"system-ui, sans-serif":"Inter, sans-serif",[r.fontStyle]),u=a??s.logo.url,f=t.useMemo(()=>({backgroundColor:o.background,color:o.text,borderColor:o.secondary,fontFamily:i}),[o,i]);return e.jsxs("div",{className:`overflow-hidden border shadow-md ${m}`,style:f,children:[r.showHeader&&e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:o.secondary},children:[u&&e.jsx("img",{src:u,alt:"Logo",className:"max-h-6 w-auto object-contain",loading:"lazy"}),e.jsx("span",{className:"text-xs font-semibold tracking-wider",children:s.companyName})]}),e.jsxs("div",{className:"space-y-6 p-6",children:[r.showProgressBar&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-[10px] font-semibold text-slate-400",children:[e.jsx("span",{children:"Progress"}),e.jsx("span",{children:"35%"})]}),e.jsx("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-slate-100",children:e.jsx("div",{className:"h-full w-[35%] rounded-full",style:{backgroundColor:o.accent}})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h4",{className:"flex items-start gap-1.5 text-sm font-bold leading-snug",children:[r.showQuestionNumbers&&e.jsx("span",{className:"font-medium text-slate-400",children:"Q1."}),e.jsx("span",{children:s.surveyTitle}),r.showRequiredAsterisk&&e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"How would you rate your overall experience?"}),e.jsx("div",{className:"grid grid-cols-5 gap-2",children:[1,2,3,4,5].map(n=>e.jsx("div",{className:`flex h-9 items-center justify-center border text-xs font-semibold ${r.borderStyle==="pill"?"rounded-full":r.borderStyle==="sharp"?"rounded-none":"rounded-lg"}`,style:n===1?{backgroundColor:o.secondary,borderColor:o.primary,color:o.primary}:{backgroundColor:o.background,borderColor:o.secondary,color:o.text},children:n},n))})]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t bg-slate-50/50 px-6 py-4",children:[r.showBackButton&&e.jsx("span",{className:`border px-3 py-1.5 text-[10px] font-semibold ${r.borderStyle==="pill"?"rounded-full":r.borderStyle==="sharp"?"rounded-none":"rounded-lg"}`,style:{borderColor:o.secondary,color:o.text},children:c.back}),e.jsx("div",{className:"flex-1"}),r.showNextButton&&e.jsx("span",{className:`px-4 py-1.5 text-[10px] font-bold ${r.borderStyle==="pill"?"rounded-full":r.borderStyle==="sharp"?"rounded-none":"rounded-lg"}`,style:{backgroundColor:o.primary,color:o.buttonText},children:c.next})]})]})});export{h as PreviewMock};
1
+ import{u as x,j as e}from"./index-C7RSJr09.js";import{b as t}from"./vendor-BwkXDkd3.js";function p(d=150){const l=x(r=>r.config),[a,s]=t.useState(l);return t.useEffect(()=>{const r=window.setTimeout(()=>s(l),d);return()=>window.clearTimeout(r)},[l,d]),a}const h=t.memo(function(){const l=p(150),a=x(n=>n.logoPreviewDataUrl),{global:s}=l,{layout:r,colorScheme:o,buttons:c}=s,m=t.useMemo(()=>r.borderStyle==="sharp"?"rounded-none":r.borderStyle==="pill"?"rounded-[32px]":"rounded-2xl",[r.borderStyle]),i=t.useMemo(()=>r.fontStyle==="serif"?"Georgia, serif":r.fontStyle==="system"?"system-ui, sans-serif":"Inter, sans-serif",[r.fontStyle]),u=a??s.logo.url,f=t.useMemo(()=>({backgroundColor:o.background,color:o.text,borderColor:o.secondary,fontFamily:i}),[o,i]);return e.jsxs("div",{className:`overflow-hidden border shadow-md ${m}`,style:f,children:[r.showHeader&&e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:o.secondary},children:[u&&e.jsx("img",{src:u,alt:"Logo",className:"max-h-6 w-auto object-contain",loading:"lazy"}),e.jsx("span",{className:"text-xs font-semibold tracking-wider",children:s.companyName})]}),e.jsxs("div",{className:"space-y-6 p-6",children:[r.showProgressBar&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-[10px] font-semibold text-slate-400",children:[e.jsx("span",{children:"Progress"}),e.jsx("span",{children:"35%"})]}),e.jsx("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-slate-100",children:e.jsx("div",{className:"h-full w-[35%] rounded-full",style:{backgroundColor:o.accent}})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h4",{className:"flex items-start gap-1.5 text-sm font-bold leading-snug",children:[r.showQuestionNumbers&&e.jsx("span",{className:"font-medium text-slate-400",children:"Q1."}),e.jsx("span",{children:s.surveyTitle}),r.showRequiredAsterisk&&e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"How would you rate your overall experience?"}),e.jsx("div",{className:"grid grid-cols-5 gap-2",children:[1,2,3,4,5].map(n=>e.jsx("div",{className:`flex h-9 items-center justify-center border text-xs font-semibold ${r.borderStyle==="pill"?"rounded-full":r.borderStyle==="sharp"?"rounded-none":"rounded-lg"}`,style:n===1?{backgroundColor:o.secondary,borderColor:o.primary,color:o.primary}:{backgroundColor:o.background,borderColor:o.secondary,color:o.text},children:n},n))})]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t bg-slate-50/50 px-6 py-4",children:[r.showBackButton&&e.jsx("span",{className:`border px-3 py-1.5 text-[10px] font-semibold ${r.borderStyle==="pill"?"rounded-full":r.borderStyle==="sharp"?"rounded-none":"rounded-lg"}`,style:{borderColor:o.secondary,color:o.text},children:c.back}),e.jsx("div",{className:"flex-1"}),r.showNextButton&&e.jsx("span",{className:`px-4 py-1.5 text-[10px] font-bold ${r.borderStyle==="pill"?"rounded-full":r.borderStyle==="sharp"?"rounded-none":"rounded-lg"}`,style:{backgroundColor:o.primary,color:o.buttonText},children:c.next})]})]})});export{h as PreviewMock};
@@ -0,0 +1 @@
1
+ import{u as m,j as e,T as P,S as b,R as d,C as i,N as t,a as R,M as z}from"./index-C7RSJr09.js";import"./vendor-BwkXDkd3.js";function C({values:n,onPatch:r}){return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(i,{label:"Label text color",value:n.columnLabelColor,onChange:a=>r({columnLabelColor:a})}),e.jsx(i,{label:"Label background",value:n.columnLabelBgColor,onChange:a=>r({columnLabelBgColor:a})})]})}function T({values:n,onPatch:r}){return e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"space-y-1 sm:col-span-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Min hint label"}),e.jsx("input",{className:"w-full rounded-lg border border-white/10 bg-slate-950/50 px-3 py-2 text-sm text-white",value:n.hintMinText,onChange:a=>r({hintMinText:a.target.value})})]}),e.jsxs("label",{className:"space-y-1 sm:col-span-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Max hint label"}),e.jsx("input",{className:"w-full rounded-lg border border-white/10 bg-slate-950/50 px-3 py-2 text-sm text-white",value:n.hintMaxText,onChange:a=>r({hintMaxText:a.target.value})})]}),e.jsx(i,{label:"Hint text color",value:n.hintLabelColor,onChange:a=>r({hintLabelColor:a})}),e.jsx(i,{label:"Hint label background",value:n.hintLabelBgColor,onChange:a=>r({hintLabelBgColor:a})})]})}function M({values:n,onPatch:r,count:a=11}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{label:"Number label style",value:n.numberLabelMode,onChange:c=>r({numberLabelMode:c}),options:[{value:"traffic",label:"Traffic light (default)"},{value:"monochrome",label:"Monochrome (one color)"},{value:"individual",label:"Individual per number"}]}),n.numberLabelMode==="monochrome"&&e.jsx(i,{label:"Monochrome color",value:n.monochromeNumberColor,onChange:c=>r({monochromeNumberColor:c})}),n.numberLabelMode==="individual"&&e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:Array.from({length:a},(c,x)=>e.jsx(i,{label:`#${x}`,value:n.individualNumberColors[x]??"#9CA3AF",onChange:j=>{const h=[...n.individualNumberColors];h[x]=j,r({individualNumberColors:h})}},x))})]})}function s({title:n,children:r}){return e.jsxs("div",{className:"space-y-3 rounded-xl border border-white/5 bg-slate-950/20 p-4",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:n}),r]})}function I({type:n,activeFormat:r}){const a=m(l=>l.config.questionTypes[n]),c=m(l=>l.updateQuestionType),x=m(l=>l.previewMultiStatementByType),j=m(l=>l.setPreviewMultiStatementForType),h=m(l=>l.heatmapPreviewPin);if(!a)return e.jsx("p",{className:"text-sm text-slate-500",children:"No configuration available for this type."});const o=l=>c(n,l),f=z.includes(n),B=!!x[n],g=r.includes("star"),u=r.includes("emoji"),p=r.includes("numbered"),v=r.includes("drag"),S=r.includes("dropdown"),N=r.includes("radio"),k=r==="CFM_bipolar",w=r.includes("graphics"),y=a.optionStyle??a.cardStyle??"outlined",L=a.buttonStyle??"numbered";return e.jsxs("div",{className:"space-y-4",children:[f&&e.jsx(P,{label:"Preview multiple statements",checked:B,onChange:l=>j(n,l)}),n==="MCQ"&&"optionGap"in a&&e.jsx(s,{title:"Option style",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(b,{label:"Option style",value:a.optionStyle??a.cardStyle??"outlined",onChange:l=>o({optionStyle:l}),options:[{value:"outlined",label:"Outlined"},{value:"filled",label:"Filled"},{value:"minimal",label:"Minimal"}]}),e.jsx(d,{label:"Option gap",value:a.optionGap,onChange:l=>o({optionGap:l}),min:0,max:32}),e.jsx(d,{label:"Border radius",value:a.borderRadius,onChange:l=>o({borderRadius:l}),min:0,max:24}),e.jsx(d,{label:"Option padding",value:a.optionPadding??12,onChange:l=>o({optionPadding:l}),min:4,max:24}),e.jsx(i,{label:"Hover border",value:a.hoverBorderColor,onChange:l=>o({hoverBorderColor:l})}),y==="filled"&&e.jsx(i,{label:"Unselected fill color",value:a.filledOptionBg??"#F9FAFB",onChange:l=>o({filledOptionBg:l})})]})}),n==="TEXTFIELD"&&"defaultPlaceholder"in a&&e.jsx(s,{title:"Text input",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:"space-y-1 sm:col-span-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Default placeholder"}),e.jsx("input",{className:"w-full rounded-lg border border-white/10 bg-slate-950/50 px-3 py-2 text-sm text-white",value:a.defaultPlaceholder,onChange:l=>o({defaultPlaceholder:l.target.value})})]}),e.jsx(t,{label:"Input radius (px)",value:a.inputRadius,onChange:l=>o({inputRadius:l}),min:0,max:24}),e.jsx(i,{label:"Border color",value:a.borderColor,onChange:l=>o({borderColor:l})}),e.jsx(i,{label:"Placeholder color",value:a.placeholderColor,onChange:l=>o({placeholderColor:l})}),e.jsx(t,{label:"Input height (px)",value:a.inputHeight,onChange:l=>o({inputHeight:l}),min:32,max:64}),e.jsx(t,{label:"Input padding (px)",value:a.inputPadding,onChange:l=>o({inputPadding:l}),min:8,max:24})]})}),n==="NPS_SCALE"&&"buttonStyle"in a&&e.jsxs(e.Fragment,{children:[e.jsxs(s,{title:"NPS buttons",children:[e.jsx(b,{label:"Button style",value:a.buttonStyle,onChange:l=>o({buttonStyle:l}),options:[{value:"standard",label:"Radio"},{value:"numbered",label:"Numbered badges"}]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Selected cell and focus ring come from Theme → Question card."})]}),e.jsx(s,{title:"Hint labels",children:e.jsx(T,{values:a,onPatch:o})}),L==="numbered"&&e.jsx(s,{title:"Number labels",children:e.jsx(M,{values:a,onPatch:o})}),e.jsx(s,{title:"Track & cells",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(t,{label:"Cell size (px)",value:a.cellSize,onChange:l=>o({cellSize:l}),min:24,max:56}),e.jsx(t,{label:"Cell gap (px)",value:a.cellGap,onChange:l=>o({cellGap:l}),min:0,max:16}),e.jsx(i,{label:"Track bar",value:a.trackBarColor,onChange:l=>o({trackBarColor:l})})]})})]}),n==="CFM_MATRIX"&&"rowLabelWidth"in a&&e.jsxs(e.Fragment,{children:[e.jsx(s,{title:"Matrix layout",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(t,{label:"Row label width (px)",value:a.rowLabelWidth,onChange:l=>o({rowLabelWidth:l}),min:120,max:280}),k&&e.jsx(t,{label:"Bipolar column width (%)",value:a.bipolarColumnWidthPercent,onChange:l=>o({bipolarColumnWidthPercent:l}),min:15,max:40}),e.jsx(t,{label:"Cell padding (px)",value:a.cellPadding,onChange:l=>o({cellPadding:l}),min:4,max:24})]})}),e.jsx(s,{title:"Label items",children:e.jsx(C,{values:a,onPatch:o})})]}),n==="CSAT_MATRIX"&&"emojiSize"in a&&e.jsxs(e.Fragment,{children:[(u||g||p)&&e.jsxs(s,{title:`${R.CSAT_MATRIX} — ${r.replace("CSAT_","")}`,children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u&&e.jsx(t,{label:"Emoji size (px)",value:a.emojiSize,onChange:l=>o({emojiSize:l}),min:16,max:40}),g&&e.jsx(i,{label:"Star color",value:a.accentColor,onChange:l=>o({accentColor:l})}),(u||g||p)&&e.jsx(d,{label:"Unselected opacity",value:Math.round(a.unselectedOpacity*100),onChange:l=>o({unselectedOpacity:l/100}),min:10,max:100})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Selected cell color and focus ring come from Theme → Question card."})]}),e.jsxs(s,{title:"Label items",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Applies to the 5 text labels above options in all formats."}),e.jsx(C,{values:a,onPatch:o})]}),w&&e.jsx(s,{title:"Graphics track",children:e.jsx(i,{label:"Track color",value:a.graphicsTrackColor,onChange:l=>o({graphicsTrackColor:l})})})]}),n==="RATING_MATRIX"&&"unselectedStarOpacity"in a&&e.jsxs(e.Fragment,{children:[(u||g||p||N)&&e.jsxs(s,{title:`Rating — ${r.replace("RATING_","")}`,children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u&&e.jsx(t,{label:"Emoji size (px)",value:a.emojiSize,onChange:l=>o({emojiSize:l}),min:16,max:40}),g&&e.jsx(i,{label:"Star color",value:a.starColor,onChange:l=>o({starColor:l})}),(u||g||p||N)&&e.jsx(d,{label:"Unselected opacity",value:Math.round(a.unselectedStarOpacity*100),onChange:l=>o({unselectedStarOpacity:l/100}),min:10,max:100})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Selected cell color and focus ring come from Theme → Question card."})]}),e.jsxs(s,{title:"Label items",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Applies to the 5 text anchor labels in all formats."}),e.jsx(C,{values:a,onPatch:o})]}),w&&e.jsx(s,{title:"Graphics track",children:e.jsx(i,{label:"Track color",value:a.graphicsTrackColor,onChange:l=>o({graphicsTrackColor:l})})})]}),n==="SLIDER_MATRIX"&&"trackColor"in a&&e.jsxs(e.Fragment,{children:[e.jsx(s,{title:"Slider track",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(i,{label:"Track",value:a.trackColor,onChange:l=>o({trackColor:l})}),e.jsx(i,{label:"Thumb",value:a.thumbColor,onChange:l=>o({thumbColor:l})}),e.jsx(t,{label:"Row label width (px)",value:a.rowLabelWidth,onChange:l=>o({rowLabelWidth:l}),min:120,max:280}),e.jsx(i,{label:"Row band",value:a.rowBandColor,onChange:l=>o({rowBandColor:l})}),e.jsx(t,{label:"Tick badge size (px)",value:a.tickBadgeSize,onChange:l=>o({tickBadgeSize:l}),min:20,max:40})]})}),e.jsx(s,{title:"Anchor hint labels",children:e.jsx(T,{values:a,onPatch:o})}),e.jsx(s,{title:"Tick number labels",children:e.jsx(M,{values:a,onPatch:o,count:11})})]}),n==="FILE_UPLOAD"&&"dropzoneStyle"in a&&e.jsx(s,{title:"Dropzone",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(b,{label:"Dropzone border",value:a.dropzoneStyle,onChange:l=>o({dropzoneStyle:l}),options:[{value:"dashed",label:"Dashed"},{value:"solid",label:"Solid"}]}),e.jsx(i,{label:"Border color",value:a.borderColor??a.accentColor,onChange:l=>o({borderColor:l})}),e.jsx(i,{label:"Fill color",value:a.dropzoneFillColor,onChange:l=>o({dropzoneFillColor:l})}),e.jsx(t,{label:"Padding (px)",value:a.dropzonePadding,onChange:l=>o({dropzonePadding:l}),min:12,max:48})]})}),n==="TEXT_AND_MEDIA"&&"mediaMaxWidth"in a&&e.jsx(s,{title:"Text & media",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(d,{label:"Media max width (%)",value:a.mediaMaxWidth,onChange:l=>o({mediaMaxWidth:l}),min:50,max:100}),e.jsx(d,{label:"Media corner radius",value:a.mediaRadius,onChange:l=>o({mediaRadius:l}),min:0,max:24}),e.jsx(i,{label:"Caption color",value:a.captionColor,onChange:l=>o({captionColor:l})}),e.jsx(t,{label:"Caption size (px)",value:a.captionSize,onChange:l=>o({captionSize:l}),min:10,max:24})]})}),n==="HEATMAP"&&"pinColor"in a&&e.jsx(s,{title:"Heatmap pin",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(i,{label:"Pin color",value:a.pinColor,onChange:l=>o({pinColor:l})}),e.jsx(i,{label:"Pin border",value:a.pinBorderColor,onChange:l=>o({pinBorderColor:l})}),e.jsx(d,{label:"Pin size",value:a.pinSize,onChange:l=>o({pinSize:l}),min:8,max:32}),e.jsx(d,{label:"Overlay opacity",value:Math.round(a.overlayOpacity*100),onChange:l=>o({overlayOpacity:l/100}),min:0,max:80}),e.jsxs("p",{className:"text-xs text-slate-500 sm:col-span-2",children:["Click the heatmap image in the preview to place a pin and see styling update live. Pin preview position: ",Math.round(h.x*100),"%, ",Math.round(h.y*100),"%"]})]})}),n==="RANK_ORDER"&&"drag"in a&&e.jsxs(e.Fragment,{children:[e.jsx(s,{title:"List",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(i,{label:"List bg",value:a.drag.itemBg,onChange:l=>o({drag:{...a.drag,itemBg:l},dropdown:{...a.dropdown,itemBg:l}})}),e.jsx(i,{label:"List hover",value:a.dropdown.itemHoverBg??a.drag.itemHoverBg??"#F3F4F6",onChange:l=>o({drag:{...a.drag,itemHoverBg:l},dropdown:{...a.dropdown,itemHoverBg:l}})})]})}),e.jsx(s,{title:v?"Drag & drop":S?"Dropdown rank":"Rank order",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[v&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"Drag handle",value:a.drag.dragHandleColor,onChange:l=>o({drag:{...a.drag,dragHandleColor:l}})}),e.jsx(i,{label:"Rank badge",value:a.drag.rankBadgeColor,onChange:l=>o({drag:{...a.drag,rankBadgeColor:l},dropdown:{...a.dropdown,rankBadgeColor:l}})})]}),S&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"Select border",value:a.dropdown.selectBorderColor,onChange:l=>o({dropdown:{...a.dropdown,selectBorderColor:l}})}),e.jsx(i,{label:"Rank badge",value:a.drag.rankBadgeColor,onChange:l=>o({drag:{...a.drag,rankBadgeColor:l},dropdown:{...a.dropdown,rankBadgeColor:l}})})]})]})})]})]})}export{I as TypePanel};