-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address pattern hashed out more; to ease testing, add a button to cre…
…ate a new empty blueprint.
- Loading branch information
1 parent
e197d32
commit 91a62f7
Showing
19 changed files
with
357 additions
and
63 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
File renamed without changes.
File renamed without changes.
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
Empty file.
Empty file.
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,147 @@ | ||
import React from 'react'; | ||
import { useFormContext } from 'react-hook-form'; | ||
|
||
import { type PatternComponent } from '../../../Form'; | ||
import { AddressComponentProps } from '@atj/forms/src/patterns/address'; | ||
import classNames from 'classnames'; | ||
|
||
const Address: PatternComponent<AddressComponentProps> = props => { | ||
const { register } = useFormContext(); | ||
return ( | ||
<fieldset className="usa-fieldset"> | ||
<legend className="usa-legend usa-legend--large">Mailing address</legend> | ||
<label | ||
className={classNames('usa-label', { | ||
'usa-label--error': props.childProps.streetAddress.error, | ||
})} | ||
htmlFor={props.childProps.streetAddress.inputId} | ||
> | ||
{props.childProps.streetAddress.label} | ||
{props.childProps.streetAddress.required && ( | ||
<abbr title="required" className="usa-hint usa-hint--required"> | ||
* | ||
</abbr> | ||
)} | ||
</label> | ||
<input | ||
className="usa-input" | ||
defaultValue={props.childProps.streetAddress.value} | ||
{...register(props.childProps.streetAddress.inputId, { | ||
//required: props.childProps.streetAddress.required, | ||
})} | ||
/> | ||
<label | ||
className={classNames('usa-label', { | ||
'usa-label--error': props.childProps.streetAddress2.error, | ||
})} | ||
htmlFor={props.childProps.streetAddress2.inputId} | ||
> | ||
{props.childProps.streetAddress2.label} | ||
{props.childProps.streetAddress2.required && ( | ||
<abbr title="required" className="usa-hint usa-hint--required"> | ||
* | ||
</abbr> | ||
)} | ||
</label> | ||
<input | ||
className="usa-input" | ||
defaultValue={props.childProps.streetAddress2.value} | ||
{...register(props.childProps.streetAddress2.inputId, { | ||
//required: props.childProps.streetAddress2.required, | ||
})} | ||
/> | ||
<label | ||
className={classNames('usa-label', { | ||
'usa-label--error': props.childProps.city.error, | ||
})} | ||
htmlFor="city" | ||
> | ||
{props.childProps.city.label} | ||
{props.childProps.city.required && ( | ||
<abbr title="required" className="usa-hint usa-hint--required"> | ||
* | ||
</abbr> | ||
)} | ||
</label> | ||
<input | ||
className="usa-input" | ||
defaultValue={props.childProps.city.value} | ||
{...register(props.childProps.city.inputId, { | ||
//required: props.childProps.city.required, | ||
})} | ||
/> | ||
<label | ||
className={classNames('usa-label', { | ||
'usa-label--error': | ||
props.childProps.stateTerritoryOrMilitaryPost.error, | ||
})} | ||
htmlFor={props.childProps.stateTerritoryOrMilitaryPost.inputId} | ||
> | ||
{props.childProps.stateTerritoryOrMilitaryPost.label} | ||
{props.childProps.stateTerritoryOrMilitaryPost.required && ( | ||
<abbr title="required" className="usa-hint usa-hint--required"> | ||
* | ||
</abbr> | ||
)} | ||
</label> | ||
<select | ||
className="usa-select" | ||
defaultValue={props.childProps.stateTerritoryOrMilitaryPost.value} | ||
{...register(props.childProps.stateTerritoryOrMilitaryPost.inputId, { | ||
//required: props.childProps.stateTerritoryOrMilitaryPost.required, | ||
})} | ||
> | ||
<option value="">- Select -</option> | ||
{props.childProps.stateTerritoryOrMilitaryPost.options.map( | ||
(jurisdiction, index) => ( | ||
<option key={index} value={jurisdiction.abbr}> | ||
{jurisdiction.label} | ||
</option> | ||
) | ||
)} | ||
</select> | ||
<label | ||
className={classNames('usa-label', { | ||
'usa-label--error': props.childProps.zipCode.error, | ||
})} | ||
htmlFor={props.childProps.zipCode.inputId} | ||
> | ||
{props.childProps.zipCode.label} | ||
{props.childProps.zipCode.required && ( | ||
<abbr title="required" className="usa-hint usa-hint--required"> | ||
* | ||
</abbr> | ||
)} | ||
</label> | ||
<input | ||
className="usa-input usa-input--medium" | ||
pattern="[\d]{5}(-[\d]{4})?" | ||
defaultValue={props.childProps.zipCode.value} | ||
{...register(props.childProps.zipCode.inputId, { | ||
//required: props.childProps.zipCode.required, | ||
})} | ||
/> | ||
<label | ||
className={classNames('usa-label', { | ||
'usa-label--error': props.childProps.urbanizationCode.error, | ||
})} | ||
htmlFor={props.childProps.urbanizationCode.inputId} | ||
> | ||
{props.childProps.urbanizationCode.label} | ||
{props.childProps.urbanizationCode.required && ( | ||
<abbr title="required" className="usa-hint usa-hint--required"> | ||
* | ||
</abbr> | ||
)} | ||
</label> | ||
<input | ||
className="usa-input" | ||
defaultValue={props.childProps.urbanizationCode.value} | ||
{...register(props.childProps.urbanizationCode.inputId, { | ||
//required: props.childProps.urbanizationCode.required, | ||
})} | ||
/> | ||
</fieldset> | ||
); | ||
}; | ||
export default Address; |
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,24 @@ | ||
import React from 'react'; | ||
import { useFormContext } from 'react-hook-form'; | ||
|
||
import { type ZipcodeProps } from '@atj/forms'; | ||
|
||
export const ZipCode = (props: ZipcodeProps) => { | ||
const { register } = useFormContext(); | ||
return ( | ||
<> | ||
<label className="usa-label" htmlFor="zip"> | ||
ZIP code | ||
</label> | ||
<input | ||
className="usa-input usa-input--medium" | ||
id={`input-${props.inputId}`} | ||
defaultValue={props.value} | ||
{...register(props.inputId, { | ||
//required: props.required, | ||
})} | ||
pattern="[\d]{5}(-[\d]{4})?" | ||
/> | ||
</> | ||
); | ||
}; |
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
Oops, something went wrong.