@explorer02/cfm-survey-sdk 0.3.8 → 0.4.0

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 (29) hide show
  1. package/dist/cli/index.js +35 -35
  2. package/dist/cli/index.mjs +35 -35
  3. package/package.json +1 -1
  4. package/templates/docs/templates/CsatMatrixScale.tsx +60 -45
  5. package/templates/docs/templates/CustomSliderTrack.tsx +2 -2
  6. package/templates/docs/templates/Header.tsx +14 -13
  7. package/templates/docs/templates/LikertMatrixScale.tsx +2 -2
  8. package/templates/docs/templates/Question.tsx +31 -13
  9. package/templates/docs/templates/RankOrderScale.tsx +10 -2
  10. package/templates/docs/templates/SliderMatrixScale.tsx +3 -4
  11. package/templates/docs/templates/uiConfig.ts +89 -2
  12. package/templates/preview-harness/preview-bridge.inline.js +55 -15
  13. package/templates/preview-harness/previewPages.js +2 -2
  14. package/templates/preview-harness/previewPages.ts +1 -1
  15. package/templates/preview-harness/vite-app/src/PreviewConfigContext.tsx +8 -1
  16. package/templates/preview-harness/vite-app/src/QuestionPreview.tsx +17 -96
  17. package/templates/preview-harness/vite-app/src/SurveyPagePreview.tsx +32 -8
  18. package/templates/preview-harness/vite-app/src/fixtures/questions.ts +72 -47
  19. package/templates/preview-harness/vite-app/src/globals.css +6 -0
  20. package/templates/preview-harness/vite-app/src/mergePreviewQuestion.ts +173 -0
  21. package/templates/preview-harness/vite-app/src/preview-live-overrides.css +22 -0
  22. package/templates/previewBridge.ts +61 -14
  23. package/templates/survey-theme.css +4 -1
  24. package/templates/wizard-dist/assets/{PreviewMock-CS4WqhDB.js → PreviewMock-BlOAvUCN.js} +1 -1
  25. package/templates/wizard-dist/assets/TypePanel-DcbMaw1b.js +1 -0
  26. package/templates/wizard-dist/assets/index-2Bi_7Fdh.js +34 -0
  27. package/templates/wizard-dist/index.html +1 -1
  28. package/templates/wizard-dist/assets/TypePanel-BgTW2c74.js +0 -1
  29. package/templates/wizard-dist/assets/index-hjm-fxWO.js +0 -34
