@coolon/angular-ui-powerups 16.1.0-alpha.258 → 16.1.0-alpha.260

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 (23) hide show
  1. package/assets/form.scss +145 -9
  2. package/esm2022/lib/components/forms/abstract-input.component.mjs +102 -2
  3. package/esm2022/lib/components/forms/autocomplete-input/autocomplete-input.component.mjs +7 -5
  4. package/esm2022/lib/components/forms/checkbox-input/checkbox-input.component.mjs +6 -4
  5. package/esm2022/lib/components/forms/multiple-select-input/multiple-select-input.component.mjs +6 -4
  6. package/esm2022/lib/components/forms/number-input/number-input.component.mjs +7 -5
  7. package/esm2022/lib/components/forms/password-input/password-input.component.mjs +7 -5
  8. package/esm2022/lib/components/forms/search-input/search-input.component.mjs +12 -10
  9. package/esm2022/lib/components/forms/select-input/select-input.component.mjs +6 -4
  10. package/esm2022/lib/components/forms/string-input/string-input.component.mjs +7 -6
  11. package/esm2022/lib/components/forms/text-input/text-input.component.mjs +6 -4
  12. package/esm2022/lib/interaction/components/editors/inline-string-editor/inline-editor-model.mjs +16 -3
  13. package/esm2022/lib/interaction/components/editors/inline-string-editor/inline-string-editor.component.mjs +3 -2
  14. package/esm2022/lib/interaction/components/input-activities/input-activity.mjs +5 -2
  15. package/esm2022/lib/interaction/components/input-activities/register-validators.mjs +17 -0
  16. package/fesm2022/coolon-angular-ui-powerups.mjs +170 -39
  17. package/fesm2022/coolon-angular-ui-powerups.mjs.map +1 -1
  18. package/lib/components/forms/abstract-input.component.d.ts +51 -0
  19. package/lib/interaction/components/editors/inline-string-editor/inline-editor-model.d.ts +8 -2
  20. package/lib/interaction/components/editors/inline-string-editor/inline-string-editor.component.d.ts +2 -1
  21. package/lib/interaction/components/input-activities/input-activity.d.ts +5 -1
  22. package/lib/interaction/components/input-activities/register-validators.d.ts +12 -0
  23. package/package.json +2 -2
@@ -2,6 +2,7 @@ import { EventEmitter } from '@angular/core';
2
2
  import { ErrorStateMatcher } from '@angular/material/core';
3
3
  import { FloatLabelType } from "@angular/material/form-field";
4
4
  import { Command, Disposable, EventListenerList, FocusManager, IMutableHasValue, ListModel, MutableValueModel, ValueModel } from '@coolon/pectin';
5
+ import type { ValidationMessage } from '@coolon/pectin';
5
6
  import { DisposableComponent } from '../disposable-component';
6
7
  import type { FormField } from "./form-field";
7
8
  import * as i0 from "@angular/core";
@@ -9,6 +10,9 @@ interface InputModel<T> extends IMutableHasValue<T>, Disposable {
9
10
  value: T;
10
11
  enabled$: ValueModel<boolean>;
11
12
  errors$: ListModel<string>;
13
+ /** Optional — models from a pectin predating message severity don't publish these. */
14
+ warnings$?: ListModel<ValidationMessage>;
15
+ info$?: ListModel<ValidationMessage>;
12
16
  focusContext: FocusManager.Context;
13
17
  }
