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,85 @@
1
+ import { ChangeDetectionStrategy } from '@angular/core';
2
+ import { Component, Input, OnInit } from '@angular/core';
3
+ import { AbstractControl } from '@angular/forms';
4
+ import { EControlTypes } from '@lib/core/aux-data/control-types.enum';
5
+ import {
6
+ SpecialFormGroup,
7
+ SpecialFormArray,
8
+ } from '../../core/forms/special-forms';
9
+ import { SpecialAutocompleteComponent } from '../special-autocomplete/special-autocomplete.component';
10
+ import { SpecialCheckboxComponent } from '../special-checkbox/special-checkbox.component';
11
+ import { SpecialDatepickerComponent } from '../special-datepicker/special-datepicker.component';
12
+ import { SpecialDropdownComponent } from '../special-dropdown/special-dropdown.component';
13
+ import { SpecialInputComponent } from '../special-input/special-input.component';
14
+ import { SpecialLabelComponent } from '../special-label/special-label.component';
15
+ import { SpecialMultipleAutocompleteComponent } from '../special-multiple-autocomplete/special-multiple-autocomplete.component';
16
+ import { SpecialTextAreaComponent } from '../special-text-area/special-text-area.component';
17
+ import { SpecialUploadComponent } from '../special-upload/special-upload.component';
18
+
19
+ @Component({
20
+ selector: 'sp-form',
21
+ templateUrl: './special-form.component.html',
22
+ styleUrls: ['./special-form.component.scss'],
23
+ changeDetection: ChangeDetectionStrategy.OnPush,
24
+ })
25
+ export class SpecialFormComponent implements OnInit {
26
+ @Input('control') form: SpecialFormGroup;
27
+
28
+ componentsBuffer = ComponentsBuffer;
29
+
30
+ set control(form: SpecialFormGroup) {
31
+ this.form = form;
32
+ }
33
+
34
+ ngOnInit(): void {}
35
+
36
+ }
37
+
38
+ @Component({
39
+ selector: 'sp-array',
40
+ templateUrl: './special-form-array.component.html',
41
+ styleUrls: ['./special-form-array.component.scss'],
42
+ changeDetection: ChangeDetectionStrategy.OnPush,
43
+ })
44
+ export class SpecialArrayComponent implements OnInit {
45
+ @Input('control') formArray: any;
46
+
47
+ componentsBuffer = ComponentsBuffer;
48
+
49
+ set control(formArray: any) {
50
+ this.formArray = formArray;
51
+ }
52
+
53
+ get withFormHeader() {
54
+ return this.formArray.settings.withFormHeader;
55
+ }
56
+
57
+ get settings() {
58
+ return this.formArray.settings;
59
+ }
60
+
61
+ constructor() {}
62
+
63
+ ngOnInit() {}
64
+
65
+ removeItem(index) {
66
+ this.formArray.removeAt(index);
67
+ }
68
+ addItem() {
69
+ this.formArray.addItem();
70
+ }
71
+ }
72
+
73
+ export const ComponentsBuffer = {
74
+ [EControlTypes.autocomplete]: SpecialAutocompleteComponent,
75
+ [EControlTypes.checkbox]: SpecialCheckboxComponent,
76
+ [EControlTypes.date]: SpecialDatepickerComponent,
77
+ [EControlTypes.dropdown]: SpecialDropdownComponent,
78
+ [EControlTypes.array]: SpecialArrayComponent,
79
+ [EControlTypes.input]: SpecialInputComponent,
80
+ [EControlTypes.multiple]: SpecialMultipleAutocompleteComponent,
81
+ [EControlTypes.textArea]: SpecialTextAreaComponent,
82
+ [EControlTypes.label]: SpecialLabelComponent,
83
+ [EControlTypes.upload]: SpecialUploadComponent,
84
+ [EControlTypes.form]: SpecialFormComponent,
85
+ };
@@ -0,0 +1,40 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { SpecialFormComponent } from './special-form.component';
4
+ import { MatButtonModule } from '@angular/material/button';
5
+ import { FormControlsListPipeModule } from '../../pipes/controls-list-pipe/controls-list.pipe.module';
6
+ import { ControlsRenderDirectiveModule } from '../../core/directives/control-render.module';
7
+ import {
8
+ SpecialDropdownModule,
9
+ SpecialInputModule,
10
+ SpecialAutocompleteModule,
11
+ SpecialDatepickerModule,
12
+ SpecialMultipleAutocompleteModule,
13
+ SpecialCheckboxModule,
14
+ SpecialTextAreaModule,
15
+ SpecialUploadModule,
16
+ SpecialArrayModule,
17
+ SpecialLabelModule
18
+ } from '../../components';
19
+
20
+ @NgModule({
21
+ declarations: [SpecialFormComponent],
22
+ imports: [
23
+ CommonModule,
24
+ ControlsRenderDirectiveModule,
25
+ FormControlsListPipeModule,
26
+ MatButtonModule,
27
+ SpecialDropdownModule,
28
+ SpecialInputModule,
29
+ SpecialAutocompleteModule,
30
+ SpecialDatepickerModule,
31
+ SpecialLabelModule,
32
+ SpecialMultipleAutocompleteModule,
33
+ SpecialCheckboxModule,
34
+ SpecialTextAreaModule,
35
+ SpecialUploadModule,
36
+ SpecialArrayModule,
37
+ ],
38
+ exports: [SpecialFormComponent],
39
+ })
40
+ export class SpecialFormModule {}
@@ -0,0 +1,45 @@
1
+ import { Story, Meta } from '@storybook/angular';
2
+ import { moduleMetadata } from '@storybook/angular';
3
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
4
+ import { EControlTypes } from '../../core/aux-data/control-types.enum';
5
+ import { ICONS_CONTROL } from '../../core/controls';
6
+ import { MasksEnum } from '../../core/masks/maks.enum';
7
+ import { THEMES_CONTROL } from '../../core/controls/theme.control';
8
+ import { FormGroupViewerModule } from '../../aux-storybook-components/form-group-viewer/form-group-viewer.module';
9
+ import { FormGroupViewerComponent } from '../../aux-storybook-components/form-group-viewer/form-group-viewer.component';
10
+ import { IFormStructure } from '../../core/interfaces/form.interfaces';
11
+
12
+ export default {
13
+ title: 'Special form group',
14
+ component: FormGroupViewerComponent,
15
+ decorators: [
16
+ moduleMetadata({
17
+ imports: [FormGroupViewerModule, BrowserAnimationsModule],
18
+ }),
19
+ ],
20
+ } as Meta;
21
+
22
+ const Template: Story<FormGroupViewerComponent> = (
23
+ args: FormGroupViewerComponent
24
+ ) => ({
25
+ title: 'Special form control',
26
+ template: `
27
+ <spf-form-group-viewer
28
+ [theme]="theme"
29
+ [fields]="fields"
30
+ >
31
+ </spf-form-group-viewer>`,
32
+ props: {
33
+ ...args,
34
+ },
35
+ });
36
+
37
+ export const light = Template.bind({});
38
+ light.args = {
39
+ theme: 'light-theme',
40
+ };
41
+
42
+ export const dark = Template.bind({});
43
+ dark.args = {
44
+ theme: 'dark-theme',
45
+ };
@@ -0,0 +1,37 @@
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
+ (blur)="onBlurAction()"
11
+ (keydown.enter)="onEnterClick()"
12
+ [inputMask]="settings?.mask"
13
+ autocomplete="off"
14
+ [type]="settings?.type || 'text'"
15
+ [readonly]="control.readOnly"
16
+ [required]="control.required"
17
+ [placeholder]="control.placeholder"
18
+ [formControl]="control"
19
+ />
20
+ <mat-icon *ngIf="control.icon" matPrefix>{{ control.icon }} </mat-icon>
21
+ <mat-hint>
22
+ {{ control.tooltip }}
23
+ </mat-hint>
24
+ <button
25
+ *ngIf="settings?.icon"
26
+ mat-icon-button
27
+ matSuffix
28
+ (click)="iconClick($event)"
29
+ >
30
+ <mat-icon>
31
+ {{ settings.icon }}
32
+ </mat-icon>
33
+ </button>
34
+ <mat-error>
35
+ {{ control.errors | errorMessage: control.errorMessages }}
36
+ </mat-error>
37
+ </mat-form-field>
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { SpecialInputComponent } from './special-input.component';
4
+
5
+ describe('SpecialInputComponent', () => {
6
+ let component: SpecialInputComponent;
7
+ let fixture: ComponentFixture<SpecialInputComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ SpecialInputComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(SpecialInputComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,39 @@
1
+ import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
2
+ import { SpecialFormControl } from '../../core/forms/special-forms';
3
+ import { IInputSettings } from './special-input.interface';
4
+ @Component({
5
+ selector: 'sp-input',
6
+ templateUrl: './special-input.component.html',
7
+ styleUrls: ['./special-input.component.scss'],
8
+ changeDetection: ChangeDetectionStrategy.OnPush,
9
+ })
10
+ export class SpecialInputComponent implements OnInit {
11
+ @Input() control: SpecialFormControl<IInputSettings>;
12
+
13
+ constructor() {}
14
+
15
+ ngOnInit(): void {}
16
+
17
+ onEnterClick() {
18
+ if (this.settings.onEnter) {
19
+ this.settings.onEnter(this.control.value);
20
+ }
21
+ }
22
+
23
+ onBlurAction() {
24
+ if (this.settings.onBlur) {
25
+ this.settings.onBlur(this.control.value);
26
+ }
27
+ }
28
+
29
+ get settings(): IInputSettings {
30
+ return this.control.settings;
31
+ }
32
+
33
+ iconClick(event) {
34
+ if (this.settings.iconAction) {
35
+ this.settings.iconAction(this.control.value);
36
+ event.stopPropagation();
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,17 @@
1
+ import { InputmaskOptions } from '@ngneat/input-mask';
2
+ import { EControlTypes } from '../../core/aux-data/control-types.enum';
3
+ import { IFieldData } from '../../core/interfaces/field-basics.interfaces';
4
+
5
+ export type IInputSettings = {
6
+ type?: string;
7
+ mask?: InputmaskOptions<any>;
8
+ icon?: string;
9
+ iconAction?: (data: any) => void;
10
+ onEnter?: (data: any) => void;
11
+ onBlur?: (data: any) => void;
12
+ };
13
+
14
+ export interface IInputField extends IFieldData {
15
+ settings: IInputSettings;
16
+ type: EControlTypes.input;
17
+ }
@@ -0,0 +1,24 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { SpecialInputComponent } from './special-input.component';
4
+ import { MatInputModule } from '@angular/material/input';
5
+ import { MatButtonModule } from '@angular/material/button';
6
+ import { InputMaskModule } from "@ngneat/input-mask";
7
+ import { MatIconModule } from '@angular/material/icon';
8
+ import { ReactiveFormsModule } from '@angular/forms';
9
+ import { ErrorMessagePipeModule } from '../../pipes';
10
+
11
+ @NgModule({
12
+ declarations: [SpecialInputComponent],
13
+ imports: [
14
+ InputMaskModule,
15
+ CommonModule,
16
+ MatInputModule,
17
+ MatIconModule,
18
+ ReactiveFormsModule,
19
+ MatButtonModule,
20
+ ErrorMessagePipeModule
21
+ ],
22
+ exports: [SpecialInputComponent],
23
+ })
24
+ export class SpecialInputModule {}
@@ -0,0 +1,91 @@
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 { MasksEnum } from '../../core/masks/maks.enum';
9
+ import { FieldBasicData } from '../../core/aux-data/field-basic-data';
10
+ import { THEMES_CONTROL } from '../../core/controls/theme.control';
11
+ import { InputTypes } from '@lib/core/aux-data/input-types';
12
+
13
+ export default {
14
+ title: 'Special input control',
15
+ component: FormControlViewerComponent,
16
+ decorators: [
17
+ moduleMetadata({
18
+ imports: [FormControlViewerModule, BrowserAnimationsModule],
19
+ }),
20
+ ],
21
+ argTypes: {
22
+ icon: ICONS_CONTROL,
23
+ icon2: ICONS_CONTROL,
24
+ theme: THEMES_CONTROL,
25
+ length: { control: { type: 'range', min: 1, max: 100, step: 5 } },
26
+ mask: {
27
+ control: 'select',
28
+ options: [null, MasksEnum.currency, MasksEnum.numeric],
29
+ },
30
+ inputType: {
31
+ control: 'select',
32
+ options: InputTypes,
33
+ },
34
+ },
35
+ } as Meta;
36
+
37
+ const Template: Story<FormControlViewerComponent> = (
38
+ args: FormControlViewerComponent
39
+ ) => ({
40
+ title: 'Special input control',
41
+ template: `
42
+ <spf-form-control-viewer
43
+ [theme]="theme"
44
+ [input]="{
45
+ placeholder: placeholder,
46
+ label: label,
47
+ tooltip: tooltip,
48
+ icon: icon,
49
+ elementId: elementId,
50
+ styleClasses: styleClasses,
51
+ length: length,
52
+ defaultValue: defaultValue,
53
+ required: required,
54
+ hidden: hidden,
55
+ readOnly: readOnly,
56
+ disabled: disabled,
57
+ type: type,
58
+ errorMessages: errorMessages,
59
+ settings:{
60
+ icon:icon2,
61
+ mask:mask,
62
+ type:inputType
63
+ }
64
+ }"
65
+ >
66
+ </spf-form-control-viewer>`,
67
+ props: {
68
+ ...args,
69
+ type: EControlTypes.input,
70
+ },
71
+ });
72
+
73
+ export const light = Template.bind({});
74
+ light.args = {
75
+ ...FieldBasicData,
76
+ theme: 'light-theme',
77
+ defaultValue: 'Default',
78
+ icon2: 'search',
79
+ mask: null,
80
+ inputType: 'text',
81
+ };
82
+
83
+ export const dark = Template.bind({});
84
+ dark.args = {
85
+ ...FieldBasicData,
86
+ theme: 'dark-theme',
87
+ defaultValue: 'Default',
88
+ icon2: 'search',
89
+ mask: null,
90
+ inputType: 'text',
91
+ };
@@ -0,0 +1,6 @@
1
+ <div class="px-2 {{control.styleClasses}} {{ control.value | textByFunction: settings.stylesPipe}}">
2
+ <div *ngIf="!!control.label" class="font-bold">{{control.label}}</div>
3
+ <div [ngClass]="{'cursor-pointer text-blue-600 hover:text-blue-700':settings.isLink }" (click)="onLink()">
4
+ {{ control.value | textByFunction: control.settings.pipe}}
5
+ </div>
6
+ </div>
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { SpecialLabelComponent } from './special-label.component';
4
+
5
+ describe('SpecialLabelComponent', () => {
6
+ let component: SpecialLabelComponent;
7
+ let fixture: ComponentFixture<SpecialLabelComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ SpecialLabelComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(SpecialLabelComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,27 @@
1
+ import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
2
+ import { SpecialFormControl } from '../../core/forms/special-forms';
3
+ import { ILabelSettings } from './special-label.interface';
4
+
5
+ @Component({
6
+ selector: 'sp-label',
7
+ templateUrl: './special-label.component.html',
8
+ styleUrls: ['./special-label.component.scss'],
9
+ changeDetection: ChangeDetectionStrategy.OnPush,
10
+ })
11
+ export class SpecialLabelComponent implements OnInit {
12
+ @Input() control: SpecialFormControl<ILabelSettings>;
13
+
14
+ constructor() {}
15
+
16
+ ngOnInit(): void {}
17
+
18
+ get settings(): ILabelSettings {
19
+ return this.control.settings || { isLink: false };
20
+ }
21
+
22
+ onLink() {
23
+ if (this.settings.isLink && this.settings.onClickLink) {
24
+ this.settings.onClickLink(this.control.value);
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,14 @@
1
+ import { EControlTypes } from '../../core/aux-data/control-types.enum';
2
+ import { IFieldData } from '../../core/interfaces/field-basics.interfaces';
3
+
4
+ export type ILabelSettings = {
5
+ pipe?: (value) => string;
6
+ stylesPipe?: (value) => string;
7
+ isLink: boolean;
8
+ onClickLink?: (value) => void;
9
+ };
10
+
11
+ export interface ILabelField extends IFieldData {
12
+ settings: ILabelSettings;
13
+ type: EControlTypes.label;
14
+ }
@@ -0,0 +1,25 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { SpecialLabelComponent } from './special-label.component';
4
+ import { MatInputModule } from '@angular/material/input';
5
+ import { MatButtonModule } from '@angular/material/button';
6
+ import { InputMaskModule } from "@ngneat/input-mask";
7
+ import { MatIconModule } from '@angular/material/icon';
8
+ import { ReactiveFormsModule } from '@angular/forms';
9
+ import { ErrorMessagePipeModule, TextByFunctionPipeModule } from '../../pipes';
10
+
11
+ @NgModule({
12
+ declarations: [SpecialLabelComponent],
13
+ imports: [
14
+ InputMaskModule,
15
+ CommonModule,
16
+ MatInputModule,
17
+ MatIconModule,
18
+ ReactiveFormsModule,
19
+ MatButtonModule,
20
+ TextByFunctionPipeModule,
21
+ ErrorMessagePipeModule
22
+ ],
23
+ exports: [SpecialLabelComponent],
24
+ })
25
+ export class SpecialLabelModule {}
@@ -0,0 +1,99 @@
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 { MasksEnum } from '../../core/masks/maks.enum';
9
+ import { FieldBasicData } from '../../core/aux-data/field-basic-data';
10
+ import { THEMES_CONTROL } from '../../core/controls/theme.control';
11
+
12
+ export default {
13
+ title: 'Special label control',
14
+ component: FormControlViewerComponent,
15
+ decorators: [
16
+ moduleMetadata({
17
+ imports: [FormControlViewerModule, BrowserAnimationsModule],
18
+ }),
19
+ ],
20
+ argTypes: {
21
+ icon: ICONS_CONTROL,
22
+ icon2: ICONS_CONTROL,
23
+ theme: THEMES_CONTROL,
24
+ length: { control: { type: 'range', min: 1, max: 100, step: 5 } },
25
+ mask: {
26
+ control: 'select',
27
+ options: [null, MasksEnum.currency, MasksEnum.numeric],
28
+ },
29
+ },
30
+ } as Meta;
31
+
32
+ const Template: Story<FormControlViewerComponent> = (
33
+ args: FormControlViewerComponent
34
+ ) => ({
35
+ title: 'Special input control',
36
+ template: `
37
+ <spf-form-control-viewer
38
+ [theme]="theme"
39
+ [field]="{
40
+ placeholder: placeholder,
41
+ label: label,
42
+ tooltip: tooltip,
43
+ icon: icon,
44
+ elementId: elementId,
45
+ styleClasses: styleClasses,
46
+ length: length,
47
+ defaultValue: defaultValue,
48
+ required: required,
49
+ hidden: hidden,
50
+ readOnly: readOnly,
51
+ disabled: disabled,
52
+ type: type,
53
+ errorMessages: errorMessages,
54
+ settings:{
55
+ pipe: pipe,
56
+ stylesPipe: stylesPipe,
57
+ isLink: isLink,
58
+ onClickLink: onClickLink
59
+ }
60
+ }"
61
+ >
62
+ </spf-form-control-viewer>`,
63
+ props: {
64
+ ...args,
65
+ type: EControlTypes.label,
66
+ },
67
+ });
68
+
69
+ export const light = Template.bind({});
70
+ light.args = {
71
+ ...FieldBasicData,
72
+ pipe: (value) => value,
73
+ stylesPipe: (value) => 'bg-red-500',
74
+ onClickLink: (value) => {
75
+ console.log('go to a url');
76
+ },
77
+ isLink: false,
78
+ theme: 'light-theme',
79
+ defaultValue: 'Default',
80
+ icon2: 'search',
81
+ mask: null,
82
+ inputType: 'text',
83
+ };
84
+
85
+ export const dark = Template.bind({});
86
+ dark.args = {
87
+ ...FieldBasicData,
88
+ pipe: (value) => value,
89
+ stylesPipe: (value) => 'bg-red-500',
90
+ onClickLink: (value) => {
91
+ console.log('go to a url', value);
92
+ },
93
+ isLink: false,
94
+ theme: 'dark-theme',
95
+ defaultValue: 'Default',
96
+ icon2: 'search',
97
+ mask: null,
98
+ inputType: 'text',
99
+ };