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

Updated to use the new FAST element 2.0 APIs for creating behaviors and creating element styles #5648

Merged
merged 3 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Updated to use the new FAST element 2.0 APIs for creating behaviors and creating element styles",
"packageName": "@microsoft/fast-foundation",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,14 @@ export class DataGridRow extends FoundationElement {

this.updateItemTemplate();

this.cellsRepeatBehavior = new RepeatDirective(
const cellsRepeatDirective = new RepeatDirective(
x => x.columnDefinitions,
x => x.activeCellItemTemplate,
{ positioning: true }
).createBehavior(this.cellsPlaceholder);
);
this.cellsRepeatBehavior = cellsRepeatDirective.createBehavior({
[cellsRepeatDirective.targetId]: this.cellsPlaceholder,
});
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
this.$fastController.addBehaviors([this.cellsRepeatBehavior!]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,14 @@ export class DataGrid extends FoundationElement {

this.toggleGeneratedHeader();

this.rowsRepeatBehavior = new RepeatDirective(
const rowsRepeatDirective = new RepeatDirective(
x => x.rowsData,
x => x.rowItemTemplate,
{ positioning: true }
).createBehavior(this.rowsPlaceholder);
);
this.rowsRepeatBehavior = rowsRepeatDirective.createBehavior({
[rowsRepeatDirective.targetId]: this.rowsPlaceholder,
});

/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
this.$fastController.addBehaviors([this.rowsRepeatBehavior!]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ export class DefaultComponentPresentation implements ComponentPresentation {
styles === void 0
? null
: Array.isArray(styles)
? ElementStyles.create(styles)
? new ElementStyles(styles)
: styles instanceof ElementStyles
? styles
: ElementStyles.create([styles]);
: new ElementStyles([styles]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ConstructableStyleSheetTarget extends QueuedStyleSheetTarget {

const sheet = new CSSStyleSheet();
this.target = (sheet.cssRules[sheet.insertRule(":host{}")] as CSSStyleRule).style;
source.$fastController.addStyles(ElementStyles.create([sheet]));
source.$fastController.addStyles(new ElementStyles([sheet]));
}
}

Expand Down
14 changes: 10 additions & 4 deletions packages/web-components/fast-foundation/src/picker/picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,14 @@ export class Picker extends FormAssociatedPicker {
this.updateListItemTemplate();
this.updateOptionTemplate();

this.itemsRepeatBehavior = new RepeatDirective(
const itemsRepeatDirective = new RepeatDirective(
x => x.selectedItems,
x => x.activeListItemTemplate,
{ positioning: true }
).createBehavior(this.itemsPlaceholderElement);
);
this.itemsRepeatBehavior = itemsRepeatDirective.createBehavior({
[itemsRepeatDirective.targetId]: this.itemsPlaceholderElement,
});

this.inputElement.addEventListener("input", this.handleTextInput);
this.inputElement.addEventListener("click", this.handleInputClick);
Expand All @@ -556,11 +559,14 @@ export class Picker extends FormAssociatedPicker {
this.handleMenuOptionsUpdated
);

this.optionsRepeatBehavior = new RepeatDirective(
const optionsRepeatDirective = new RepeatDirective(
x => x.filteredOptionsList,
x => x.activeMenuOptionTemplate,
{ positioning: true }
).createBehavior(this.optionsPlaceholder);
);
this.optionsRepeatBehavior = optionsRepeatDirective.createBehavior({
[optionsRepeatDirective.targetId]: this.optionsPlaceholder,
});

/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
this.$fastController.addBehaviors([this.optionsRepeatBehavior!]);
Expand Down