Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add two-way binding #5995

Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: add two-way binding",
"packageName": "@microsoft/fast-element",
"email": "[email protected]",
"dependentChangeType": "patch"
}
25 changes: 25 additions & 0 deletions packages/web-components/fast-element/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export interface CaptureType<TSource> {
export class ChangeBinding extends UpdateBinding {
constructor(directive: HTMLBindingDirective, updateTarget: UpdateTarget);
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
protected getObserver(target: Node): BindingObserver;
// @internal (undocumented)
handleChange(binding: Binding, observer: BindingObserver): void;
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
Expand Down Expand Up @@ -284,6 +285,12 @@ export type DecoratorAttributeConfiguration = Omit<AttributeConfiguration, "prop
// @public
export type DefaultBindingOptions = AddEventListenerOptions;

// @public
export type DefaultTwoWayBindingOptions = DefaultBindingOptions & {
changeEvent?: string;
fromView?: (value: any) => any;
};

// @public
export const DOM: Readonly<{
queueUpdate: (callable: Callable) => void;
Expand Down Expand Up @@ -533,6 +540,7 @@ export abstract class NodeObservationDirective<T extends NodeBehaviorOptions> ex
protected computeNodes(target: any): Node[];
protected abstract disconnect(target: any): void;
protected abstract getNodes(target: any): Node[];
protected getSource(target: Node): any;
protected abstract observe(target: any): void;
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
protected updateTarget(source: any, value: ReadonlyArray<any>): void;
Expand Down Expand Up @@ -813,6 +821,23 @@ export type TrustedTypesPolicy = {
createHTML(html: string): string;
};

// @public
export const twoWay: BindingConfig<DefaultTwoWayBindingOptions> & BindingConfigResolver<DefaultTwoWayBindingOptions>;

// @public
export class TwoWayBinding extends ChangeBinding {
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
static configure(settings: TwoWaySettings): void;
// @internal (undocumented)
handleEvent(event: Event): void;
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
}

// @public
export interface TwoWaySettings {
determineChangeEvent(directive: HTMLBindingDirective, target: HTMLElement): string;
}

// Warning: (ae-internal-missing-underscore) The name "TypeDefinition" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
Expand Down
Loading