-
Notifications
You must be signed in to change notification settings - Fork 369
Delete most InputNumber code, replace with NumericInput #3760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
benchristel
wants to merge
26
commits into
main
Choose a base branch
from
benc/input-number-v2-take-3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
5487dbf
[benc/input-number-v2-take-3] Align input-number options type with nu…
benchristel 20bbee9
[benc/input-number-v2-take-3] Update getInputNumberPublicWidgetOptions
benchristel 728fa23
[benc/input-number-v2-take-3] Use v1 options in scoring tests
benchristel 7f66ef7
[benc/input-number-v2-take-3] Delete InputNumber component; replace w…
benchristel 258f958
[benc/input-number-v2-take-3] Move IN->NI conversion functions into p…
benchristel b7b7826
[benc/input-number-v2-take-3] Fix lint
benchristel 07b6d30
[benc/input-number-v2-take-3] Remove input-number editor code
benchristel 064e563
[benc/input-number-v2-take-3] Knip
benchristel 6231ad3
[benc/input-number-v2-take-3] Update pnpm-lock.yaml
benchristel fa61e4f
[benc/input-number-v2-take-3] docs(changeset): The InputNumber widget…
benchristel 91e4651
[benc/input-number-v2-take-3] docs(changeset): Removes the experiment…
benchristel 3a5c114
[benc/input-number-v2-take-3] Delete v0 types
benchristel 4dc3bb1
[benc/input-number-v2-take-3] Make InputNumber types alias NumericInp…
benchristel ac40ed3
[benc/input-number-v2-take-3] Remove TODO
benchristel 28f6b75
[benc/input-number-v2-take-3] Use generators to abbreviate tests
benchristel dc7e98a
[benc/input-number-v2-take-3] Fold input-number case into numeric-input
benchristel 0821496
[benc/input-number-v2-take-3] Use generators again
benchristel bb1a872
[benc/input-number-v2-take-3] Use numeric-input code for public widge…
benchristel 8634617
[benc/input-number-v2-take-3] Use PerseusNumericInputRubric type
benchristel 22eedbb
[benc/input-number-v2-take-3] Use generators
benchristel 8d1d0a9
[benc/input-number-v2-take-3] Delete scoring code
benchristel 9f4974b
[benc/input-number-v2-take-3] Fix answerless types
benchristel fe6a95e
[benc/input-number-v2-take-3] Ensure generated input-number widgets h…
benchristel 07d6f6e
[benc/input-number-v2-take-3] Add test coverage for version number in…
benchristel 0f4791e
[benc/input-number-v2-take-3] Remove non-actionable TODO
benchristel 2f62c39
[benc/input-number-v2-take-3] Delete unused test data file
benchristel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import {describe, expect, it} from "tstyche"; | ||
|
|
||
| import type { | ||
| PerseusInputNumberWidgetOptions, | ||
| PerseusNumericInputWidgetOptions, | ||
| } from "./data-schema"; | ||
|
|
||
| describe("PerseusInputNumberWidgetOptions", () => { | ||
| it("is assignable to PerseusNumericInputWidgetOptions", () => { | ||
| // This test is needed because the PerseusInputNumberWidgetOptions now | ||
| // get passed to the NumericInput component. We are currently (May | ||
| // 2026) removing the deprecated InputNumber code in favor of using | ||
| // NumericInput everywhere, but we need to keep separate types for | ||
| // InputNumber to support legacy content. | ||
| expect<PerseusInputNumberWidgetOptions>().type.toBeAssignableTo<PerseusNumericInputWidgetOptions>(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/perseus-core/src/parse-perseus-json/general-purpose-parsers/singleton.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import {describe, expect, it} from "@jest/globals"; | ||
|
|
||
| import {success} from "../result"; | ||
|
|
||
| import {number} from "./number"; | ||
| import {singleton} from "./singleton"; | ||
| import {ctx, parseFailureWith} from "./test-helpers"; | ||
|
|
||
| describe("singleton", () => { | ||
| const singleNumber = singleton(number); | ||
|
|
||
| it("accepts a one-element array", () => { | ||
| expect(singleNumber([1], ctx())).toEqual(success([1])); | ||
| }); | ||
|
|
||
| it("rejects an empty array", () => { | ||
| expect(singleNumber([], ctx())).toEqual( | ||
| parseFailureWith({expected: ["array of length 1"]}), | ||
| ); | ||
| }); | ||
|
|
||
| it("rejects a two-element array", () => { | ||
| expect(singleNumber([1, 2], ctx())).toEqual( | ||
| parseFailureWith({expected: ["array of length 1"]}), | ||
| ); | ||
| }); | ||
|
|
||
| it("rejects a non-array", () => { | ||
| expect(singleNumber(1, ctx())).toEqual( | ||
| parseFailureWith({expected: ["array"]}), | ||
| ); | ||
| }); | ||
|
|
||
| it("rejects an invalid element type", () => { | ||
| expect(singleNumber(["bad"], ctx())).toEqual( | ||
| parseFailureWith({expected: ["number"], path: [0]}), | ||
| ); | ||
| }); | ||
| }); |
25 changes: 25 additions & 0 deletions
25
packages/perseus-core/src/parse-perseus-json/general-purpose-parsers/singleton.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import {isFailure} from "../result"; | ||
|
|
||
| import type {Parser} from "../parser-types"; | ||
|
|
||
| /** | ||
| * Parses a one-element tuple. | ||
| */ | ||
| export function singleton<T>(parseElement: Parser<T>): Parser<[T]> { | ||
| return (rawValue, ctx) => { | ||
| if (!Array.isArray(rawValue)) { | ||
| return ctx.failure("array", rawValue); | ||
| } | ||
| if (rawValue.length !== 1) { | ||
| return ctx.failure("array of length 1", rawValue); | ||
| } | ||
|
|
||
| const [rawElement] = rawValue; | ||
| const result = parseElement(rawElement, ctx.forSubtree(0)); | ||
| if (isFailure(result)) { | ||
| return result; | ||
| } | ||
|
|
||
| return ctx.success([result.value]); | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.