special-forms 1.0.0
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/.editorconfig +16 -0
- package/.storybook/db-theme.js +8 -0
- package/.storybook/main.js +15 -0
- package/.storybook/manager.js +7 -0
- package/.storybook/preview-head.html +16 -0
- package/.storybook/preview.js +20 -0
- package/.storybook/tsconfig.json +21 -0
- package/.storybook/typings.d.ts +4 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +20 -0
- package/.vscode/tasks.json +42 -0
- package/README.md +27 -0
- package/angular.json +38 -0
- package/documentation.json +10829 -0
- package/package.json +65 -0
- package/projects/special-forms/README.md +24 -0
- package/projects/special-forms/karma.conf.js +44 -0
- package/projects/special-forms/ng-package.json +7 -0
- package/projects/special-forms/package.json +11 -0
- package/projects/special-forms/src/lib/assets/styles.scss +213 -0
- package/projects/special-forms/src/lib/assets/themes/dark.scss +80 -0
- package/projects/special-forms/src/lib/assets/themes/light.scss +78 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.html +5 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.scss +6 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.spec.ts +21 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.ts +21 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.module.ts +36 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.html +5 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.scss +18 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.ts +66 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.module.ts +16 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.html +31 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.scss +0 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.spec.ts +22 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.ts +102 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/autocomplete.form.ts +87 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/checkbox.form.ts +51 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/common.form.interface.ts +24 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/common.form.ts +31 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/datepicker.form.ts +56 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/dropdown.form.ts +80 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/field.form.ts +189 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/input.form.ts +71 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/label.form.ts +33 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/text-area.form.ts +17 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/upload.form.ts +35 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.html +37 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.scss +41 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.spec.ts +22 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.ts +95 -0
- package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.module.ts +32 -0
- package/projects/special-forms/src/lib/components/index.ts +61 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.html +62 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.spec.ts +24 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.ts +58 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.interface.ts +20 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.module.ts +25 -0
- package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.stories.ts +81 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.html +17 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.ts +19 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.interface.ts +12 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.module.ts +25 -0
- package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.stories.ts +76 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.html +26 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.ts +21 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.interface.ts +13 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.module.ts +26 -0
- package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.stories.ts +69 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.html +41 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.scss +15 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.spec.ts +24 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.ts +34 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.interface.ts +18 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.module.ts +22 -0
- package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.stories.ts +83 -0
- package/projects/special-forms/src/lib/components/special-form/special-form-array.component.html +208 -0
- package/projects/special-forms/src/lib/components/special-form/special-form-array.component.scss +70 -0
- package/projects/special-forms/src/lib/components/special-form/special-form-array.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-form/special-form-array.module.ts +18 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.component.html +20 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.component.spec.ts +22 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.component.ts +85 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.module.ts +40 -0
- package/projects/special-forms/src/lib/components/special-form/special-form.stories.ts +45 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.component.html +37 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.component.ts +39 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.interface.ts +17 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.module.ts +24 -0
- package/projects/special-forms/src/lib/components/special-input/special-input.stories.ts +91 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.component.html +6 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.component.ts +27 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.interface.ts +14 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.module.ts +25 -0
- package/projects/special-forms/src/lib/components/special-label/special-label.stories.ts +99 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.html +82 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.ts +86 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.interface.ts +20 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.module.ts +28 -0
- package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.stories.ts +81 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.html +29 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.scss +3 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.ts +20 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.interface.ts +9 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.module.ts +24 -0
- package/projects/special-forms/src/lib/components/special-text-area/special-text-area.stories.ts +69 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.component.html +50 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.component.scss +29 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.component.spec.ts +23 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.component.ts +79 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.interface.ts +12 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.module.ts +23 -0
- package/projects/special-forms/src/lib/components/special-upload/special-upload.stories.ts +81 -0
- package/projects/special-forms/src/lib/core/aux-data/all-icons.ts +99 -0
- package/projects/special-forms/src/lib/core/aux-data/control-types.enum.ts +16 -0
- package/projects/special-forms/src/lib/core/aux-data/countries.ts +247 -0
- package/projects/special-forms/src/lib/core/aux-data/field-basic-data.ts +14 -0
- package/projects/special-forms/src/lib/core/aux-data/input-types.ts +23 -0
- package/projects/special-forms/src/lib/core/controls/icons.control.ts +8 -0
- package/projects/special-forms/src/lib/core/controls/index.ts +2 -0
- package/projects/special-forms/src/lib/core/controls/theme.control.ts +1 -0
- package/projects/special-forms/src/lib/core/controls/types.control.ts +9 -0
- package/projects/special-forms/src/lib/core/directives/control-render.directive.ts +19 -0
- package/projects/special-forms/src/lib/core/directives/control-render.module.ts +10 -0
- package/projects/special-forms/src/lib/core/forms/special-forms.ts +395 -0
- package/projects/special-forms/src/lib/core/interfaces/field-basics.interfaces.ts +22 -0
- package/projects/special-forms/src/lib/core/interfaces/form.interfaces.ts +83 -0
- package/projects/special-forms/src/lib/core/interfaces/special-control.interface.ts +9 -0
- package/projects/special-forms/src/lib/core/masks/currency.mask.ts +11 -0
- package/projects/special-forms/src/lib/core/masks/maks.enum.ts +12 -0
- package/projects/special-forms/src/lib/core/masks/number.mask.ts +4 -0
- package/projects/special-forms/src/lib/core/services/index.ts +3 -0
- package/projects/special-forms/src/lib/core/services/special-form-builder/special-form-builder.service.spec.ts +16 -0
- package/projects/special-forms/src/lib/core/services/special-form-builder/special-form-builder.service.ts +220 -0
- package/projects/special-forms/src/lib/core/utils/enum-to-array.util.ts +6 -0
- package/projects/special-forms/src/lib/pipes/controls-list-pipe/controls-list.pipe.module.ts +10 -0
- package/projects/special-forms/src/lib/pipes/controls-list-pipe/controls-list.pipe.ts +17 -0
- package/projects/special-forms/src/lib/pipes/error-message-pipe/error.pipe.module.ts +13 -0
- package/projects/special-forms/src/lib/pipes/error-message-pipe/error.pipe.ts +21 -0
- package/projects/special-forms/src/lib/pipes/index.ts +3 -0
- package/projects/special-forms/src/lib/pipes/text-by-function/text-by-function.pipe.module.ts +13 -0
- package/projects/special-forms/src/lib/pipes/text-by-function/text-by-function.pipe.ts +14 -0
- package/projects/special-forms/src/public-api.ts +8 -0
- package/projects/special-forms/src/test.ts +27 -0
- package/projects/special-forms/tsconfig.lib.json +15 -0
- package/projects/special-forms/tsconfig.lib.prod.json +10 -0
- package/projects/special-forms/tsconfig.spec.json +17 -0
- package/scss-bundle.config.json +6 -0
- package/stories/Button.stories.ts +42 -0
- package/stories/Header.stories.ts +35 -0
- package/stories/Introduction.stories.mdx +211 -0
- package/stories/Page.stories.ts +36 -0
- package/stories/User.ts +2 -0
- package/stories/assets/code-brackets.svg +1 -0
- package/stories/assets/colors.svg +1 -0
- package/stories/assets/comments.svg +1 -0
- package/stories/assets/direction.svg +1 -0
- package/stories/assets/flow.svg +1 -0
- package/stories/assets/plugin.svg +1 -0
- package/stories/assets/repo.svg +1 -0
- package/stories/assets/stackalt.svg +1 -0
- package/stories/button.component.ts +53 -0
- package/stories/button.css +30 -0
- package/stories/header.component.ts +75 -0
- package/stories/header.css +32 -0
- package/stories/page.component.ts +77 -0
- package/stories/page.css +69 -0
- package/tailwind.config.js +30 -0
- package/tsconfig.json +39 -0
package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.html
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<mat-form-field
|
|
2
|
+
*ngIf="control"
|
|
3
|
+
[id]="control.elementId"
|
|
4
|
+
class="w-full {{ control.styleClasses }}"
|
|
5
|
+
[appearance]="control.label ? 'outline' : 'standard'"
|
|
6
|
+
>
|
|
7
|
+
<mat-label *ngIf="control.label">
|
|
8
|
+
{{ control.label }}
|
|
9
|
+
</mat-label>
|
|
10
|
+
<mat-select
|
|
11
|
+
[formControl]="control"
|
|
12
|
+
[required]="control.required"
|
|
13
|
+
(selectionChange)="optionSelected($event.value)"
|
|
14
|
+
[placeholder]="control.placeholder"
|
|
15
|
+
>
|
|
16
|
+
<mat-option *ngIf="!control.required" [value]="null">
|
|
17
|
+
{{ control.placeholder || control.settings.notSelectedText }}
|
|
18
|
+
</mat-option>
|
|
19
|
+
<mat-option
|
|
20
|
+
*ngFor="let item of control.settings.source | async"
|
|
21
|
+
[value]="item[control.settings.fieldId]"
|
|
22
|
+
>
|
|
23
|
+
{{ item | textByFunction: control.settings.fieldName }}
|
|
24
|
+
</mat-option>
|
|
25
|
+
</mat-select>
|
|
26
|
+
<button
|
|
27
|
+
*ngIf="settings.icon"
|
|
28
|
+
mat-icon-button
|
|
29
|
+
matSuffix
|
|
30
|
+
(click)="iconClick($event)"
|
|
31
|
+
>
|
|
32
|
+
<mat-icon>
|
|
33
|
+
{{ settings.icon }}
|
|
34
|
+
</mat-icon>
|
|
35
|
+
</button>
|
|
36
|
+
<mat-icon *ngIf="control.icon" matPrefix>{{ control.icon }}</mat-icon>
|
|
37
|
+
<mat-hint *ngIf="control.tooltip">{{ control.tooltip }}</mat-hint>
|
|
38
|
+
<mat-error>
|
|
39
|
+
{{ control.errors | errorMessage: control.errorMessages }}
|
|
40
|
+
</mat-error>
|
|
41
|
+
</mat-form-field>
|
package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.scss
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: contents;
|
|
3
|
+
}
|
|
4
|
+
// .dark {
|
|
5
|
+
// ::ng-deep {
|
|
6
|
+
// .mat-select-panel {
|
|
7
|
+
// background: linear-gradient(
|
|
8
|
+
// 93deg,
|
|
9
|
+
// rgba(0, 0, 0, 1) 0%,
|
|
10
|
+
// rgba(29, 43, 69, 1) 0%,
|
|
11
|
+
// rgba(27, 15, 46, 1) 100%
|
|
12
|
+
// );
|
|
13
|
+
// }
|
|
14
|
+
// }
|
|
15
|
+
// }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { SpecialDropdownComponent } from './special-dropdown.component';
|
|
4
|
+
|
|
5
|
+
describe('SpecialDropdownComponent', () => {
|
|
6
|
+
let component: SpecialDropdownComponent;
|
|
7
|
+
let fixture: ComponentFixture<SpecialDropdownComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [SpecialDropdownComponent],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
fixture = TestBed.createComponent(SpecialDropdownComponent);
|
|
17
|
+
component = fixture.componentInstance;
|
|
18
|
+
fixture.detectChanges();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should create', () => {
|
|
22
|
+
expect(component).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
});
|
package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
Input,
|
|
5
|
+
HostBinding,
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
import { SpecialFormControl } from '../../core/forms/special-forms';
|
|
8
|
+
import { IDropdownSettings } from './special-dropdown.interface';
|
|
9
|
+
import { OverlayContainer } from '@angular/cdk/overlay';
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'sp-dropdown',
|
|
12
|
+
templateUrl: './special-dropdown.component.html',
|
|
13
|
+
styleUrls: ['./special-dropdown.component.scss'],
|
|
14
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
15
|
+
})
|
|
16
|
+
export class SpecialDropdownComponent {
|
|
17
|
+
@Input() control: SpecialFormControl<IDropdownSettings>;
|
|
18
|
+
|
|
19
|
+
get settings(): IDropdownSettings {
|
|
20
|
+
return this.control.settings;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
iconClick(event) {
|
|
24
|
+
if (this.settings.iconAction) {
|
|
25
|
+
this.settings.iconAction(this.control.value);
|
|
26
|
+
event.stopPropagation();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
optionSelected(value) {
|
|
31
|
+
if (this.settings.onSelect) this.settings.onSelect(value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.interface.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { EControlTypes } from '../../core/aux-data/control-types.enum';
|
|
3
|
+
import { IFieldData } from '../../core/interfaces/field-basics.interfaces';
|
|
4
|
+
|
|
5
|
+
export type IDropdownSettings = {
|
|
6
|
+
icon?: string;
|
|
7
|
+
onSelect?: (data: any) => void;
|
|
8
|
+
iconAction?: (data: any) => void;
|
|
9
|
+
source: Observable<any[]>;
|
|
10
|
+
fieldId: string;
|
|
11
|
+
fieldName: string | ((a?: any) => string);
|
|
12
|
+
notSelectedText?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export interface IDropdownField extends IFieldData {
|
|
16
|
+
settings: IDropdownSettings;
|
|
17
|
+
type: EControlTypes.dropdown;
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { SpecialDropdownComponent } from './special-dropdown.component';
|
|
4
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
5
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
6
|
+
import { ErrorMessagePipeModule, TextByFunctionPipeModule } from '../../pipes';
|
|
7
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
8
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
9
|
+
@NgModule({
|
|
10
|
+
declarations: [SpecialDropdownComponent],
|
|
11
|
+
imports: [
|
|
12
|
+
CommonModule,
|
|
13
|
+
MatSelectModule,
|
|
14
|
+
ReactiveFormsModule,
|
|
15
|
+
ErrorMessagePipeModule,
|
|
16
|
+
MatIconModule,
|
|
17
|
+
MatButtonModule,
|
|
18
|
+
TextByFunctionPipeModule
|
|
19
|
+
],
|
|
20
|
+
exports: [SpecialDropdownComponent],
|
|
21
|
+
})
|
|
22
|
+
export class SpecialDropdownModule {}
|
package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.stories.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
2
|
+
import { Story, Meta } from '@storybook/angular';
|
|
3
|
+
import { moduleMetadata } from '@storybook/angular';
|
|
4
|
+
import { FormControlViewerComponent } from '../../aux-storybook-components/form-control-viewer/form-control-viewer.component';
|
|
5
|
+
import { FormControlViewerModule } from '../../aux-storybook-components/form-control-viewer/form-control-viewer.module';
|
|
6
|
+
import { EControlTypes } from '../../core/aux-data/control-types.enum';
|
|
7
|
+
import { countries } from '../../core/aux-data/countries';
|
|
8
|
+
import { FieldBasicData } from '../../core/aux-data/field-basic-data';
|
|
9
|
+
import { ICONS_CONTROL } from '../../core/controls';
|
|
10
|
+
import { THEMES_CONTROL } from '../../core/controls/theme.control';
|
|
11
|
+
import { SpecialDropdownComponent } from './special-dropdown.component';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: 'Special dropdown control',
|
|
15
|
+
component: FormControlViewerComponent,
|
|
16
|
+
decorators: [
|
|
17
|
+
moduleMetadata({
|
|
18
|
+
imports: [FormControlViewerModule, BrowserAnimationsModule],
|
|
19
|
+
}),
|
|
20
|
+
],
|
|
21
|
+
argTypes: {
|
|
22
|
+
icon: ICONS_CONTROL,
|
|
23
|
+
theme: THEMES_CONTROL,
|
|
24
|
+
},
|
|
25
|
+
} as Meta;
|
|
26
|
+
|
|
27
|
+
const Template: Story<FormControlViewerComponent> = (
|
|
28
|
+
args: FormControlViewerComponent
|
|
29
|
+
) => ({
|
|
30
|
+
title: 'Special dropdown control',
|
|
31
|
+
template: `
|
|
32
|
+
<spf-form-control-viewer
|
|
33
|
+
[theme]="theme"
|
|
34
|
+
[dropdown]="{
|
|
35
|
+
placeholder: placeholder,
|
|
36
|
+
label: label,
|
|
37
|
+
tooltip: tooltip,
|
|
38
|
+
icon: icon,
|
|
39
|
+
elementId: elementId,
|
|
40
|
+
styleClasses: styleClasses,
|
|
41
|
+
length: length,
|
|
42
|
+
required: required,
|
|
43
|
+
hidden: false,
|
|
44
|
+
readOnly: readOnly,
|
|
45
|
+
defaultValue:defaultValue,
|
|
46
|
+
type:type,
|
|
47
|
+
errorMessages: errorMessages,
|
|
48
|
+
settings:{
|
|
49
|
+
source:source,
|
|
50
|
+
fieldId: fieldId,
|
|
51
|
+
fieldName:fieldName,
|
|
52
|
+
notSelectedText:notSelectedText
|
|
53
|
+
}
|
|
54
|
+
}"
|
|
55
|
+
>
|
|
56
|
+
</spf-form-control-viewer>`,
|
|
57
|
+
props: {
|
|
58
|
+
...args,
|
|
59
|
+
type: EControlTypes.dropdown,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const light = Template.bind({});
|
|
64
|
+
light.args = {
|
|
65
|
+
...FieldBasicData,
|
|
66
|
+
theme: 'light-theme',
|
|
67
|
+
defaultValue: 'CO',
|
|
68
|
+
notSelectedText:'Seleccione un item',
|
|
69
|
+
fieldName: 'name',
|
|
70
|
+
fieldId: 'code',
|
|
71
|
+
source: countries(),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const dark = Template.bind({});
|
|
75
|
+
dark.args = {
|
|
76
|
+
...FieldBasicData,
|
|
77
|
+
theme: 'dark-theme',
|
|
78
|
+
defaultValue: 'CO',
|
|
79
|
+
notSelectedText:'Seleccione un item',
|
|
80
|
+
fieldName: 'name',
|
|
81
|
+
fieldId: 'code',
|
|
82
|
+
source: countries(),
|
|
83
|
+
};
|
package/projects/special-forms/src/lib/components/special-form/special-form-array.component.html
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
<div class="w-full box-border p-2">
|
|
2
|
+
<div
|
|
3
|
+
*ngIf="formArray"
|
|
4
|
+
class="w-full mt-2 p-3 border-slate-200 border border-solid box-border"
|
|
5
|
+
>
|
|
6
|
+
<h1 *ngIf="!!formArray.label" class="font-bold py-3">
|
|
7
|
+
{{ formArray.label }}
|
|
8
|
+
</h1>
|
|
9
|
+
<div class="divide-y divide-solid">
|
|
10
|
+
<div
|
|
11
|
+
*ngIf="formArray.form"
|
|
12
|
+
[ngClass]="{ 'md:grid-cols-15': settings.withActionButtons }"
|
|
13
|
+
class="grid gap-4 grid-cols-12"
|
|
14
|
+
>
|
|
15
|
+
<ng-container *ngIf="!withFormHeader; else FORMHEADERREF">
|
|
16
|
+
<h2
|
|
17
|
+
[class]="item.styleClasses"
|
|
18
|
+
*ngFor="let item of formArray.form.controls | controlsList"
|
|
19
|
+
>
|
|
20
|
+
{{ item.label }}
|
|
21
|
+
</h2>
|
|
22
|
+
<div
|
|
23
|
+
*ngIf="settings.withActionButtons"
|
|
24
|
+
class="
|
|
25
|
+
col-start-7 col-end-13
|
|
26
|
+
md:col-start-13 md:col-end-16
|
|
27
|
+
pb-5
|
|
28
|
+
my-auto
|
|
29
|
+
ml-auto
|
|
30
|
+
md:m-auto
|
|
31
|
+
"
|
|
32
|
+
></div>
|
|
33
|
+
</ng-container>
|
|
34
|
+
<ng-template #FORMHEADERREF>
|
|
35
|
+
<ng-template
|
|
36
|
+
*ngFor="let item of formArray.form.controls | controlsList"
|
|
37
|
+
controlRender
|
|
38
|
+
[components]="componentsBuffer"
|
|
39
|
+
[control]="item"
|
|
40
|
+
></ng-template>
|
|
41
|
+
<div
|
|
42
|
+
*ngIf="settings.withActionButtons"
|
|
43
|
+
class="
|
|
44
|
+
col-start-7 col-end-13
|
|
45
|
+
md:col-start-13 md:col-end-16
|
|
46
|
+
pb-5
|
|
47
|
+
my-auto
|
|
48
|
+
ml-auto
|
|
49
|
+
md:m-auto
|
|
50
|
+
"
|
|
51
|
+
>
|
|
52
|
+
<button
|
|
53
|
+
mat-flat-button
|
|
54
|
+
color="primary"
|
|
55
|
+
[disabled]="formArray.form.invalid"
|
|
56
|
+
(click)="addItem()"
|
|
57
|
+
>
|
|
58
|
+
Add
|
|
59
|
+
</button>
|
|
60
|
+
</div>
|
|
61
|
+
</ng-template>
|
|
62
|
+
</div>
|
|
63
|
+
<div
|
|
64
|
+
class="w-full pt-5 grid gap-4 grid-cols-12 md:grid-cols-15"
|
|
65
|
+
*ngFor="let formGroup of formArray.controls; let i = index"
|
|
66
|
+
>
|
|
67
|
+
<ng-template
|
|
68
|
+
*ngFor="let item of formGroup.controls | controlsList"
|
|
69
|
+
controlRender
|
|
70
|
+
[components]="componentsBuffer"
|
|
71
|
+
[control]="item"
|
|
72
|
+
></ng-template>
|
|
73
|
+
<div
|
|
74
|
+
class="
|
|
75
|
+
col-start-7 col-end-13
|
|
76
|
+
md:col-start-13 md:col-end-16
|
|
77
|
+
pb-5
|
|
78
|
+
my-auto
|
|
79
|
+
ml-auto
|
|
80
|
+
md:m-auto
|
|
81
|
+
"
|
|
82
|
+
>
|
|
83
|
+
<button mat-flat-button color="warn" (click)="removeItem(i)">
|
|
84
|
+
Remove
|
|
85
|
+
</button>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<!-- <table class="form-array-container__table">
|
|
93
|
+
<thead *ngIf="formArray.form">
|
|
94
|
+
<tr
|
|
95
|
+
*ngIf="headerForm; else HEADERFORMREF"
|
|
96
|
+
class="form-array-container__table-header"
|
|
97
|
+
>
|
|
98
|
+
<th
|
|
99
|
+
class="header-cell"
|
|
100
|
+
*ngFor="let control of formArray.form | controlsList"
|
|
101
|
+
>
|
|
102
|
+
{{ control.label | translate }}
|
|
103
|
+
</th>
|
|
104
|
+
<th *ngIf="!formArray.readOnly"></th>
|
|
105
|
+
</tr>
|
|
106
|
+
<ng-template #HEADERFORMREF>
|
|
107
|
+
<tr class="table-form-header">
|
|
108
|
+
<th
|
|
109
|
+
class="header-cell"
|
|
110
|
+
[ngSwitch]="control.type"
|
|
111
|
+
*ngFor="let control of formArray.form | controlsList"
|
|
112
|
+
>
|
|
113
|
+
<sp-form-control-selector
|
|
114
|
+
[control]="control"
|
|
115
|
+
></sp-form-control-selector>
|
|
116
|
+
</th>
|
|
117
|
+
<th class="header-cell" *ngIf="!formArray.readOnly">
|
|
118
|
+
<ng-container *ngTemplateOutlet="ADDBUTTON"></ng-container>
|
|
119
|
+
</th>
|
|
120
|
+
</tr>
|
|
121
|
+
</ng-template>
|
|
122
|
+
</thead> -->
|
|
123
|
+
|
|
124
|
+
<!-- [ngStyle]="{'max-height':'calc(100vh - '+maxHeight+'px)' }"> -->
|
|
125
|
+
<!-- <tbody>
|
|
126
|
+
<tr *ngFor="let formGroup of formArray.controls; let i = index">
|
|
127
|
+
<td [ngSwitch]="control.type" *ngFor="let control of formGroup.controls | controlsList">
|
|
128
|
+
<sp-form-control-selector
|
|
129
|
+
[control]="control"
|
|
130
|
+
></sp-form-control-selector>
|
|
131
|
+
</td>
|
|
132
|
+
<td *ngIf="!formArray.readOnly">
|
|
133
|
+
<bmb-button
|
|
134
|
+
[icon]="'delete_outline'"
|
|
135
|
+
[type]="'Raised'"
|
|
136
|
+
[size]="'XLarge'"
|
|
137
|
+
[bdrColor]="'error-500'"
|
|
138
|
+
[tColor]="'error-500'"
|
|
139
|
+
(onClick)="deleteItem(i)"
|
|
140
|
+
>
|
|
141
|
+
</bmb-button>
|
|
142
|
+
</td>
|
|
143
|
+
</tr>
|
|
144
|
+
</tbody> -->
|
|
145
|
+
<!-- </table> -->
|
|
146
|
+
|
|
147
|
+
<!-- <ng-template #TABLET>
|
|
148
|
+
<div class="mt-1">
|
|
149
|
+
<ng-container *ngIf="headerFormEnable">
|
|
150
|
+
<div class="card-form-container">
|
|
151
|
+
<automatic-forms [form]="formArray.form" [enableButtons]="false">
|
|
152
|
+
</automatic-forms>
|
|
153
|
+
<ng-container *ngTemplateOutlet="ADDBUTTON"></ng-container>
|
|
154
|
+
</div>
|
|
155
|
+
</ng-container>
|
|
156
|
+
<ng-content select="[header]"></ng-content>
|
|
157
|
+
</div>
|
|
158
|
+
<div class="accordion-container">
|
|
159
|
+
<mat-accordion>
|
|
160
|
+
<mat-expansion-panel
|
|
161
|
+
class="mat-elevation-z1"
|
|
162
|
+
*ngFor="let item of formArray.controls; let i = index"
|
|
163
|
+
>
|
|
164
|
+
<mat-expansion-panel-header
|
|
165
|
+
class="expanded-header"
|
|
166
|
+
collapsedHeight="3rem"
|
|
167
|
+
expandedHeight="3rem"
|
|
168
|
+
>
|
|
169
|
+
<ng-container
|
|
170
|
+
*ngTemplateOutlet="cardHeaderTemplate; context: { $implicit: item }"
|
|
171
|
+
>
|
|
172
|
+
</ng-container>
|
|
173
|
+
<mat-icon
|
|
174
|
+
*ngIf="!formArray.readOnly"
|
|
175
|
+
class="mobile-delete"
|
|
176
|
+
(click)="deleteItem(i)"
|
|
177
|
+
color="warn"
|
|
178
|
+
>
|
|
179
|
+
delete_outline
|
|
180
|
+
</mat-icon>
|
|
181
|
+
</mat-expansion-panel-header>
|
|
182
|
+
<ng-container
|
|
183
|
+
*ngTemplateOutlet="cardBodyTemplate; context: { $implicit: item }"
|
|
184
|
+
>
|
|
185
|
+
</ng-container>
|
|
186
|
+
</mat-expansion-panel>
|
|
187
|
+
</mat-accordion>
|
|
188
|
+
</div>
|
|
189
|
+
</ng-template>
|
|
190
|
+
|
|
191
|
+
<div class="text-error" *ngIf="formArray.dirty && formArray.invalid">
|
|
192
|
+
{{ formArray.errors | errorMessage | translate }}
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<ng-template #ADDBUTTON>
|
|
196
|
+
<div class="add-item-btn">
|
|
197
|
+
<bmb-button
|
|
198
|
+
[icon]="'add'"
|
|
199
|
+
[type]="'Raised'"
|
|
200
|
+
[bdrColor]="'aux-success'"
|
|
201
|
+
[size]="'XLarge'"
|
|
202
|
+
[tColor]="'aux-success'"
|
|
203
|
+
[disabled]="!formArray.form.valid || !formArray.form.dirty"
|
|
204
|
+
(onClick)="addItemAction()"
|
|
205
|
+
>
|
|
206
|
+
</bmb-button>
|
|
207
|
+
</div>
|
|
208
|
+
</ng-template> -->
|
package/projects/special-forms/src/lib/components/special-form/special-form-array.component.scss
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// // @import "../../../scss-modules/variables.scss";
|
|
2
|
+
:host{
|
|
3
|
+
display: contents;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// .form-array-container {
|
|
7
|
+
// padding: 0;
|
|
8
|
+
// font-family: var(--font-family-primary);
|
|
9
|
+
// width: 100%;
|
|
10
|
+
// box-sizing: border-box;
|
|
11
|
+
// font-size: var(--font-size-small);
|
|
12
|
+
|
|
13
|
+
// &__table {
|
|
14
|
+
// border-collapse: collapse;
|
|
15
|
+
// width: 100%;
|
|
16
|
+
// }
|
|
17
|
+
// &__table-header {
|
|
18
|
+
// background-color: var(--color-primary-500);
|
|
19
|
+
// color: var(--color-primary-50);
|
|
20
|
+
// }
|
|
21
|
+
// thead {
|
|
22
|
+
// width: calc(100% - 5px);
|
|
23
|
+
// }
|
|
24
|
+
|
|
25
|
+
// thead,
|
|
26
|
+
// tbody tr {
|
|
27
|
+
// display: table;
|
|
28
|
+
// width: 100%;
|
|
29
|
+
// table-layout: fixed;
|
|
30
|
+
// }
|
|
31
|
+
|
|
32
|
+
// tbody {
|
|
33
|
+
// display: block;
|
|
34
|
+
// overflow-y: auto;
|
|
35
|
+
// }
|
|
36
|
+
|
|
37
|
+
// td,
|
|
38
|
+
// th {
|
|
39
|
+
// padding: 5px;
|
|
40
|
+
// box-sizing: border-box;
|
|
41
|
+
// text-align: left;
|
|
42
|
+
// }
|
|
43
|
+
|
|
44
|
+
// tr:nth-child(even) {
|
|
45
|
+
// // background-color: var(--color-primary-50);
|
|
46
|
+
// }
|
|
47
|
+
// }
|
|
48
|
+
|
|
49
|
+
// .add-item-btn {
|
|
50
|
+
// width: 100%;
|
|
51
|
+
// display: flex;
|
|
52
|
+
// justify-content: center;
|
|
53
|
+
// align-items: center;
|
|
54
|
+
// margin-bottom: 13px;
|
|
55
|
+
// @media only screen and (max-width: $screem-sm) {
|
|
56
|
+
// justify-content: flex-end;
|
|
57
|
+
// }
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
// .accordion-container {
|
|
61
|
+
// margin-top: 1rem;
|
|
62
|
+
|
|
63
|
+
// .expanded-header {
|
|
64
|
+
// background-color: var(--color-primary-50-10);
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
// .mobile-delete {
|
|
69
|
+
// margin-right: 16px;
|
|
70
|
+
// }
|
package/projects/special-forms/src/lib/components/special-form/special-form-array.component.spec.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { SpecialArrayComponent } from './special-form.component';
|
|
3
|
+
|
|
4
|
+
describe('SpecialArrayComponent', () => {
|
|
5
|
+
let component: SpecialArrayComponent;
|
|
6
|
+
let fixture: ComponentFixture<SpecialArrayComponent>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async(() => {
|
|
9
|
+
TestBed.configureTestingModule({
|
|
10
|
+
declarations: [SpecialArrayComponent],
|
|
11
|
+
}).compileComponents();
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
fixture = TestBed.createComponent(SpecialArrayComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
4
|
+
import { FormControlsListPipeModule } from '../../pipes/controls-list-pipe/controls-list.pipe.module';
|
|
5
|
+
import { ControlsRenderDirectiveModule } from '../../core/directives/control-render.module';
|
|
6
|
+
import { SpecialArrayComponent } from './special-form.component';
|
|
7
|
+
|
|
8
|
+
@NgModule({
|
|
9
|
+
declarations: [SpecialArrayComponent],
|
|
10
|
+
imports: [
|
|
11
|
+
CommonModule,
|
|
12
|
+
FormControlsListPipeModule,
|
|
13
|
+
MatButtonModule,
|
|
14
|
+
ControlsRenderDirectiveModule,
|
|
15
|
+
],
|
|
16
|
+
exports: [SpecialArrayComponent],
|
|
17
|
+
})
|
|
18
|
+
export class SpecialArrayModule {}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<div class="w-full box-border p-2">
|
|
2
|
+
<div
|
|
3
|
+
*ngIf="form"
|
|
4
|
+
[class]="
|
|
5
|
+
form.label
|
|
6
|
+
? 'w-full mt-2 p-3 border-slate-200 border border-solid box-border'
|
|
7
|
+
: 'container'
|
|
8
|
+
"
|
|
9
|
+
>
|
|
10
|
+
<h1 *ngIf="!!form.label" class="font-bold py-3">{{ form.label }}</h1>
|
|
11
|
+
<div class="w-full flex flex-wrap">
|
|
12
|
+
<ng-template
|
|
13
|
+
*ngFor="let control of form.controls | controlsList"
|
|
14
|
+
controlRender
|
|
15
|
+
[control]="control"
|
|
16
|
+
[components]="componentsBuffer"
|
|
17
|
+
></ng-template>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { SpecialFormComponent } from './special-form.component';
|
|
3
|
+
|
|
4
|
+
describe('SpecialFormComponent', () => {
|
|
5
|
+
let component: SpecialFormComponent;
|
|
6
|
+
let fixture: ComponentFixture<SpecialFormComponent>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
await TestBed.configureTestingModule({
|
|
10
|
+
declarations: [ SpecialFormComponent ]
|
|
11
|
+
})
|
|
12
|
+
.compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(SpecialFormComponent);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
fixture.detectChanges();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|