Blocks / Response summary

Response summary

What came back, one mini-chart per question: bars, histogram with mean and NPS, list of texts, matrix grid.

import { ResponseSummary, summarizeForm, formResponseGrid, formPercent } from "@forgeron/ui";
/01 → Default
Responses
24
Completed
100 %
Questions
4
  1. 1

    Which session did you attend?

    Single choice

    24 answered

    Which session did you attend?
    • Morning8 · 33 %
    • Afternoon8 · 33 %
    • Both8 · 33 %
  2. 2

    How was it?

    Rating

    24 answered

    How was it?
    • 01 answers: 0
    • 02 answers: 0
    • 83 answers: 8
    • 84 answers: 8
    • 85 answers: 8

    Mean 4Median 4

  3. 3

    Which topics helped you?

    Multiple choice

    24 answered

    Which topics helped you?
    • Design12 · 50 %
    • Code12 · 50 %
    • Process12 · 50 %
  4. 4

    What should we change?

    Long text

    8 answered, 16 skipped

    • Share the slides beforehand.
    • More time for questions.
    • The room was too warm.
    • A real project to work on would help.
ResponseidSubmitteddateWhich session did you attend?single choiceHow was it?ratingWhich topics helped you?multiple choiceWhat should we change?long text
r12026-11-01Morning3DesignMore time for questions.
r22026-11-02Afternoon5Design, CodeNULL
r32026-11-03Both4Code, ProcessNULL
r42026-11-04Morning3ProcessThe room was too warm.
r52026-11-05Afternoon5DesignNULL
r62026-11-06Both4Design, CodeNULL
import {
  DataGrid,
  ResponseSummary,
  formResponseGrid,
  type FormResponse,
  type FormSchema,
} from "@forgeron/ui";

const schema: FormSchema = {
  version: 1,
  title: "Workshop feedback",
  sections: [
    {
      id: "s1",
      title: "",
      questions: [
        {
          id: "session",
          type: "singleChoice",
          title: "Which session did you attend?",
          required: true,
          options: [
            { id: "am", label: "Morning" },
            { id: "pm", label: "Afternoon" },
            { id: "both", label: "Both" },
          ],
        },
        { id: "stars", type: "rating", title: "How was it?", range: { min: 1, max: 5 } },
        {
          id: "topics",
          type: "multiChoice",
          title: "Which topics helped you?",
          options: [
            { id: "t1", label: "Design" },
            { id: "t2", label: "Code" },
            { id: "t3", label: "Process" },
          ],
        },
        { id: "words", type: "longText", title: "What should we change?" },
      ],
    },
  ],
};

const comments = [
  "More time for questions.",
  "The room was too warm.",
  "Share the slides beforehand.",
  "Shorter breaks, longer sessions.",
  "A real project to work on would help.",
];

// Fake data, made from a counter: no real person is behind these rows.
const responses: FormResponse[] = Array.from({ length: 24 }, (_, i) => ({
  id: `r${i + 1}`,
  submittedAt: `2026-11-${String(1 + (i % 9)).padStart(2, "0")}`,
  answers: {
    session: ["am", "pm", "both"][(i * 7) % 3]!,
    stars: 3 + ((i * 5) % 3),
    topics: [["t1"], ["t1", "t2"], ["t2", "t3"], ["t3"]][i % 4]!,
    ...(i % 3 === 0 ? { words: comments[(i / 3) % comments.length]! } : {}),
  },
}));

export default function Default() {
  const grid = formResponseGrid(schema, responses);
  return (
    <div style={{ display: "grid", gap: 24 }}>
      <ResponseSummary schema={schema} responses={responses} />
      <DataGrid label="Responses" columns={grid.columns} rows={grid.rows.slice(0, 6)} />
    </div>
  );
}
/02 → Nps
Responses
18
Completed
100 %
Questions
3
  1. 1

    Would you recommend us?

    Scale

    18 answered

    Would you recommend us?
    • 00 answers: 0
    • 01 answers: 0
    • 02 answers: 0
    • 13 answers: 1
    • 04 answers: 0
    • 15 answers: 1
    • 26 answers: 2
    • 27 answers: 2
    • 28 answers: 2
    • 59 answers: 5
    • 510 answers: 5

    Mean 8.06Median 9

    NPS
    +33
    Promoters
    10
    Passives
    4
    Detractors
    4
  2. 2

    How satisfied are you with each part?

    Matrix

    18 answered

    How satisfied are you with each part?
    PoorFairGood
    Speed3312
    Docs378
  3. 3

    What do you want next?

    Ranking

    18 answered

    What do you want next?
    • A public API (avg place 1.67)42 pts
    • A mobile app (avg place 2)36 pts
    • Single sign-on (avg place 2.33)30 pts
import { ResponseSummary, type FormResponse, type FormSchema } from "@forgeron/ui";

// A scale marked as NPS adds the score; a matrix is counted cell by cell; a ranking by points.
const schema: FormSchema = {
  version: 1,
  title: "Customer survey",
  sections: [
    {
      id: "s1",
      title: "",
      questions: [
        {
          id: "nps",
          type: "scale",
          title: "Would you recommend us?",
          range: { min: 0, max: 10, nps: true },
        },
        {
          id: "grid",
          type: "matrix",
          title: "How satisfied are you with each part?",
          options: [
            { id: "speed", label: "Speed" },
            { id: "docs", label: "Docs" },
          ],
          columns: [
            { id: "1", label: "Poor" },
            { id: "2", label: "Fair" },
            { id: "3", label: "Good" },
          ],
        },
        {
          id: "rank",
          type: "ranking",
          title: "What do you want next?",
          options: [
            { id: "api", label: "A public API" },
            { id: "app", label: "A mobile app" },
            { id: "sso", label: "Single sign-on" },
          ],
        },
      ],
    },
  ],
};

const orders = [
  ["api", "app", "sso"],
  ["app", "api", "sso"],
  ["sso", "api", "app"],
];
const responses: FormResponse[] = Array.from({ length: 18 }, (_, i) => ({
  id: `r${i + 1}`,
  answers: {
    nps: [10, 9, 8, 7, 10, 6, 9, 3, 10, 8, 9, 5][(i * 5) % 12]!,
    grid: {
      speed: ["3", "3", "2", "3", "1", "3"][i % 6]!,
      docs: ["2", "3", "3", "1", "2", "3", "2"][i % 7]!,
    },
    rank: orders[(i * 7) % 3]!,
  },
}));

export default function Nps() {
  return <ResponseSummary schema={schema} responses={responses} />;
}
API → Props
PropTypeDefaultDescription
schemaFormSchema—{ version: 1, title, description?, sections: { id, title, description?, showIf?, questions: FormQuestion[] }[], submitLabel?, thanks? }. Plain data: store it as JSON.
responses{ id, submittedAt?, answers }[]—One per respondent. A conditional question is counted only for the responses that were shown it.
labelstring"Responses"Names the summary for assistive technology.
textLimitnumber4How many text answers show before Show all.
classNamestring—Extra classes.