shirkasoft-ui-components 2.0.0 → 2.0.1

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.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as i0 from "@angular/core";
5
5
  import { OnDestroy } from "@angular/core";
6
- import { FormValueControl } from "@angular/forms/signals";
6
+ import { FormValueControl, ValidationError } from "@angular/forms/signals";
7
7
  interface FileUploadError {
8
8
  type: 'size' | 'type';
9
9
  message: string;
@@ -48,6 +48,14 @@ export declare class FileUploadComponent implements OnDestroy, FormValueControl<
48
48
  existingFiles: import("@angular/core").InputSignal<ExistingFile[]>;
49
49
  /** How existing files are rendered. */
50
50
  existingDisplay: import("@angular/core").InputSignal<"chips" | "tiles">;
51
+ /** Errors bound automatically by the Signal Forms `[formField]` directive. */
52
+ errors: import("@angular/core").InputSignal<readonly ValidationError.WithOptionalFieldTree[]>;
53
+ /** Invalid status bound automatically by `[formField]`. */
54
+ invalid: import("@angular/core").InputSignal<boolean>;
55
+ /** Touched status bound automatically by `[formField]`. */
56
+ touched: import("@angular/core").InputSignal<boolean>;
57
+ /** Dirty status bound automatically by `[formField]`. */
58
+ dirty: import("@angular/core").InputSignal<boolean>;
51
59
  /** Emitted with the currently selected files. */
52
60
  fileSelected: import("@angular/core").OutputEmitterRef<File[]>;
53
61
  /** Emitted when the last selected file is removed. */
@@ -70,6 +78,12 @@ export declare class FileUploadComponent implements OnDestroy, FormValueControl<
70
78
  errorMessage: import("@angular/core").WritableSignal<string>;
71
79
  /** Whether the user is dragging files over the zone. */
72
80
  isDragOver: import("@angular/core").WritableSignal<boolean>;
81
+ /**
82
+ * Error message rendered under the uploader. Local type/size errors take
83
+ * precedence; otherwise the first Signal Forms error is shown once the field
84
+ * has been touched or modified.
85
+ */
86
+ displayError: import("@angular/core").Signal<string>;
73
87
  /** Object URLs used for image previews. */
74
88
  private previewUrls;
75
89
  /** Whether another selection is allowed. */
@@ -172,6 +186,26 @@ export declare class FileUploadComponent implements OnDestroy, FormValueControl<
172
186
  "required": false;
173
187
  "isSignal": true;
174
188
  };
