@ng-formworks/material 15.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -0
- package/assets/material-design-themes.scss +71 -0
- package/karma.conf.js +46 -0
- package/ng-package.json +13 -0
- package/package.json +49 -0
- package/src/lib/flexlayout-replacement-styles.scss +95 -0
- package/src/lib/material-design-cssframework.ts +20 -0
- package/src/lib/material-design-framework.component.html +13 -0
- package/src/lib/material-design-framework.component.scss +58 -0
- package/src/lib/material-design-framework.component.spec.ts +39 -0
- package/src/lib/material-design-framework.component.ts +143 -0
- package/src/lib/material-design-framework.module.ts +81 -0
- package/src/lib/material-design-themes.scss +71 -0
- package/src/lib/material-design.framework.ts +83 -0
- package/src/lib/tailwind-output.scss +622 -0
- package/src/lib/widgets/flex-layout-root.component.html +4 -0
- package/src/lib/widgets/flex-layout-root.component.ts +52 -0
- package/src/lib/widgets/flex-layout-section.component.ts +216 -0
- package/src/lib/widgets/material-add-reference.component.ts +56 -0
- package/src/lib/widgets/material-button-group.component.ts +68 -0
- package/src/lib/widgets/material-button.component.ts +66 -0
- package/src/lib/widgets/material-checkbox.component.ts +112 -0
- package/src/lib/widgets/material-checkboxes.component.ts +108 -0
- package/src/lib/widgets/material-chip-list.component.ts +35 -0
- package/src/lib/widgets/material-datepicker.component.ts +89 -0
- package/src/lib/widgets/material-file.component.ts +35 -0
- package/src/lib/widgets/material-input.component.ts +97 -0
- package/src/lib/widgets/material-number.component.ts +95 -0
- package/src/lib/widgets/material-one-of.component.ts +35 -0
- package/src/lib/widgets/material-radios.component.ts +91 -0
- package/src/lib/widgets/material-select.component.ts +118 -0
- package/src/lib/widgets/material-slider.component.ts +65 -0
- package/src/lib/widgets/material-stepper.component.ts +35 -0
- package/src/lib/widgets/material-tabs.component.ts +72 -0
- package/src/lib/widgets/material-textarea.component.ts +88 -0
- package/src/lib/widgets/public_api.ts +54 -0
- package/src/public_api.ts +9 -0
- package/src/test.ts +17 -0
- package/tailwind-input.css +3 -0
- package/tailwind.config.js +12 -0
- package/tsconfig.lib.json +25 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +17 -0
- package/tslint.json +11 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
+
import { JsonSchemaFormService } from '@ng-formworks/core';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
// tslint:disable-next-line:component-selector
|
|
6
|
+
selector: 'material-tabs-widget',
|
|
7
|
+
template: `
|
|
8
|
+
<nav mat-tab-nav-bar [tabPanel]="tabPanel"
|
|
9
|
+
[attr.aria-label]="options?.label || options?.title || ''"
|
|
10
|
+
[style.width]="'100%'">
|
|
11
|
+
<a mat-tab-link *ngFor="let item of layoutNode?.items; let i = index"
|
|
12
|
+
[active]="selectedItem === i"
|
|
13
|
+
(click)="select(i)">
|
|
14
|
+
<span *ngIf="showAddTab || item.type !== '$ref'"
|
|
15
|
+
[innerHTML]="setTabTitle(item, i)"></span>
|
|
16
|
+
</a>
|
|
17
|
+
</nav>
|
|
18
|
+
<mat-tab-nav-panel #tabPanel>
|
|
19
|
+
<div *ngFor="let layoutItem of layoutNode?.items; let i = index"
|
|
20
|
+
[class]="options?.htmlClass || ''">
|
|
21
|
+
<select-framework-widget *ngIf="selectedItem === i"
|
|
22
|
+
[class]="(options?.fieldHtmlClass || '') + ' ' + (options?.activeClass || '') + ' ' + (options?.style?.selected || '')"
|
|
23
|
+
[dataIndex]="layoutNode?.dataType === 'array' ? (dataIndex || []).concat(i) : dataIndex"
|
|
24
|
+
[layoutIndex]="(layoutIndex || []).concat(i)"
|
|
25
|
+
[layoutNode]="layoutItem"></select-framework-widget>
|
|
26
|
+
</div>
|
|
27
|
+
</mat-tab-nav-panel>
|
|
28
|
+
`,
|
|
29
|
+
styles: [` a { cursor: pointer; } `],
|
|
30
|
+
})
|
|
31
|
+
export class MaterialTabsComponent implements OnInit {
|
|
32
|
+
options: any;
|
|
33
|
+
itemCount: number;
|
|
34
|
+
selectedItem = 0;
|
|
35
|
+
showAddTab = true;
|
|
36
|
+
@Input() layoutNode: any;
|
|
37
|
+
@Input() layoutIndex: number[];
|
|
38
|
+
@Input() dataIndex: number[];
|
|
39
|
+
|
|
40
|
+
constructor(
|
|
41
|
+
private jsf: JsonSchemaFormService
|
|
42
|
+
) { }
|
|
43
|
+
|
|
44
|
+
ngOnInit() {
|
|
45
|
+
this.options = this.layoutNode.options || {};
|
|
46
|
+
this.itemCount = this.layoutNode.items.length - 1;
|
|
47
|
+
this.updateControl();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
select(index) {
|
|
51
|
+
if (this.layoutNode.items[index].type === '$ref') {
|
|
52
|
+
this.jsf.addItem({
|
|
53
|
+
layoutNode: this.layoutNode.items[index],
|
|
54
|
+
layoutIndex: this.layoutIndex.concat(index),
|
|
55
|
+
dataIndex: this.dataIndex.concat(index)
|
|
56
|
+
});
|
|
57
|
+
this.updateControl();
|
|
58
|
+
}
|
|
59
|
+
this.selectedItem = index;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
updateControl() {
|
|
63
|
+
this.itemCount = this.layoutNode.items.length - 1;
|
|
64
|
+
const lastItem = this.layoutNode.items[this.layoutNode.items.length - 1];
|
|
65
|
+
this.showAddTab = lastItem.type === '$ref' &&
|
|
66
|
+
this.itemCount < (lastItem.options.maxItems || 1000);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setTabTitle(item: any, index: number): string {
|
|
70
|
+
return this.jsf.setArrayItemTitle(this, item, index);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Component, Inject, Input, OnInit, Optional } from '@angular/core';
|
|
2
|
+
import { AbstractControl } from '@angular/forms';
|
|
3
|
+
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
|
|
4
|
+
import { JsonSchemaFormService } from '@ng-formworks/core';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
// tslint:disable-next-line:component-selector
|
|
8
|
+
selector: 'material-textarea-widget',
|
|
9
|
+
template: `
|
|
10
|
+
<mat-form-field [appearance]="options?.appearance || matFormFieldDefaultOptions?.appearance || 'fill'"
|
|
11
|
+
[class]="options?.htmlClass || ''"
|
|
12
|
+
[floatLabel]="options?.floatLabel || matFormFieldDefaultOptions?.floatLabel || (options?.notitle ? 'never' : 'auto')"
|
|
13
|
+
[hideRequiredMarker]="options?.hideRequired ? 'true' : 'false'"
|
|
14
|
+
[style.width]="'100%'">
|
|
15
|
+
<mat-label *ngIf="!options?.notitle">{{options?.title}}</mat-label>
|
|
16
|
+
<span matPrefix *ngIf="options?.prefix || options?.fieldAddonLeft"
|
|
17
|
+
[innerHTML]="options?.prefix || options?.fieldAddonLeft"></span>
|
|
18
|
+
<textarea matInput *ngIf="boundControl"
|
|
19
|
+
[formControl]="formControl"
|
|
20
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
21
|
+
[attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
|
|
22
|
+
[attr.maxlength]="options?.maxLength"
|
|
23
|
+
[attr.minlength]="options?.minLength"
|
|
24
|
+
[attr.pattern]="options?.pattern"
|
|
25
|
+
[required]="options?.required"
|
|
26
|
+
[id]="'control' + layoutNode?._id"
|
|
27
|
+
[name]="controlName"
|
|
28
|
+
[placeholder]="options?.notitle ? options?.placeholder : options?.title"
|
|
29
|
+
[readonly]="options?.readonly ? 'readonly' : null"
|
|
30
|
+
[style.width]="'100%'"
|
|
31
|
+
(blur)="options.showErrors = true"></textarea>
|
|
32
|
+
<textarea matInput *ngIf="!boundControl"
|
|
33
|
+
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
|
|
34
|
+
[attr.list]="'control' + layoutNode?._id + 'Autocomplete'"
|
|
35
|
+
[attr.maxlength]="options?.maxLength"
|
|
36
|
+
[attr.minlength]="options?.minLength"
|
|
37
|
+
[attr.pattern]="options?.pattern"
|
|
38
|
+
[required]="options?.required"
|
|
39
|
+
[disabled]="controlDisabled"
|
|
40
|
+
[id]="'control' + layoutNode?._id"
|
|
41
|
+
[name]="controlName"
|
|
42
|
+
[placeholder]="options?.notitle ? options?.placeholder : options?.title"
|
|
43
|
+
[readonly]="options?.readonly ? 'readonly' : null"
|
|
44
|
+
[style.width]="'100%'"
|
|
45
|
+
[value]="controlValue"
|
|
46
|
+
(input)="updateValue($event)"
|
|
47
|
+
(blur)="options.showErrors = true"></textarea>
|
|
48
|
+
<span matSuffix *ngIf="options?.suffix || options?.fieldAddonRight"
|
|
49
|
+
[innerHTML]="options?.suffix || options?.fieldAddonRight"></span>
|
|
50
|
+
<mat-hint *ngIf="options?.description && (!options?.showErrors || !options?.errorMessage)"
|
|
51
|
+
align="end" [innerHTML]="options?.description"></mat-hint>
|
|
52
|
+
</mat-form-field>
|
|
53
|
+
<mat-error *ngIf="options?.showErrors && options?.errorMessage"
|
|
54
|
+
[innerHTML]="options?.errorMessage"></mat-error>`,
|
|
55
|
+
styles: [`
|
|
56
|
+
mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }
|
|
57
|
+
::ng-deep json-schema-form mat-form-field .mat-mdc-form-field-wrapper .mat-form-field-flex
|
|
58
|
+
.mat-form-field-infix { width: initial; }
|
|
59
|
+
`],
|
|
60
|
+
})
|
|
61
|
+
export class MaterialTextareaComponent implements OnInit {
|
|
62
|
+
formControl: AbstractControl;
|
|
63
|
+
controlName: string;
|
|
64
|
+
controlValue: any;
|
|
65
|
+
controlDisabled = false;
|
|
66
|
+
boundControl = false;
|
|
67
|
+
options: any;
|
|
68
|
+
@Input() layoutNode: any;
|
|
69
|
+
@Input() layoutIndex: number[];
|
|
70
|
+
@Input() dataIndex: number[];
|
|
71
|
+
|
|
72
|
+
constructor(
|
|
73
|
+
@Inject(MAT_FORM_FIELD_DEFAULT_OPTIONS) @Optional() public matFormFieldDefaultOptions,
|
|
74
|
+
private jsf: JsonSchemaFormService
|
|
75
|
+
) { }
|
|
76
|
+
|
|
77
|
+
ngOnInit() {
|
|
78
|
+
this.options = this.layoutNode.options || {};
|
|
79
|
+
this.jsf.initializeControl(this);
|
|
80
|
+
if (!this.options.notitle && !this.options.description && this.options.placeholder) {
|
|
81
|
+
this.options.description = this.options.placeholder;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
updateValue(event) {
|
|
86
|
+
this.jsf.updateValue(this, event.target.value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { FlexLayoutRootComponent } from './flex-layout-root.component';
|
|
2
|
+
import { FlexLayoutSectionComponent } from './flex-layout-section.component';
|
|
3
|
+
import { MaterialAddReferenceComponent } from './material-add-reference.component';
|
|
4
|
+
import { MaterialButtonComponent } from './material-button.component';
|
|
5
|
+
import { MaterialButtonGroupComponent } from './material-button-group.component';
|
|
6
|
+
import { MaterialCheckboxComponent } from './material-checkbox.component';
|
|
7
|
+
import { MaterialCheckboxesComponent } from './material-checkboxes.component';
|
|
8
|
+
import { MaterialChipListComponent } from './material-chip-list.component';
|
|
9
|
+
import { MaterialDatepickerComponent } from './material-datepicker.component';
|
|
10
|
+
import { MaterialDesignFrameworkComponent } from '../material-design-framework.component';
|
|
11
|
+
import { MaterialFileComponent } from './material-file.component';
|
|
12
|
+
import { MaterialInputComponent } from './material-input.component';
|
|
13
|
+
import { MaterialNumberComponent } from './material-number.component';
|
|
14
|
+
import { MaterialOneOfComponent } from './material-one-of.component';
|
|
15
|
+
import { MaterialRadiosComponent } from './material-radios.component';
|
|
16
|
+
import { MaterialSelectComponent } from './material-select.component';
|
|
17
|
+
import { MaterialSliderComponent } from './material-slider.component';
|
|
18
|
+
import { MaterialStepperComponent } from './material-stepper.component';
|
|
19
|
+
import { MaterialTabsComponent } from './material-tabs.component';
|
|
20
|
+
import { MaterialTextareaComponent } from './material-textarea.component';
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export const MATERIAL_FRAMEWORK_COMPONENTS = [
|
|
24
|
+
FlexLayoutRootComponent, FlexLayoutSectionComponent,
|
|
25
|
+
MaterialAddReferenceComponent, MaterialOneOfComponent,
|
|
26
|
+
MaterialButtonComponent, MaterialButtonGroupComponent,
|
|
27
|
+
MaterialCheckboxComponent, MaterialCheckboxesComponent,
|
|
28
|
+
MaterialChipListComponent, MaterialDatepickerComponent,
|
|
29
|
+
MaterialFileComponent, MaterialInputComponent, MaterialNumberComponent,
|
|
30
|
+
MaterialRadiosComponent, MaterialSelectComponent, MaterialSliderComponent,
|
|
31
|
+
MaterialStepperComponent, MaterialTabsComponent, MaterialTextareaComponent,
|
|
32
|
+
MaterialDesignFrameworkComponent
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
export { FlexLayoutRootComponent } from './flex-layout-root.component';
|
|
36
|
+
export { FlexLayoutSectionComponent } from './flex-layout-section.component';
|
|
37
|
+
export { MaterialAddReferenceComponent } from './material-add-reference.component';
|
|
38
|
+
export { MaterialOneOfComponent } from './material-one-of.component';
|
|
39
|
+
export { MaterialButtonComponent } from './material-button.component';
|
|
40
|
+
export { MaterialButtonGroupComponent } from './material-button-group.component';
|
|
41
|
+
export { MaterialCheckboxComponent } from './material-checkbox.component';
|
|
42
|
+
export { MaterialCheckboxesComponent } from './material-checkboxes.component';
|
|
43
|
+
export { MaterialChipListComponent } from './material-chip-list.component';
|
|
44
|
+
export { MaterialDatepickerComponent } from './material-datepicker.component';
|
|
45
|
+
export { MaterialFileComponent } from './material-file.component';
|
|
46
|
+
export { MaterialInputComponent } from './material-input.component';
|
|
47
|
+
export { MaterialNumberComponent } from './material-number.component';
|
|
48
|
+
export { MaterialRadiosComponent } from './material-radios.component';
|
|
49
|
+
export { MaterialSelectComponent } from './material-select.component';
|
|
50
|
+
export { MaterialSliderComponent } from './material-slider.component';
|
|
51
|
+
export { MaterialStepperComponent } from './material-stepper.component';
|
|
52
|
+
export { MaterialTabsComponent } from './material-tabs.component';
|
|
53
|
+
export { MaterialTextareaComponent } from './material-textarea.component';
|
|
54
|
+
export { MaterialDesignFrameworkComponent } from '../material-design-framework.component';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of @ng-formworks/material-framework
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * from './lib/material-design-framework.component';
|
|
6
|
+
export * from './lib/material-design-framework.module';
|
|
7
|
+
export * from './lib/material-design.framework';
|
|
8
|
+
export * from './lib/widgets/public_api';
|
|
9
|
+
|
package/src/test.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
+
|
|
3
|
+
import 'zone.js';
|
|
4
|
+
import 'zone.js/testing';
|
|
5
|
+
import { getTestBed } from '@angular/core/testing';
|
|
6
|
+
import {
|
|
7
|
+
BrowserDynamicTestingModule,
|
|
8
|
+
platformBrowserDynamicTesting
|
|
9
|
+
} from '@angular/platform-browser-dynamic/testing';
|
|
10
|
+
|
|
11
|
+
// First, initialize the Angular testing environment.
|
|
12
|
+
getTestBed().initTestEnvironment(
|
|
13
|
+
BrowserDynamicTestingModule,
|
|
14
|
+
platformBrowserDynamicTesting(), {
|
|
15
|
+
teardown: { destroyAfterEach: false }
|
|
16
|
+
}
|
|
17
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
/** @type {import('tailwindcss').Config} */
|
|
3
|
+
module.exports = {
|
|
4
|
+
content: [
|
|
5
|
+
"./src/**/*.{html,ts}",
|
|
6
|
+
"./projects/ng-formworks-material/**/*.{html,ts}"
|
|
7
|
+
],
|
|
8
|
+
theme: {
|
|
9
|
+
extend: {},
|
|
10
|
+
},
|
|
11
|
+
plugins: [],
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../out-tsc/lib",
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"inlineSources": true,
|
|
8
|
+
"types": [],
|
|
9
|
+
"lib": [
|
|
10
|
+
"dom",
|
|
11
|
+
"es2018"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"angularCompilerOptions": {
|
|
15
|
+
"skipTemplateCodegen": true,
|
|
16
|
+
"strictMetadataEmit": true,
|
|
17
|
+
"fullTemplateTypeCheck": true,
|
|
18
|
+
"strictInjectionParameters": true,
|
|
19
|
+
"enableResourceInlining": true
|
|
20
|
+
},
|
|
21
|
+
"exclude": [
|
|
22
|
+
"src/test.ts",
|
|
23
|
+
"**/*.spec.ts"
|
|
24
|
+
]
|
|
25
|
+
}
|