Skip to content

Commit

Permalink
removed flex layout dependency (replaced with css)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasDev17 committed Apr 13, 2023
1 parent c8a681e commit c8027b7
Show file tree
Hide file tree
Showing 15 changed files with 187 additions and 31 deletions.
2 changes: 0 additions & 2 deletions packages/angular-material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"@angular/cdk": "^14.2.0 || ^15.0.0",
"@angular/common": "^14.2.0 || ^15.0.0",
"@angular/core": "^14.2.0 || ^15.0.0",
"@angular/flex-layout": "^14.0.0-beta || ^15.0.0-beta",
"@angular/forms": "^14.2.0 || ^15.0.0",
"@angular/material": "^14.2.0 || ^15.0.0",
"@angular/platform-browser": "^14.2.0 || ^15.0.0",
Expand All @@ -83,7 +82,6 @@
"@angular/compiler": "^14.2.0",
"@angular/compiler-cli": "^14.2.0",
"@angular/core": "^14.2.0",
"@angular/flex-layout": "^14.0.0-beta || ^15.0.0-beta",
"@angular/forms": "^14.2.0",
"@angular/material": "^14.2.0",
"@angular/platform-browser": "^14.2.0",
Expand Down
14 changes: 12 additions & 2 deletions packages/angular-material/src/controls/autocomplete.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { startWith } from 'rxjs/operators';
@Component({
selector: 'AutocompleteControlRenderer',
template: `
<mat-form-field fxFlex [fxHide]="hidden">
<mat-form-field [ngClass]="{'simple-flex-item':true,'d-none': hidden}">
<mat-label>{{ label }}</mat-label>
<input
matInput
Expand Down Expand Up @@ -93,11 +93,21 @@ import { startWith } from 'rxjs/operators';
<mat-error>{{ error }}</mat-error>
</mat-form-field>
`,
styles: [
`.d-none {
display: none;
}
.simple-flex-item {
flex: 1 1 0%;
box-sizing: border-box;
}
`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AutocompleteControlRenderer extends JsonFormsControl {
@Input() options: string[];

focused: boolean = false;
filteredOptions: Observable<string[]>;
shouldFilter: boolean;
Expand Down
18 changes: 14 additions & 4 deletions packages/angular-material/src/controls/boolean.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ import { isBooleanControl, RankedTester, rankWith } from '@jsonforms/core';
selector: 'BooleanControlRenderer',
template: `
<div
[fxHide]="hidden"
fxLayout="column"
fxLayoutAlign="center"
style="height:100%"
[ngClass]="{'boolean-control': true, 'd-none': hidden}"
>
<mat-checkbox
(change)="onChange($event)"
Expand All @@ -47,6 +44,19 @@ import { isBooleanControl, RankedTester, rankWith } from '@jsonforms/core';
<mat-error class="mat-caption">{{ error }}</mat-error>
</div>
`,
styles: [
`.d-none {
display: none;
}
.boolean-control {
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: 'center';
height: 100%;
}
`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class BooleanControlRenderer extends JsonFormsControl {
Expand Down
12 changes: 11 additions & 1 deletion packages/angular-material/src/controls/date.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { JsonFormsAngularService, JsonFormsControl } from '@jsonforms/angular';
@Component({
selector: 'DateControlRenderer',
template: `
<mat-form-field fxFlex [fxHide]="hidden">
<mat-form-field [ngClass]="{'simple-flex-item': true, 'd-none': hidden}">
<mat-label>{{ label }}</mat-label>
<input
matInput
Expand All @@ -53,6 +53,16 @@ import { JsonFormsAngularService, JsonFormsControl } from '@jsonforms/angular';
<mat-error>{{ error }}</mat-error>
</mat-form-field>
`,
styles: [
`.d-none {
display: none;
}
.simple-flex-item {
flex: 1 1 0%;
box-sizing: border-box;
}
`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DateControlRenderer extends JsonFormsControl {
Expand Down
12 changes: 11 additions & 1 deletion packages/angular-material/src/controls/number.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import merge from 'lodash/merge';
@Component({
selector: 'NumberControlRenderer',
template: `
<mat-form-field fxFlex [fxHide]="hidden">
<mat-form-field [ngClass]="{'simple-flex-item': true, 'd-none': hidden}">
<mat-label>{{ label }}</mat-label>
<input
matInput
Expand All @@ -55,6 +55,16 @@ import merge from 'lodash/merge';
<mat-error>{{ error }}</mat-error>
</mat-form-field>
`,
styles: [
`.d-none {
display: none;
}
.simple-flex-item {
flex: 1 1 0%;
box-sizing: border-box;
}
`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class NumberControlRenderer extends JsonFormsControl {
Expand Down
18 changes: 17 additions & 1 deletion packages/angular-material/src/controls/range.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { isRangeControl, RankedTester, rankWith } from '@jsonforms/core';
@Component({
selector: 'RangeControlRenderer',
template: `
<div fxFlex fxLayout="column" [fxHide]="hidden">
<div [ngClass]="{'simple-flex-item': true, 'd-none': hidden}">
<label class="mat-caption" style="color:rgba(0,0,0,.54)">{{
label
}}</label>
Expand All @@ -48,6 +48,22 @@ import { isRangeControl, RankedTester, rankWith } from '@jsonforms/core';
<mat-error class="mat-caption">{{ error }}</mat-error>
</div>
`,
styles: [
`
.range-control {
box-sizing: border-box;
display: flex;
flex-direction: column;
}
.d-none {
display: none;
}
.simple-flex-item {
flex: 1 1 0%;
box-sizing: border-box;
}
`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class RangeControlRenderer extends JsonFormsControl {
Expand Down
12 changes: 11 additions & 1 deletion packages/angular-material/src/controls/text.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { isStringControl, RankedTester, rankWith } from '@jsonforms/core';
@Component({
selector: 'TextControlRenderer',
template: `
<mat-form-field fxFlex [fxHide]="hidden">
<mat-form-field [ngClass]="{'simple-flex-item': true, 'd-none': hidden}">
<mat-label>{{ label }}</mat-label>
<input
matInput
Expand All @@ -44,6 +44,16 @@ import { isStringControl, RankedTester, rankWith } from '@jsonforms/core';
<mat-error>{{ error }}</mat-error>
</mat-form-field>
`,
styles: [
`.d-none {
display: none;
}
.simple-flex-item {
flex: 1 1 0%;
box-sizing: border-box;
}
`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class TextControlRenderer extends JsonFormsControl {
Expand Down
12 changes: 11 additions & 1 deletion packages/angular-material/src/controls/textarea.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { isMultiLineControl, RankedTester, rankWith } from '@jsonforms/core';
@Component({
selector: 'TextAreaRenderer',
template: `
<mat-form-field fxFlex [fxHide]="hidden">
<mat-form-field [ngClass]="{'simple-flex-item': true, 'd-none': hidden}">
<mat-label>{{ label }}</mat-label>
<textarea
matInput
Expand All @@ -43,6 +43,16 @@ import { isMultiLineControl, RankedTester, rankWith } from '@jsonforms/core';
<mat-error>{{ error }}</mat-error>
</mat-form-field>
`,
styles: [
`.d-none {
display: none;
}
.simple-flex-item {
flex: 1 1 0%;
box-sizing: border-box;
}
`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class TextAreaRenderer extends JsonFormsControl {
Expand Down
8 changes: 7 additions & 1 deletion packages/angular-material/src/controls/toggle.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
@Component({
selector: 'ToggleControlRenderer',
template: `
<div [fxHide]="hidden">
<div [ngClass]="{'d-none': hidden}">
<mat-slide-toggle
(change)="onChange($event)"
[checked]="isChecked()"
Expand All @@ -48,6 +48,12 @@ import {
<mat-error class="mat-caption">{{ error }}</mat-error>
</div>
`,
styles: [
`.d-none {
display: none;
}
`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ToggleControlRenderer extends JsonFormsControl {
Expand Down
21 changes: 17 additions & 4 deletions packages/angular-material/src/layouts/array-layout.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ import {
@Component({
selector: 'app-array-layout-renderer',
template: `
<div fxLayout="column" fxLayoutGap="16px" [fxHide]="hidden">
<div [ngClass]="{'array-layout-col': true, 'd-none': hidden}">
<div [ngClass]="'array-layout-toolbar'">
<h2 [ngClass]="['mat-h2', 'array-layout-title']">{{ label }}</h2>
<span fxFlex></span>
<span ></span>
<mat-icon
*ngIf="this.error?.length"
color="warn"
Expand All @@ -65,7 +65,7 @@ import {
>
error_outline
</mat-icon>
<span fxFlex></span>
<span [ngClass]="'simple-flex-item'"></span>
<button
mat-button
matTooltip="{{ this.addTooltip }}"
Expand Down Expand Up @@ -131,7 +131,20 @@ import {
</div>
`,
styles: [
`.array-layout-toolbar {
`
.d-none {
display: none;
}
.array-layout-col {
display: flex;
flex-direction: column;
gap: 1rem; /** 16px */
}
.simple-flex-item {
flex: 1 1 0%;
box-sizing: border-box;
}
.array-layout-toolbar {
display: flex;
align-items: center;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { Subscription } from 'rxjs';
@Component({
selector: 'jsonforms-categorization-layout',
template: `
<mat-tab-group dynamicHeight="true" [fxHide]="hidden">
<mat-tab-group dynamicHeight="true" [ngClass]="{'d-none': hidden}">
<mat-tab
*ngFor="let category of visibleCategories; let i = index"
[label]="categoryLabels[i]"
Expand All @@ -58,7 +58,14 @@ import { Subscription } from 'rxjs';
</div>
</mat-tab>
</mat-tab-group>
`
`,
styles: [
`
.d-none{
display: none
}
`
]
})
export class CategorizationTabLayoutRenderer
extends JsonFormsBaseRenderer<Categorization>
Expand Down
20 changes: 18 additions & 2 deletions packages/angular-material/src/layouts/group-layout.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,29 @@ import { JsonFormsAngularService } from '@jsonforms/angular';
@Component({
selector: 'GroupLayoutRenderer',
template: `
<mat-card fxLayout="column" [fxHide]="hidden">
<mat-card [ngClass]="{'group-layout-col': true, 'd-none': hidden}">
<mat-card-title class="mat-title">{{ label }}</mat-card-title>
<div *ngFor="let props of uischema | layoutChildrenRenderProps: schema: path; trackBy: trackElement" fxFlex>
<div *ngFor="let props of uischema | layoutChildrenRenderProps: schema: path; trackBy: trackElement" [ngClass]="'simple-flex-item'">
<jsonforms-outlet [renderProps]="props"></jsonforms-outlet>
</div>
</mat-card>
`,
styles: [
`
.d-none {
display: none;
}
.group-layout-col {
display: flex;
flex-direction: column;
box-sizing: border-box;
}
.simple-flex-item {
flex: 1 1 0%;
box-sizing: border-box;
}
`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class GroupLayoutRenderer extends LayoutRenderer<GroupLayout> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,32 @@ import { JsonFormsAngularService } from '@jsonforms/angular';
selector: 'HorizontalLayoutRenderer',
template: `
<div
fxLayout="row wrap"
fxLayoutGap="16px"
[fxHide]="hidden"
fxLayoutAlign="center start"
[ngClass]="{'horizontal-layout-row': true, 'd-none': hidden}"
>
<div *ngFor="let props of uischema | layoutChildrenRenderProps: schema: path; trackBy: trackElement" fxFlex>
<div *ngFor="let props of uischema | layoutChildrenRenderProps: schema: path; trackBy: trackElement" [ngClass]="'simple-flex-item'">
<jsonforms-outlet [renderProps]="props"></jsonforms-outlet>
</div>
</div>
`,
styles: [
`
.horizontal-layout-row {
flex-flow: row wrap;
box-sizing: border-box;
display: flex;
place-content: flex-start center;
align-items: flex-start;
gap: 1rem;
}
.d-none {
display: none;
}
.simple-flex-item {
flex: 1 1 0%;
box-sizing: border-box;
}
`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class HorizontalLayoutRenderer extends LayoutRenderer<HorizontalLayout> {
Expand Down
Loading

0 comments on commit c8027b7

Please sign in to comment.