ng-hub-ui-forms 22.45.1 → 22.46.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.
- package/README.md +14 -0
- package/fesm2022/ng-hub-ui-forms.mjs +37 -18
- package/fesm2022/ng-hub-ui-forms.mjs.map +1 -1
- package/package.json +1 -1
- package/styles/_field.scss +69 -0
- package/styles/_tokens.scss +3 -0
- package/types/ng-hub-ui-forms.d.ts +47 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng-hub-ui-forms",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.46.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Accessible, signal-based form fields for Angular (input, textarea, slider, segmented, select, datepicker, file input with drag & drop and upload progress) with automatic error display for controls, FormGroups and FormArrays. Reactive Forms today, Signal Forms ready. Part of the ng-hub-ui family.",
|
|
6
6
|
"author": "Carlos Morcillo Fernández <carlos.morcillo@me.com> (https://www.carlosmorcillo.com)",
|
package/styles/_field.scss
CHANGED
|
@@ -289,6 +289,74 @@ hub-timepicker {
|
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Feedback motion, picked with `provideHubForms({ feedbackAnimation })`.
|
|
294
|
+
*
|
|
295
|
+
* Angular adds `--<preset>-enter` while a message appears and `--<preset>-leave` while it goes,
|
|
296
|
+
* and waits for the animation before removing the element. `collapse` animates the row height
|
|
297
|
+
* through `grid-template-rows` (0fr to 1fr), the one way to reach the message's natural height
|
|
298
|
+
* without measuring it, so the fields below slide down instead of jumping.
|
|
299
|
+
*/
|
|
300
|
+
@keyframes hub-field-feedback-collapse {
|
|
301
|
+
from {
|
|
302
|
+
grid-template-rows: 0fr;
|
|
303
|
+
margin-top: 0;
|
|
304
|
+
opacity: 0;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
to {
|
|
308
|
+
grid-template-rows: 1fr;
|
|
309
|
+
margin-top: var(--hub-form-feedback-margin-top);
|
|
310
|
+
opacity: 1;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
@keyframes hub-field-feedback-fade {
|
|
315
|
+
from {
|
|
316
|
+
opacity: 0;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
@keyframes hub-field-feedback-slide {
|
|
321
|
+
from {
|
|
322
|
+
opacity: 0;
|
|
323
|
+
transform: translateY(calc(-1 * var(--hub-form-feedback-slide-distance)));
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
@each $preset in collapse, fade, slide {
|
|
328
|
+
.hub-field__feedback--#{$preset}-enter,
|
|
329
|
+
.hub-field__feedback--#{$preset}-leave {
|
|
330
|
+
animation: hub-field-feedback-#{$preset}
|
|
331
|
+
var(--hub-form-feedback-motion-duration)
|
|
332
|
+
var(--hub-form-feedback-motion-easing)
|
|
333
|
+
both;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.hub-field__feedback--#{$preset}-leave {
|
|
337
|
+
animation-direction: reverse;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.hub-field__feedback--collapse-enter,
|
|
342
|
+
.hub-field__feedback--collapse-leave {
|
|
343
|
+
display: grid;
|
|
344
|
+
|
|
345
|
+
> * {
|
|
346
|
+
min-height: 0;
|
|
347
|
+
overflow: hidden;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
@media (prefers-reduced-motion: reduce) {
|
|
352
|
+
@each $preset in collapse, fade, slide {
|
|
353
|
+
.hub-field__feedback--#{$preset}-enter,
|
|
354
|
+
.hub-field__feedback--#{$preset}-leave {
|
|
355
|
+
animation: none;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
292
360
|
/**
|
|
293
361
|
* Feedback as a tooltip, asked for by a container through `HUB_FIELD_FEEDBACK` (the paginable
|
|
294
362
|
* table does it under `flushFields`).
|
|
@@ -305,6 +373,7 @@ hub-timepicker {
|
|
|
305
373
|
|
|
306
374
|
.hub-field__feedback {
|
|
307
375
|
position: absolute;
|
|
376
|
+
animation: none;
|
|
308
377
|
width: 1px;
|
|
309
378
|
height: 1px;
|
|
310
379
|
padding: 0;
|
package/styles/_tokens.scss
CHANGED
|
@@ -45,6 +45,9 @@
|
|
|
45
45
|
--hub-form-feedback-color: var(--hub-form-invalid-color);
|
|
46
46
|
--hub-form-feedback-font-size: var(--hub-ref-font-size-sm, 0.875rem);
|
|
47
47
|
--hub-form-feedback-margin-top: var(--hub-ref-space-1, 0.25rem);
|
|
48
|
+
--hub-form-feedback-motion-duration: var(--hub-sys-transition-duration-base, 260ms);
|
|
49
|
+
--hub-form-feedback-motion-easing: cubic-bezier(0.2, 0, 0, 1);
|
|
50
|
+
--hub-form-feedback-slide-distance: var(--hub-ref-space-1, 0.25rem);
|
|
48
51
|
|
|
49
52
|
--hub-form-text-color: var(--hub-sys-text-muted, #6a737b);
|
|
50
53
|
--hub-form-text-font-size: var(--hub-ref-font-size-sm, 0.875rem);
|
|
@@ -135,6 +135,11 @@ declare abstract class HubFieldControl extends HubFormControl implements Control
|
|
|
135
135
|
protected _errorTemplates: {
|
|
136
136
|
[key: string]: TemplateRef<any> | undefined;
|
|
137
137
|
};
|
|
138
|
+
/** Classes that animate the messages under the field in and out, from the global config. */
|
|
139
|
+
protected readonly feedbackMotion: {
|
|
140
|
+
enter: string;
|
|
141
|
+
leave: string;
|
|
142
|
+
};
|
|
138
143
|
/** Stable unique id linking the label and the control. */
|
|
139
144
|
readonly id: string;
|
|
140
145
|
/** Query for a projected `hubFormText` helper template. */
|
|
@@ -254,6 +259,11 @@ declare abstract class HubGroupControl implements AfterContentInit, OnDestroy {
|
|
|
254
259
|
protected _errorTemplates: {
|
|
255
260
|
[key: string]: TemplateRef<any> | undefined;
|
|
256
261
|
};
|
|
262
|
+
/** Classes that animate the group's error message in and out, from the global config. */
|
|
263
|
+
protected readonly feedbackMotion: {
|
|
264
|
+
enter: string;
|
|
265
|
+
leave: string;
|
|
266
|
+
};
|
|
257
267
|
/**
|
|
258
268
|
* The currently bound group control. A `computed` (not an `effect`-fed signal) so it resolves
|
|
259
269
|
* synchronously on first render — otherwise a `<form [formGroup]>` would briefly bind `null` and
|
|
@@ -281,19 +291,6 @@ declare abstract class HubGroupControl implements AfterContentInit, OnDestroy {
|
|
|
281
291
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<HubGroupControl, never, never, { "group": { "alias": "group"; "required": false; "isSignal": true; }; "groupName": { "alias": "groupName"; "required": false; "isSignal": true; }; "errorTrigger": { "alias": "errorTrigger"; "required": false; "isSignal": true; }; "invalidFeedbackTemplateFn": { "alias": "invalidFeedbackTemplateFn"; "required": false; "isSignal": true; }; }, {}, ["errorTpts"], never, true, never>;
|
|
282
292
|
}
|
|
283
293
|
|
|
284
|
-
/**
|
|
285
|
-
* Default, human-readable messages for the most common Angular validation errors.
|
|
286
|
-
*
|
|
287
|
-
* Consumers can override this per field (via the `invalidFeedbackTemplateFn` input) or globally
|
|
288
|
-
* (via {@link provideHubForms}). The function receives the error `key` and its `value` (the payload
|
|
289
|
-
* Angular stores for that error) and returns the message string (HTML allowed).
|
|
290
|
-
*
|
|
291
|
-
* @param key - The validation error key (e.g. `required`, `min`, `minlength`, `equal`).
|
|
292
|
-
* @param value - The error payload as stored on the control's `errors` object.
|
|
293
|
-
* @returns A localized-by-default English message describing the error.
|
|
294
|
-
*/
|
|
295
|
-
declare function defaultInvalidFeedback(key: string, value: any): string;
|
|
296
|
-
|
|
297
294
|
/**
|
|
298
295
|
* Selection mode for `<hub-datepicker>`: how many points are picked, and how they relate.
|
|
299
296
|
*
|
|
@@ -666,6 +663,21 @@ declare const defaultHubColorConfig: HubColorConfig;
|
|
|
666
663
|
/** Built-in (English) password labels. */
|
|
667
664
|
declare const defaultHubPasswordLabels: HubPasswordLabels;
|
|
668
665
|
|
|
666
|
+
/** Built-in motions for validation messages; `none` shows and hides them at once. */
|
|
667
|
+
type HubFeedbackAnimationPreset = 'collapse' | 'fade' | 'slide' | 'none';
|
|
668
|
+
/**
|
|
669
|
+
* Your own motion for validation messages: CSS classes Angular adds while the message
|
|
670
|
+
* enters and while it leaves. Their rules must be global (not encapsulated in a component),
|
|
671
|
+
* because the class lands on the field's feedback element.
|
|
672
|
+
*/
|
|
673
|
+
interface HubFeedbackAnimationClasses {
|
|
674
|
+
/** Classes added while the message appears (an `animation` or a `transition` on them). */
|
|
675
|
+
enter: string;
|
|
676
|
+
/** Classes added while the message goes; without them it is removed at once. */
|
|
677
|
+
leave?: string;
|
|
678
|
+
}
|
|
679
|
+
/** How validation messages appear and go: a built-in preset or your own classes. */
|
|
680
|
+
type HubFeedbackAnimation = HubFeedbackAnimationPreset | HubFeedbackAnimationClasses;
|
|
669
681
|
/**
|
|
670
682
|
* Global configuration contract for `ng-hub-ui-forms`.
|
|
671
683
|
*/
|
|
@@ -684,6 +696,14 @@ interface HubFormsConfig {
|
|
|
684
696
|
* (only invalid is automatic); a per-field `showValid` input overrides this.
|
|
685
697
|
*/
|
|
686
698
|
showValid: boolean;
|
|
699
|
+
/**
|
|
700
|
+
* How the validation messages under a field appear and go. `collapse` (the default) opens
|
|
701
|
+
* the space the message needs while it fades in, so the fields below slide instead of
|
|
702
|
+
* jumping; `fade` and `slide` keep the jump and only soften the text; `none` turns motion
|
|
703
|
+
* off. Pass {@link HubFeedbackAnimationClasses} for your own. Every built-in preset stops
|
|
704
|
+
* under `prefers-reduced-motion`.
|
|
705
|
+
*/
|
|
706
|
+
feedbackAnimation: HubFeedbackAnimation;
|
|
687
707
|
/** Global datepicker defaults (locale labels, formats, first day of week…). */
|
|
688
708
|
datepicker: HubDatepickerConfig;
|
|
689
709
|
/** Global file-input labels (button text, accessible names, size and rejection formatting). */
|
|
@@ -731,6 +751,19 @@ type DeepPartial<T> = {
|
|
|
731
751
|
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
|
|
732
752
|
};
|
|
733
753
|
|
|
754
|
+
/**
|
|
755
|
+
* Default, human-readable messages for the most common Angular validation errors.
|
|
756
|
+
*
|
|
757
|
+
* Consumers can override this per field (via the `invalidFeedbackTemplateFn` input) or globally
|
|
758
|
+
* (via {@link provideHubForms}). The function receives the error `key` and its `value` (the payload
|
|
759
|
+
* Angular stores for that error) and returns the message string (HTML allowed).
|
|
760
|
+
*
|
|
761
|
+
* @param key - The validation error key (e.g. `required`, `min`, `minlength`, `equal`).
|
|
762
|
+
* @param value - The error payload as stored on the control's `errors` object.
|
|
763
|
+
* @returns A localized-by-default English message describing the error.
|
|
764
|
+
*/
|
|
765
|
+
declare function defaultInvalidFeedback(key: string, value: any): string;
|
|
766
|
+
|
|
734
767
|
/**
|
|
735
768
|
* An event emitted while a single file is being uploaded.
|
|
736
769
|
*
|
|
@@ -4219,4 +4252,4 @@ interface HubFormControlAdapter {
|
|
|
4219
4252
|
declare const hubFormControlAdapter: HubFormControlAdapter;
|
|
4220
4253
|
|
|
4221
4254
|
export { FormTextTypes, HUB_COLOR_PALETTES, HUB_FILE_UPLOADER, HUB_FORMS_CONFIG, HubAppendDirective, HubAutoresizeDirective, HubDatepickerComponent, HubFieldControl, HubFieldsetComponent, HubFileDropDirective, HubFileDropOverlayComponent, HubFileDropzoneNoticeDirective, HubFileIconDirective, HubFileInputComponent, HubFilePreviewDirective, HubFormComponent, HubFormControl, HubFormTextDirective, HubGroupControl, HubInputComponent, HubInputFormats, HubInputPrefixDirective, HubInputSuffixDirective, HubInvertColorPipe, HubJoinButLastPipe, HubLabelTypes, HubLegendComponent, HubLegendDirective, HubMapPipe, HubOtpInputComponent, HubPrependDirective, HubSafeUrlPipe, HubScrollToErrorDirective, HubSegmentedComponent, HubSegmentedOptionDirective, HubSelectClearButtonDirective, HubSelectComponent, HubSelectFooterDirective, HubSelectFormats, HubSelectHeaderDirective, HubSelectLabelDirective, HubSelectLoadingSpinnerDirective, HubSelectLoadingTextDirective, HubSelectMultiLabelDirective, HubSelectNotFoundDirective, HubSelectOptgroupDirective, HubSelectOptionDirective, HubSelectSuffixDirective, HubSelectTagDirective, HubSelectTypeToSearchDirective, HubSliderComponent, HubSnakeUpperPipe, HubTextareaComponent, HubTimepickerComponent, HubUcfirstPipe, HubValidationErrorDirective, NgClearButtonTemplateDirective, NgFooterTemplateDirective, NgHeaderTemplateDirective, NgLabelTemplateDirective, NgLoadingSpinnerTemplateDirective, NgLoadingTextTemplateDirective, NgMultiLabelTemplateDirective, NgNotFoundTemplateDirective, NgOptgroupTemplateDirective, NgOptionComponent, NgOptionTemplateDirective, NgSelectConfig, NgTagTemplateDirective, NgTypeToSearchTemplateDirective, applyMask, areEqual, camelToSnakeUpper, controlHasMinOrMaxValidator, defaultHubColorConfig, defaultHubDatepickerConfig, defaultHubDatepickerLabels, defaultHubFileInputLabels, defaultHubFormsConfig, defaultHubPasswordLabels, defaultInvalidFeedback, fileKey, fileKind, formatFileSize, get, getActiveElement, getMinOrMaxValueFromValidator, hubAcceptedFiles, hubAreEqual, hubFormControlAdapter, hubMaxFileSize, hubMaxFiles, hubMaxTotalSize, hubMinFileSize, hubMinFiles, isDefined, isMaskActive, isString, joinButLast, matchesAccept, provideHubFileUploader, provideHubForms, runInZone, scorePasswordStrength, toFileArray, uuid };
|
|
4222
|
-
export type { FormTextType, HubColorConfig, HubColorPaletteName, HubColorSwatch, HubColorSwatchInput, HubCurrentFile, HubDateRange, HubDateValue, HubDatepickerConfig, HubDatepickerGranularity, HubDatepickerLabels, HubDatepickerMode, HubDatepickerValueFormat, HubFileConstraints, HubFileDropScope, HubFileIconContext, HubFileInputAppearance, HubFileInputLabels, HubFileItem, HubFileKind, HubFilePreview, HubFilePreviewContext, HubFileRejection, HubFileRejectionReason, HubFileStatus, HubFileUploadEvent, HubFileUploader, HubFileValue, HubFormControlAdapter, HubFormControlConfig, HubFormControlHandle, HubFormControlOption, HubFormsConfig, HubGroupErrorTrigger, HubInputFormat, HubLabelType, HubMaskResult, HubOtpMode, HubPasswordLabels, HubPasswordStrengthScore, HubSegmentedOption, HubSegmentedOptionContext, HubSegmentedSize, HubSelectFormat, HubSliderValue };
|
|
4255
|
+
export type { FormTextType, HubColorConfig, HubColorPaletteName, HubColorSwatch, HubColorSwatchInput, HubCurrentFile, HubDateRange, HubDateValue, HubDatepickerConfig, HubDatepickerGranularity, HubDatepickerLabels, HubDatepickerMode, HubDatepickerValueFormat, HubFeedbackAnimation, HubFeedbackAnimationClasses, HubFeedbackAnimationPreset, HubFileConstraints, HubFileDropScope, HubFileIconContext, HubFileInputAppearance, HubFileInputLabels, HubFileItem, HubFileKind, HubFilePreview, HubFilePreviewContext, HubFileRejection, HubFileRejectionReason, HubFileStatus, HubFileUploadEvent, HubFileUploader, HubFileValue, HubFormControlAdapter, HubFormControlConfig, HubFormControlHandle, HubFormControlOption, HubFormsConfig, HubGroupErrorTrigger, HubInputFormat, HubLabelType, HubMaskResult, HubOtpMode, HubPasswordLabels, HubPasswordStrengthScore, HubSegmentedOption, HubSegmentedOptionContext, HubSegmentedSize, HubSelectFormat, HubSliderValue };
|