14
18
  export declare class AbstractInputComponent<T> extends DisposableComponent {
@@ -57,12 +61,50 @@ export declare class AbstractInputComponent<T> extends DisposableComponent {
57
61
  hasErrors(): boolean;
58
62
  get errorList$(): ListModel<string>;
59
63
  get firstError(): string;
64
+ /**
65
+ * Material gives us one message slot, so severity decides who gets it:
66
+ * error, then warning, then info, then the plain hint.
67
+ */
68
+ hasWarnings(): boolean;
69
+ get warningList$(): ListModel<ValidationMessage> | undefined;
70
+ get firstWarning(): string;
71
+ hasInfo(): boolean;
72
+ get infoList$(): ListModel<ValidationMessage> | undefined;
73
+ get firstInfo(): string;
60
74
  get focusContext(): FocusManager.Context;
61
75
  get label(): string;
62
76
  get hint(): string;
63
77
  get placeholder(): string;
64
78
  get floatLabel(): FloatLabelType;
65
79
  get showHint(): boolean;
80
+ /**
81
+ * The one message this field has to communicate, highest severity first.
82
+ *
83
+ * Resolved here rather than in each template so the inline subscript and the dense popup can
84
+ * never disagree about which message wins.
85
+ */
86
+ get validationMessage(): AbstractInputComponent.Message | null;
87
+ /**
88
+ * Dense fields have no room for a subscript, so they show their message in a popup instead.
89
+ */
90
+ private get inlineMessage();
91
+ get inlineError(): string | null;
92
+ /** Warning, info and the plain hint all share Material's single hint slot. */
93
+ get inlineHintText(): string | null;
94
+ get inlineHintClass(): string | null;
95
+ /**
96
+ * Drives the subscript collapse — the reserved space only opens up when there is something to
97
+ * put in it.
98
+ */
99
+ get hasInlineMessage(): boolean;
100
+ /**
101
+ * The message a dense field shows in its popup. A plain hint stays suppressed when dense, as it
102
+ * always has been — the popup is for validation results, not decoration.
103
+ */
104
+ get popupMessage(): string | null;
105
+ get popupIcon(): string | null;
106
+ get popupSeverityClass(): string | null;
107
+ private get popupSeverity();
66
108
  /**
67
109
  * Invokes the callback when this components value is changed by a user edit.
68
110
  * @param callback
@@ -72,4 +114,13 @@ export declare class AbstractInputComponent<T> extends DisposableComponent {
72
114
  static ɵfac: i0.ɵɵFactoryDeclaration<AbstractInputComponent<any>, never>;
73
115
  static ɵcmp: i0.ɵɵComponentDeclaration<AbstractInputComponent<any>, "ng-component", never, { "i18n$": { "alias": "i18n$"; "required": false; }; "i18n": { "alias": "i18n"; "required": false; }; "_label": { "alias": "label"; "required": false; }; "userFloatLabel": { "alias": "floatLabel"; "required": false; }; "_hint": { "alias": "hint"; "required": false; }; "_placeholder": { "alias": "placeholder"; "required": false; }; "dense": { "alias": "dense"; "required": false; }; "enabled$": { "alias": "enabled$"; "required": false; }; "focusCommand": { "alias": "command.focus"; "required": false; }; "blurCommand": { "alias": "command.blur"; "required": false; }; "enterCommand": { "alias": "command.enter"; "required": false; }; "escapeCommand": { "alias": "command.escape"; "required": false; }; "clickCommand": { "alias": "command.click"; "required": false; }; }, { "focus": "focus"; "blur": "blur"; "enterKey": "enterKey"; "escapeKey": "escapeKey"; }, never, never, false, never>;
74
116
  }
117
+ export declare namespace AbstractInputComponent {
118
+ /** 'hint' is the plain, non-validation hint — it has no severity of its own. */
119
+ type Severity = 'error' | 'warning' | 'info';
120
+ interface Message {
121
+ text: string;
122
+ severity: Severity | 'hint';
123
+ }
124
+ const SEVERITY_ICONS: Record<Severity, string>;
125
+ }
75
126
  export {};
@@ -1,4 +1,5 @@
1
1
  import { GarbageCollector, ListModel, MutableValueModel, Validator, ValueModel } from '@coolon/pectin';
2
+ import type { HasValidators } from '@coolon/pectin';
2
3
  import type { EditContext } from '../edit-context';
3
4
  export declare class InlineEditorModel<T> extends GarbageCollector {
4
5
  readonly valueModel: ValueModel<T>;
@@ -10,8 +11,13 @@ export declare class InlineEditorModel<T> extends GarbageCollector {
10
11
  get editingEnabled(): ValueModel<boolean>;
11
12
  disableWhile(condition: ValueModel<boolean>): this;
12
13
  enableWhile(condition: ValueModel<boolean>): this;
13
- get validators(): ListModel<Validator<T>>;
14
- validateUsing(validator: Validator<T>): this;
14
+ /**
15
+ * The registered validators, each either bare or paired with its options. Applied to the
16
+ * activity's model when an edit starts — see registerValidators.
17
+ */
18
+ get validators(): ListModel<Validator.Registerable<T>>;
19
+ validateUsing(validators: readonly Validator<T>[], options?: HasValidators.Options): this;
20
+ validateUsing(validator: Validator<T>, options?: HasValidators.Options): this;
15
21
  isEditing(): boolean;
16
22
  cancelEdit(): void;
17
23
  startEditing(): void;
@@ -15,7 +15,8 @@ import * as i0 from "@angular/core";
15
15
  * } catch(error) {
16
16
  * context.injectError(error)
17
17
  * }
18
- * }).validateUsing(Validator.present("We'll need a value");
18
+ * }).validateUsing(Validator.present("We'll need a value"))
19
+ * .validateUsing(looksShouty, { severity: 'warning' }); // options are honoured here
19
20
  *
