Skip to content
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

feat: Add more overloads for SelectField options. #999

Merged
merged 2 commits into from
Feb 5, 2024
Merged

Conversation

stephenh
Copy link
Contributor

@stephenh stephenh commented Feb 4, 2024

getOptionValue is now optional for options with ids or codes.

getOptionLabel is now optional for options with name, displayName, or labels.

`getOptionValue` is not necessary for options with ids or codes.

`getOptionLabel` is not necessary for options with name, displayName, or
labels.
@stephenh stephenh requested a review from TylerR909 February 5, 2024 19:38
Comment on lines +124 to +125
{ code: AuthorHeight.SHORT, name: "Shortish" },
{ code: AuthorHeight.TALL, name: "Tallish" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

}

export function defaultOptionLabel<O>(opt: O): any {
if (typeof opt !== "object" || !opt) fail(`Option ${opt} has no id or code`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... how destructive would it be to allow strings. Like, I'd like to be able to do

options={["One", "Two", "Three"]}
// or
options={Object.values(SomeEnum)}

where ID/Val would be the same. Seems unnecessary to map an Enum over to an Object just for the sake of this. But, I'm sure a lot of infra expects an Object so makes sense it would be rough to support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a fair ask. Will think about it...

@stephenh stephenh merged commit 0663afe into main Feb 5, 2024
7 checks passed
@stephenh stephenh deleted the add-more-overloads branch February 5, 2024 21:05
homebound-team-bot pushed a commit that referenced this pull request Feb 5, 2024
## [2.335.0](v2.334.3...v2.335.0) (2024-02-05)

### Features

* Add more overloads for SelectField options. ([#999](#999)) ([0663afe](0663afe))
@homebound-team-bot
Copy link

🎉 This PR is included in version 2.335.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants