@masterkeymaterial/ui 0.0.1 → 0.0.2

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 (141) hide show
  1. package/README.md +9 -59
  2. package/ng-package.json +10 -0
  3. package/package.json +5 -14
  4. package/src/elements/ui-button/ui-button.css +229 -0
  5. package/src/elements/ui-button/ui-button.html +12 -0
  6. package/src/elements/ui-button/ui-button.ts +133 -0
  7. package/src/elements/ui-check-box/ui-check-box.css +66 -0
  8. package/src/elements/ui-check-box/ui-check-box.html +5 -0
  9. package/src/elements/ui-check-box/ui-check-box.ts +65 -0
  10. package/src/elements/ui-chip/ui-chip.css +24 -0
  11. package/src/elements/ui-chip/ui-chip.html +3 -0
  12. package/src/elements/ui-chip/ui-chip.ts +25 -0
  13. package/src/elements/ui-drop-zone/ui-drop-zone.css +91 -0
  14. package/src/elements/ui-drop-zone/ui-drop-zone.html +8 -0
  15. package/src/elements/ui-drop-zone/ui-drop-zone.ts +153 -0
  16. package/src/elements/ui-file-list/ui-file-list.css +43 -0
  17. package/src/elements/ui-file-list/ui-file-list.html +17 -0
  18. package/src/elements/ui-file-list/ui-file-list.ts +22 -0
  19. package/src/elements/ui-list-errors/ui-list-errors.css +30 -0
  20. package/src/elements/ui-list-errors/ui-list-errors.html +10 -0
  21. package/src/elements/ui-list-errors/ui-list-errors.ts +14 -0
  22. package/src/elements/ui-loading/ui-loading.css +13 -0
  23. package/src/elements/ui-loading/ui-loading.html +1 -0
  24. package/src/elements/ui-loading/ui-loading.ts +10 -0
  25. package/src/elements/ui-menu/ui-menu.css +69 -0
  26. package/src/elements/ui-menu/ui-menu.html +20 -0
  27. package/src/elements/ui-menu/ui-menu.ts +267 -0
  28. package/src/elements/ui-procurar/ui-procurar.css +48 -0
  29. package/src/elements/ui-procurar/ui-procurar.html +14 -0
  30. package/src/elements/ui-procurar/ui-procurar.ts +82 -0
  31. package/src/elements/ui-progress/ui-progress.css +0 -0
  32. package/src/elements/ui-progress/ui-progress.html +1 -0
  33. package/src/elements/ui-progress/ui-progress.ts +15 -0
  34. package/src/elements/ui-select/ui-select.css +211 -0
  35. package/src/elements/ui-select/ui-select.html +46 -0
  36. package/src/elements/ui-select/ui-select.ts +482 -0
  37. package/src/elements/ui-slide/ui-slide.css +75 -0
  38. package/src/elements/ui-slide/ui-slide.html +7 -0
  39. package/src/elements/ui-slide/ui-slide.ts +61 -0
  40. package/src/fields/Base/BaseFieldsForm/BaseFieldsForm.component.ts +113 -0
  41. package/src/fields/Base/BaseFieldsValues/BaseFieldsValues.ts +112 -0
  42. package/src/fields/Formulario/Formulario.ts +1056 -0
  43. package/src/fields/Formulario/form-action/form-action.css +98 -0
  44. package/src/fields/Formulario/form-action/form-action.html +75 -0
  45. package/src/fields/Formulario/form-action/form-action.ts +187 -0
  46. package/src/fields/Formulario/form-controls/form-controls.css +108 -0
  47. package/src/fields/Formulario/form-controls/form-controls.html +105 -0
  48. package/src/fields/Formulario/form-controls/form-controls.ts +122 -0
  49. package/src/fields/Formulario/form-fase/form-fase.css +84 -0
  50. package/src/fields/Formulario/form-fase/form-fase.html +24 -0
  51. package/src/fields/Formulario/form-fase/form-fase.ts +157 -0
  52. package/src/fields/Formulario/form-filter/form-filter.css +50 -0
  53. package/src/fields/Formulario/form-filter/form-filter.html +25 -0
  54. package/src/fields/Formulario/form-filter/form-filter.ts +53 -0
  55. package/src/fields/Formulario/form-no-action/form-no-action.css +32 -0
  56. package/src/fields/Formulario/form-no-action/form-no-action.html +12 -0
  57. package/src/fields/Formulario/form-no-action/form-no-action.ts +21 -0
  58. package/src/fields/Formulario/formated-values/formated-values.css +104 -0
  59. package/src/fields/Formulario/formated-values/formated-values.html +15 -0
  60. package/src/fields/Formulario/formated-values/formated-values.ts +186 -0
  61. package/src/fields/Formulario/single-values/single-values.css +88 -0
  62. package/src/fields/Formulario/single-values/single-values.html +11 -0
  63. package/src/fields/Formulario/single-values/single-values.ts +65 -0
  64. package/src/fields/autocomplete/autocomplete.css +94 -0
  65. package/src/fields/autocomplete/autocomplete.html +38 -0
  66. package/src/fields/autocomplete/autocomplete.ts +294 -0
  67. package/src/fields/button/button.css +7 -0
  68. package/src/fields/button/button.html +19 -0
  69. package/src/fields/button/button.ts +38 -0
  70. package/src/fields/checkbox/checkbox.css +27 -0
  71. package/src/fields/checkbox/checkbox.html +20 -0
  72. package/src/fields/checkbox/checkbox.ts +44 -0
  73. package/src/fields/color/CirculoColorido/circulocolorido.css +50 -0
  74. package/src/fields/color/CirculoColorido/circulocolorido.html +8 -0
  75. package/src/fields/color/CirculoColorido/circulocolorido.ts +24 -0
  76. package/src/fields/color/color.css +15 -0
  77. package/src/fields/color/color.html +24 -0
  78. package/src/fields/color/color.ts +47 -0
  79. package/src/fields/date/date.html +19 -0
  80. package/src/fields/date/date.ts +29 -0
  81. package/src/fields/datetime/datetime.html +19 -0
  82. package/src/fields/datetime/datetime.ts +29 -0
  83. package/src/fields/display/display.css +7 -0
  84. package/src/fields/display/display.html +20 -0
  85. package/src/fields/display/display.ts +43 -0
  86. package/src/fields/editor/editor.css +51 -0
  87. package/src/fields/editor/editor.html +37 -0
  88. package/src/fields/editor/editor.ts +218 -0
  89. package/src/fields/email/email.html +19 -0
  90. package/src/fields/email/email.ts +29 -0
  91. package/src/fields/fields.css +180 -0
  92. package/src/fields/generic/generic.html +3 -0
  93. package/src/fields/generic/generic.ts +91 -0
  94. package/src/fields/hidden/hidden.html +3 -0
  95. package/src/fields/hidden/hidden.ts +20 -0
  96. package/src/fields/icon/icon.css +19 -0
  97. package/src/fields/icon/icon.html +27 -0
  98. package/src/fields/icon/icon.ts +31 -0
  99. package/src/fields/multifactor/multifactor.css +21 -0
  100. package/src/fields/multifactor/multifactor.html +39 -0
  101. package/src/fields/multifactor/multifactor.ts +106 -0
  102. package/src/fields/multikv/multikv.css +43 -0
  103. package/src/fields/multikv/multikv.html +47 -0
  104. package/src/fields/multikv/multikv.ts +88 -0
  105. package/src/fields/multitext/multitext.css +36 -0
  106. package/src/fields/multitext/multitext.html +38 -0
  107. package/src/fields/multitext/multitext.ts +75 -0
  108. package/src/fields/number/number.html +20 -0
  109. package/src/fields/number/number.ts +35 -0
  110. package/src/fields/password/password.html +23 -0
  111. package/src/fields/password/password.ts +37 -0
  112. package/src/fields/search/search.css +0 -0
  113. package/src/fields/search/search.html +19 -0
  114. package/src/fields/search/search.ts +54 -0
  115. package/src/fields/select/select.css +15 -0
  116. package/src/fields/select/select.html +18 -0
  117. package/src/fields/select/select.ts +52 -0
  118. package/src/fields/slide/slide.css +27 -0
  119. package/src/fields/slide/slide.html +20 -0
  120. package/src/fields/slide/slide.ts +45 -0
  121. package/src/fields/text/text.html +19 -0
  122. package/src/fields/text/text.ts +30 -0
  123. package/src/fields/textarea/textarea.css +4 -0
  124. package/src/fields/textarea/textarea.html +20 -0
  125. package/src/fields/textarea/textarea.ts +31 -0
  126. package/src/fields/time/time.html +19 -0
  127. package/src/fields/time/time.ts +29 -0
  128. package/src/fields/upload/upload.css +24 -0
  129. package/src/fields/upload/upload.html +41 -0
  130. package/src/fields/upload/upload.ts +137 -0
  131. package/src/interfaces/interfaces.ts +61 -0
  132. package/src/public-api.ts +38 -0
  133. package/src/util/ClassOf.pipe.ts +11 -0
  134. package/src/util/JsonColorido.pipe.ts +11 -0
  135. package/src/util/util.ts +2151 -0
  136. package/tsconfig.lib.json +16 -0
  137. package/tsconfig.lib.prod.json +9 -0
  138. package/tsconfig.spec.json +13 -0
  139. package/fesm2022/masterkeymaterial-ui.mjs +0 -6457
  140. package/fesm2022/masterkeymaterial-ui.mjs.map +0 -1
  141. package/types/masterkeymaterial-ui.d.ts +0 -928
