@explorer02/cfm-survey-sdk 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +24 -26
- package/dist/index.d.ts +24 -26
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/postinstall.js +21 -30
- package/templates/AGENT.md +24 -10
- package/templates/docs/00-integration/constraints.md +54 -0
- package/templates/docs/00-integration/setup.md +80 -0
- package/templates/docs/00-integration/useSurveySDK.md +107 -0
- package/templates/docs/{03-client-components → 01-components}/README.md +1 -1
- package/templates/docs/02-question-types/01-rating.md +0 -8
- package/templates/docs/02-reference/question-types/01-rating.md +52 -0
- package/templates/docs/02-reference/question-types/README.md +71 -0
- package/templates/docs/02-reference/routing-table.md +37 -0
- package/templates/docs/MANIFEST.json +129 -0
- package/templates/docs/index.md +100 -142
- package/templates/docs/templates/implementation_plan.md +78 -0
- package/templates/docs/01-sdk-core/01-fetch-survey.md +0 -68
- package/templates/docs/01-sdk-core/02-survey-mapper.md +0 -85
- package/templates/docs/01-sdk-core/03-question-mappers.md +0 -114
- package/templates/docs/01-sdk-core/04-pagination.md +0 -72
- package/templates/docs/01-sdk-core/05-validation.md +0 -66
- package/templates/docs/01-sdk-core/06-submit-survey.md +0 -90
- package/templates/docs/01-sdk-core/07-language-handling.md +0 -111
- package/templates/docs/01-sdk-core/08-icons-and-emojis.md +0 -56
- package/templates/docs/01-sdk-core/README.md +0 -53
- package/templates/docs/02-question-types/02-radio.md +0 -26
- package/templates/docs/02-question-types/03-text.md +0 -26
- package/templates/docs/02-question-types/12-text-and-media.md +0 -35
- package/templates/docs/02-question-types/README.md +0 -74
- package/templates/docs/04-critical-rules/01-import-rules.md +0 -51
- package/templates/docs/04-critical-rules/02-action-dispatching.md +0 -56
- package/templates/docs/04-critical-rules/03-scroll-navigation.md +0 -37
- package/templates/docs/04-critical-rules/04-logo-branding.md +0 -42
- package/templates/docs/04-critical-rules/05-troubleshooting.md +0 -46
- package/templates/docs/04-critical-rules/README.md +0 -29
- /package/templates/docs/{03-client-components → 01-components}/01-survey-page.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/02-question.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/03-rating-scale.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/04-csat-scale.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/05-csat-matrix-scale.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/06-likert-matrix-scale.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/07-slider-matrix-scale.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/08-file-upload-scale.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/09-custom-slider-track.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/10-header-footer.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/11-progress-bar.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/12-language-selector.md +0 -0
- /package/templates/docs/{03-client-components → 01-components}/13-matrix-dropdown.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/04-csat.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/05-rating-scale.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/06-slider.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/07-matrix-cfm.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/08-matrix-csat.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/09-matrix-rating.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/10-slider-matrix.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/11-file-upload.md +0 -0
|
@@ -21,14 +21,6 @@ type RatingQuestion = QuestionBase & {
|
|
|
21
21
|
## Answer Shape: `number`
|
|
22
22
|
Example: `7` (the selected badge value)
|
|
23
23
|
|
|
24
|
-
## Options Auto-Generation
|
|
25
|
-
If the API provides no explicit options, the SDK generates 0-10:
|
|
26
|
-
```typescript
|
|
27
|
-
Array.from({ length: 11 }, (_, i) => ({
|
|
28
|
-
id: String(i), label: String(i), value: i, color: getColor(i)
|
|
29
|
-
}));
|
|
30
|
-
```
|
|
31
|
-
|
|
32
24
|
## NPS Traffic-Light Colors
|
|
33
25
|
```
|
|
34
26
|
0: #e2001a (red) 3: #f18b00 (orange) 6: #fcd900 (yellow)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Rating Question (NPS 0-10)
|
|
2
|
+
|
|
3
|
+
> **Type**: `'rating'` | **API Source**: `SCALE` with `SCALE_TYPE=TEN_POINT` or `NPS_SCALE`
|
|
4
|
+
> **Mapper**: `ratingMapper.ts` | **Component**: `RatingScale`
|
|
5
|
+
|
|
6
|
+
## TypeScript Type
|
|
7
|
+
|
|
8
|
+
```typescript
|
|
9
|
+
type RatingQuestion = QuestionBase & {
|
|
10
|
+
type: 'rating';
|
|
11
|
+
options: SurveyOption[]; // 0-10 with NPS traffic-light colors
|
|
12
|
+
minLabel?: string; // Left label (e.g. "Not Likely")
|
|
13
|
+
midLabel?: string; // Middle label (e.g. "Neutral")
|
|
14
|
+
maxLabel?: string; // Right label (e.g. "Extremely Likely")
|
|
15
|
+
midLabelIndex?: number; // Fractional position for mid-label CSS
|
|
16
|
+
reverseScaleOrder?: boolean; // Render high→low
|
|
17
|
+
buttonVariant?: 'radio' | 'numbered' | 'emoji';
|
|
18
|
+
};
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Answer Shape: `number`
|
|
22
|
+
Example: `7` (the selected badge value)
|
|
23
|
+
|
|
24
|
+
## Options Auto-Generation
|
|
25
|
+
If the API provides no explicit options, the SDK generates 0-10:
|
|
26
|
+
```typescript
|
|
27
|
+
Array.from({ length: 11 }, (_, i) => ({
|
|
28
|
+
id: String(i), label: String(i), value: i, color: getColor(i)
|
|
29
|
+
}));
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## NPS Traffic-Light Colors
|
|
33
|
+
```
|
|
34
|
+
0: #e2001a (red) 3: #f18b00 (orange) 6: #fcd900 (yellow)
|
|
35
|
+
1: #e4251b 4: #f7b200 7: #9fca00 (lime)
|
|
36
|
+
2: #ec610a 5: #fcd900 8: #6bb300 (green)
|
|
37
|
+
9: #339a00
|
|
38
|
+
10: #008000
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Mid-Label Positioning
|
|
42
|
+
```typescript
|
|
43
|
+
// CSS left percentage for mid-label
|
|
44
|
+
const left = (midLabelIndex / (options.length - 1)) * 100;
|
|
45
|
+
// For 11-point scale: midLabelIndex defaults to 7.5
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Rendering Guidance
|
|
49
|
+
- Display as horizontal row of numbered badge buttons
|
|
50
|
+
- Each badge uses `option.color` as background
|
|
51
|
+
- Selected badge: emphasized border/scale, all others dimmed
|
|
52
|
+
- Labels positioned: minLabel (left), midLabel (calculated %), maxLabel (right)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Question Types Reference
|
|
2
|
+
|
|
3
|
+
> Read **on demand** — only for types present in the fetched survey.
|
|
4
|
+
> UI implementation: `01-components/`. Routing table: `02-reference/routing-table.md`.
|
|
5
|
+
|
|
6
|
+
## Discriminated Union
|
|
7
|
+
|
|
8
|
+
```typescript
|
|
9
|
+
type SurveyQuestion =
|
|
10
|
+
| RatingQuestion // 'rating'
|
|
11
|
+
| RadioQuestion // 'radio'
|
|
12
|
+
| TextQuestion // 'text'
|
|
13
|
+
| CsatQuestion // 'csat'
|
|
14
|
+
| RatingScaleQuestion // 'rating_scale'
|
|
15
|
+
| SliderQuestion // 'slider'
|
|
16
|
+
| MatrixQuestion // 'matrix' (check subType)
|
|
17
|
+
| RatingMatrixQuestion // 'rating_matrix'
|
|
18
|
+
| SliderMatrixQuestion // 'slider_matrix'
|
|
19
|
+
| FileUploadQuestion // 'file_upload'
|
|
20
|
+
| TextAndMediaQuestion; // 'text_and_media'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Shared `QuestionBase` Properties
|
|
24
|
+
|
|
25
|
+
| Property | Type | Notes |
|
|
26
|
+
|----------|------|-------|
|
|
27
|
+
| `id` | `string` | **MUST** be DOM `id` on wrapper |
|
|
28
|
+
| `text` | `string` | HTML — use `dangerouslySetInnerHTML` |
|
|
29
|
+
| `description` | `string?` | HTML |
|
|
30
|
+
| `required` | `boolean?` | |
|
|
31
|
+
| `requiredErrorMessage` | `string?` | Custom validation message |
|
|
32
|
+
| `questionNumber` | `number?` | 1-indexed |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## radio {#radio}
|
|
37
|
+
|
|
38
|
+
- **Type:** `RadioQuestion` — `type: 'radio'`
|
|
39
|
+
- **Answer:** `string | number` (option id or value)
|
|
40
|
+
- **UI:** Inline MCQ radio cards in `Question.tsx` — see `01-components/02-question.md`
|
|
41
|
+
- **No separate reference doc needed**
|
|
42
|
+
|
|
43
|
+
## text {#text}
|
|
44
|
+
|
|
45
|
+
- **Type:** `TextQuestion` — `type: 'text'`
|
|
46
|
+
- **Answer:** `string`
|
|
47
|
+
- **UI:** Inline `<textarea>` or `<input>` in `Question.tsx`
|
|
48
|
+
- **No separate reference doc needed**
|
|
49
|
+
|
|
50
|
+
## text_and_media {#text_and_media}
|
|
51
|
+
|
|
52
|
+
- **Type:** `TextAndMediaQuestion` — `type: 'text_and_media'`
|
|
53
|
+
- **Answer:** none — display-only, skipped in validation and submission
|
|
54
|
+
- **UI:** Inline `<video>` or `<img>` from `question.mediaUrl` — no scale component
|
|
55
|
+
- **No separate reference doc needed**
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Detailed Reference Docs
|
|
60
|
+
|
|
61
|
+
| File | Type | When to read |
|
|
62
|
+
|------|------|--------------|
|
|
63
|
+
| `01-rating.md` | `rating` | NPS / numeric scales |
|
|
64
|
+
| `04-csat.md` | `csat` | CSAT emoji/star (≤5 options) |
|
|
65
|
+
| `05-rating-scale.md` | `rating_scale` | Star/emoji rating |
|
|
66
|
+
| `06-slider.md` | `slider` | Single range slider |
|
|
67
|
+
| `07-matrix-cfm.md` | `matrix` + `CFM_MATRIX` | Likert text grid |
|
|
68
|
+
| `08-matrix-csat.md` | `matrix` + CSAT/RATING | Satisfaction grid |
|
|
69
|
+
| `09-matrix-rating.md` | `rating_matrix` | NPS-style grid |
|
|
70
|
+
| `10-slider-matrix.md` | `slider_matrix` | Slider grid |
|
|
71
|
+
| `11-file-upload.md` | `file_upload` | File attachments |
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Question Type → Component Routing
|
|
2
|
+
|
|
3
|
+
> Canonical mapping. For UI implementation details, read `01-components/`. For data shapes, read `02-reference/question-types/`.
|
|
4
|
+
|
|
5
|
+
| `question.type` | `question.subType` | Component | Answer Shape | Reference Doc |
|
|
6
|
+
|-----------------|-------------------|-----------|--------------|---------------|
|
|
7
|
+
| `'rating'` | — | `RatingScale` | `number` | `question-types/01-rating.md` |
|
|
8
|
+
| `'radio'` | — | Inline in `Question` | `string \| number` | `question-types/README.md#radio` |
|
|
9
|
+
| `'text'` | — | Inline in `Question` | `string` | `question-types/README.md#text` |
|
|
10
|
+
| `'csat'` | — | `CsatScale` | `number \| null` | `question-types/04-csat.md` |
|
|
11
|
+
| `'rating_scale'` | — | `RatingScale` | `number` | `question-types/05-rating-scale.md` |
|
|
12
|
+
| `'slider'` | — | `CustomSliderTrack` | `number` | `question-types/06-slider.md` |
|
|
13
|
+
| `'matrix'` | `'CFM_MATRIX'` | `LikertMatrixScale` | `MatrixAnswerMap` | `question-types/07-matrix-cfm.md` |
|
|
14
|
+
| `'matrix'` | `'CSAT_MATRIX'` | `CsatMatrixScale` | `MatrixAnswerMap` | `question-types/08-matrix-csat.md` |
|
|
15
|
+
| `'matrix'` | `'RATING_MATRIX'` | `CsatMatrixScale` | `MatrixAnswerMap` | `question-types/08-matrix-csat.md` |
|
|
16
|
+
| `'rating_matrix'` | — | `CsatMatrixScale` | `MatrixAnswerMap` | `question-types/09-matrix-rating.md` |
|
|
17
|
+
| `'slider_matrix'` | — | `SliderMatrixScale` | `MatrixAnswerMap` | `question-types/10-slider-matrix.md` |
|
|
18
|
+
| `'file_upload'` | — | `FileUploadScale` | `UploadedFile[]` | `question-types/11-file-upload.md` |
|
|
19
|
+
| `'text_and_media'` | — | Inline in `Question` | (no answer) | `question-types/README.md#text_and_media` |
|
|
20
|
+
|
|
21
|
+
## Component Blueprint Docs
|
|
22
|
+
|
|
23
|
+
| Component | Blueprint |
|
|
24
|
+
|-----------|-----------|
|
|
25
|
+
| `SurveyPage` | `01-components/01-survey-page.md` |
|
|
26
|
+
| `Question` | `01-components/02-question.md` |
|
|
27
|
+
| `RatingScale` | `01-components/03-rating-scale.md` |
|
|
28
|
+
| `CsatScale` | `01-components/04-csat-scale.md` |
|
|
29
|
+
| `CsatMatrixScale` | `01-components/05-csat-matrix-scale.md` |
|
|
30
|
+
| `LikertMatrixScale` | `01-components/06-likert-matrix-scale.md` |
|
|
31
|
+
| `SliderMatrixScale` | `01-components/07-slider-matrix-scale.md` |
|
|
32
|
+
| `FileUploadScale` | `01-components/08-file-upload-scale.md` |
|
|
33
|
+
| `CustomSliderTrack` | `01-components/09-custom-slider-track.md` |
|
|
34
|
+
| `Header` / `Footer` | `01-components/10-header-footer.md` |
|
|
35
|
+
| `ProgressBar` | `01-components/11-progress-bar.md` |
|
|
36
|
+
| `LanguageSelector` | `01-components/12-language-selector.md` |
|
|
37
|
+
| `MatrixDropdown` | `01-components/13-matrix-dropdown.md` |
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"packageNames": {
|
|
4
|
+
"npm": "@explorer02/cfm-survey-sdk",
|
|
5
|
+
"monorepo": "@repo/sdk"
|
|
6
|
+
},
|
|
7
|
+
"entryPoint": "index.md",
|
|
8
|
+
"clientInputs": ["initialPrompt", "instanceIdJwt", "deployConfirmation"],
|
|
9
|
+
"phases": [
|
|
10
|
+
{
|
|
11
|
+
"id": 0,
|
|
12
|
+
"name": "orient",
|
|
13
|
+
"read": ["index.md", "../AGENT.md"],
|
|
14
|
+
"actions": ["detectFramework", "extractBrandingFromClientPrompt"]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": 1,
|
|
18
|
+
"name": "scaffold",
|
|
19
|
+
"read": ["00-integration/setup.md"],
|
|
20
|
+
"frameworks": ["nextjs", "vite", "cra"]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": 2,
|
|
24
|
+
"name": "instanceId",
|
|
25
|
+
"read": ["00-integration/useSurveySDK.md"]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": 3,
|
|
29
|
+
"name": "sdkContract",
|
|
30
|
+
"read": ["00-integration/useSurveySDK.md"]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": 4,
|
|
34
|
+
"name": "planAndIngest",
|
|
35
|
+
"read": [
|
|
36
|
+
"01-components/README.md",
|
|
37
|
+
"01-components/01-survey-page.md",
|
|
38
|
+
"01-components/02-question.md",
|
|
39
|
+
"01-components/03-rating-scale.md",
|
|
40
|
+
"01-components/04-csat-scale.md",
|
|
41
|
+
"01-components/05-csat-matrix-scale.md",
|
|
42
|
+
"01-components/06-likert-matrix-scale.md",
|
|
43
|
+
"01-components/07-slider-matrix-scale.md",
|
|
44
|
+
"01-components/08-file-upload-scale.md",
|
|
45
|
+
"01-components/09-custom-slider-track.md",
|
|
46
|
+
"01-components/10-header-footer.md",
|
|
47
|
+
"01-components/11-progress-bar.md",
|
|
48
|
+
"01-components/12-language-selector.md",
|
|
49
|
+
"01-components/13-matrix-dropdown.md"
|
|
50
|
+
],
|
|
51
|
+
"template": "templates/implementation_plan.md",
|
|
52
|
+
"output": "implementation_plan.md"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"id": 5,
|
|
56
|
+
"name": "build",
|
|
57
|
+
"read": ["00-integration/constraints.md", "02-reference/routing-table.md"],
|
|
58
|
+
"onDemand": "02-reference/question-types"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": 6,
|
|
62
|
+
"name": "verify",
|
|
63
|
+
"read": ["00-integration/constraints.md"],
|
|
64
|
+
"checklist": [
|
|
65
|
+
"questionDispatcherCoversAll12Types",
|
|
66
|
+
"everyQuestionWrapperHasId",
|
|
67
|
+
"noInternalSdkImports",
|
|
68
|
+
"surveyPageFiveStates",
|
|
69
|
+
"npmRunBuildPasses"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": 7,
|
|
74
|
+
"name": "deploy",
|
|
75
|
+
"command": "npx cfm-sdk deploy"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"questionTypes": {
|
|
79
|
+
"rating": {
|
|
80
|
+
"component": "01-components/03-rating-scale.md",
|
|
81
|
+
"reference": "02-reference/question-types/01-rating.md"
|
|
82
|
+
},
|
|
83
|
+
"radio": {
|
|
84
|
+
"component": "01-components/02-question.md",
|
|
85
|
+
"reference": "02-reference/question-types/README.md#radio"
|
|
86
|
+
},
|
|
87
|
+
"text": {
|
|
88
|
+
"component": "01-components/02-question.md",
|
|
89
|
+
"reference": "02-reference/question-types/README.md#text"
|
|
90
|
+
},
|
|
91
|
+
"csat": {
|
|
92
|
+
"component": "01-components/04-csat-scale.md",
|
|
93
|
+
"reference": "02-reference/question-types/04-csat.md"
|
|
94
|
+
},
|
|
95
|
+
"rating_scale": {
|
|
96
|
+
"component": "01-components/03-rating-scale.md",
|
|
97
|
+
"reference": "02-reference/question-types/05-rating-scale.md"
|
|
98
|
+
},
|
|
99
|
+
"slider": {
|
|
100
|
+
"component": "01-components/09-custom-slider-track.md",
|
|
101
|
+
"reference": "02-reference/question-types/06-slider.md"
|
|
102
|
+
},
|
|
103
|
+
"matrix": {
|
|
104
|
+
"component": "01-components/06-likert-matrix-scale.md",
|
|
105
|
+
"reference": "02-reference/question-types/07-matrix-cfm.md",
|
|
106
|
+
"subTypes": {
|
|
107
|
+
"CFM_MATRIX": "01-components/06-likert-matrix-scale.md",
|
|
108
|
+
"CSAT_MATRIX": "01-components/05-csat-matrix-scale.md",
|
|
109
|
+
"RATING_MATRIX": "01-components/05-csat-matrix-scale.md"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"rating_matrix": {
|
|
113
|
+
"component": "01-components/05-csat-matrix-scale.md",
|
|
114
|
+
"reference": "02-reference/question-types/09-matrix-rating.md"
|
|
115
|
+
},
|
|
116
|
+
"slider_matrix": {
|
|
117
|
+
"component": "01-components/07-slider-matrix-scale.md",
|
|
118
|
+
"reference": "02-reference/question-types/10-slider-matrix.md"
|
|
119
|
+
},
|
|
120
|
+
"file_upload": {
|
|
121
|
+
"component": "01-components/08-file-upload-scale.md",
|
|
122
|
+
"reference": "02-reference/question-types/11-file-upload.md"
|
|
123
|
+
},
|
|
124
|
+
"text_and_media": {
|
|
125
|
+
"component": "01-components/02-question.md",
|
|
126
|
+
"reference": "02-reference/question-types/README.md#text_and_media"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
package/templates/docs/index.md
CHANGED
|
@@ -1,151 +1,109 @@
|
|
|
1
1
|
# CFM SURVEY SDK — AGENT DOCUMENTATION INDEX
|
|
2
2
|
|
|
3
|
-
**@explorer02/cfm-survey-sdk**
|
|
3
|
+
**@explorer02/cfm-survey-sdk** (npm) · **@repo/sdk** (monorepo)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
It is a structured roadmap that tells the agent exactly which documentation files to read and in what order.
|
|
5
|
+
Master guide for AI coding agents. Machine-readable index: `MANIFEST.json`.
|
|
7
6
|
|
|
8
|
-
##
|
|
9
|
-
|
|
10
|
-
The `docs/` folder mirrors the SDK's internal architecture:
|
|
7
|
+
## Documentation Layout
|
|
11
8
|
|
|
12
9
|
```
|
|
13
10
|
docs/
|
|
14
|
-
├── index.md
|
|
15
|
-
├──
|
|
16
|
-
├──
|
|
17
|
-
├──
|
|
18
|
-
|
|
11
|
+
├── index.md ← YOU ARE HERE
|
|
12
|
+
├── MANIFEST.json ← Phase + question-type routing (for tooling)
|
|
13
|
+
├── 00-integration/ ← Setup, hook contract, constraints
|
|
14
|
+
├── 01-components/ ← UI blueprints (read ALL before coding)
|
|
15
|
+
├── 02-reference/ ← Routing table + question-type data (on demand)
|
|
16
|
+
└── templates/
|
|
17
|
+
└── implementation_plan.md
|
|
19
18
|
```
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Read
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Then for EACH question type present in the fetched survey, read the matching question-type doc AND component doc:
|
|
112
|
-
|
|
113
|
-
| `question.type` | Question Doc | Component Doc |
|
|
114
|
-
|---|---|---|
|
|
115
|
-
| `'rating'` | `02-question-types/01-rating` | `03-components/03-rating` |
|
|
116
|
-
| `'radio'` | `02-question-types/02-radio` | (inline in Question) |
|
|
117
|
-
| `'text'` | `02-question-types/03-text` | (inline in Question) |
|
|
118
|
-
| `'csat'` | `02-question-types/04-csat` | `03-components/04-csat` |
|
|
119
|
-
| `'rating_scale'` | `02-question-types/05-rating-s` | `03-components/03-rating` |
|
|
120
|
-
| `'slider'` | `02-question-types/06-slider` | `03-components/09-slider` |
|
|
121
|
-
| `'matrix'` CFM | `02-question-types/07-matrix-c` | `03-components/06-likert` |
|
|
122
|
-
| `'matrix'` CSAT | `02-question-types/08-matrix-c` | `03-components/05-csat-m` |
|
|
123
|
-
| `'matrix'` RATING| `02-question-types/09-matrix-r` | `03-components/05-csat-m` |
|
|
124
|
-
| `'slider_matrix'`| `02-question-types/10-slider-m` | `03-components/07-slider` |
|
|
125
|
-
| `'file_upload'` | `02-question-types/11-file-up` | `03-components/08-file` |
|
|
126
|
-
| `'text_and_media'`| `02-question-types/12-text-med` | (inline in Question) |
|
|
127
|
-
|
|
128
|
-
Also read these shared component docs:
|
|
129
|
-
- `03-client-components/09-custom-slider-track.md` (used by CSAT matrix, slider matrix when sliderType='graphics')
|
|
130
|
-
- `03-client-components/13-matrix-dropdown.md` (used by matrix dropdown fmt)
|
|
131
|
-
|
|
132
|
-
### PHASE 5: APPLY CRITICAL RULES
|
|
133
|
-
Read ALL files in `04-critical-rules/`:
|
|
134
|
-
1. `01-import-rules.md` — Package imports, 'use client', Suspense
|
|
135
|
-
2. `02-action-dispatching.md` — onAction pattern, placeholder constants
|
|
136
|
-
3. `03-scroll-navigation.md` — id={question.id} requirement
|
|
137
|
-
4. `04-logo-branding.md` — CSS-only logo, no external image needed
|
|
138
|
-
5. `05-troubleshooting.md` — Common build errors and fixes
|
|
139
|
-
|
|
140
|
-
Verify your implementation against every rule before proceeding.
|
|
141
|
-
|
|
142
|
-
### PHASE 6: BUILD VERIFICATION
|
|
143
|
-
1. Run: `npm run build`
|
|
144
|
-
2. If errors → fix automatically → re-run until clean
|
|
145
|
-
3. Run: `npm run dev`
|
|
146
|
-
4. Verify: survey loads, navigation works, validation fires, submit works
|
|
147
|
-
|
|
148
|
-
### PHASE 7: DEPLOYMENT (INPUT 3)
|
|
149
|
-
Ask the client: "Your survey is built and verified. Ready to deploy to Vercel?"
|
|
150
|
-
If yes → run: `npx vercel --prod --yes`
|
|
151
|
-
Report the final deployment URL to the client.
|
|
20
|
+
**Import rule:** Use whatever package name appears in the project's `package.json` (`@explorer02/cfm-survey-sdk` or `@repo/sdk`).
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Client Inputs (3 only)
|
|
25
|
+
|
|
26
|
+
1. **Initial prompt** — mockup, brand colors, layout preferences
|
|
27
|
+
2. **Instance ID** — JWT token (agent asks in chat)
|
|
28
|
+
3. **Deploy confirmation** — yes/no for production deploy
|
|
29
|
+
|
|
30
|
+
**Branding comes from INPUT 1 only.** No setup wizard. No `survey-config.json`.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Execution Pipeline
|
|
35
|
+
|
|
36
|
+
### PHASE 0: ORIENT
|
|
37
|
+
|
|
38
|
+
- Read this file and `AGENT.md`
|
|
39
|
+
- Detect framework: read `package.json` — Next.js / Vite / CRA (see `00-integration/setup.md`)
|
|
40
|
+
- Extract branding and layout from client prompt
|
|
41
|
+
- For existing apps: read project structure; do not blindly scaffold
|
|
42
|
+
|
|
43
|
+
### PHASE 1: SCAFFOLD
|
|
44
|
+
|
|
45
|
+
Read: `00-integration/setup.md` (matching framework section)
|
|
46
|
+
|
|
47
|
+
Install SDK + `@tanstack/react-query` + `react-icons`. Apply framework-specific config.
|
|
48
|
+
|
|
49
|
+
### PHASE 2: INSTANCE ID (INPUT 2)
|
|
50
|
+
|
|
51
|
+
Read: `00-integration/useSurveySDK.md`
|
|
52
|
+
|
|
53
|
+
Ask: *"Please provide your survey instance ID (JWT token)."*
|
|
54
|
+
|
|
55
|
+
### PHASE 3: SDK CONTRACT
|
|
56
|
+
|
|
57
|
+
Read: `00-integration/useSurveySDK.md`
|
|
58
|
+
|
|
59
|
+
Understand `useSurveySDK`, `onAction`, states. Do **not** read internal mapper/source paths.
|
|
60
|
+
|
|
61
|
+
Optional: read `02-reference/routing-table.md` for type overview.
|
|
62
|
+
|
|
63
|
+
### PHASE 4: PLAN + INGEST (CRITICAL)
|
|
64
|
+
|
|
65
|
+
1. Read **every** file in `01-components/` (all 14 blueprints)
|
|
66
|
+
2. Copy `docs/templates/implementation_plan.md` → `./implementation_plan.md`
|
|
67
|
+
3. Fill every section — do **not** invent a different structure
|
|
68
|
+
4. **Auto-proceed to Phase 5** — do not wait for approval
|
|
69
|
+
|
|
70
|
+
For each question type in the fetched survey, also read matching docs from `02-reference/question-types/` (see `MANIFEST.json` or `02-reference/routing-table.md`).
|
|
71
|
+
|
|
72
|
+
### PHASE 5: BUILD
|
|
73
|
+
|
|
74
|
+
Read: `00-integration/constraints.md`
|
|
75
|
+
|
|
76
|
+
Implement components per blueprints. Use exported types:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { useSurveySDK, ACTIONS, type SurveyAction } from '@explorer02/cfm-survey-sdk';
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### PHASE 6: VERIFY
|
|
83
|
+
|
|
84
|
+
Read: `00-integration/constraints.md` (troubleshooting)
|
|
85
|
+
|
|
86
|
+
Checklist:
|
|
87
|
+
|
|
88
|
+
- [ ] `Question.tsx` switch covers all 12 `question.type` values
|
|
89
|
+
- [ ] Every question wrapper has `id={question.id}`
|
|
90
|
+
- [ ] No imports from `@explorer02/cfm-survey-sdk/src/...`
|
|
91
|
+
- [ ] `SurveyPage` handles loading / error / empty / submitted / active
|
|
92
|
+
- [ ] `npm run build` exits 0
|
|
93
|
+
|
|
94
|
+
### PHASE 7: DEPLOY (INPUT 3)
|
|
95
|
+
|
|
96
|
+
Ask: *"Your survey is built and verified. Ready to deploy?"*
|
|
97
|
+
|
|
98
|
+
If yes: `npx cfm-sdk deploy` (preferred) or `npx vercel --prod --yes`
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Progressive Reading Guide
|
|
103
|
+
|
|
104
|
+
| When | Read |
|
|
105
|
+
|------|------|
|
|
106
|
+
| Always first | `index.md`, `00-integration/setup.md`, `00-integration/useSurveySDK.md`, `00-integration/constraints.md` |
|
|
107
|
+
| Before any React code | All `01-components/*.md` |
|
|
108
|
+
| On demand | `02-reference/question-types/<type>.md` for types in survey |
|
|
109
|
+
| Tooling | `MANIFEST.json`, `templates/implementation_plan.md` |
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Survey UI Implementation Plan
|
|
2
|
+
|
|
3
|
+
> Copy this file to `./implementation_plan.md` in the project root. Fill every section before writing React code.
|
|
4
|
+
|
|
5
|
+
## 0. Project Context
|
|
6
|
+
|
|
7
|
+
- **Framework:** [ ] Next.js App Router [ ] Vite [ ] CRA [ ] Existing app
|
|
8
|
+
- **Package import name:** (from `package.json` — `@explorer02/cfm-survey-sdk` or `@repo/sdk`)
|
|
9
|
+
- **instanceId:** (JWT — wired in SurveyPage)
|
|
10
|
+
- **Branding source:** (client prompt / mockup description — no wizard)
|
|
11
|
+
|
|
12
|
+
## 1. Data Fetching & State
|
|
13
|
+
|
|
14
|
+
- [ ] `useSurveySDK` options: instanceId, language, placeholders, debug
|
|
15
|
+
- [ ] `SurveyPage` 5-state machine: loading / error / empty / submitted / active
|
|
16
|
+
- [ ] `surveyQueryResults.isLoading`, `.error`, `.data` handling
|
|
17
|
+
- [ ] `submitSurveyResults.isLoading`, `.error`, `.data` handling
|
|
18
|
+
|
|
19
|
+
## 2. Pagination, Actions & Flow
|
|
20
|
+
|
|
21
|
+
- [ ] `onAction` NEXT / PREVIOUS / SUBMIT wiring
|
|
22
|
+
- [ ] `ProgressBar` bound to `state.progressPercentage`
|
|
23
|
+
- [ ] Back/Next button visibility per layout config
|
|
24
|
+
- [ ] Last-page NEXT → auto SUBMIT behavior
|
|
25
|
+
|
|
26
|
+
## 3. Question Dispatching (`Question.tsx`)
|
|
27
|
+
|
|
28
|
+
Exhaustive switch — check each:
|
|
29
|
+
|
|
30
|
+
- [ ] `rating` → `RatingScale`
|
|
31
|
+
- [ ] `csat` → `CsatScale`
|
|
32
|
+
- [ ] `radio` → inline MCQ
|
|
33
|
+
- [ ] `text` → inline textarea/input
|
|
34
|
+
- [ ] `rating_scale` → `RatingScale` (star/emoji)
|
|
35
|
+
- [ ] `slider` → `CustomSliderTrack`
|
|
36
|
+
- [ ] `matrix` + `CFM_MATRIX` → `LikertMatrixScale`
|
|
37
|
+
- [ ] `matrix` + `CSAT_MATRIX` / `RATING_MATRIX` → `CsatMatrixScale`
|
|
38
|
+
- [ ] `rating_matrix` → `CsatMatrixScale`
|
|
39
|
+
- [ ] `slider_matrix` → `SliderMatrixScale`
|
|
40
|
+
- [ ] `file_upload` → `FileUploadScale`
|
|
41
|
+
- [ ] `text_and_media` → inline media (no scale)
|
|
42
|
+
- [ ] `dangerouslySetInnerHTML` for `question.text` / `description`
|
|
43
|
+
- [ ] `validationError` banner per question
|
|
44
|
+
- [ ] `id={question.id}` on every question wrapper
|
|
45
|
+
|
|
46
|
+
## 4. Component Architecture Checklist
|
|
47
|
+
|
|
48
|
+
| Component | In survey? | Blueprint doc | Key constraints verified |
|
|
49
|
+
|-----------|------------|---------------|--------------------------|
|
|
50
|
+
| RatingScale | | `01-components/03-rating-scale.md` | |
|
|
51
|
+
| CsatScale | | `01-components/04-csat-scale.md` | |
|
|
52
|
+
| CsatMatrixScale | | `01-components/05-csat-matrix-scale.md` | |
|
|
53
|
+
| LikertMatrixScale | | `01-components/06-likert-matrix-scale.md` | |
|
|
54
|
+
| SliderMatrixScale | | `01-components/07-slider-matrix-scale.md` | |
|
|
55
|
+
| FileUploadScale | | `01-components/08-file-upload-scale.md` | |
|
|
56
|
+
| CustomSliderTrack | | `01-components/09-custom-slider-track.md` | |
|
|
57
|
+
| Header / Footer | | `01-components/10-header-footer.md` | |
|
|
58
|
+
| ProgressBar | | `01-components/11-progress-bar.md` | |
|
|
59
|
+
| LanguageSelector | | `01-components/12-language-selector.md` | |
|
|
60
|
+
| MatrixDropdown | | `01-components/13-matrix-dropdown.md` | |
|
|
61
|
+
|
|
62
|
+
## 5. Theme, Brand & Logo
|
|
63
|
+
|
|
64
|
+
- [ ] CSS-only logo (no `<img>`, no `public/` uploads)
|
|
65
|
+
- [ ] Primary / hover colors from client prompt
|
|
66
|
+
- [ ] Header / Footer / ProgressBar / LanguageSelector per layout
|
|
67
|
+
|
|
68
|
+
## 6. Submit & Thank You
|
|
69
|
+
|
|
70
|
+
- [ ] `onAction({ type: 'SUBMIT' })` on final page
|
|
71
|
+
- [ ] Thank-you screen when `submitSurveyResults.data` is set
|
|
72
|
+
- [ ] Custom thank-you message from client prompt if provided
|
|
73
|
+
|
|
74
|
+
## 7. Pre-Build Verification
|
|
75
|
+
|
|
76
|
+
- [ ] No imports from `.../src/` internal paths
|
|
77
|
+
- [ ] All mutations via `onAction` — no direct state mutation
|
|
78
|
+
- [ ] `npm run build` passes
|