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.
Files changed (182) hide show
  1. package/.editorconfig +16 -0
  2. package/.storybook/db-theme.js +8 -0
  3. package/.storybook/main.js +15 -0
  4. package/.storybook/manager.js +7 -0
  5. package/.storybook/preview-head.html +16 -0
  6. package/.storybook/preview.js +20 -0
  7. package/.storybook/tsconfig.json +21 -0
  8. package/.storybook/typings.d.ts +4 -0
  9. package/.vscode/extensions.json +4 -0
  10. package/.vscode/launch.json +20 -0
  11. package/.vscode/tasks.json +42 -0
  12. package/README.md +27 -0
  13. package/angular.json +38 -0
  14. package/documentation.json +10829 -0
  15. package/package.json +65 -0
  16. package/projects/special-forms/README.md +24 -0
  17. package/projects/special-forms/karma.conf.js +44 -0
  18. package/projects/special-forms/ng-package.json +7 -0
  19. package/projects/special-forms/package.json +11 -0
  20. package/projects/special-forms/src/lib/assets/styles.scss +213 -0
  21. package/projects/special-forms/src/lib/assets/themes/dark.scss +80 -0
  22. package/projects/special-forms/src/lib/assets/themes/light.scss +78 -0
  23. package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.html +5 -0
  24. package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.scss +6 -0
  25. package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.spec.ts +21 -0
  26. package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.component.ts +21 -0
  27. package/projects/special-forms/src/lib/aux-storybook-components/form-control-selector/form-control-selector.module.ts +36 -0
  28. package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.html +5 -0
  29. package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.scss +18 -0
  30. package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.spec.ts +23 -0
  31. package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.component.ts +66 -0
  32. package/projects/special-forms/src/lib/aux-storybook-components/form-control-viewer/form-control-viewer.module.ts +16 -0
  33. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.html +31 -0
  34. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.scss +0 -0
  35. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.spec.ts +22 -0
  36. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/control-dialog.component.ts +102 -0
  37. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/autocomplete.form.ts +87 -0
  38. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/checkbox.form.ts +51 -0
  39. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/common.form.interface.ts +24 -0
  40. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/common.form.ts +31 -0
  41. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/datepicker.form.ts +56 -0
  42. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/dropdown.form.ts +80 -0
  43. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/field.form.ts +189 -0
  44. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/input.form.ts +71 -0
  45. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/label.form.ts +33 -0
  46. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/text-area.form.ts +17 -0
  47. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/components/settings-strategy/upload.form.ts +35 -0
  48. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.html +37 -0
  49. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.scss +41 -0
  50. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.spec.ts +22 -0
  51. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.component.ts +95 -0
  52. package/projects/special-forms/src/lib/aux-storybook-components/form-group-viewer/form-group-viewer.module.ts +32 -0
  53. package/projects/special-forms/src/lib/components/index.ts +61 -0
  54. package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.html +62 -0
  55. package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.scss +3 -0
  56. package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.spec.ts +24 -0
  57. package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.component.ts +58 -0
  58. package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.interface.ts +20 -0
  59. package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.module.ts +25 -0
  60. package/projects/special-forms/src/lib/components/special-autocomplete/special-autocomplete.stories.ts +81 -0
  61. package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.html +17 -0
  62. package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.scss +3 -0
  63. package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.spec.ts +23 -0
  64. package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.component.ts +19 -0
  65. package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.interface.ts +12 -0
  66. package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.module.ts +25 -0
  67. package/projects/special-forms/src/lib/components/special-checkbox/special-checkbox.stories.ts +76 -0
  68. package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.html +26 -0
  69. package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.scss +3 -0
  70. package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.spec.ts +23 -0
  71. package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.component.ts +21 -0
  72. package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.interface.ts +13 -0
  73. package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.module.ts +26 -0
  74. package/projects/special-forms/src/lib/components/special-datepicker/special-datepicker.stories.ts +69 -0
  75. package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.html +41 -0
  76. package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.scss +15 -0
  77. package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.spec.ts +24 -0
  78. package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.component.ts +34 -0
  79. package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.interface.ts +18 -0
  80. package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.module.ts +22 -0
  81. package/projects/special-forms/src/lib/components/special-dropdown/special-dropdown.stories.ts +83 -0
  82. package/projects/special-forms/src/lib/components/special-form/special-form-array.component.html +208 -0
  83. package/projects/special-forms/src/lib/components/special-form/special-form-array.component.scss +70 -0
  84. package/projects/special-forms/src/lib/components/special-form/special-form-array.component.spec.ts +23 -0
  85. package/projects/special-forms/src/lib/components/special-form/special-form-array.module.ts +18 -0
  86. package/projects/special-forms/src/lib/components/special-form/special-form.component.html +20 -0
  87. package/projects/special-forms/src/lib/components/special-form/special-form.component.scss +3 -0
  88. package/projects/special-forms/src/lib/components/special-form/special-form.component.spec.ts +22 -0
  89. package/projects/special-forms/src/lib/components/special-form/special-form.component.ts +85 -0
  90. package/projects/special-forms/src/lib/components/special-form/special-form.module.ts +40 -0
  91. package/projects/special-forms/src/lib/components/special-form/special-form.stories.ts +45 -0
  92. package/projects/special-forms/src/lib/components/special-input/special-input.component.html +37 -0
  93. package/projects/special-forms/src/lib/components/special-input/special-input.component.scss +3 -0
  94. package/projects/special-forms/src/lib/components/special-input/special-input.component.spec.ts +23 -0
  95. package/projects/special-forms/src/lib/components/special-input/special-input.component.ts +39 -0
  96. package/projects/special-forms/src/lib/components/special-input/special-input.interface.ts +17 -0
  97. package/projects/special-forms/src/lib/components/special-input/special-input.module.ts +24 -0
  98. package/projects/special-forms/src/lib/components/special-input/special-input.stories.ts +91 -0
  99. package/projects/special-forms/src/lib/components/special-label/special-label.component.html +6 -0
  100. package/projects/special-forms/src/lib/components/special-label/special-label.component.scss +3 -0
  101. package/projects/special-forms/src/lib/components/special-label/special-label.component.spec.ts +23 -0
  102. package/projects/special-forms/src/lib/components/special-label/special-label.component.ts +27 -0
  103. package/projects/special-forms/src/lib/components/special-label/special-label.interface.ts +14 -0
  104. package/projects/special-forms/src/lib/components/special-label/special-label.module.ts +25 -0
  105. package/projects/special-forms/src/lib/components/special-label/special-label.stories.ts +99 -0
  106. package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.html +82 -0
  107. package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.scss +3 -0
  108. package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.spec.ts +23 -0
  109. package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.component.ts +86 -0
  110. package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.interface.ts +20 -0
  111. package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.module.ts +28 -0
  112. package/projects/special-forms/src/lib/components/special-multiple-autocomplete/special-multiple-autocomplete.stories.ts +81 -0
  113. package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.html +29 -0
  114. package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.scss +3 -0
  115. package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.spec.ts +23 -0
  116. package/projects/special-forms/src/lib/components/special-text-area/special-text-area.component.ts +20 -0
  117. package/projects/special-forms/src/lib/components/special-text-area/special-text-area.interface.ts +9 -0
  118. package/projects/special-forms/src/lib/components/special-text-area/special-text-area.module.ts +24 -0
  119. package/projects/special-forms/src/lib/components/special-text-area/special-text-area.stories.ts +69 -0
  120. package/projects/special-forms/src/lib/components/special-upload/special-upload.component.html +50 -0
  121. package/projects/special-forms/src/lib/components/special-upload/special-upload.component.scss +29 -0
  122. package/projects/special-forms/src/lib/components/special-upload/special-upload.component.spec.ts +23 -0
  123. package/projects/special-forms/src/lib/components/special-upload/special-upload.component.ts +79 -0
  124. package/projects/special-forms/src/lib/components/special-upload/special-upload.interface.ts +12 -0
  125. package/projects/special-forms/src/lib/components/special-upload/special-upload.module.ts +23 -0
  126. package/projects/special-forms/src/lib/components/special-upload/special-upload.stories.ts +81 -0
  127. package/projects/special-forms/src/lib/core/aux-data/all-icons.ts +99 -0
  128. package/projects/special-forms/src/lib/core/aux-data/control-types.enum.ts +16 -0
  129. package/projects/special-forms/src/lib/core/aux-data/countries.ts +247 -0
  130. package/projects/special-forms/src/lib/core/aux-data/field-basic-data.ts +14 -0
  131. package/projects/special-forms/src/lib/core/aux-data/input-types.ts +23 -0
  132. package/projects/special-forms/src/lib/core/controls/icons.control.ts +8 -0
  133. package/projects/special-forms/src/lib/core/controls/index.ts +2 -0
  134. package/projects/special-forms/src/lib/core/controls/theme.control.ts +1 -0
  135. package/projects/special-forms/src/lib/core/controls/types.control.ts +9 -0
  136. package/projects/special-forms/src/lib/core/directives/control-render.directive.ts +19 -0
  137. package/projects/special-forms/src/lib/core/directives/control-render.module.ts +10 -0
  138. package/projects/special-forms/src/lib/core/forms/special-forms.ts +395 -0
  139. package/projects/special-forms/src/lib/core/interfaces/field-basics.interfaces.ts +22 -0
  140. package/projects/special-forms/src/lib/core/interfaces/form.interfaces.ts +83 -0
  141. package/projects/special-forms/src/lib/core/interfaces/special-control.interface.ts +9 -0
  142. package/projects/special-forms/src/lib/core/masks/currency.mask.ts +11 -0
  143. package/projects/special-forms/src/lib/core/masks/maks.enum.ts +12 -0
  144. package/projects/special-forms/src/lib/core/masks/number.mask.ts +4 -0
  145. package/projects/special-forms/src/lib/core/services/index.ts +3 -0
  146. package/projects/special-forms/src/lib/core/services/special-form-builder/special-form-builder.service.spec.ts +16 -0
  147. package/projects/special-forms/src/lib/core/services/special-form-builder/special-form-builder.service.ts +220 -0
  148. package/projects/special-forms/src/lib/core/utils/enum-to-array.util.ts +6 -0
  149. package/projects/special-forms/src/lib/pipes/controls-list-pipe/controls-list.pipe.module.ts +10 -0
  150. package/projects/special-forms/src/lib/pipes/controls-list-pipe/controls-list.pipe.ts +17 -0
  151. package/projects/special-forms/src/lib/pipes/error-message-pipe/error.pipe.module.ts +13 -0
  152. package/projects/special-forms/src/lib/pipes/error-message-pipe/error.pipe.ts +21 -0
  153. package/projects/special-forms/src/lib/pipes/index.ts +3 -0
  154. package/projects/special-forms/src/lib/pipes/text-by-function/text-by-function.pipe.module.ts +13 -0
  155. package/projects/special-forms/src/lib/pipes/text-by-function/text-by-function.pipe.ts +14 -0
  156. package/projects/special-forms/src/public-api.ts +8 -0
  157. package/projects/special-forms/src/test.ts +27 -0
  158. package/projects/special-forms/tsconfig.lib.json +15 -0
  159. package/projects/special-forms/tsconfig.lib.prod.json +10 -0
  160. package/projects/special-forms/tsconfig.spec.json +17 -0
  161. package/scss-bundle.config.json +6 -0
  162. package/stories/Button.stories.ts +42 -0
  163. package/stories/Header.stories.ts +35 -0
  164. package/stories/Introduction.stories.mdx +211 -0
  165. package/stories/Page.stories.ts +36 -0
  166. package/stories/User.ts +2 -0
  167. package/stories/assets/code-brackets.svg +1 -0
  168. package/stories/assets/colors.svg +1 -0
  169. package/stories/assets/comments.svg +1 -0
  170. package/stories/assets/direction.svg +1 -0
  171. package/stories/assets/flow.svg +1 -0
  172. package/stories/assets/plugin.svg +1 -0
  173. package/stories/assets/repo.svg +1 -0
  174. package/stories/assets/stackalt.svg +1 -0
  175. package/stories/button.component.ts +53 -0
  176. package/stories/button.css +30 -0
  177. package/stories/header.component.ts +75 -0
  178. package/stories/header.css +32 -0
  179. package/stories/page.component.ts +77 -0
  180. package/stories/page.css +69 -0
  181. package/tailwind.config.js +30 -0
  182. package/tsconfig.json +39 -0
