-
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 submission registry class * In-progress * Add ability to register multiple handlers to the form platform, to later be registered at the plugin level. Wire this submission handler system up to the submit-form service * Wire "next page" action handler to UI. * Add "package download" pattern, which provides a submit button to download a PDF package. * Wire package download button up to UI. There are still issues with PDF data serialization that need to be resolved. * Get submit action string when submitting via JS * Fix typo * Add initial documentation for the forms package and its patterns directory
- Loading branch information
1 parent
2663178
commit 63a1ae5
Showing
39 changed files
with
2,650 additions
and
1,459 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
16 changes: 16 additions & 0 deletions
16
packages/design/src/Form/components/PackageDownload/index.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,16 @@ | ||
import React from 'react'; | ||
|
||
import { type PackageDownloadProps } from '@atj/forms'; | ||
|
||
import { type PatternComponent } from '../../../Form/index.js'; | ||
import ActionBar from '../../../Form/ActionBar/index.js'; | ||
|
||
const PackageDownload: PatternComponent<PackageDownloadProps> = props => { | ||
return ( | ||
<> | ||
<p className="maxw-tablet">{props.text}</p> | ||
<ActionBar actions={props.actions} /> | ||
</> | ||
); | ||
}; | ||
export default PackageDownload; |
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
77 changes: 77 additions & 0 deletions
77
packages/design/src/FormManager/FormEdit/components/PackageDownloadPatternEdit.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,77 @@ | ||
import classnames from 'classnames'; | ||
import React from 'react'; | ||
|
||
import { enLocale as message } from '@atj/common'; | ||
import { | ||
type PackageDownloadPattern, | ||
type PackageDownloadProps, | ||
type PatternId, | ||
} from '@atj/forms'; | ||
|
||
import PackageDownload from '../../../Form/components/PackageDownload/index.js'; | ||
import { PatternEditComponent } from '../types.js'; | ||
|
||
import { PatternEditActions } from './common/PatternEditActions.js'; | ||
import { PatternEditForm } from './common/PatternEditForm.js'; | ||
import { usePatternEditFormContext } from './common/hooks.js'; | ||
import { useFormManagerStore } from '../../store.js'; | ||
|
||
const PackageDownloadPatternEdit: PatternEditComponent< | ||
PackageDownloadProps | ||
> = ({ focus, previewProps }) => { | ||
return ( | ||
<> | ||
{focus ? ( | ||
<PatternEditForm | ||
pattern={focus.pattern} | ||
editComponent={<EditComponent patternId={focus.pattern.id} />} | ||
></PatternEditForm> | ||
) : ( | ||
<div className="padding-left-3 padding-bottom-3 padding-right-3"> | ||
<PackageDownload {...previewProps} /> | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
const EditComponent = ({ patternId }: { patternId: PatternId }) => { | ||
const pattern = useFormManagerStore<PackageDownloadPattern>( | ||
state => state.session.form.patterns[patternId] | ||
); | ||
const { fieldId, getFieldState, register } = | ||
usePatternEditFormContext<PackageDownloadPattern>(patternId); | ||
const text = getFieldState('text'); | ||
|
||
return ( | ||
<div className="grid-row grid-gap-1"> | ||
<div className="tablet:grid-col-12"> | ||
<label | ||
className={classnames('usa-label', { | ||
'usa-label--error': text.error, | ||
})} | ||
htmlFor={fieldId('text')} | ||
> | ||
{message.patterns.packageDownload.fieldLabel} | ||
</label> | ||
{text.error ? ( | ||
<span className="usa-error-message" role="alert"> | ||
{text.error.message} | ||
</span> | ||
) : null} | ||
<textarea | ||
id={fieldId('text')} | ||
className="usa-textarea bg-primary-lighter text-bold" | ||
style={{ height: 'unset' }} | ||
rows={4} | ||
{...register('text')} | ||
defaultValue={pattern.data.text} | ||
autoFocus | ||
></textarea> | ||
</div> | ||
<PatternEditActions /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PackageDownloadPatternEdit; |
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,9 @@ | ||
# @atj/forms | ||
|
||
This library includes all of the core business logic of the Forms Platform. | ||
|
||
- [./src/services](./src/services): The public interface of the Forms Platform is implemented here | ||
- [./src/patterns](./src/patterns/README.md): Form building blocks, aka "patterns" | ||
- [./src/repository](./src/repository): Database routines | ||
- [./src/documents](./src/documents): Document ingest and creation | ||
- [./src/context](./src/context): Runtime contexts for the platform (testing, in-browser, server-side) are defined here |
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.