-
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.
- Loading branch information
1 parent
8f12d38
commit f80fb76
Showing
7 changed files
with
175 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import { useFormContext } from 'react-hook-form'; | ||
|
||
import { type FormSummary } from '@atj/forms/src/config/elements/form-summary'; | ||
|
||
import { FormElementEditComponent } from '..'; | ||
|
||
const FormSummaryEdit: FormElementEditComponent<FormSummary> = ({ | ||
element, | ||
}) => { | ||
const { register } = useFormContext(); | ||
return ( | ||
<div className="grid-row grid-gap"> | ||
<div className="grid-col grid-col-4"> | ||
<label className="usa-label"> | ||
Title | ||
<input | ||
className="usa-input" | ||
{...register(`${element.id}.data.title`)} | ||
type="text" | ||
></input> | ||
</label> | ||
</div> | ||
<div className="grid-col grid-col-2"> | ||
<label className="usa-label"> | ||
Description | ||
<textarea | ||
className="usa-textarea" | ||
{...register(`${element.id}.data.description`)} | ||
></textarea> | ||
</label> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FormSummaryEdit; |
72 changes: 72 additions & 0 deletions
72
packages/design/src/config/edit/SubmissionConfirmationEdit.tsx
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,72 @@ | ||
import React from 'react'; | ||
import { useFormContext } from 'react-hook-form'; | ||
|
||
import { type InputElement } from '@atj/forms/src/config/elements/input'; | ||
|
||
import { FormElementEditComponent } from '..'; | ||
|
||
const InputElementEdit: FormElementEditComponent<InputElement> = ({ | ||
element, | ||
}) => { | ||
const { register } = useFormContext(); | ||
return ( | ||
<div className="grid-row grid-gap"> | ||
<div className="grid-col grid-col-4"> | ||
<label className="usa-label"> | ||
Field label | ||
<input | ||
className="usa-input" | ||
{...register(`${element.id}.data.text`)} | ||
type="text" | ||
></input> | ||
</label> | ||
</div> | ||
<div className="grid-col grid-col-2"> | ||
<label className="usa-label"> | ||
Default field value | ||
<input | ||
className="usa-input" | ||
type="text" | ||
{...register(`${element.id}.data.initial`)} | ||
></input> | ||
</label> | ||
</div> | ||
<div className="grid-col grid-col-2"> | ||
<label className="usa-label"> | ||
Maximum length | ||
<input | ||
className="usa-input" | ||
type="text" | ||
{...register(`${element.id}.data.maxLength`)} | ||
></input> | ||
</label> | ||
</div> | ||
<div className="grid-col grid-col-2"> | ||
<label className="usa-label"> | ||
Field type | ||
<select className="usa-select" {...register(`${element.id}.type`)}> | ||
<option value={'input'}>Input</option> | ||
</select> | ||
</label> | ||
</div> | ||
<div className="grid-col grid-col-2"> | ||
<div className="usa-checkbox"> | ||
<input | ||
className="usa-checkbox__input" | ||
type="checkbox" | ||
id={`${element.id}.required`} | ||
{...register(`${element.id}.data.required`)} | ||
/> | ||
<label | ||
className="usa-checkbox__label" | ||
htmlFor={`${element.id}.data.required`} | ||
> | ||
Required | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default InputElementEdit; |
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,38 @@ | ||
import * as z from 'zod'; | ||
|
||
import { type FormElementConfig } from '..'; | ||
import { type FormElement } from '../../element'; | ||
import { FormSummaryPattern, type Pattern } from '../../pattern'; | ||
import { safeZodParse } from '../../util/zod'; | ||
|
||
const configSchema = z.object({ | ||
title: z.string().max(128), | ||
summary: z.string().max(2024), | ||
}); | ||
export type FormSummary = FormElement<z.infer<typeof configSchema>>; | ||
|
||
export const formSummaryConfig: FormElementConfig<FormSummary> = { | ||
acceptsInput: false, | ||
initial: { | ||
text: '', | ||
initial: '', | ||
required: true, | ||
maxLength: 128, | ||
}, | ||
parseData: obj => safeZodParse(configSchema, obj), // make this optional? | ||
parseConfigData: obj => safeZodParse(configSchema, obj), | ||
getChildren() { | ||
return []; | ||
}, | ||
createPrompt(_, session, element, options) { | ||
return { | ||
pattern: { | ||
_elementId: element.id, | ||
type: 'form-summary', | ||
title: element.data.title, | ||
description: element.data.description, | ||
} as FormSummaryPattern, | ||
children: [], | ||
}; | ||
}, | ||
}; |
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