@@ -0,0 +1,173 @@
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
+ export function applyMatrixRowCount<T extends MatrixRowCapable>(
41
+ q: T,
42
+ multiStatement: boolean | undefined,
43
+ options?: { preserveSurveyPageRows?: boolean },
44
+ ): T {
45
+ if (!MULTI_STATEMENT_MATRIX_TYPES.has(q.type)) return q;
46
+ if (!('statementRows' in q) || !Array.isArray(q.statementRows)) return q;
47
+
48
+ const isBipolar = q.type === 'CFM_MATRIX' && q.statementLayout === 'bipolar';
49
+ const isSlider = q.type === 'SLIDER_MATRIX';
50
+
51
+ if (options?.preserveSurveyPageRows && q.statementRows.length >= 2) return q;
52
+
53
+ if (multiStatement === true) {
54
+ if (isBipolar) {
55
+ return { ...q, statementRows: BIPOLAR_ROWS_MULTI } as T;
56
+ }
57
+ if (isSlider) {
58
+ return { ...q, statementRows: SLIDER_ROWS_MULTI } as T;
59
+ }
60
+ if (q.statementRows.length >= 3) return q;
61
+ return { ...q, statementRows: MATRIX_ROWS_MULTI } as T;
62
+ }
63
+
64
+ if (multiStatement === false) {
65
+ if (isBipolar) {
66
+ return { ...q, statementRows: BIPOLAR_ROWS_SINGLE } as T;
67
+ }
68
+ if (isSlider) {
69
+ return { ...q, statementRows: SLIDER_ROWS_SINGLE } as T;
70
+ }
71
+ return { ...q, statementRows: [...MATRIX_ROW_SINGLE] } as T;
72
+ }
73
+
74
+ // Before bridge snapshot — keep fixture row count (single-row fixtures stay single).
75
+ return q;
76
+ }
77
+
78
+ function applyCfmMatrixLayout(
79
+ q: SurveyQuestion & {
80
+ statementLayout?: string;
81
+ gridLayout?: string;
82
+ transposeTable?: boolean;
83
+ showColumnHeaders?: boolean;
84
+ },
85
+ previewKey: string,
86
+ ): SurveyQuestion {
87
+ if (previewKey === 'survey_page' || previewKey === 'CFM_likert' || !previewKey.startsWith('CFM_')) {
88
+ return {
89
+ ...q,
90
+ statementLayout: 'likert',
91
+ gridLayout: 'standard',
92
+ transposeTable: false,
93
+ showColumnHeaders: true,
94
+ } as SurveyQuestion;
95
+ }
96
+ if (previewKey === 'CFM_bipolar') {
97
+ return {
98
+ ...q,
99
+ statementLayout: 'bipolar',
100
+ showColumnHeaders: false,
101
+ gridLayout: 'standard',
102
+ transposeTable: false,
103
+ } as SurveyQuestion;
104
+ }
105
+ if (previewKey === 'CFM_transpose') {
106
+ return { ...q, statementLayout: 'likert', transposeTable: true, gridLayout: 'standard' } as SurveyQuestion;
107
+ }
108
+ if (previewKey === 'CFM_carousel') {
109
+ return { ...q, statementLayout: 'likert', gridLayout: 'carousel', transposeTable: false } as SurveyQuestion;
110
+ }
111
+ if (previewKey === 'CFM_dropdown') {
112
+ return { ...q, statementLayout: 'likert', gridLayout: 'dropdown', transposeTable: false } as SurveyQuestion;
113
+ }
114
+ return { ...q, statementLayout: 'likert', gridLayout: 'standard', transposeTable: false } as SurveyQuestion;
115
+ }
116
+
117
+ /** Apply wizard bridge previewState onto a fixture question. */
118
+ export function mergePreviewQuestion(
119
+ question: SurveyQuestion,
120
+ previewState: PreviewStatePatch,
121
+ ): SurveyQuestion {
122
+ let q = { ...question } as SurveyQuestion;
123
+ const previewKey = previewState.activePreviewKey ?? '';
124
+ const isSurveyPage = previewKey === 'survey_page';
125
+
126
+ if (previewState.textfieldPlaceholder && q.type === 'TEXTFIELD') {
127
+ q = { ...q, placeholder: previewState.textfieldPlaceholder };
128
+ }
129
+
130
+ if (q.type === 'NPS_SCALE') {
131
+ q = {
132
+ ...q,
133
+ buttonStyle: mapNpsButtonStyle(previewState.npsButtonStyle ?? q.buttonStyle ?? 'numbered'),
134
+ minLabel: previewState.hintMinText ?? q.minLabel,
135
+ maxLabel: previewState.hintMaxText ?? q.maxLabel,
136
+ };
137
+ } else if (previewState.hintMinText !== undefined || previewState.hintMaxText !== undefined) {
138
+ if (q.type === 'SLIDER_MATRIX') {
139
+ q = {
140
+ ...q,
141
+ scaleAnchorLabels: [
142
+ previewState.hintMinText ?? q.scaleAnchorLabels?.[0] ?? '',
143
+ previewState.hintMaxText ?? q.scaleAnchorLabels?.[1] ?? '',
144
+ ],
145
+ };
146
+ }
147
+ }
148
+
149
+ if (q.type === 'CFM_MATRIX') {
150
+ q = applyCfmMatrixLayout(q, isSurveyPage ? 'survey_page' : previewKey);
151
+ }
152
+
153
+ if (q.type === 'RANK_ORDER') {
154
+ if (previewState.rankVariant === 'drag' || previewKey === 'RANK_drag') {
155
+ q = { ...q, interactionMode: 'dragAndDrop', optionDisplay: 'textAndImage' };
156
+ }
157
+ if (previewState.rankVariant === 'dropdown' || previewKey === 'RANK_dropdown') {
158
+ q = { ...q, interactionMode: 'dropdown', optionDisplay: 'textAndImage' };
159
+ }
160
+ }
161
+
162
+ return applyMatrixRowCount(q, previewState.multiStatement, {
163
+ preserveSurveyPageRows: isSurveyPage,
164
+ });
165
+ }
166
+
167
+ /** Survey page layout — each question reflects its type-tab customization mapping. */
168
+ export function mergeSurveyPageQuestion(
169
+ question: SurveyQuestion,
170
+ previewState: PreviewStatePatch,
171
+ ): SurveyQuestion {
172
+ return mergePreviewQuestion(question, normalizeSurveyPagePreviewState(previewState));
173
+ }
@@ -106,3 +106,25 @@ html.cfm-live-edit input[data-cfm-textfield]::placeholder {
106
106
  color: var(--cfm-input-placeholder, #9ca3af) !important;
107
107
  opacity: 1;
108
108
  }
109
+
110
+ /* Keep every question-type preview inside the wizard iframe without horizontal bleed */
111
+ html.cfm-live-edit,
112
+ html.cfm-live-edit body,
113
+ html.cfm-live-edit #root {
114
+ max-width: 100%;
115
+ overflow-x: hidden;
116
+ box-sizing: border-box;
117
+ }
118
+
119
+ html.cfm-live-edit [data-cfm-question-area],
120
+ html.cfm-live-edit .cfm-question-card {
121
+ max-width: 100%;
122
+ min-width: 0;
123
+ overflow-x: auto;
124
+ box-sizing: border-box;
125
+ }
126
+
127
+ html.cfm-live-edit [data-cfm-nps-area] {
128
+ max-width: 100%;
129
+ overflow-x: auto;
130
+ }
@@ -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,19 +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
- htmlEl.style.display = htmlEl.textContent?.trim() ? '' : 'none';
95
- }
96
- });
97
147
  }
