nath-angular-ui 0.3.0 → 0.4.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.
@@ -10,13 +10,13 @@ import { RouterModule, Router, NavigationEnd, RouterLink, RouterLinkActive } fro
10
10
  import * as i1$2 from '@angular/forms';
11
11
  import { FormsModule, FormControl, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms';
12
12
  import { BasePortalOutlet, CdkPortalOutlet, TemplatePortal, ComponentPortal } from '@angular/cdk/portal';
13
- import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
13
+ import { toObservable, toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
14
14
  import * as i1$3 from '@angular/cdk/drag-drop';
15
15
  import { DragDropModule } from '@angular/cdk/drag-drop';
16
16
  import { filter } from 'rxjs/operators';
17
+ import { of, fromEvent } from 'rxjs';
17
18
  import { DomSanitizer } from '@angular/platform-browser';
18
19
  import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
19
- import { fromEvent } from 'rxjs';
20
20
  import { Tabs, TabList, Tab, TabPanel, TabContent } from '@angular/aria/tabs';
21
21
 
22
22
  class NathAutocomplete {
@@ -1103,38 +1103,75 @@ class NathShowErrors {
1103
1103
  maxValue: (message) => message,
1104
1104
  integer: () => `Must be an integer`,
1105
1105
  };
1106
- signalField = input.required(/* @ts-ignore */
1107
- ...(ngDevMode ? [{ debugName: "signalField" }] : /* istanbul ignore next */ []));
1106
+ signalField = input(/* @ts-ignore */
1107
+ ...(ngDevMode ? [undefined, { debugName: "signalField" }] : /* istanbul ignore next */ []));
1108
+ control = input(/* @ts-ignore */
1109
+ ...(ngDevMode ? [undefined, { debugName: "control" }] : /* istanbul ignore next */ []));
1110
+ controlValue = toSignal(this.control()?.valueChanges ?? of(null));
1111
+ controlErrors = computed(() => {
1112
+ this.controlValue();
1113
+ return this.listOfErrors();
1114
+ }, /* @ts-ignore */
1115
+ ...(ngDevMode ? [{ debugName: "controlErrors" }] : /* istanbul ignore next */ []));
1108
1116
  static getMessage(type, params) {
1109
1117
  return NathShowErrors.errorMessages[type](params);
1110
1118
  }
1111
1119
  shouldShowErrors() {
1112
1120
  const fieldState = this.signalField();
1113
- return !!fieldState && !!fieldState.errors() && (fieldState.dirty() || fieldState.touched());
1121
+ const control = this.control();
1122
+ return ((!!fieldState && !!fieldState.errors() && (fieldState.dirty() || fieldState.touched())) ||
1123
+ (!!control && !!control.errors && (control.dirty || control.touched)));
1124
+ }
1125
+ listOfErrors() {
1126
+ const result = [];
1127
+ const control = this.control();
1128
+ if (control?.errors) {
1129
+ for (const errorsKey in control.errors) {
1130
+ result.push({
1131
+ kind: errorsKey,
1132
+ message: NathShowErrors.getMessage(errorsKey, control?.errors?.[errorsKey]),
1133
+ });
1134
+ }
1135
+ }
1136
+ return result;
1114
1137
  }
1115
1138
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: NathShowErrors, deps: [], target: i0.ɵɵFactoryTarget.Component });
1116
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: NathShowErrors, isStandalone: true, selector: "nath-show-errors", inputs: { signalField: { classPropertyName: "signalField", publicName: "signalField", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
1117
- @if (shouldShowErrors()) {
1118
- <div class="nath-show-errors-container">
1119
- @for (error of signalField().errors(); track error.kind) {
1120
- <div class="nath-show-errors-item">{{ error.message }}</div>
1121
- }
1122
- </div>
1123
- }
1139
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: NathShowErrors, isStandalone: true, selector: "nath-show-errors", inputs: { signalField: { classPropertyName: "signalField", publicName: "signalField", isSignal: true, isRequired: false, transformFunction: null }, control: { classPropertyName: "control", publicName: "control", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
1140
+ @if (shouldShowErrors()) {
1141
+ <div class="nath-show-errors-container">
1142
+ @if (signalField()) {
1143
+ @for (error of signalField()!.errors(); track error.kind) {
1144
+ <div class="nath-show-errors-item">{{ error.message }}</div>
1145
+ }
1146
+ }
1147
+ @if (control()) {
1148
+ @for (error of controlErrors(); track error.message) {
1149
+ <div class="nath-show-errors-item">{{ error.message }}</div>
1150
+ }
1151
+ }
1152
+ </div>
1153
+ }
1124
1154
  `, isInline: true, styles: ["nath-show-errors,.nath-show-errors-theme{--nath-show-errors-gap: .5rem;--nath-show-errors-text: var(--color-danger-500, oklch(55% .22 25));display:block;padding:0}.dark nath-show-errors,.dark .nath-show-errors-theme{--nath-show-errors-text: var(--color-danger-400, oklch(65% .22 25))}.nath-show-errors-container{display:flex;flex-direction:column;gap:var(--nath-show-errors-gap)}.nath-show-errors-item{color:var(--nath-show-errors-text)}.ng-invalid.ng-dirty+nath-show-errors,.ng-invalid.ng-touched+nath-show-errors{color:var(--nath-show-errors-text)}\n"], encapsulation: i0.ViewEncapsulation.None });
1125
1155
  }
1126
1156
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: NathShowErrors, decorators: [{
1127
1157
  type: Component,
1128
- args: [{ selector: 'nath-show-errors', imports: [], template: `
1129
- @if (shouldShowErrors()) {
1130
- <div class="nath-show-errors-container">
1131
- @for (error of signalField().errors(); track error.kind) {
1132
- <div class="nath-show-errors-item">{{ error.message }}</div>
1133
- }
1134
- </div>
1135
- }
1158
+ args: [{ selector: 'nath-show-errors', imports: [], template: `
1159
+ @if (shouldShowErrors()) {
1160
+ <div class="nath-show-errors-container">
1161
+ @if (signalField()) {
1162
+ @for (error of signalField()!.errors(); track error.kind) {
1163
+ <div class="nath-show-errors-item">{{ error.message }}</div>
1164
+ }
1165
+ }
1166
+ @if (control()) {
1167
+ @for (error of controlErrors(); track error.message) {
1168
+ <div class="nath-show-errors-item">{{ error.message }}</div>
1169
+ }
1170
+ }
1171
+ </div>
1172
+ }
1136
1173
  `, encapsulation: ViewEncapsulation.None, styles: ["nath-show-errors,.nath-show-errors-theme{--nath-show-errors-gap: .5rem;--nath-show-errors-text: var(--color-danger-500, oklch(55% .22 25));display:block;padding:0}.dark nath-show-errors,.dark .nath-show-errors-theme{--nath-show-errors-text: var(--color-danger-400, oklch(65% .22 25))}.nath-show-errors-container{display:flex;flex-direction:column;gap:var(--nath-show-errors-gap)}.nath-show-errors-item{color:var(--nath-show-errors-text)}.ng-invalid.ng-dirty+nath-show-errors,.ng-invalid.ng-touched+nath-show-errors{color:var(--nath-show-errors-text)}\n"] }]
1137
- }], propDecorators: { signalField: [{ type: i0.Input, args: [{ isSignal: true, alias: "signalField", required: true }] }] } });
1174
+ }], propDecorators: { signalField: [{ type: i0.Input, args: [{ isSignal: true, alias: "signalField", required: false }] }], control: [{ type: i0.Input, args: [{ isSignal: true, alias: "control", required: false }] }] } });
1138
1175
 
