-
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.
* Add clickable preview component to the form manager's edit page. Remaining work is to style it, so it's not possible to click on form elements, tab to them, or enter data. * Preview UI has selectable patterns, to open the corresponding form element edit ui. * In-progress work wiring up saving to the WSYIWYG ui
- Loading branch information
1 parent
de8d2be
commit e5d777c
Showing
41 changed files
with
550 additions
and
325 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
import React from 'react'; | ||
|
||
import { FormRouter } from '@atj/design'; | ||
import { FormRouter, defaultFormElementComponents } from '@atj/design'; | ||
import { getAppContext } from '../context'; | ||
|
||
export default function AppFormRouter() { | ||
const ctx = getAppContext(); | ||
return <FormRouter config={ctx.formConfig} formService={ctx.formService} />; | ||
return ( | ||
<FormRouter | ||
context={{ | ||
config: ctx.formConfig, | ||
components: defaultFormElementComponents, | ||
}} | ||
formService={ctx.formService} | ||
/> | ||
); | ||
} |
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
14 changes: 0 additions & 14 deletions
14
packages/design/src/Form/PromptSegment/FormSummary/index.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.
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
52 changes: 52 additions & 0 deletions
52
packages/design/src/FormManager/FormEdit/FormElementEdit.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,52 @@ | ||
import React from 'react'; | ||
import { FormProvider, useForm } from 'react-hook-form'; | ||
|
||
import { | ||
FormDefinition, | ||
FormElement, | ||
FormElementMap, | ||
updateElement, | ||
} from '@atj/forms'; | ||
import { FormEditUIContext } from '../../config'; | ||
|
||
export const FormElementEdit = ({ | ||
context, | ||
initialForm, | ||
formElement, | ||
onChange, | ||
}: { | ||
context: FormEditUIContext; | ||
initialForm: FormDefinition; | ||
formElement: FormElement; | ||
onChange: (form: FormDefinition) => void; | ||
}) => { | ||
const methods = useForm<FormElementMap>({ | ||
defaultValues: { | ||
[formElement.id]: formElement, | ||
}, | ||
}); | ||
const SelectedEditComponent = context.editComponents[formElement.type]; | ||
return ( | ||
<FormProvider {...methods}> | ||
<form | ||
className="editForm" | ||
onSubmit={methods.handleSubmit(formData => { | ||
const updatedForm = updateElement( | ||
context.config, | ||
initialForm, | ||
formElement.id, | ||
formData | ||
); | ||
//onChange(updatedForm); | ||
})} | ||
> | ||
<input className="usa-button" type="submit" value="Save" /> | ||
<SelectedEditComponent | ||
context={context} | ||
form={initialForm} | ||
element={formElement} | ||
/> | ||
</form> | ||
</FormProvider> | ||
); | ||
}; |
Oops, something went wrong.