From 8e77df4c09b719d9b82c9f661d6f382ff577a1f8 Mon Sep 17 00:00:00 2001 From: cchang-vassar <79338042+cchang-vassar@users.noreply.github.com> Date: Thu, 17 Jul 2025 16:45:20 -0700 Subject: [PATCH 1/4] add a variation of plugin-survey-text where new input fields are generated for a question when user presses Enter or spacebar, and can be deleted if the user presses backspace on an empty field (unless it is the first input field) --- .changeset/serious-suns-hang.md | 5 + package-lock.json | 16 + packages/plugin-survey-text-dynamic/demo.html | 78 +++ .../jest.config.cjs | 1 + .../plugin-survey-text-dynamic/package.json | 43 ++ .../rollup.config.mjs | 3 + .../src/index.spec.ts | 215 ++++++++ .../plugin-survey-text-dynamic/src/index.ts | 476 ++++++++++++++++++ .../plugin-survey-text-dynamic/tsconfig.json | 7 + 9 files changed, 844 insertions(+) create mode 100644 .changeset/serious-suns-hang.md create mode 100644 packages/plugin-survey-text-dynamic/demo.html create mode 100644 packages/plugin-survey-text-dynamic/jest.config.cjs create mode 100644 packages/plugin-survey-text-dynamic/package.json create mode 100644 packages/plugin-survey-text-dynamic/rollup.config.mjs create mode 100644 packages/plugin-survey-text-dynamic/src/index.spec.ts create mode 100644 packages/plugin-survey-text-dynamic/src/index.ts create mode 100644 packages/plugin-survey-text-dynamic/tsconfig.json diff --git a/.changeset/serious-suns-hang.md b/.changeset/serious-suns-hang.md new file mode 100644 index 0000000000..e44a20511f --- /dev/null +++ b/.changeset/serious-suns-hang.md @@ -0,0 +1,5 @@ +--- +"@jspsych/plugin-survey-text-dynamic": minor +--- + +FEATURE: Added a new plugin that is a variation on plugin-survey-text, where a new input field is generated on the right for the same question when the user presses Enter or spacebar while in the existing input field. diff --git a/package-lock.json b/package-lock.json index 03f1e9e3d8..c6bdb04bab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2514,6 +2514,10 @@ "resolved": "packages/plugin-survey-text", "link": true }, + "node_modules/@jspsych/plugin-survey-text-dynamic": { + "resolved": "packages/plugin-survey-text-dynamic", + "link": true + }, "node_modules/@jspsych/plugin-video-button-response": { "resolved": "packages/plugin-video-button-response", "link": true @@ -14402,6 +14406,18 @@ "jspsych": ">=7.1.0" } }, + "packages/plugin-survey-text-dynamic": { + "name": "@jspsych/plugin-survey-text-dynamic", + "version": "1.0.0", + "license": "MIT", + "devDependencies": { + "@jspsych/config": "^3.2.0", + "@jspsych/test-utils": "^1.2.0" + }, + "peerDependencies": { + "jspsych": ">=7.1.0" + } + }, "packages/plugin-survey/node_modules/survey-core": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/survey-core/-/survey-core-2.2.0.tgz", diff --git a/packages/plugin-survey-text-dynamic/demo.html b/packages/plugin-survey-text-dynamic/demo.html new file mode 100644 index 0000000000..5aaefa96ee --- /dev/null +++ b/packages/plugin-survey-text-dynamic/demo.html @@ -0,0 +1,78 @@ + + +
+