98
148
 
99
149
  if (patch.companyName !== undefined) {
100
150
  const name = patch.companyName ?? '';
101
151
  document.querySelectorAll('[data-cfm-company]').forEach((el) => {
102
152
  (el as HTMLElement).textContent = name;
103
- (el as HTMLElement).style.display = name ? '' : 'none';
104
153
  });
105
154
  document.querySelectorAll('[data-cfm-logo-text]').forEach((el) => {
106
155
  const logoImg = document.querySelector('[data-cfm-logo]') as HTMLImageElement | null;
@@ -163,7 +212,7 @@ function applyContentPatch(patch: ContentPatch): void {
163
212
  if (patch.layoutFlags) {
164
213
  const flags = patch.layoutFlags;
165
214
  if (flags.showCompanyName !== undefined) {
166
- setDisplay('[data-cfm-company]', Boolean(flags.showCompanyName));
215
+ syncCompanyNameVisibility(Boolean(flags.showCompanyName));
167
216
  }
168
217
  if (flags.showHeader !== undefined) {
169
218
  setDisplay('.cfm-header, header.cfm-header', Boolean(flags.showHeader));
@@ -184,10 +233,10 @@ function applyContentPatch(patch: ContentPatch): void {
184
233
  setDisplay('[data-cfm-btn-back]', Boolean(flags.showBackButton));
185
234
  }
186
235
  if (flags.showQuestionNumbers !== undefined) {
187
- setDisplay('[data-cfm-question-number]', Boolean(flags.showQuestionNumbers));
236
+ syncQuestionChromeVisibility(Boolean(flags.showQuestionNumbers), undefined);
188
237
  }
189
238
  if (flags.showRequiredAsterisk !== undefined) {
190
- setDisplay('[data-cfm-required]', Boolean(flags.showRequiredAsterisk));
239
+ syncQuestionChromeVisibility(undefined, Boolean(flags.showRequiredAsterisk));
191
240
  }
192
241
  if (flags.showFooterLogo !== undefined) {
193
242
  setDisplay('[data-cfm-footer-logo]', Boolean(flags.showFooterLogo));
@@ -225,15 +274,13 @@ function applyContentPatch(patch: ContentPatch): void {
225
274
  (el as HTMLElement).style.display = show ? '' : 'none';
226
275
  });
227
276
  }
277
+ syncCompanyNameVisibility();
278
+ syncQuestionChromeVisibility();
228
279
  applyThemeSideEffects();
229
280
  }
230
281
 
231
282
  const TRAFFIC_BADGE = ['#ef4444', '#f97316', '#eab308', '#84cc16', '#22c55e', '#14b8a6', '#06b6d4', '#3b82f6', '#6366f1', '#8b5cf6', '#a855f7'];
232
283
 
233
- function readCssVar(name: string, fallback: string): string {
234
- return getComputedStyle(document.documentElement).getPropertyValue(name).trim() || fallback;
235
- }
236
-
237
284
  function applyThemeSideEffects(): void {
238
285
  const mode = readCssVar('--cfm-number-label-mode', 'traffic');
239
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;
@@ -37,7 +39,7 @@
37
39
  --cfm-footer-link-hover: #ffffff;
38
40
  --cfm-footer-logo-width: 120px;
39
41
  --cfm-footer-logo-height: 32px;
40
- --cfm-footer-padding-y: 24px;
42
+ --cfm-footer-padding-y: 21px;
41
43
  --cfm-footer-padding-x: 40px;
42
44
  --cfm-footer-logo-copyright-gap: 12px;
43
45
  --cfm-footer-inner-display: grid;
@@ -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);
@@ -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-2Bi_7Fdh.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-2Bi_7Fdh.js";import"./vendor-BwkXDkd3.js";function C({values:o,onPatch:r}){return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(i,{label:"Label text color",value:o.columnLabelColor,onChange:a=>r({columnLabelColor:a})}),e.jsx(i,{label:"Label background",value:o.columnLabelBgColor,onChange:a=>r({columnLabelBgColor:a})})]})}function w({values:o,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:o.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:o.hintMaxText,onChange:a=>r({hintMaxText:a.target.value})})]}),e.jsx(i,{label:"Hint text color",value:o.hintLabelColor,onChange:a=>r({hintLabelColor:a})}),e.jsx(i,{label:"Hint label background",value:o.hintLabelBgColor,onChange:a=>r({hintLabelBgColor:a})})]})}function M({values:o,onPatch:r,count:a=11}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{label:"Number label style",value:o.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"}]}),o.numberLabelMode==="monochrome"&&e.jsx(i,{label:"Monochrome color",value:o.monochromeNumberColor,onChange:c=>r({monochromeNumberColor:c})}),o.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:o.individualNumberColors[x]??"#9CA3AF",onChange:j=>{const g=[...o.individualNumberColors];g[x]=j,r({individualNumberColors:g})}},x))})]})}function s({title:o,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:o}),r]})}function I({type:o,activeFormat:r}){const a=m(l=>l.config.questionTypes[o]),c=m(l=>l.updateQuestionType),x=m(l=>l.previewMultiStatementByType),j=m(l=>l.setPreviewMultiStatementForType),g=m(l=>l.heatmapPreviewPin);if(!a)return e.jsx("p",{className:"text-sm text-slate-500",children:"No configuration available for this type."});const n=l=>c(o,l),f=z.includes(o),y=!!x[o],u=r.includes("star"),h=r.includes("emoji"),p=r.includes("numbered"),v=r.includes("drag"),S=r.includes("dropdown"),N=r.includes("radio"),B=r==="CFM_bipolar",T=r.includes("graphics"),k=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:y,onChange:l=>j(o,l)}),o==="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=>n({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=>n({optionGap:l}),min:0,max:32}),e.jsx(d,{label:"Border radius",value:a.borderRadius,onChange:l=>n({borderRadius:l}),min:0,max:24}),e.jsx(d,{label:"Option padding",value:a.optionPadding??12,onChange:l=>n({optionPadding:l}),min:4,max:24}),e.jsx(i,{label:"Hover border",value:a.hoverBorderColor,onChange:l=>n({hoverBorderColor:l})}),k==="filled"&&e.jsx(i,{label:"Unselected fill color",value:a.filledOptionBg??"#F9FAFB",onChange:l=>n({filledOptionBg:l})})]})}),o==="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=>n({defaultPlaceholder:l.target.value})})]}),e.jsx(t,{label:"Input radius (px)",value:a.inputRadius,onChange:l=>n({inputRadius:l}),min:0,max:24}),e.jsx(i,{label:"Border color",value:a.borderColor,onChange:l=>n({borderColor:l})}),e.jsx(i,{label:"Placeholder color",value:a.placeholderColor,onChange:l=>n({placeholderColor:l})}),e.jsx(t,{label:"Input height (px)",value:a.inputHeight,onChange:l=>n({inputHeight:l}),min:32,max:64}),e.jsx(t,{label:"Input padding (px)",value:a.inputPadding,onChange:l=>n({inputPadding:l}),min:8,max:24})]})}),o==="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=>n({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(w,{values:a,onPatch:n})}),L==="numbered"&&e.jsx(s,{title:"Number labels",children:e.jsx(M,{values:a,onPatch:n})}),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=>n({cellSize:l}),min:24,max:56}),e.jsx(t,{label:"Cell gap (px)",value:a.cellGap,onChange:l=>n({cellGap:l}),min:0,max:16}),e.jsx(i,{label:"Track bar",value:a.trackBarColor,onChange:l=>n({trackBarColor:l})})]})})]}),o==="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=>n({rowLabelWidth:l}),min:120,max:280}),B&&e.jsx(t,{label:"Bipolar column width (%)",value:a.bipolarColumnWidthPercent,onChange:l=>n({bipolarColumnWidthPercent:l}),min:15,max:40}),e.jsx(t,{label:"Cell padding (px)",value:a.cellPadding,onChange:l=>n({cellPadding:l}),min:4,max:24})]})}),e.jsx(s,{title:"Label items",children:e.jsx(C,{values:a,onPatch:n})})]}),o==="CSAT_MATRIX"&&"emojiSize"in a&&e.jsxs(e.Fragment,{children:[(h||u||p)&&e.jsxs(s,{title:`${R.CSAT_MATRIX} — ${r.replace("CSAT_","")}`,children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h&&e.jsx(t,{label:"Emoji size (px)",value:a.emojiSize,onChange:l=>n({emojiSize:l}),min:16,max:40}),u&&e.jsx(i,{label:"Star color",value:a.accentColor,onChange:l=>n({accentColor:l})}),(h||u||p)&&e.jsx(d,{label:"Unselected opacity",value:Math.round(a.unselectedOpacity*100),onChange:l=>n({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:n})]}),T&&e.jsx(s,{title:"Graphics track",children:e.jsx(i,{label:"Track color",value:a.graphicsTrackColor,onChange:l=>n({graphicsTrackColor:l})})})]}),o==="RATING_MATRIX"&&"unselectedStarOpacity"in a&&e.jsxs(e.Fragment,{children:[(h||u||p||N)&&e.jsxs(s,{title:`Rating — ${r.replace("RATING_","")}`,children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h&&e.jsx(t,{label:"Emoji size (px)",value:a.emojiSize,onChange:l=>n({emojiSize:l}),min:16,max:40}),u&&e.jsx(i,{label:"Star color",value:a.starColor,onChange:l=>n({starColor:l})}),(h||u||p||N)&&e.jsx(d,{label:"Unselected opacity",value:Math.round(a.unselectedStarOpacity*100),onChange:l=>n({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:n})]}),T&&e.jsx(s,{title:"Graphics track",children:e.jsx(i,{label:"Track color",value:a.graphicsTrackColor,onChange:l=>n({graphicsTrackColor:l})})})]}),o==="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=>n({trackColor:l})}),e.jsx(i,{label:"Thumb",value:a.thumbColor,onChange:l=>n({thumbColor:l})}),e.jsx(t,{label:"Row label width (px)",value:a.rowLabelWidth,onChange:l=>n({rowLabelWidth:l}),min:120,max:280}),e.jsx(i,{label:"Row band",value:a.rowBandColor,onChange:l=>n({rowBandColor:l})}),e.jsx(t,{label:"Tick badge size (px)",value:a.tickBadgeSize,onChange:l=>n({tickBadgeSize:l}),min:20,max:40})]})}),e.jsx(s,{title:"Anchor hint labels",children:e.jsx(w,{values:a,onPatch:n})}),e.jsx(s,{title:"Tick number labels",children:e.jsx(M,{values:a,onPatch:n,count:11})})]}),o==="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=>n({dropzoneStyle:l}),options:[{value:"dashed",label:"Dashed"},{value:"solid",label:"Solid"}]}),e.jsx(i,{label:"Border color",value:a.borderColor??a.accentColor,onChange:l=>n({borderColor:l})}),e.jsx(i,{label:"Fill color",value:a.dropzoneFillColor,onChange:l=>n({dropzoneFillColor:l})}),e.jsx(t,{label:"Padding (px)",value:a.dropzonePadding,onChange:l=>n({dropzonePadding:l}),min:12,max:48})]})}),o==="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=>n({mediaMaxWidth:l}),min:50,max:100}),e.jsx(d,{label:"Media corner radius",value:a.mediaRadius,onChange:l=>n({mediaRadius:l}),min:0,max:24}),e.jsx(i,{label:"Caption color",value:a.captionColor,onChange:l=>n({captionColor:l})}),e.jsx(t,{label:"Caption size (px)",value:a.captionSize,onChange:l=>n({captionSize:l}),min:10,max:24})]})}),o==="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=>n({pinColor:l})}),e.jsx(i,{label:"Pin border",value:a.pinBorderColor,onChange:l=>n({pinBorderColor:l})}),e.jsx(d,{label:"Pin size",value:a.pinSize,onChange:l=>n({pinSize:l}),min:8,max:32}),e.jsx(d,{label:"Overlay opacity",value:Math.round(a.overlayOpacity*100),onChange:l=>n({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(g.x*100),"%, ",Math.round(g.y*100),"%"]})]})}),o==="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=>n({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=>n({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=>n({drag:{...a.drag,dragHandleColor:l}})}),e.jsx(i,{label:"Rank badge",value:a.drag.rankBadgeColor,onChange:l=>n({drag:{...a.drag,rankBadgeColor:l}})})]}),S&&e.jsx(i,{label:"Select border",value:a.dropdown.selectBorderColor,onChange:l=>n({dropdown:{...a.dropdown,selectBorderColor:l}})})]})})]})]})}export{I as TypePanel};