20
21
  * # in the view
21
22
  * <aup-inline-string-editor
@@ -33,7 +33,11 @@ export declare namespace InputActivity {
33
33
  layout?: InputActivity.Layout;
34
34
  confirmFace?: CommandFace;
35
35
  cancelFace?: CommandFace;
36
- validators?: Validator<T>[] | ReadonlyArray<Validator<T>>;
36
+ /**
37
+ * Each entry is either a bare validator or a {validator, options} pair, so conditional and
38
+ * non-error-severity validators work here as they do on a form model.
39
+ */
40
+ validators?: ReadonlyArray<Validator.Registerable<T>>;
37
41
  cancelOnEscape?: boolean;
38
42
  cssClassName?: string;
39
43
  dataCy?: string;
@@ -0,0 +1,12 @@
1
+ import type { HasValidators, Validator } from '@coolon/pectin';
2
+ /**
3
+ * Registers a mixed list of bare validators and `{validator, options}` pairs, preserving each
4
+ * one's options — the array overload of `validateUsing` cannot, since there is one options
5
+ * argument for the whole array.
6
+ *
7
+ * Deliberately implemented here rather than calling an equivalent pectin helper: this library
8
+ * builds against a *published* pectin, so depending on a newly added function would turn a
9
+ * version skew into a runtime TypeError instead of a graceful degradation. The types it uses
10
+ * are erased at compile time and cost nothing.
11
+ */
12
+ export declare function registerValidators<T>(target: HasValidators<T>, validators: readonly Validator.Registerable<T>[] | undefined): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coolon/angular-ui-powerups",
3
- "version": "16.1.0-alpha.258",
3
+ "version": "16.1.0-alpha.260",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "^16.2.9",
6
6
  "@angular/common": "^16.2.9",
@@ -12,7 +12,7 @@
12
12
  "@angular/platform-browser-dynamic": "^16.2.9",
13
13
  "@angular/material-moment-adapter": "^16.2.10",
14
14
  "@angular/router": "^16.2.9",
15
- "@coolon/pectin": "^5.0.0-alpha.128",
15
+ "@coolon/pectin": "^5.0.0-alpha.130",
16
16
  "fast-typescript-memoize": "^1.1.1",
17
17
  "lodash-es": "^4.17.21",
18
18
  "marked": "4.0.10",