189
+ "errors": {
190
+ "alias": "errors";
191
+ "required": false;
192
+ "isSignal": true;
193
+ };
194
+ "invalid": {
195
+ "alias": "invalid";
196
+ "required": false;
197
+ "isSignal": true;
198
+ };
199
+ "touched": {
200
+ "alias": "touched";
201
+ "required": false;
202
+ "isSignal": true;
203
+ };
204
+ "dirty": {
205
+ "alias": "dirty";
206
+ "required": false;
207
+ "isSignal": true;
208
+ };
175
209
  "value": {
176
210
  "alias": "value";
177
211
  "required": false;
@@ -2,7 +2,7 @@
2
2
  * Generated bundle index. Do not edit.
3
3
  */
4
4
  import { ControlValueAccessor, FormControl } from "@angular/forms";
5
- import { FormValueControl } from "@angular/forms/signals";
5
+ import { FormValueControl, ValidationError } from "@angular/forms/signals";
6
6
  import * as i0 from "@angular/core";
7
7
  /**
8
8
  * Shirkasoft UI Components.
@@ -34,6 +34,14 @@ export declare class PriceInputComponent implements ControlValueAccessor, FormVa
34
34
  required: import("@angular/core").InputSignal<boolean>;
35
35
  /** Disables the input. */
36
36
  disabled: import("@angular/core").InputSignal<boolean>;
37
+ /** Errors bound automatically by the Signal Forms `[formField]` directive. */
38
+ errors: import("@angular/core").InputSignal<readonly ValidationError.WithOptionalFieldTree[]>;
39
+ /** Invalid status bound automatically by `[formField]`. */
40
+ invalid: import("@angular/core").InputSignal<boolean>;
41
+ /** Touched status bound automatically by `[formField]`. */
42
+ touched: import("@angular/core").InputSignal<boolean>;
43
+ /** Dirty status bound automatically by `[formField]`. */
44
+ dirty: import("@angular/core").InputSignal<boolean>;
37
45
  /** Minimum allowed value (clamped on blur). */
38
46
  min: import("@angular/core").InputSignal<number | undefined>;
39
47
  /** Maximum allowed value (clamped on blur). */
@@ -82,12 +90,18 @@ export declare class PriceInputComponent implements ControlValueAccessor, FormVa
82
90
  private ctrlSubscribed;
83
91
  /** Bumped on control status changes / blur so error computeds refresh. */
84
92
  private statusTick;
93
+ /**
94
+ * True when the input is driven by Signal Forms instead of a reactive control.
95
+ * Detected by the absence of a reactive control: `[formField]` provides the
96
+ * state through its `errors`/`invalid`/`touched`/`dirty` inputs.
97
+ */
98
+ protected readonly usesSignalForms: import("@angular/core").Signal<boolean>;
85
99
  /**
86
100
  * Whether the error state is shown: forced with `showError`, or when the
87
101
  * bound `control` is invalid and has been touched or modified.
88
102
  */
89
103
  hasError: import("@angular/core").Signal<boolean>;
90
- /** Message shown under the field: `errorMessage` or one derived from the control errors. */
104
+ /** Message shown under the field: `errorMessage` or one derived from the errors. */
91
105
  errorText: import("@angular/core").Signal<string>;
92
106
  /** Effective disabled state combining the input and the form binding. */
93
107
  isDisabled: import("@angular/core").Signal<boolean>;
@@ -160,6 +174,26 @@ export declare class PriceInputComponent implements ControlValueAccessor, FormVa
160
174
  "required": false;
161
175
  "isSignal": true;
162
176
  };
