-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from alsiola/develop
Merge v0.2.2 into master
- Loading branch information
Showing
25 changed files
with
520 additions
and
172 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,16 @@ | ||
import * as React from "react"; | ||
import { InjectedFieldProps } from "../lib/index"; | ||
import { Form, Radio } from "semantic-ui-react"; | ||
|
||
export const PrettyRadio: React.SFC< | ||
InjectedFieldProps<{ value: string; title: string }> | ||
> = ({ input, ownProps: { value, title } }) => ( | ||
<Form.Field> | ||
<Radio | ||
label={title} | ||
value={value} | ||
checked={input.value === value} | ||
onChange={input.onChange} | ||
/> | ||
</Form.Field> | ||
); |
This file contains 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,54 @@ | ||
import * as React from "react"; | ||
import { Form, Input, Label, Icon } from "semantic-ui-react"; | ||
import { InjectedFieldProps } from "../lib"; | ||
|
||
export interface ReversingFieldProps { | ||
submitted: boolean; | ||
label: string; | ||
hint: string; | ||
reverse: boolean; | ||
} | ||
|
||
const reverseString = (v?: string) => | ||
((v as string) || "") | ||
.split("") | ||
.reverse() | ||
.join(""); | ||
|
||
export const ReversingField: React.SFC< | ||
InjectedFieldProps<ReversingFieldProps> | ||
> = ({ | ||
input, | ||
meta: { valid, pristine, touched, active, error, isValidating }, | ||
ownProps: { submitted, label, hint, reverse } | ||
}) => ( | ||
<Form.Field> | ||
<Input | ||
{...input} | ||
value={reverse ? reverseString(input.value as string) : input.value} | ||
onChange={e => | ||
input.onChange(e, { | ||
value: reverse | ||
? reverseString(e.currentTarget.value) | ||
: e.currentTarget.value | ||
}) | ||
} | ||
focus={active} | ||
error={!valid} | ||
icon={ | ||
isValidating ? ( | ||
<Icon loading={true} name="sun" /> | ||
) : ( | ||
(touched || active || submitted) && | ||
(valid ? ( | ||
<Icon name="checkmark" /> | ||
) : ( | ||
<Icon name="warning circle" /> | ||
)) | ||
) | ||
} | ||
label={label} | ||
/> | ||
{!valid && active && error && <Label pointing={true}>{error}</Label>} | ||
</Form.Field> | ||
); |
This file contains 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 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,34 @@ | ||
import * as React from "react"; | ||
import { Form } from "../../lib"; | ||
|
||
import { PrettyForm } from "../PrettyForm"; | ||
import { ReversingField } from "../ReversingField"; | ||
|
||
const fields = [ | ||
{ | ||
name: "field1", | ||
label: "Forward", | ||
reverse: false, | ||
key: "field1forward" | ||
}, | ||
{ | ||
name: "field1", | ||
label: "Reverse", | ||
reverse: true, | ||
key: "field1backward" | ||
} | ||
]; | ||
|
||
export const LinkedInputForm = () => ( | ||
<Form | ||
name="basic-form" | ||
onSubmit={values => { | ||
console.log("Submitted with values", values); | ||
}} | ||
render={PrettyForm} | ||
renderProps={{ | ||
fields, | ||
title: "Linked Form" | ||
}} | ||
/> | ||
); |
Oops, something went wrong.