@explorer02/cfm-survey-sdk 0.4.0 → 0.4.2

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 (27) hide show
  1. package/dist/cli/index.js +69 -65
  2. package/dist/cli/index.mjs +69 -65
  3. package/package.json +1 -1
  4. package/templates/docs/templates/CsatMatrixScale.tsx +102 -29
  5. package/templates/docs/templates/Footer.tsx +3 -2
  6. package/templates/docs/templates/RatingScale.tsx +4 -20
  7. package/templates/docs/templates/labelStyles.ts +44 -0
  8. package/templates/docs/templates/surveyUiIcons.tsx +6 -1
  9. package/templates/docs/templates/uiConfig.ts +23 -8
  10. package/templates/preview-harness/preview-bridge.inline.js +12 -0
  11. package/templates/preview-harness/preview-google-fonts.html +6 -0
  12. package/templates/preview-harness/previewPages.js +3 -2
  13. package/templates/preview-harness/vite-app/src/PreviewConfigContext.tsx +82 -18
  14. package/templates/preview-harness/vite-app/src/QuestionPreview.tsx +1 -1
  15. package/templates/preview-harness/vite-app/src/SurveyPagePreview.tsx +3 -3
  16. package/templates/preview-harness/vite-app/src/fixtures/questions.ts +6 -9
  17. package/templates/preview-harness/vite-app/src/globals.css +4 -3
  18. package/templates/preview-harness/vite-app/src/mergePreviewQuestion.ts +67 -7
  19. package/templates/preview-harness/vite-app/src/preview-live-overrides.css +9 -0
  20. package/templates/previewBridge.ts +13 -0
  21. package/templates/survey-theme.css +13 -0
  22. package/templates/wizard-dist/assets/{PreviewMock-BlOAvUCN.js → PreviewMock-B2SDZ408.js} +1 -1
  23. package/templates/wizard-dist/assets/TypePanel-COi_YFKb.js +1 -0
  24. package/templates/wizard-dist/assets/index-BbqXvrx7.js +34 -0
  25. package/templates/wizard-dist/index.html +1 -1
  26. package/templates/wizard-dist/assets/TypePanel-DcbMaw1b.js +0 -1
  27. package/templates/wizard-dist/assets/index-2Bi_7Fdh.js +0 -34
@@ -181,7 +181,7 @@ export const FIXTURE_CFM_LIKERT = base({
181
181
  showColumnHeaders: true,
182
182
  repeatColumnHeaders: false,
183
183
  hasNotApplicableOption: false,
184
- statementRows: MATRIX_ROWS_MULTI,
184
+ statementRows: MATRIX_ROW_SINGLE,
185
185
  scaleColumns: LIKERT_COLUMNS,
186
186
  });
187
187
 
@@ -221,7 +221,7 @@ export const FIXTURE_CFM_CAROUSEL = base({
221
221
  showColumnHeaders: true,
222
222
  repeatColumnHeaders: false,
223
223
  hasNotApplicableOption: false,
224
- statementRows: MATRIX_ROWS_MULTI,
224
+ statementRows: MATRIX_ROW_SINGLE,
225
225
  scaleColumns: LIKERT_COLUMNS,
226
226
  });
227
227
 
@@ -267,7 +267,7 @@ export const FIXTURE_CSAT_NUMBERED = base({
267
267
  type: 'CSAT_MATRIX',
268
268
  displayStyle: 'numbered',
269
269
  gridLayout: 'standard',
270
- statementRows: MATRIX_ROWS_MULTI,
270
+ statementRows: MATRIX_ROW_SINGLE,
271
271
  scaleColumns: LIKERT_COLUMNS,
272
272
  scaleAnchorLabels: LIKERT_ANCHOR_LABELS,
273
273
  });
@@ -307,7 +307,7 @@ export const FIXTURE_RATING_STAR = base({
307
307
  displayStyle: 'star',
308
308
  gridLayout: 'standard',
309
309
  showColumnHeaders: true,
310
- statementRows: MATRIX_ROWS_MULTI,
310
+ statementRows: MATRIX_ROW_SINGLE,
311
311
  scaleColumns: RATING_TEN_COLUMNS,
312
312
  scaleAnchorLabels: LIKERT_ANCHOR_LABELS,
313
313
  });
