mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
[PM-9869] Create SendFormContainer (#10147)
* Move SendV2component into send-v2 subFolder * Create SendFormContainer and related services * Add initial SendFormComponent which uses the SendFormContainer * Remove AdditionalOptionsSectionComponent which will be added with a future PR * Add libs/tools/send to root tsconfig * Register libs/tools/send/send-ui with root jest.config.js * Register libs/tools/send/send-ui with root tailwind.config.js * Fix service injection on DefaultSendFormService --------- Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
beeb0354fd
commit
1320d96cb4
36
libs/tools/send/send-ui/src/send-form/send-form-container.ts
Normal file
36
libs/tools/send/send-ui/src/send-form/send-form-container.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
|
||||
|
||||
import { SendFormConfig } from "./abstractions/send-form-config.service";
|
||||
/**
|
||||
* The complete form for a send. Includes all the sub-forms from their respective section components.
|
||||
* TODO: Add additional form sections as they are implemented.
|
||||
*/
|
||||
export type SendForm = object;
|
||||
|
||||
/**
|
||||
* A container for the {@link SendForm} that allows for registration of child form groups and patching of the send
|
||||
* to be updated/created. Child form components inject this container in order to register themselves with the parent form
|
||||
* and access configuration options.
|
||||
*
|
||||
* This is an alternative to passing the form groups down through the component tree via @Inputs() and form updates via
|
||||
* @Outputs(). It allows child forms to define their own structure and validation rules, while still being able to
|
||||
* update the parent send.
|
||||
*/
|
||||
export abstract class SendFormContainer {
|
||||
/**
|
||||
* The configuration for the send form.
|
||||
*/
|
||||
readonly config: SendFormConfig;
|
||||
|
||||
/**
|
||||
* The original send that is being edited/cloned. Used to pre-populate the form and compare changes.
|
||||
*/
|
||||
readonly originalSendView: SendView | null;
|
||||
|
||||
abstract registerChildForm<K extends keyof SendForm>(
|
||||
name: K,
|
||||
group: Exclude<SendForm[K], undefined>,
|
||||
): void;
|
||||
|
||||
abstract patchSend(send: Partial<SendView>): void;
|
||||
}
|
||||
Reference in New Issue
Block a user