1139
1176
  class NathFormField {
1140
1177
  inputId = input(null, /* @ts-ignore */
@@ -1172,7 +1209,7 @@ class NathFormField {
1172
1209
  <nath-show-errors [signalField]="signalField()!" />
1173
1210
  }
1174
1211
  </div>
1175
- `, isInline: true, styles: ["nath-form-field,.nath-form-field-theme{--nath-form-field-gap: .5rem;--nath-form-field-label-color: var(--color-zinc-900, oklch(21% .006 285.885));--nath-form-field-label-font-size: .875rem;--nath-form-field-label-font-weight: 500;--nath-form-field-required-color: var(--color-red-500, oklch(63.7% .237 25.331));--nath-form-field-error-color: var(--color-red-600, oklch(57.7% .245 27.325))}.dark nath-form-field,.dark .nath-form-field-theme{--nath-form-field-label-color: var(--color-zinc-200, oklch(92% .004 286.32))}nath-form-field{display:block}.nath-form-field-container{display:flex;width:100%;flex-direction:column;gap:var(--nath-form-field-gap)}.nath-form-field-label{width:100%;color:var(--nath-form-field-label-color);font-size:var(--nath-form-field-label-font-size);font-weight:var(--nath-form-field-label-font-weight)}.nath-form-field-label--required:after{content:\"*\";margin-left:.25rem;color:var(--nath-form-field-required-color)}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "component", type: NathShowErrors, selector: "nath-show-errors", inputs: ["signalField"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.Eager, encapsulation: i0.ViewEncapsulation.None });
1212
+ `, isInline: true, styles: ["nath-form-field,.nath-form-field-theme{--nath-form-field-gap: .5rem;--nath-form-field-label-color: var(--color-zinc-900, oklch(21% .006 285.885));--nath-form-field-label-font-size: .875rem;--nath-form-field-label-font-weight: 500;--nath-form-field-required-color: var(--color-red-500, oklch(63.7% .237 25.331));--nath-form-field-error-color: var(--color-red-600, oklch(57.7% .245 27.325))}.dark nath-form-field,.dark .nath-form-field-theme{--nath-form-field-label-color: var(--color-zinc-200, oklch(92% .004 286.32))}nath-form-field{display:block}.nath-form-field-container{display:flex;width:100%;flex-direction:column;gap:var(--nath-form-field-gap)}.nath-form-field-label{width:100%;color:var(--nath-form-field-label-color);font-size:var(--nath-form-field-label-font-size);font-weight:var(--nath-form-field-label-font-weight)}.nath-form-field-label--required:after{content:\"*\";margin-left:.25rem;color:var(--nath-form-field-required-color)}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "component", type: NathShowErrors, selector: "nath-show-errors", inputs: ["signalField", "control"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.Eager, encapsulation: i0.ViewEncapsulation.None });
1176
1213
  }
1177
1214
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: NathFormField, decorators: [{
1178
1215
  type: Component,
@@ -5484,5 +5521,5 @@ function isSortOrderValid(order) {
5484
5521
  * Generated bundle index. Do not edit.
5485
5522
  */
5486
5523
 
5487
- export { BreadcrumbService, ConfirmationService, DARK_THEME_CLASS, DIALOG_DATA, DialogRef, DialogService, NathAutocomplete, NathBooleanControl, NathBreadcrumbs, NathCodeViewer, NathConfirmationDialog, NathDatepicker, NathDialogContainer, NathDrawer, NathFileUpload, NathFloatingLabel, NathFormField, NathImagePreview, NathMenu, NathMenuList, NathMultiselect, NathPaginatedView, NathPaginator, NathPanel, NathPickList, NathProgressBar, NathProgressCircle, NathRadioButtonGroup, NathRatingHeart, NathRatingInput, NathSelect, NathSkeleton, NathSlider, NathSortIcon, NathSplitButton, NathTabs, NathThemeSwitch, NathToastContainer, NathToc, NathTooltipContainer, NathTooltipDirective, ORDER, RATING_MAP, THEME_CONFIG, TabDirective, TabPanelDirective, ThemeService, ToastService, getRatingColor, hasRequiredValidator, isRequired, isSortOrderValid, isTruthy, next, provideThemeConfig, rangeMinMax, rangeNotMinMax, validateAllFormFields };
5524
+ export { BreadcrumbService, ConfirmationService, DARK_THEME_CLASS, DIALOG_DATA, DialogRef, DialogService, NathAutocomplete, NathBooleanControl, NathBreadcrumbs, NathCodeViewer, NathConfirmationDialog, NathDatepicker, NathDialogContainer, NathDrawer, NathFileUpload, NathFloatingLabel, NathFormField, NathImagePreview, NathMenu, NathMenuList, NathMultiselect, NathPaginatedView, NathPaginator, NathPanel, NathPickList, NathProgressBar, NathProgressCircle, NathRadioButtonGroup, NathRatingHeart, NathRatingInput, NathSelect, NathShowErrors, NathSkeleton, NathSlider, NathSortIcon, NathSplitButton, NathTabs, NathThemeSwitch, NathToastContainer, NathToc, NathTooltipContainer, NathTooltipDirective, ORDER, RATING_MAP, THEME_CONFIG, TabDirective, TabPanelDirective, ThemeService, ToastService, getRatingColor, hasRequiredValidator, isRequired, isSortOrderValid, isTruthy, next, provideThemeConfig, rangeMinMax, rangeNotMinMax, validateAllFormFields };
5488
5525
  //# sourceMappingURL=nath-angular-ui.mjs.map