Skip to content

Commit

Permalink
input props: errors => error
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan committed Feb 18, 2024
1 parent f937f19 commit 89b00b5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/components/form/inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ type HtmlInputType = "text" | "date" | "time" | "datetime-local";

const InputTextGeneric =
(type: HtmlInputType = "text") =>
({ onChange, errors, disabled, value, placeholder }: T.InputProps<string>) =>
({ onChange, error, disabled, value, placeholder }: T.InputProps<string>) =>
(
<input
className={getClassName(errors)}
className={getClassName(error)}
type={type}
value={value || ""}
onChange={(v) => onChange(v.target.value)}
Expand All @@ -65,12 +65,12 @@ export const Timepicker = InputTextGeneric("time");

export const Textarea = ({
onChange,
errors,
error,
disabled,
value,
}: T.InputProps<string>) => (
<textarea
className={getClassName(errors, "border p-2 rounded resize-y")}
className={getClassName(error, "border p-2 rounded resize-y")}
value={value}
onChange={(v) => onChange(v.target.value)}
disabled={disabled}
Expand All @@ -81,11 +81,11 @@ export const Select = <A, Id extends number | string>({
onChange,
options,
value,
errors,
error,
disabled,
}: T.InputProps<A, Id>) => (
<select
className={getClassName(errors, "border p-2 rounded bg-white")}
className={getClassName(error, "border p-2 rounded bg-white")}
onChange={(v) => {
const { value } = v.target;

Expand Down
4 changes: 2 additions & 2 deletions src/examples/form/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const FormUI = ({
onChange={(firstName) => setForm({ ...form, firstName })}
disabled={loading}
placeholder={"First Name"}
errors={errors["firstName"]}
error={errors["firstName"]}
/>
</Inputs.InputWrapper>
<Inputs.InputWrapper error={errors["lastName"]}>
Expand All @@ -27,7 +27,7 @@ const FormUI = ({
onChange={(lastName) => setForm({ ...form, lastName })}
disabled={loading}
placeholder={"Last Name"}
errors={errors["lastName"]}
error={errors["lastName"]}
/>
</Inputs.InputWrapper>

Expand Down
2 changes: 1 addition & 1 deletion src/examples/simple-list/list-add/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const FormUI = ({
onChange={(name) => setForm({ ...form, name })}
disabled={loading}
placeholder={"Name"}
errors={errors["name"]}
error={errors["name"]}
/>
<button
disabled={loading || form.name === "" || !form.name}
Expand Down
4 changes: 2 additions & 2 deletions src/examples/simple-list/list-form/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const FormUI = ({
onChange={(name) => setForm({ ...form, name })}
disabled={loading}
placeholder={"Name"}
errors={errors["name"]}
error={errors["name"]}
/>
</Inputs.InputWrapper>

Expand All @@ -36,7 +36,7 @@ const FormUI = ({
onChange={(description) => setForm({ ...form, description })}
disabled={loading}
placeholder={"Description"}
errors={errors["description"]}
error={errors["description"]}
/>
</Inputs.InputWrapper>
<button
Expand Down
2 changes: 1 addition & 1 deletion src/lib/form/generator/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const FormUIGenerator =
onChange={(val) => setForm({ ...form, [item.name]: val })}
disabled={loading}
placeholder={item.placeholder}
errors={errors[item.name]}
error={errors[item.name]}
options={item.options && item.options}
/>
</InputWrapper>
Expand Down
3 changes: 2 additions & 1 deletion src/lib/form/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface OptionUnit<Id = string> {
export interface InputProps<A, Id extends string | number = number> {
value?: A;
onChange: (a?: A) => void;
errors?: string;
error?: string;
disabled?: boolean;
placeholder?: string;
options?: OptionUnit<Id>[];
Expand All @@ -72,6 +72,7 @@ export interface InputOptionProps<A, Id extends string | number>
export interface InputWrapperProps {
label?: string;
error?: string;
//errors?: string[];
info?: string;
children: JSX.Element;
}
Expand Down

0 comments on commit 89b00b5

Please sign in to comment.