mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-04 22:31:33 +09:00
## Description - always use defaultValue and defaultChecked props when passing to react - expose value and checked as props, remove default* - reorder initial props to make more sense (name, value, checked - in this order) Affected components: Forms: - checkbox - radio - input - select - textarea Radix: - checkbox - radio group - select - switch ## Steps for reproduction 1. test each component named above how bound and unbound value/checked works 2. use in regular form and bind to url params 3. use in webhook form ## Code Review - [ ] hi @john, I need you to do - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 5de6) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file --------- Co-authored-by: Ivan Starkov <istarkov@gmail.com> Co-authored-by: Bogdan Chadkin <opensource@trysound.io>
41 lines
820 B
TypeScript
41 lines
820 B
TypeScript
import { forwardRef, type ElementRef, type ComponentProps } from "react";
|
|
|
|
export const defaultTag = "input";
|
|
|
|
export const Input = forwardRef<
|
|
ElementRef<typeof defaultTag>,
|
|
ComponentProps<typeof defaultTag> & {
|
|
type?:
|
|
| "color"
|
|
| "date"
|
|
| "datetime-local"
|
|
| "email"
|
|
| "hidden"
|
|
| "month"
|
|
| "number"
|
|
| "password"
|
|
| "range"
|
|
| "search"
|
|
| "tel"
|
|
| "text"
|
|
| "time"
|
|
| "url"
|
|
| "week";
|
|
}
|
|
// Make sure children are not passed down to an input, because this will result in error.
|
|
>(
|
|
(
|
|
{ children: _children, type = "text", value, defaultValue, ...props },
|
|
ref
|
|
) => (
|
|
<input
|
|
{...props}
|
|
defaultValue={value ?? defaultValue}
|
|
type={type}
|
|
ref={ref}
|
|
/>
|
|
)
|
|
);
|
|
|
|
Input.displayName = "Input";
|