@@ -0,0 +1,91 @@
1
+ import { NgComponentOutlet } from '@angular/common';
2
+ import { Component, computed } from '@angular/core';
3
+ import { BaseFieldsForm } from '../Base/BaseFieldsForm/BaseFieldsForm.component';
4
+
5
+ import { FieldsAutocomplete } from '../autocomplete/autocomplete';
6
+ import { FieldsButton } from "../button/button";
7
+ import { FieldsCheckbox } from '../checkbox/checkbox';
8
+ import { FieldsColor } from '../color/color';
9
+ import { FieldsDate } from '../date/date';
10
+ import { FieldsDatetime } from '../datetime/datetime';
11
+ import { FieldsDisplay } from '../display/display';
12
+ import { FieldsEditor } from '../editor/editor';
13
+ import { FieldsEmail } from '../email/email';
14
+ import { FieldsHidden } from '../hidden/hidden';
15
+ import { FieldsIcon } from '../icon/icon';
16
+ import { FieldsMultifactor } from '../multifactor/multifactor';
17
+ import { FieldsMultiText } from '../multitext/multitext';
18
+ import { FieldsNumber } from '../number/number';
19
+ import { FieldsPassword } from '../password/password';
20
+ import { FieldsSearch } from '../search/search';
21
+ import { FieldsSelect } from '../select/select';
22
+ import { FieldsSlide } from '../slide/slide';
23
+ import { FieldsText } from '../text/text';
24
+ import { FieldsUpload } from '../upload/upload';
25
+ import { FieldsTime } from '../time/time';
26
+ import { FieldsTextarea } from '../textarea/textarea';
27
+ import { IField } from '../Formulario/Formulario';
28
+ import { FieldsMultiKV } from '../multikv/multikv';
29
+
30
+ @Component({
31
+ selector: 'fields-g',
32
+ templateUrl: './generic.html',
33
+ // styles: `:host.hidden {
34
+ // display: none;
35
+ // }`,
36
+ imports: [NgComponentOutlet],
37
+ })
38
+ export class FieldsGeneric extends BaseFieldsForm {
39
+
40
+ readonly campos = computed(() => this.form().campos());
41
+
42
+ // @HostBinding('class.hidden')
43
+ // isHidden = false;
44
+
45
+ // Mapeamento de tipos para componentes
46
+ getComponentForType(tipo?: IField): any {
47
+ // Tipo Hidden não exibe componente e coloca o host como hidden
48
+ // if (tipo == IField.Hidden) {
49
+ // this.isHidden = true;
50
+ // return null;
51
+ // }
52
+
53
+ /************************************************\\
54
+ // MAPA: Tipo de Campo - Componente Responsável \\
55
+ //*************************************************/
56
+ // Comente o campo caso haja algum problema de dependência circular ou outro...
57
+
58
+ const FIELDS_MAP: Partial<Record<IField, any>> = {
59
+ [IField.AutoComplete]: FieldsAutocomplete,
60
+ [IField.Button]: FieldsButton,
61
+ [IField.Checkbox]: FieldsCheckbox,
62
+ [IField.Color]: FieldsColor,
63
+ [IField.Date]: FieldsDate,
64
+ [IField.DateTime]: FieldsDatetime,
65
+ [IField.Display]: FieldsDisplay,
66
+ [IField.Editor]: FieldsEditor,
67
+ [IField.Email]: FieldsEmail,
68
+ [IField.Hidden]: FieldsHidden,
69
+ [IField.Icon]: FieldsIcon,
70
+ [IField.MultiFactor]: FieldsMultifactor,
71
+ [IField.MultiKV]: FieldsMultiKV,
72
+ [IField.MultiText]: FieldsMultiText,
73
+ [IField.Number]: FieldsNumber,
74
+ [IField.Password]: FieldsPassword,
75
+ [IField.Referencia]: FieldsDisplay,
76
+ [IField.Search]: FieldsSearch,
77
+ [IField.Select]: FieldsSelect,
78
+ [IField.Slide]: FieldsSlide,
79
+ [IField.Text]: FieldsText,
80
+ [IField.Textarea]: FieldsTextarea,
81
+ [IField.Time]: FieldsTime,
82
+ [IField.Upload]: FieldsUpload,
83
+
84
+ [IField.Custom]: this.campo()?.componente,
85
+ }
86
+ if (tipo) return FIELDS_MAP[tipo] || null;
87
+ return null;
88
+ }
89
+
90
+ }
91
+
@@ -0,0 +1,3 @@
1
+ <div class="fieldHidden" [class.isTouched]="campo()?.touched" [class.showTouched]="form().showTouched()"
2
+ [class.isInvalid]="campo()?.invalid" [class.isDisabled]="campo()?.disabled" [class.isReadonly]="campo()?.readonly"
3
+ [class.isNeed]="campo()?.need" [class.isPending]="campo()?.pending" [class.isEmpty]="campo()?.empty"></div>
@@ -0,0 +1,20 @@
1
+ import { Component, effect } from '@angular/core';
2
+ import { BaseFieldsForm } from '../Base/BaseFieldsForm/BaseFieldsForm.component';
3
+
4
+ @Component({
5
+ selector: 'fields-hidden',
6
+ templateUrl: './hidden.html',
7
+ styles: `.fieldHidden{display: none;}`
8
+ })
9
+ export class FieldsHidden extends BaseFieldsForm {
10
+
11
+ constructor() {
12
+ super();
13
+ effect(() => {
14
+ const val = this.value();
15
+ let empty = val === null || val === undefined || val === '';
16
+ this.updateCampo({ empty });
17
+ });
18
+ }
19
+
20
+ }
@@ -0,0 +1,19 @@
1
+ .noIcon {
2
+ display: inline-block;
3
+ transform: rotate(-10deg) skewX(-15deg) skewY(-15deg) translate(0px, -5px);
4
+ font-size: 16px;
5
+ position: relative;
6
+ }
7
+
8
+ .noIcon:after {
9
+ content: 'ICO';
10
+ position: absolute;
11
+ bottom: 0;
12
+ left: 0;
13
+ transform: scaleY(-1) skewX(-50deg);
14
+ transform-origin: bottom;
15
+ background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.6) 100%);
16
+ background-clip: text;
17
+ -webkit-background-clip: text;
18
+ -webkit-text-fill-color: transparent;
19
+ }
@@ -0,0 +1,27 @@
1
+ <div class="fieldContainer" [class.isTouched]="campo()?.touched" [class.showTouched]="form().showTouched()"
2
+ [class.isInvalid]="campo()?.invalid" [class.isDisabled]="campo()?.disabled" [class.isReadonly]="campo()?.readonly"
3
+ [class.isNeed]="campo()?.need" [class.isPending]="campo()?.pending" [class.isEmpty]="campo()?.empty">
4
+ <div class="fieldLabel" (click)="onClickLabel()" [class.hideLabel]="campo()?.hideLabel">
5
+ @if(campo()?.icone){ <div class="fieldIcon"><i [class]="campo()?.icone"></i></div> }
6
+ {{ campo()?.titulo }}
7
+ </div>
8
+ <div class="fieldControl doCampo">
9
+ <ui-button tipo="raised" tema="secondary" (clicked)="onClickEmit()" [disabled]="campo()?.disabled"
10
+ [style.width.px]="100">
11
+ @if(value()){
12
+ <i [class]="value()" [style.fontSize]="'25px'"></i>
13
+ }@else {
14
+ <div class="noIcon">ICO</div>
15
+ }
16
+ </ui-button>
17
+ <div class="fieldEffect">
18
+ <div class="fieldField FieldIconType">
19
+ <input type="text" [value]="value()" (input)="onInput($event.target.value)" (change)="onChangeEmit()"
20
+ [name]="campo()?.prop" [disabled]="campo()?.disabled" [placeholder]="campo()?.placeholder ?? ''"
21
+ [attr.maxLength]="campo()?.maxl" [attr.minLength]="campo()?.minl" [class]="campo()?.classe"
22
+ [style]="campo()?.style" [class.outlined]="true" [class.input]="true" />
23
+ </div>
24
+ </div>
25
+ </div>
26
+ <ui-list-errors [errors]="campo()?.errors" [dica]="campo()?.dica" [show]="campo()?.touched"></ui-list-errors>
27
+ </div>
@@ -0,0 +1,31 @@
1
+ import { Component, effect } from '@angular/core';
2
+ import { LibUtil } from '../../util/util';
3
+ import { UiButton } from "../../elements/ui-button/ui-button";
4
+ import { BaseFieldsForm } from '../Base/BaseFieldsForm/BaseFieldsForm.component';
5
+ import { UiListErrors } from "../../elements/ui-list-errors/ui-list-errors";
6
+
7
+ @Component({
8
+ selector: 'fields-icon',
9
+ templateUrl: './icon.html',
10
+ styleUrls: ['../fields.css', './icon.css'],
11
+ imports: [UiButton, UiListErrors]
12
+ })
13
+ export class FieldsIcon extends BaseFieldsForm {
14
+
15
+ constructor() {
16
+ super();
17
+ effect(() => {
18
+ const val = this.value();
19
+ let empty = val === null || val === undefined || val === '';
20
+ this.updateCampo({ empty });
21
+ });
22
+ }
23
+
24
+ onInput(newValue: string) {
25
+ if (this.campo()?.mask) newValue = LibUtil.mascarar(newValue, this.campo()?.mask) ?? '';
26
+ this.updateValue(newValue);
27
+ this.campo()?.onInput?.(this.form());
28
+ }
29
+
30
+
31
+ }
@@ -0,0 +1,21 @@
1
+ .gridFactor {
2
+ display: grid;
3
+ grid-template-columns: repeat(6, 1fr);
4
+ gap: 0.5rem;
5
+ padding: 5px;
6
+ width: 100%;
7
+ }
8
+
9
+ .fieldField.FieldMultifactor {
10
+ border: 0;
11
+ }
12
+
13
+ .fieldField.FieldMultifactor input {
14
+ text-align: center;
15
+ outline: 1px solid var(--sys-outline);
16
+ height: 37px;
17
+ }
18
+
19
+ .fieldField.FieldMultifactor .corpo:focus-visible {
20
+ outline: 2px solid var(--campoCor);
21
+ }
@@ -0,0 +1,39 @@
1
+ <div class="fieldContainer" [class.isTouched]="campo()?.touched" [class.showTouched]="form().showTouched()"
2
+ [class.isInvalid]="campo()?.invalid" [class.isDisabled]="campo()?.disabled" [class.isReadonly]="campo()?.readonly"
3
+ [class.isNeed]="campo()?.need" [class.isPending]="campo()?.pending" [class.isEmpty]="campo()?.empty">
4
+ <div class="fieldLabel" (click)="onClickLabel()" [class.hideLabel]="campo()?.hideLabel">
5
+ @if(campo()?.icone){ <div class="fieldIcon"><i [class]="campo()?.icone"></i></div> }
6
+ {{ campo()?.titulo }}
7
+ </div>
8
+ <div class="fieldControl doCampo">
9
+ <div class="fieldEffect">
10
+ <div class="fieldField FieldMultifactor">
11
+ <input type="text" [value]="value()" (input)="onInput($event.target.value)" [name]="campo()?.prop"
12
+ [disabled]="campo()?.disabled" [placeholder]="campo()?.placeholder ?? ''" [class]="campo()?.classe"
13
+ [style]="campo()?.style" [hidden]="true" [readOnly]="true" />
14
+
15
+ <div class="gridFactor">
16
+ <input #controle class="fieldSingleInput" name="a" size="1" type="text" [maxLength]="1" min="0" max="9"
17
+ pattern="\d{1,1}" (input)="onInputChar($event)" (keyup)="onKeyUp($event)" (focus)="onFocus($event)"
18
+ [class.corpo]="true" [class.input]="true" />
19
+ <input class="fieldSingleInput" name="b" size="1" type="text" [maxLength]="1" min="0" max="9"
20
+ pattern="\d{1,1}" (input)="onInputChar($event)" (keyup)="onKeyUp($event)" (focus)="onFocus($event)"
21
+ [class.corpo]="true" [class.input]="true" />
22
+ <input class="fieldSingleInput" name="c" size="1" type="text" [maxLength]="1" min="0" max="9"
23
+ pattern="\d{1,1}" (input)="onInputChar($event)" (keyup)="onKeyUp($event)" (focus)="onFocus($event)"
24
+ [class.corpo]="true" [class.input]="true" />
25
+ <input class="fieldSingleInput" name="d" size="1" type="text" [maxLength]="1" min="0" max="9"
26
+ pattern="\d{1,1}" (input)="onInputChar($event)" (keyup)="onKeyUp($event)" (focus)="onFocus($event)"
27
+ [class.corpo]="true" [class.input]="true" />
28
+ <input class="fieldSingleInput" name="e" size="1" type="text" [maxLength]="1" min="0" max="9"
29
+ pattern="\d{1,1}" (input)="onInputChar($event)" (keyup)="onKeyUp($event)" (focus)="onFocus($event)"
30
+ [class.corpo]="true" [class.input]="true" />
31
+ <input class="fieldSingleInput" name="f" size="1" type="text" [maxLength]="1" min="0" max="9"
32
+ pattern="\d{1,1}" (input)="onInputChar($event)" (keyup)="onKeyUp($event)" (focus)="onFocus($event)"
33
+ [class.corpo]="true" [class.input]="true" />
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ <ui-list-errors [errors]="campo()?.errors" [dica]="campo()?.dica" [show]="campo()?.touched"></ui-list-errors>
39
+ </div>
@@ -0,0 +1,106 @@
1
+ import { AfterViewInit, Component, effect, ElementRef, viewChild } from '@angular/core';
2
+ import { LibUtil, LOG } from '../../util/util';
3
+ import { BaseFieldsForm } from '../Base/BaseFieldsForm/BaseFieldsForm.component';
4
+ import { UiListErrors } from "../../elements/ui-list-errors/ui-list-errors";
5
+
6
+ interface ICode {
7
+ [key: string]: string;
8
+ }
9
+
10
+ @Component({
11
+ selector: 'fields-multifactor',
12
+ templateUrl: './multifactor.html',
13
+ styleUrls: ['../fields.css', './multifactor.css'],
14
+ imports: [UiListErrors],
15
+ })
16
+ export class FieldsMultifactor extends BaseFieldsForm implements AfterViewInit {
17
+
18
+ code: ICode = {};
19
+ controle = viewChild('controle', { read: ElementRef });
20
+
21
+ constructor() {
22
+ super();
23
+ effect(() => {
24
+ const val = this.value();
25
+ let empty = val === null || val === undefined || val === '';
26
+ this.updateCampo({ empty });
27
+ });
28
+ }
29
+
30
+ ngAfterViewInit() {
31
+ setTimeout(() => {
32
+ if (this.campo()?.autofocus && this.controle()?.nativeElement) {
33
+ this.controle()?.nativeElement.focus();
34
+ }
35
+ }, 100);
36
+ }
37
+
38
+ onInput(newValue: string) {
39
+ if (this.campo()?.mask) newValue = LibUtil.mascarar(newValue, this.campo()?.mask) ?? '';
40
+ this.updateValue(newValue);
41
+ this.campo()?.onInput?.(this.form());
42
+ }
43
+
44
+
45
+ onInputChar(ev: Event) {
46
+ let e = (ev.target as HTMLInputElement);
47
+ let v = e.value;
48
+ let name = e.name;
49
+ let order = "abcdef";
50
+ let nextInputName: String = "b";
51
+ let isLast = false;
52
+
53
+ if (v && v != "" && "0123456789".includes(v)) {
54
+ // Só seta no objeto se for válido
55
+ this.code[name] = v;
56
+ // Identificar próximo campo
57
+ nextInputName = order.charAt(order.indexOf(name) + 1);
58
+ // Tentativa de focar próximo elemento
59
+ let nextE = (document.querySelector(`.fieldSingleInput[name='${nextInputName}']`) as HTMLInputElement | null);
60
+ if (nextE) {
61
+ nextE.focus();
62
+ } else {
63
+ isLast = true;
64
+ }
65
+ } else {
66
+ e.value = "";
67
+ delete this.code[name];
68
+ }
69
+
70
+ // Seta valor do campo de forma ordenada
71
+ let novoValor = Object.values(Object.fromEntries(Object.entries(this.code).sort())).join("");
72
+ this.updateValue(novoValor);
73
+
74
+ // Verifica se completou
75
+ if (this.campo()?.onComplete && novoValor.length == 6 && isLast) {
76
+ try {
77
+ this.campo()?.onComplete?.(this.form(), novoValor);
78
+ this.onChangeEmit();
79
+ } catch (err) {
80
+ LOG(1, `❌ Erro ao executar onMatch do campo '${this.name.toString()}'`, err);
81
+ }
82
+ }
83
+ }
84
+
85
+ onKeyUp(ev: KeyboardEvent) {
86
+ let key = ev.key;
87
+ let e = (ev.target as HTMLInputElement);
88
+ let v = e.value;
89
+ if (e && v == "" && key == "Backspace") {
90
+ let order = "abcdef";
91
+ let indexOf = order.indexOf(e.name);
92
+ let nextInputName: String = order.charAt(indexOf - 1);
93
+ // Tentativa de focar próximo elemento
94
+ let nextE = (document.querySelector(`.fieldSingleInput[name='${nextInputName}']`) as HTMLInputElement | null);
95
+ if (nextE) {
96
+ if (nextE.value != "") {
97
+ nextE.focus();
98
+ }
99
+ }
100
+ }
101
+ }
102
+
103
+ onFocus(ev: Event) {
104
+ (ev.target as HTMLInputElement)?.select();
105
+ }
106
+ }
@@ -0,0 +1,43 @@
1
+ .FieldMultiKv {
2
+ display: grid;
3
+ grid-template-columns: 1fr 1fr auto;
4
+ grid-template-rows: 40px;
5
+ gap: 8px;
6
+ align-items: center;
7
+ padding: 8px;
8
+ border: 0;
9
+ }
10
+
11
+
12
+ .fieldField.FieldMultiKv .input {
13
+ outline: 1px solid var(--sys-outline);
14
+ }
15
+
16
+ .fieldField.FieldMultiKv .input:focus-visible {
17
+ outline: 2px solid var(--campoCor);
18
+ }
19
+
20
+ .index {
21
+ text-align: center;
22
+ font-weight: bold;
23
+ min-width: 18px;
24
+ }
25
+
26
+ .add {
27
+ grid-area: auto / auto / auto / span 3;
28
+ }
29
+
30
+ .input {
31
+ height: 40px;
32
+ }
33
+
34
+ .action {
35
+ min-width: 32px;
36
+ min-height: 32px;
37
+ }
38
+
39
+ .header {
40
+ font-weight: bold;
41
+ text-decoration: underline;
42
+ padding-left: 10px;
43
+ }
@@ -0,0 +1,47 @@
1
+ <div class="fieldContainer" [class.isTouched]="campo()?.touched" [class.showTouched]="form().showTouched()"
2
+ [class.isInvalid]="campo()?.invalid" [class.isDisabled]="campo()?.disabled" [class.isReadonly]="campo()?.readonly"
3
+ [class.isNeed]="campo()?.need" [class.isPending]="campo()?.pending" [class.isEmpty]="campo()?.empty">
4
+ <div class="fieldLabel" (click)="onClickLabel()" [class.hideLabel]="campo()?.hideLabel">
5
+ @if(campo()?.icone){ <div class="fieldIcon"><i [class]="campo()?.icone"></i></div> }
6
+ {{ campo()?.titulo }}
7
+ </div>
8
+ <div class="fieldControl doCampo">
9
+ <div class="fieldEffect">
10
+ <div class="fieldField FieldMultiKv">
11
+ @if(campo()?.showHeader != false){
12
+ <div class="header">{{ campo()?.tituloChave ?? 'Chaves'}}</div>
13
+ <div class="header">{{ campo()?.tituloValor ?? 'Valores'}}</div>
14
+ <div class="header action"></div>
15
+ }
16
+ @for (item of items; track $index) {
17
+ <div>
18
+ <input type="text" [value]="item.k" [name]="campo()?.prop" [disabled]="campo()?.disabled"
19
+ [placeholder]="campo()?.placeholder ?? ''" [class]="campo()?.classe" [style]="campo()?.style"
20
+ [attr.maxLength]="campo()?.maxl" [attr.minLength]="campo()?.minl" [class.input]="true"
21
+ [class.outlined]="true" (input)="_onLocalInputK($event.target.value, $index)"
22
+ (change)="_onLocalChangeK($event.target.value, $index)" />
23
+ </div>
24
+ <div>
25
+ <input type="text" [value]="item.v" [name]="campo()?.prop" [disabled]="campo()?.disabled"
26
+ [placeholder]="campo()?.placeholder ?? ''" [class]="campo()?.classe" [style]="campo()?.style"
27
+ [attr.maxLength]="campo()?.maxl" [attr.minLength]="campo()?.minl" [class.input]="true"
28
+ [class.outlined]="true" (input)="_onLocalInputV($event.target.value, $index)"
29
+ (change)="_onLocalChangeV($event.target.value, $index)" />
30
+ </div>
31
+ <div class="action">
32
+ <ui-button tipo="icon" tema="error" title="Remover Linha" (click)="onClickDelItem($index)"
33
+ icone="bi bi-trash">
34
+ </ui-button>
35
+ </div>
36
+ }
37
+ <div class="add">
38
+ <ui-button tipo="nofill" tema="primary" title="Adicionar Linha" (click)="onClickAddItem()"
39
+ icone="bi bi-plus-circle">
40
+ Adicionar Linha
41
+ </ui-button>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ <ui-list-errors [errors]="campo()?.errors" [dica]="campo()?.dica" [show]="campo()?.touched"></ui-list-errors>
47
+ </div>
@@ -0,0 +1,88 @@
1
+ import { Component, effect, OnInit } from '@angular/core';
2
+ import { BaseFieldsForm } from '../Base/BaseFieldsForm/BaseFieldsForm.component';
3
+ import { UiButton } from "../../elements/ui-button/ui-button";
4
+ import { UiListErrors } from "../../elements/ui-list-errors/ui-list-errors";
5
+ import { IKV } from '../../interfaces/interfaces';
6
+
7
+ @Component({
8
+ selector: 'fields-multikv',
9
+ templateUrl: './multikv.html',
10
+ styleUrls: ['../fields.css', './multikv.css'],
11
+ imports: [UiButton, UiListErrors],
12
+ })
13
+ export class FieldsMultiKV extends BaseFieldsForm implements OnInit {
14
+
15
+ // Componente para adicionar ou retirar itens em forma KV (Como usado nos seletores)
16
+ items: IKV[] | null = [];
17
+
18
+ constructor() {
19
+ super();
20
+ effect(() => {
21
+ const val = this.value();
22
+ let empty = val === null || val === undefined || val === '';
23
+ if (val && Array.isArray(val) && val.length <= 0) empty = true;
24
+ // if (!Array.isArray(val)) errors = [...errors, Valide.msg.apenasLista];
25
+ this.updateCampo({ empty });
26
+ });
27
+ }
28
+
29
+ override ngOnInit() {
30
+ super.ngOnInit();
31
+ let value = this.value();
32
+ if (value && Array.isArray(value)) this.items = value ?? [];
33
+ else this.items = [];
34
+ }
35
+
36
+ ngAfterViewInit(): void {
37
+ this.updateValue(this.items ?? [], false);
38
+ }
39
+
40
+ onClickAddItem() {
41
+ let value: IKV = this.campo()?.value ?? { k: "", v: "" };
42
+ if (!this.items) this.items = [];
43
+ this.items = [...this.items, value];
44
+ this.updateValue(this.items);
45
+ this.campo()?.onInput?.(this.form());
46
+ this.onChangeEmit();
47
+
48
+ setTimeout(() => {
49
+ let allInputs = (document.querySelectorAll(`.FieldMultiText .input`) as NodeListOf<HTMLInputElement> | null);
50
+ if (allInputs && allInputs.length > 0) {
51
+ allInputs[allInputs.length - 1].focus();
52
+ }
53
+ }, 1);
54
+ }
55
+
56
+ onClickDelItem(index: number) {
57
+ this.items = this.items?.filter((v, i) => i != index) ?? [];
58
+ if (this.items && this.items?.length <= 0) this.items = [];
59
+ this.updateValue(this.items);
60
+ this.campo()?.onInput?.(this.form());
61
+ this.onChangeEmit();
62
+ }
63
+
64
+ _onLocalInputK(key: string, index: number) {
65
+ if (this.items) this.items[index].k = key;
66
+ this.updateValue(this.items);
67
+ this.campo()?.onInput?.(this.form());
68
+ }
69
+
70
+ _onLocalInputV(value: string, index: number) {
71
+ if (this.items) this.items[index].v = value;
72
+ this.updateValue(this.items);
73
+ this.campo()?.onInput?.(this.form());
74
+ }
75
+
76
+ _onLocalChangeK(key: string, index: number) {
77
+ if (this.items) this.items[index].k = key;
78
+ this.updateValue(this.items);
79
+ this.onChangeEmit();
80
+ }
81
+
82
+ _onLocalChangeV(value: string, index: number) {
83
+ if (this.items) this.items[index].v = value;
84
+ this.updateValue(this.items);
85
+ this.onChangeEmit();
86
+ }
87
+
88
+ }
@@ -0,0 +1,36 @@
1
+ .FieldMultiText {
2
+ display: grid;
3
+ grid-template-columns: 1fr auto;
4
+ grid-template-rows: 40px;
5
+ gap: 8px;
6
+ align-items: center;
7
+ padding: 8px;
8
+ border: 0;
9
+ }
10
+
11
+ .fieldField.FieldMultiText .input {
12
+ outline: 1px solid var(--sys-outline);
13
+ }
14
+
15
+ .fieldField.FieldMultiText .input:focus-visible {
16
+ outline: 2px solid var(--campoCor);
17
+ }
18
+
19
+ .index {
20
+ text-align: center;
21
+ font-weight: bold;
22
+ min-width: 18px;
23
+ }
24
+
25
+ .add {
26
+ grid-area: auto / auto / auto / span 2;
27
+ }
28
+
29
+ .input {
30
+ height: 40px;
31
+ }
32
+
33
+ .action {
34
+ min-width: 32px;
35
+ min-height: 32px;
36
+ }
@@ -0,0 +1,38 @@
1
+ <div class="fieldContainer" [class.isTouched]="campo()?.touched" [class.showTouched]="form().showTouched()"
2
+ [class.isInvalid]="campo()?.invalid" [class.isDisabled]="campo()?.disabled" [class.isReadonly]="campo()?.readonly"
3
+ [class.isNeed]="campo()?.need" [class.isPending]="campo()?.pending" [class.isEmpty]="campo()?.empty">
4
+ <div class="fieldLabel" (click)="onClickLabel()" [class.hideLabel]="campo()?.hideLabel">
5
+ @if(campo()?.icone){ <div class="fieldIcon"><i [class]="campo()?.icone"></i></div> }
6
+ {{ campo()?.titulo }}
7
+ </div>
8
+ <div class="fieldControl doCampo">
9
+ <div class="fieldEffect">
10
+ <div class="fieldField FieldMultiText">
11
+ @if(campo()?.showHeader){
12
+ <div>Itens</div>
13
+ <div class="action"></div>
14
+ }
15
+ @for (item of items; track $index) {
16
+ <div>
17
+ <input type="text" [value]="item" [name]="campo()?.prop" [disabled]="campo()?.disabled"
18
+ [placeholder]="campo()?.placeholder ?? ''" [class]="campo()?.classe" [style]="campo()?.style"
19
+ [attr.maxLength]="campo()?.maxl" [attr.minLength]="campo()?.minl" [class.input]="true"
20
+ [class.outlined]="true" (input)="_onLocalInput($event.target.value, $index)" />
21
+ </div>
22
+ <div class="action">
23
+ <ui-button tipo="icon" tema="error" title="Remover Linha" (click)="onClickDelItem($index)"
24
+ icone="bi bi-trash">
25
+ </ui-button>
26
+ </div>
27
+ }
28
+ <div class="add">
29
+ <ui-button tipo="nofill" tema="primary" title="Adicionar Linha" (click)="onClickAddItem()"
30
+ icone="bi bi-plus-circle">
31
+ Adicionar Linha
32
+ </ui-button>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ <ui-list-errors [errors]="campo()?.errors" [dica]="campo()?.dica" [show]="campo()?.touched"></ui-list-errors>
38
+ </div>