@@ -0,0 +1,62 @@
1
+ <ng-container *ngIf="control && !control.hidden">
2
+ <mat-form-field
3
+ class="w-full {{ control.styleClasses }}"
4
+ [appearance]="control.label ? 'outline' : 'standard'"
5
+ >
6
+ <mat-label
7
+ [ngClass]="{ 'is-link': control.label }"
8
+ class="control-label"
9
+ *ngIf="control.label"
10
+ >
11
+ {{ control.label }}
12
+ </mat-label>
13
+ <input
14
+ type="text"
15
+ autocomplete="off"
16
+ [required]="control.required"
17
+ [readonly]="control.readOnly"
18
+ [placeholder]="control.placeholder"
19
+ matInput
20
+ [formControl]="control"
21
+ [matAutocomplete]="auto"
22
+ />
23
+ <mat-autocomplete
24
+ class="autocomplete-options"
25
+ #auto="matAutocomplete"
26
+ [displayWith]="configValue"
27
+ (optionSelected)="optionSelected($event)"
28
+ >
29
+ <mat-option
30
+ *ngFor="let option of settings?.source | async"
31
+ [value]="option"
32
+ >
33
+ <div class="flex items-center">
34
+ <img
35
+ *ngIf="settings.fieldImage"
36
+ class="w-8 pr-2"
37
+ alt=""
38
+ [src]="option | textByFunction: settings.fieldImage"
39
+ />
40
+ <span>
41
+ {{ option | textByFunction: settings.fieldName }}
42
+ </span>
43
+ </div>
44
+ </mat-option>
45
+ </mat-autocomplete>
46
+ <mat-icon *ngIf="control.icon" matPrefix>{{ control.icon }}</mat-icon>
47
+ <button
48
+ *ngIf="settings.icon"
49
+ mat-icon-button
50
+ matSuffix
51
+ (click)="iconClick($event)"
52
+ >
53
+ <mat-icon>
54
+ {{ settings.icon }}
55
+ </mat-icon>
56
+ </button>
57
+ <mat-hint>{{ control.tooltip }}</mat-hint>
58
+ <mat-error>
59
+ {{ control.errors | errorMessage: control.errorMessages }}
60
+ </mat-error>
61
+ </mat-form-field>
62
+ </ng-container>
@@ -0,0 +1,24 @@
1
+ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { SpecialAutocompleteComponent } from './special-autocomplete.component';
4
+
5
+ describe('SpecialAutocompleteComponent', () => {
6
+ let component: SpecialAutocompleteComponent;
7
+ let fixture: ComponentFixture<SpecialAutocompleteComponent>;
8
+
9
+ beforeEach(async(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [SpecialAutocompleteComponent],
12
+ }).compileComponents();
13
+ }));
14
+
15
+ beforeEach(() => {
16
+ fixture = TestBed.createComponent(SpecialAutocompleteComponent);
17
+ component = fixture.componentInstance;
18
+ fixture.detectChanges();
19
+ });
20
+
21
+ it('should create', () => {
22
+ expect(component).toBeTruthy();
23
+ });
24
+ });
@@ -0,0 +1,58 @@
1
+ import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
2
+ import { debounceTime } from 'rxjs/operators';
3
+ import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
4
+ import { Subscription } from 'rxjs';
5
+ import { SpecialFormControl } from '../../core/forms/special-forms';
6
+ import { IAutocompleteSettings } from './special-autocomplete.interface';
7
+ @Component({
8
+ selector: 'sp-autocomplete',
9
+ templateUrl: './special-autocomplete.component.html',
10
+ styleUrls: ['./special-autocomplete.component.scss'],
11
+ changeDetection: ChangeDetectionStrategy.OnPush,
12
+ })
13
+ export class SpecialAutocompleteComponent {
14
+ @Input() control: SpecialFormControl<IAutocompleteSettings>;
15
+
16
+ subs = new Subscription();
17
+
18
+ constructor() {}
19
+
20
+ ngOnInit() {
21
+ this.init();
22
+ }
23
+
24
+ get settings(): IAutocompleteSettings {
25
+ return this.control.settings;
26
+ }
27
+
28
+ init() {
29
+ this.subs.add(
30
+ this.control.valueChanges.pipe(debounceTime(500)).subscribe((value) => {
31
+ if (typeof value === 'string') {
32
+ this.settings.getData(value, this.control);
33
+ }
34
+ })
35
+ );
36
+ }
37
+ configValue = (item: any) => {
38
+ if (!item) return '';
39
+ const fieldName = this.settings.fieldName;
40
+ return fieldName instanceof Function ? fieldName(item) : item[fieldName];
41
+ };
42
+
43
+ optionSelected(data: MatAutocompleteSelectedEvent) {
44
+ this.control.setValue(data.option.value);
45
+ if (this.settings.onSelect) this.settings.onSelect(data.option.value);
46
+ }
47
+
48
+ iconClick(event) {
49
+ if (this.settings.iconAction) {
50
+ this.settings.iconAction(this.control.value);
51
+ event.stopPropagation();
52
+ }
53
+ }
54
+
55
+ ngOnDestroy() {
56
+ this.subs.unsubscribe();
57
+ }
58
+ }
@@ -0,0 +1,20 @@
1
+ import { AbstractControl } from '@angular/forms';
2
+ import { Observable } from 'rxjs';
3
+ import { EControlTypes } from '../../core/aux-data/control-types.enum';
4
+ import { IFieldData } from '../../core/interfaces/field-basics.interfaces';
5
+
6
+ export type IAutocompleteSettings = {
7
+ getData: (query: string, control?: AbstractControl) => void;
8
+ source: Observable<any[]>;
9
+ fieldId: string;
10
+ icon?: string;
11
+ iconAction?: (data: any) => void;
12
+ onSelect?: (data: any) => void;
13
+ fieldName: string | ((a?: any) => string);
14
+ fieldImage?: string | ((a?: any) => string);
15
+ };
16
+
17
+ export interface IAutocompleteField extends IFieldData {
18
+ settings: IAutocompleteSettings;
19
+ type: EControlTypes.autocomplete;
20
+ }
@@ -0,0 +1,25 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { MatAutocompleteModule } from '@angular/material/autocomplete';
4
+ import { MatButtonModule } from '@angular/material/button';
5
+ import { MatIconModule } from '@angular/material/icon';
6
+ import { ReactiveFormsModule } from '@angular/forms';
7
+ import { ErrorMessagePipeModule, TextByFunctionPipeModule } from '../../pipes';
8
+ import { SpecialAutocompleteComponent } from './special-autocomplete.component';
9
+ import { MatInputModule } from '@angular/material/input';
10
+
11
+ @NgModule({
12
+ declarations: [SpecialAutocompleteComponent],
13
+ imports: [
14
+ MatInputModule,
15
+ CommonModule,
16
+ MatAutocompleteModule,
17
+ MatIconModule,
18
+ ReactiveFormsModule,
19
+ MatButtonModule,
20
+ ErrorMessagePipeModule,
21
+ TextByFunctionPipeModule,
22
+ ],
23
+ exports: [SpecialAutocompleteComponent],
24
+ })
25
+ export class SpecialAutocompleteModule {}
@@ -0,0 +1,81 @@
1
+ import { Meta, moduleMetadata, Story } from '@storybook/angular';
2
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
3
+ import { FormControlViewerModule } from '../../aux-storybook-components/form-control-viewer/form-control-viewer.module';
4
+ import { FormControlViewerComponent } from '../../aux-storybook-components/form-control-viewer/form-control-viewer.component';
5
+ import { ICONS_CONTROL } from '../../core/controls/icons.control';
6
+ import { action } from '@storybook/addon-actions';
7
+ import { countries } from '../../core/aux-data/countries';
8
+ import { EControlTypes } from '../../core/aux-data/control-types.enum';
9
+ import { THEMES_CONTROL } from '../../core/controls/theme.control';
10
+ import { FieldBasicData } from '../../core/aux-data/field-basic-data';
11
+
12
+ export default {
13
+ title: 'Special autocomplete control',
14
+ component: FormControlViewerComponent,
15
+ decorators: [
16
+ moduleMetadata({
17
+ imports: [FormControlViewerModule, BrowserAnimationsModule],
18
+ }),
19
+ ],
20
+ argTypes: {
21
+ icon: ICONS_CONTROL,
22
+ theme: THEMES_CONTROL,
23
+ },
24
+ } as Meta;
25
+
26
+ const Template: Story<FormControlViewerComponent> = (
27
+ args: FormControlViewerComponent
28
+ ) => ({
29
+ title: 'Special autocomplete control',
30
+ template: `
31
+ <spf-form-control-viewer
32
+ (getData)="getData($event)"
33
+ [theme]="theme"
34
+ [autocomplete]="{
35
+ placeholder: placeholder,
36
+ label: label,
37
+ tooltip: tooltip,
38
+ icon: icon,
39
+ elementId: elementId,
40
+ styleClasses: styleClasses,
41
+ length: 0,
42
+ required: required,
43
+ hidden: false,
44
+ readOnly: readOnly,
45
+ defaultValue: defaultValue,
46
+ errorMessages: errorMessages,
47
+ type:type,
48
+ settings:{
49
+ fieldId: fieldId,
50
+ fieldName:fieldName,
51
+ source:source
52
+ }
53
+ }"
54
+ >
55
+ </spf-form-control-viewer>`,
56
+ props: {
57
+ ...args,
58
+ type: EControlTypes.autocomplete,
59
+ getData: action('Get data'),
60
+ },
61
+ });
62
+
63
+ export const light = Template.bind({});
64
+ light.args = {
65
+ ...FieldBasicData,
66
+ theme: 'light-theme',
67
+ defaultValue: { name: 'Colombia', code: 'CO' },
68
+ fieldName: 'name',
69
+ fieldId: 'code',
70
+ source: countries(),
71
+ };
72
+
73
+ export const dark = Template.bind({});
74
+ dark.args = {
75
+ ...FieldBasicData,
76
+ theme: 'dark-theme',
77
+ defaultValue: { name: 'Colombia', code: 'CO' },
78
+ fieldName: 'name',
79
+ fieldId: 'code',
80
+ source: countries(),
81
+ };
@@ -0,0 +1,17 @@
1
+ <div
2
+ *ngIf="control"
3
+ [id]="control.elementId"
4
+ class="w-full flex flex-col {{ control.styleClasses }}"
5
+ >
6
+ <mat-label *ngIf="control.label">{{ control.label }}</mat-label>
7
+ <mat-checkbox
8
+ [ngModel]="control.value"
9
+ (ngModelChange)="control.setValue($event); control.markAsDirty()"
10
+ [indeterminate]="control.settings.indeterminate"
11
+ [labelPosition]="control.settings.labelPosition"
12
+ [disabled]="control.disabled"
13
+ >
14
+ <mat-icon *ngIf="control.icon" matSuffix>{{ control.icon }} </mat-icon>
15
+ {{ control.placeholder }}
16
+ </mat-checkbox>
17
+ </div>
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { SpecialCheckboxComponent } from './special-checkbox.component';
4
+
5
+ describe('SpecialCheckboxComponent', () => {
6
+ let component: SpecialCheckboxComponent;
7
+ let fixture: ComponentFixture<SpecialCheckboxComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ SpecialCheckboxComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(SpecialCheckboxComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,19 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ Component,
4
+ Input,
5
+ OnInit,
6
+ } from '@angular/core';
7
+ import { SpecialFormControl } from '../../core/forms/special-forms';
8
+ import { ICheckboxSettings } from './special-checkbox.interface';
9
+ @Component({
10
+ selector: 'sp-checkbox',
11
+ templateUrl: './special-checkbox.component.html',
12
+ styleUrls: ['./special-checkbox.component.scss'],
13
+ changeDetection: ChangeDetectionStrategy.OnPush,
14
+ })
15
+ export class SpecialCheckboxComponent implements OnInit {
16
+ @Input() control: SpecialFormControl<ICheckboxSettings>;
17
+ constructor() {}
18
+ ngOnInit(): void {}
19
+ }
@@ -0,0 +1,12 @@
1
+ import { EControlTypes } from '../../core/aux-data/control-types.enum';
2
+ import { IFieldData } from '../../core/interfaces/field-basics.interfaces';
3
+
4
+ export type ICheckboxSettings = {
5
+ labelPosition?: 'before' | 'after';
6
+ indeterminate?:boolean
7
+ };
8
+
9
+ export interface ICheckboxField extends IFieldData {
10
+ settings: ICheckboxSettings;
11
+ type: EControlTypes.checkbox;
12
+ }
@@ -0,0 +1,25 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { SpecialCheckboxComponent } from './special-checkbox.component';
4
+ import { MatInputModule } from '@angular/material/input';
5
+ import { MatButtonModule } from '@angular/material/button';
6
+ import { MatIconModule } from '@angular/material/icon';
7
+ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
8
+ import { ErrorMessagePipeModule } from '../../pipes';
9
+ import {MatCheckboxModule} from '@angular/material/checkbox';
10
+
11
+ @NgModule({
12
+ declarations: [SpecialCheckboxComponent],
13
+ imports: [
14
+ FormsModule,
15
+ MatCheckboxModule,
16
+ CommonModule,
17
+ MatInputModule,
18
+ MatIconModule,
19
+ ReactiveFormsModule,
20
+ MatButtonModule,
21
+ ErrorMessagePipeModule
22
+ ],
23
+ exports: [SpecialCheckboxComponent],
24
+ })
25
+ export class SpecialCheckboxModule {}
@@ -0,0 +1,76 @@
1
+ import { Story, Meta } from '@storybook/angular';
2
+ import { moduleMetadata } from '@storybook/angular';
3
+ import { FormControlViewerModule } from '../../aux-storybook-components/form-control-viewer/form-control-viewer.module';
4
+ import { FormControlViewerComponent } from '../../aux-storybook-components/form-control-viewer/form-control-viewer.component';
5
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
6
+ import { EControlTypes } from '../../core/aux-data/control-types.enum';
7
+ import { ICONS_CONTROL } from '../../core/controls';
8
+ import { THEMES_CONTROL } from '../../core/controls/theme.control';
9
+ import { FieldBasicData } from '../../core/aux-data/field-basic-data';
10
+
11
+ export default {
12
+ title: 'Special checkbox control',
13
+ component: FormControlViewerComponent,
14
+ decorators: [
15
+ moduleMetadata({
16
+ imports: [FormControlViewerModule, BrowserAnimationsModule],
17
+ }),
18
+ ],
19
+ argTypes: {
20
+ icon: ICONS_CONTROL,
21
+ theme: THEMES_CONTROL,
22
+ labelPosition: { control: 'radio', options: ['before', 'after'] },
23
+ },
24
+ } as Meta;
25
+
26
+ const Template: Story<FormControlViewerComponent> = (
27
+ args: FormControlViewerComponent
28
+ ) => ({
29
+ title: 'Special checkbox control',
30
+ template: `
31
+ <spf-form-control-viewer
32
+ [theme]="theme"
33
+ [field]="{
34
+ placeholder: placeholder,
35
+ label: label,
36
+ tooltip: tooltip,
37
+ icon: icon,
38
+ elementId: elementId,
39
+ styleClasses: styleClasses,
40
+ length: length,
41
+ defaultValue:defaultValue,
42
+ required: required,
43
+ hidden: false,
44
+ type:type,
45
+ readOnly: readOnly,
46
+ settings:{
47
+ labelPosition:labelPosition,
48
+ indeterminate:indeterminate
49
+ },
50
+ errorMessages: errorMessages
51
+ }"
52
+ >
53
+ </spf-form-control-viewer>`,
54
+ props: {
55
+ ...args,
56
+ type: EControlTypes.checkbox,
57
+ },
58
+ });
59
+
60
+ export const light = Template.bind({});
61
+ light.args = {
62
+ ...FieldBasicData,
63
+ theme: 'light-theme',
64
+ defaultValue: false,
65
+ indeterminate: false,
66
+ labelPosition: 'before',
67
+ };
68
+
69
+ export const dark = Template.bind({});
70
+ dark.args = {
71
+ ...FieldBasicData,
72
+ theme: 'dark-theme',
73
+ defaultValue: true,
74
+ indeterminate: false,
75
+ labelPosition: 'before',
76
+ };
@@ -0,0 +1,26 @@
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">{{ control.label }}</mat-label>
8
+ <input
9
+ matInput
10
+ autocomplete="off"
11
+ [readonly]="control.readOnly"
12
+ [matDatepicker]="picker"
13
+ [required]="control.required"
14
+ [placeholder]="control.placeholder"
15
+ [formControl]="control"
16
+ />
17
+ <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
18
+ <mat-datepicker #picker startView="year" [startAt]="startAt">
19
+ </mat-datepicker>
20
+ <mat-hint>
21
+ {{ control.tooltip }}
22
+ </mat-hint>
23
+ <mat-error>
24
+ {{ control.errors | errorMessage: control.errorMessages }}
25
+ </mat-error>
26
+ </mat-form-field>
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { SpecialDatepickerComponent } from './special-datepicker.component';
4
+
5
+ describe('SpecialDatepickerComponent', () => {
6
+ let component: SpecialDatepickerComponent;
7
+ let fixture: ComponentFixture<SpecialDatepickerComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ SpecialDatepickerComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(SpecialDatepickerComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,21 @@
1
+ import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
2
+ import { SpecialFormControl } from '../../core/forms/special-forms';
3
+ import { IDatePickerSettings } from './special-datepicker.interface';
4
+
5
+ @Component({
6
+ selector: 'sp-datepicker',
7
+ templateUrl: './special-datepicker.component.html',
8
+ styleUrls: ['./special-datepicker.component.scss'],
9
+ changeDetection: ChangeDetectionStrategy.OnPush,
10
+ })
11
+ export class SpecialDatepickerComponent implements OnInit {
12
+ @Input() control: SpecialFormControl<IDatePickerSettings>;
13
+
14
+ constructor() {}
15
+
16
+ get startAt() {
17
+ return this.control.settings?.startAt || new Date();
18
+ }
19
+
20
+ ngOnInit(): void {}
21
+ }
@@ -0,0 +1,13 @@
1
+ import { EControlTypes } from '../../core/aux-data/control-types.enum';
2
+ import { IFieldData } from '../../core/interfaces/field-basics.interfaces';
3
+
4
+ export type IDatePickerSettings = {
5
+ lowerLimit?: number;
6
+ upperLimit?: number;
7
+ startAt?: Date;
8
+ };
9
+
10
+ export interface IDatePickerField extends IFieldData {
11
+ settings: IDatePickerSettings;
12
+ type: EControlTypes.date;
13
+ }
@@ -0,0 +1,26 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { SpecialDatepickerComponent } from './special-datepicker.component';
4
+ import { MatInputModule } from '@angular/material/input';
5
+ import { MatButtonModule } from '@angular/material/button';
6
+ import { MatIconModule } from '@angular/material/icon';
7
+ import { ReactiveFormsModule } from '@angular/forms';
8
+ import { ErrorMessagePipeModule } from '../../pipes';
9
+ import { MatDatepickerModule } from '@angular/material/datepicker';
10
+ import { MatNativeDateModule } from '@angular/material/core';
11
+
12
+ @NgModule({
13
+ declarations: [SpecialDatepickerComponent],
14
+ imports: [
15
+ MatInputModule,
16
+ MatDatepickerModule,
17
+ CommonModule,
18
+ MatIconModule,
19
+ ReactiveFormsModule,
20
+ MatButtonModule,
21
+ ErrorMessagePipeModule,
22
+ MatNativeDateModule
23
+ ],
24
+ exports: [SpecialDatepickerComponent],
25
+ })
26
+ export class SpecialDatepickerModule {}
@@ -0,0 +1,69 @@
1
+ import { Story, Meta } from '@storybook/angular';
2
+ import { moduleMetadata } from '@storybook/angular';
3
+ import { FormControlViewerModule } from '../../aux-storybook-components/form-control-viewer/form-control-viewer.module';
4
+ import { FormControlViewerComponent } from '../../aux-storybook-components/form-control-viewer/form-control-viewer.component';
5
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
6
+ import { ICONS_CONTROL } from '../../core/controls';
7
+ import { EControlTypes } from '../../core/aux-data/control-types.enum';
8
+ import { THEMES_CONTROL } from '../../core/controls/theme.control';
9
+ import { FieldBasicData } from '../../core/aux-data/field-basic-data';
10
+
11
+ export default {
12
+ title: 'Special datepicker control',
13
+ component: FormControlViewerComponent,
14
+ decorators: [
15
+ moduleMetadata({
16
+ imports: [FormControlViewerModule, BrowserAnimationsModule],
17
+ }),
18
+ ],
19
+ argTypes: {
20
+ icon: ICONS_CONTROL,
21
+ theme: THEMES_CONTROL,
22
+ length: { control: { type: 'range', min: 1, max: 100, step: 5 } },
23
+ },
24
+ } as Meta;
25
+
26
+ const Template: Story<FormControlViewerComponent> = (
27
+ args: FormControlViewerComponent
28
+ ) => ({
29
+ title: 'Special input control',
30
+ template: `
31
+ <spf-form-control-viewer
32
+ [theme]="theme"
33
+ [field]="{
34
+ placeholder: placeholder,
35
+ label: label,
36
+ tooltip: tooltip,
37
+ icon: icon,
38
+ elementId: elementId,
39
+ styleClasses: styleClasses,
40
+ length: length,
41
+ defaultValue:defaultValue,
42
+ required: required,
43
+ hidden: false,
44
+ readOnly: readOnly,
45
+ type:type,
46
+ settings:{},
47
+ errorMessages: errorMessages
48
+ }"
49
+ >
50
+ </spf-form-control-viewer>`,
51
+ props: {
52
+ ...args,
53
+ type: EControlTypes.date,
54
+ },
55
+ });
56
+
57
+ export const light = Template.bind({});
58
+ light.args = {
59
+ ...FieldBasicData,
60
+ theme: 'light-theme',
61
+ defaultValue: new Date(),
62
+ };
63
+
64
+ export const dark = Template.bind({});
65
+ dark.args = {
66
+ ...FieldBasicData,
67
+ theme: 'dark-theme',
68
+ defaultValue: new Date(),
69
+ };