177
+ "errors": {
178
+ "alias": "errors";
179
+ "required": false;
180
+ "isSignal": true;
181
+ };
182
+ "invalid": {
183
+ "alias": "invalid";
184
+ "required": false;
185
+ "isSignal": true;
186
+ };
187
+ "touched": {
188
+ "alias": "touched";
189
+ "required": false;
190
+ "isSignal": true;
191
+ };
192
+ "dirty": {
193
+ "alias": "dirty";
194
+ "required": false;
195
+ "isSignal": true;
196
+ };
163
197
  "min": {
164
198
  "alias": "min";
165
199
  "required": false;
@@ -4,7 +4,7 @@
4
4
  import * as i0 from "@angular/core";
5
5
  import { ElementRef } from "@angular/core";
6
6
  import { ControlValueAccessor, FormControl, FormGroup } from "@angular/forms";
7
- import { FormValueControl } from "@angular/forms/signals";
7
+ import { FormValueControl, ValidationError } from "@angular/forms/signals";
8
8
  /** Option rendered by the select, optionally prefixed with a "new entry" badge. */
9
9
  interface SelectOption {
10
10
  label: string;
@@ -53,6 +53,14 @@ export declare class SelectComponent implements ControlValueAccessor, FormValueC
53
53
  usePagination: import("@angular/core").InputSignal<boolean>;
54
54
  /** Disables the whole select. */
55
55
  disabled: import("@angular/core").InputSignal<boolean>;
56
+ /** Errors bound automatically by the Signal Forms `[formField]` directive. */
57
+ errors: import("@angular/core").InputSignal<readonly ValidationError.WithOptionalFieldTree[]>;
58
+ /** Invalid status bound automatically by `[formField]`. */
59
+ invalid: import("@angular/core").InputSignal<boolean>;
60
+ /** Touched status bound automatically by `[formField]`. */
61
+ touched: import("@angular/core").InputSignal<boolean>;
62
+ /** Dirty status bound automatically by `[formField]`. */
63
+ dirty: import("@angular/core").InputSignal<boolean>;
56
64
  /** Custom per-validation-error messages shown under the select. */
57
65
  errorMessages: import("@angular/core").InputSignal<{
58
66
  [key: string]: string;
@@ -108,7 +116,13 @@ export declare class SelectComponent implements ControlValueAccessor, FormValueC
108
116
  isDisabled: import("@angular/core").Signal<boolean>;
109
117
  /** Resolves the form control from `control` or from `formGroup`+`label`. */
110
118
  actualControl: import("@angular/core").Signal<FormControl<any> | undefined>;
111
- /** Whether the bound control should display its error (invalid + touched/dirty). */
119
+ /**
120
+ * True when the select is driven by Signal Forms instead of a reactive control.
121
+ * Detected by the absence of a reactive control: `[formField]` provides the
122
+ * state through its `errors`/`invalid`/`touched`/`dirty` inputs.
123
+ */
124
+ protected readonly usesSignalForms: import("@angular/core").Signal<boolean>;
125
+ /** Whether the select should display its validation errors. */
112
126
  shouldShowError: import("@angular/core").Signal<boolean | undefined>;
113
127
  /** Whether an error was shown before and the control is now valid + touched. */
114
128
  wasFixedError: import("@angular/core").Signal<boolean | undefined>;
@@ -275,6 +289,26 @@ export declare class SelectComponent implements ControlValueAccessor, FormValueC
275
289
  "required": false;
276
290
  "isSignal": true;
277
291
  };
292
+ "errors": {
293
+ "alias": "errors";
294
+ "required": false;
295
+ "isSignal": true;
296
+ };
297
+ "invalid": {
298
+ "alias": "invalid";
299
+ "required": false;
300
+ "isSignal": true;
301
+ };
302
+ "touched": {
303
+ "alias": "touched";
304
+ "required": false;
305
+ "isSignal": true;
306
+ };
307
+ "dirty": {
308
+ "alias": "dirty";
309
+ "required": false;
310
+ "isSignal": true;
311
+ };
278
312
  "errorMessages": {
279
313
  "alias": "errorMessages";
280
314
  "required": false;
@@ -4,7 +4,7 @@
4
4
  import * as i0 from "@angular/core";
5
5
  import { ElementRef } from "@angular/core";
6
6
  import { ControlValueAccessor, FormControl, FormGroup } from "@angular/forms";
7
- import { FormValueControl } from "@angular/forms/signals";
7
+ import { FormValueControl, ValidationError } from "@angular/forms/signals";
8
8
  /**
9
9
  * Shirkasoft UI Components.
10
10
  * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
@@ -44,6 +44,14 @@ export declare class TextFieldComponent implements ControlValueAccessor, FormVal
44
44
  control: import("@angular/core").InputSignal<FormControl<any> | undefined>;
45
45
  /** Disables the field. */
46
46
  disabled: import("@angular/core").InputSignal<boolean>;
47
+ /** Errors bound automatically by the Signal Forms `[formField]` directive. */
48
+ errors: import("@angular/core").InputSignal<readonly ValidationError.WithOptionalFieldTree[]>;
49
+ /** Invalid status bound automatically by `[formField]`. */
50
+ invalid: import("@angular/core").InputSignal<boolean>;
51
+ /** Touched status bound automatically by `[formField]`. */
52
+ touched: import("@angular/core").InputSignal<boolean>;
53
+ /** Dirty status bound automatically by `[formField]`. */
54
+ dirty: import("@angular/core").InputSignal<boolean>;
47
55
  /** Custom error message shown regardless of validation errors. */
48
56
  errorMessage: import("@angular/core").InputSignal<string>;
49
57
  /** Renders a textarea instead of an input. */
@@ -93,11 +101,15 @@ export declare class TextFieldComponent implements ControlValueAccessor, FormVal
93
101
  private readonly innerControl;
94
102
  /** Explicit `control`, or `formGroup.get(label)`, or `undefined` if none. */
95
103
  private externalControl;
96
- /** True when the field is driven by its internal control (no reactive control given). */
97
- private usesInnerControl;
104
+ /**
105
+ * True when the field is driven by Signal Forms (or plain `[(value)]`) instead
106
+ * of a reactive control. Detected by the absence of an external control:
107
+ * `[formField]` then provides `errors`/`invalid`/`touched`/`dirty`.
108
+ */
109
+ protected usesSignalForms: import("@angular/core").Signal<boolean>;
98
110
  /** Resolves the reactive control: external one if any, otherwise the internal one. */
99
111
  actualControl: import("@angular/core").Signal<FormControl<any>>;
100
- /** True when the resolved control is invalid and dirty or touched. */
112
+ /** True when the field should display its validation errors. */
101
113
  shouldShowError: import("@angular/core").Signal<boolean>;
102
114
  /** True when the control had an error before and is now valid (success state). */
103
115
  wasFixedError: import("@angular/core").Signal<boolean>;
@@ -197,6 +209,26 @@ export declare class TextFieldComponent implements ControlValueAccessor, FormVal
197
209
  "required": false;
198
210
  "isSignal": true;
199
211
  };
212
+ "errors": {
213
+ "alias": "errors";
214
+ "required": false;
215
+ "isSignal": true;
216
+ };
217
+ "invalid": {
218
+ "alias": "invalid";
219
+ "required": false;
220
+ "isSignal": true;
221
+ };
222
+ "touched": {
223
+ "alias": "touched";
224
+ "required": false;
225
+ "isSignal": true;
226
+ };
227
+ "dirty": {
228
+ "alias": "dirty";
229
+ "required": false;
230
+ "isSignal": true;
231
+ };
200
232
  "errorMessage": {
201
233
  "alias": "errorMessage";
202
234
  "required": false;
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { IconNode } from "shirkasoft-ui-components/icons";
5
5
  import * as i0 from "@angular/core";
6
+ import { ValidationError } from "@angular/forms/signals";
6
7
  /** Maps the icon names used across the library to their SVG data. */
7
8
  export declare const ICONS: Record<string, IconNode>;
8
9
  /**
@@ -58,4 +59,36 @@ export declare class PortalDirective {
58
59
  constructor();
59
60
  static ɵfac: i0.ɵɵFactoryDeclaration<PortalDirective, never>;
60
61
  static ɵdir: i0.ɵɵDirectiveDeclaration<PortalDirective, "[shkPortal]", never, {}, {}, never, never, true, never>;
61
- }
62
+ }
63
+ /**
64
+ * Messages keyed by error kind. Accepts both Reactive Forms keys
65
+ * (`required`, `minlength`, `maxlength`…) and Signal Forms keys
66
+ * (`required`, `minLength`, `maxLength`, `minDate`…).
67
+ */
68
+ type ShkErrorMessages = {
69
+ [kind: string]: string;
70
+ };
71
+ /**
72
+ * Converts Signal Forms errors (the ones the `FormField` directive delivers to
73
+ * the `errors` input) into the same map exposed by `AbstractControl.errors`.
74
+ *
75
+ * This way controls reuse a single message mapping for Reactive Forms and
76
+ * Signal Forms, and the error parameters (`minLength`, `min`, `maxDate`…) are
77
+ * available under the names Signal Forms uses.
78
+ */
79
+ export declare function signalErrorsToMap(errors: readonly ValidationError.WithOptionalFieldTree[] | undefined): Record<string, any> | null;
80
+ /**
81
+ * Builds the readable message list for an error map.
82
+ *
83
+ * The map may come from `AbstractControl.errors` (Reactive Forms) or from
84
+ * `signalErrorsToMap` (Signal Forms). Priority order:
85
+ * 1. Message configured in `errorMessages`.
86
+ * 2. The error's own message (`message`), e.g. `requiredError({ message })`.
87
+ * 3. Translated message for the error kind.
88
+ *
89
+ * Signal Forms `minLength`/`maxLength` keys are translated with the same
90
+ * `validation.minlength`/`validation.maxlength` keys Reactive Forms uses, so no
91
+ * extra translations are needed.
92
+ */
93
+ export declare function errorMessagesFromMap(errors: Record<string, any> | null | undefined, customErrors: ShkErrorMessages, translate: (key: string, params?: Record<string, any>) => string): string[];
94
+ export type { ShkErrorMessages };