@@ -316,7 +316,7 @@ export const FIXTURE_RATING_NUMBERED = base({
316
316
  type: 'RATING_MATRIX',
317
317
  displayStyle: 'numbered',
318
318
  gridLayout: 'standard',
319
- statementRows: MATRIX_ROWS_MULTI,
319
+ statementRows: MATRIX_ROW_SINGLE,
320
320
  scaleColumns: RATING_TEN_COLUMNS,
321
321
  scaleAnchorLabels: LIKERT_ANCHOR_LABELS,
322
322
  });
@@ -352,10 +352,7 @@ export const FIXTURE_RATING_SLIDER = base({
352
352
  type: 'RATING_MATRIX',
353
353
  displayStyle: 'graphics',
354
354
  gridLayout: 'standard',
355
- statementRows: [
356
- { id: 'r1', statementText: 'Statement Item 1' },
357
- { id: 'r2', statementText: 'Statement Item 2' },
358
- ],
355
+ statementRows: MATRIX_ROW_SINGLE,
359
356
  scaleColumns: [
360
357
  { id: 'c1', label: 'Likely' },
361
358
  { id: 'c2', label: 'Unlikely' },
@@ -6,9 +6,9 @@
6
6
 
7
7
  body {
8
8
  margin: 0;
9
- font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
10
- color: #262626;
11
- background-color: #ffffff;
9
+ font-family: var(--cfm-font-family, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
10
+ color: var(--cfm-text, #262626);
11
+ background-color: var(--cfm-background, #ffffff);
12
12
  max-width: 100%;
13
13
  overflow-x: hidden;
14
14
  box-sizing: border-box;
@@ -19,4 +19,5 @@ body {
19
19
  max-width: 100%;
20
20
  overflow-x: hidden;
21
21
  box-sizing: border-box;
22
+ font-family: inherit;
22
23
  }
@@ -37,6 +37,46 @@ const MULTI_STATEMENT_MATRIX_TYPES = new Set([
37
37
  'SLIDER_MATRIX',
38
38
  ]);
39
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
+
40
80
  export function applyMatrixRowCount<T extends MatrixRowCapable>(
41
81
  q: T,
42
82
  multiStatement: boolean | undefined,
@@ -52,18 +92,27 @@ export function applyMatrixRowCount<T extends MatrixRowCapable>(
52
92
 
53
93
  if (multiStatement === true) {
54
94
  if (isBipolar) {
55
- return { ...q, statementRows: BIPOLAR_ROWS_MULTI } as T;
95
+ return {
96
+ ...q,
97
+ statementRows: BIPOLAR_ROWS_MULTI,
98
+ showColumnHeaders: false,
99
+ statementLayout: 'bipolar',
100
+ } as T;
56
101
  }
57
102
  if (isSlider) {
58
103
  return { ...q, statementRows: SLIDER_ROWS_MULTI } as T;
59
104
  }
60
- if (q.statementRows.length >= 3) return q;
61
105
  return { ...q, statementRows: MATRIX_ROWS_MULTI } as T;
62
106
  }
63
107
 
64
108
  if (multiStatement === false) {
65
109
  if (isBipolar) {
66
- return { ...q, statementRows: BIPOLAR_ROWS_SINGLE } as T;
110
+ return {
111
+ ...q,
112
+ statementRows: BIPOLAR_ROWS_SINGLE,
113
+ showColumnHeaders: false,
114
+ statementLayout: 'bipolar',
115
+ } as T;
67
116
  }
68
117
  if (isSlider) {
69
118
  return { ...q, statementRows: SLIDER_ROWS_SINGLE } as T;
@@ -71,7 +120,6 @@ export function applyMatrixRowCount<T extends MatrixRowCapable>(
71
120
  return { ...q, statementRows: [...MATRIX_ROW_SINGLE] } as T;
72
121
  }
73
122
 
74
- // Before bridge snapshot — keep fixture row count (single-row fixtures stay single).
75
123
  return q;
76
124
  }
77
125
 
@@ -84,7 +132,19 @@ function applyCfmMatrixLayout(
84
132
  },
85
133
  previewKey: string,
86
134
  ): SurveyQuestion {
87
- if (previewKey === 'survey_page' || previewKey === 'CFM_likert' || !previewKey.startsWith('CFM_')) {
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_')) {
88
148
  return {
89
149
  ...q,
90
150
  statementLayout: 'likert',
@@ -120,7 +180,7 @@ export function mergePreviewQuestion(
120
180
  previewState: PreviewStatePatch,
121
181
  ): SurveyQuestion {
122
182
  let q = { ...question } as SurveyQuestion;
123
- const previewKey = previewState.activePreviewKey ?? '';
183
+ const previewKey = resolvePreviewKey(previewState, question);
124
184
  const isSurveyPage = previewKey === 'survey_page';
125
185
 
126
186
  if (previewState.textfieldPlaceholder && q.type === 'TEXTFIELD') {
@@ -159,7 +219,7 @@ export function mergePreviewQuestion(
159
219
  }
160
220
  }
161
221
 
162
- return applyMatrixRowCount(q, previewState.multiStatement, {
222
+ return applyMatrixRowCount(q, resolveMultiStatementFlag(previewState), {
163
223
  preserveSurveyPageRows: isSurveyPage,
164
224
  });
165
225
  }
@@ -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 {
@@ -114,6 +122,7 @@ html.cfm-live-edit #root {
114
122
  max-width: 100%;
115
123
  overflow-x: hidden;
116
124
  box-sizing: border-box;
125
+ font-family: var(--cfm-font-family, system-ui, sans-serif) !important;
117
126
  }
118
127
 
119
128
  html.cfm-live-edit [data-cfm-question-area],
@@ -33,6 +33,18 @@ let rafId: number | null = null;
33
33
  const pendingVars: Record<string, string> = {};
34
34
  let liveEditClass = false;
35
35
 
36
+ const PREVIEW_FONTS_HREF =
37
+ 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Roboto:wght@400;500;600;700&family=Open+Sans:wght@400;500;600;700&family=Lato:wght@400;500;600;700&family=Poppins:wght@400;500;600;700&family=Montserrat:wght@400;500;600;700&family=Nunito:wght@400;500;600;700&family=Raleway:wght@400;500;600;700&family=Source+Sans+3:wght@400;500;600;700&family=Merriweather:wght@400;500;600;700&family=Playfair+Display:wght@400;500;600;700&display=swap';
38
+
39
+ function ensurePreviewFonts(): void {
40
+ if (document.getElementById('cfm-preview-fonts')) return;
41
+ const link = document.createElement('link');
42
+ link.id = 'cfm-preview-fonts';
43
+ link.rel = 'stylesheet';
44
+ link.href = PREVIEW_FONTS_HREF;
45
+ document.head.appendChild(link);
46
+ }
47
+
36
48
  function flushCssVars(): void {
37
49
  rafId = null;
38
50
  const root = document.documentElement;
@@ -302,6 +314,7 @@ function applyThemeSideEffects(): void {
302
314
  function setLiveEditMode(on: boolean): void {
303
315
  if (liveEditClass === on) return;
304
316
  liveEditClass = on;
317
+ if (on) ensurePreviewFonts();
305
318
  document.documentElement.classList.toggle('cfm-live-edit', on);
306
319
  }
307
320
 
@@ -228,6 +228,19 @@ body {
228
228
  grid-row: 1;
229
229
  justify-self: var(--cfm-footer-logo-justify, start);
230
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;
231
244
  }
232
245
 
233
246
  .cfm-footer-links {
@@ -1 +1 @@
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};
1
+ import{u as x,j as e}from"./index-BbqXvrx7.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-BbqXvrx7.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};