@compsych-ui-components/angular 7.0.9 → 7.0.11

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.
@@ -0,0 +1,24 @@
1
+ import { DialogRef } from '@angular/cdk/dialog';
2
+ /**
3
+ * Reference to a dialog opened via {@link DialogService.open}. Returned to the opener and
4
+ * also injectable by the opened content component/template (to close with a result).
5
+ *
6
+ * Wraps the CDK `DialogRef`. `closed` is a `Promise` that resolves with the close result — or
7
+ * `undefined` when the dialog is dismissed (close button / Escape / backdrop). CDK emits its
8
+ * own `closed` synchronously inside `close()`, which can trigger `ExpressionChangedAfter-
9
+ * ItHasBeenChecked` (NG0100) when a subscriber updates view state; a Promise defers to a
10
+ * microtask, so handlers are change-detection safe. Using a Promise (rather than an rxjs
11
+ * Observable) also keeps the library rxjs-free and mirrors ng-bootstrap's `NgbModalRef.result`.
12
+ */
13
+ export declare class CompsychDialogRef<R = unknown> {
14
+ private readonly _cdkRef;
15
+ /** Resolves once the dialog has closed, with the result (or `undefined` when dismissed). */
16
+ readonly closed: Promise<R | undefined>;
17
+ constructor(_cdkRef: DialogRef<R, unknown>);
18
+ /** The opened component instance, or `null` for template content. */
19
+ get componentInstance(): unknown;
20
+ /** Unique id of the open dialog. */
21
+ get id(): string;
22
+ /** Closes the dialog, optionally passing a result to `closed`. */
23
+ close(result?: R): void;
24
+ }
@@ -0,0 +1,54 @@
1
+ import { SafeHtml } from '@angular/platform-browser';
2
+ import { DialogVariant } from './dialog-types';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Internal presentational chrome for the dialog: the surface box, header (leading icon +
6
+ * title + close, or a floating close), centered icon badge + title/description, the body
7
+ * slot, and the actions footer. Rendered by BOTH the declarative `compsych-dialog` and the
8
+ * imperative `DialogService` container, so the chrome has a single source of truth.
9
+ *
10
+ * Not part of the public API. Overlay/a11y state (role, aria-modal, focus, open) is owned
11
+ * by the host (the CDK dialog container); `titleId`/`descId` are supplied by the host so its
12
+ * `aria-labelledby`/`aria-describedby` can reference the rendered title/description elements.
13
+ * The host renders `display: contents`, so `.cmp-dialog` is the layout box.
14
+ */
15
+ export declare class DialogSurfaceComponent {
16
+ /** Layout type. */
17
+ readonly variant: import("@angular/core").InputSignal<DialogVariant>;
18
+ /** Optional CSS-length width override (falls back to the variant width). */
19
+ readonly width: import("@angular/core").InputSignal<string>;
20
+ /** Heading text. */
21
+ readonly title: import("@angular/core").InputSignal<string>;
22
+ /** Supporting text (rendered for `centered` and `alert` variants). */
23
+ readonly description: import("@angular/core").InputSignal<string>;
24
+ /** Lucide icon name (leading header icon / centered badge glyph). */
25
+ readonly icon: import("@angular/core").InputSignal<string>;
26
+ /** Whether the close button is shown. */
27
+ readonly dismissible: import("@angular/core").InputSignal<boolean>;
28
+ /** Accessible label for the close button. */
29
+ readonly closeLabel: import("@angular/core").InputSignal<string>;
30
+ /** Whether the projected actions footer is rendered. */
31
+ readonly showActions: import("@angular/core").InputSignal<boolean>;
32
+ /** Id for the title element (host supplies it for `aria-labelledby`). */
33
+ readonly titleId: import("@angular/core").InputSignal<string>;
34
+ /** Id for the description element (host supplies it for `aria-describedby`). */
35
+ readonly descId: import("@angular/core").InputSignal<string>;
36
+ /** Emitted when the close button is activated. */
37
+ readonly closeClick: import("@angular/core").OutputEmitterRef<void>;
38
+ private readonly sanitizer;
39
+ constructor();
40
+ /** Header (leading) icon markup at 24px. */
41
+ protected readonly iconMarkup: import("@angular/core").Signal<SafeHtml>;
42
+ /** Centered badge icon markup at 32px. */
43
+ protected readonly centeredIconMarkup: import("@angular/core").Signal<SafeHtml>;
44
+ /** Close (`x`) icon markup at 20px. */
45
+ protected readonly closeMarkup: import("@angular/core").Signal<SafeHtml>;
46
+ /**
47
+ * Looks up a Lucide icon by name and injects an explicit width/height so it renders at the
48
+ * right size when bound via `[innerHTML]` (Angular's CSS encapsulation does not reach
49
+ * dynamically injected content). Matches the Card/Button icon helper.
50
+ */
51
+ private buildIcon;
52
+ static ɵfac: i0.ɵɵFactoryDeclaration<DialogSurfaceComponent, never>;
53
+ static ɵcmp: i0.ɵɵComponentDeclaration<DialogSurfaceComponent, "cmp-dialog-surface", never, { "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "description": { "alias": "description"; "required": false; "isSignal": true; }; "icon": { "alias": "icon"; "required": false; "isSignal": true; }; "dismissible": { "alias": "dismissible"; "required": false; "isSignal": true; }; "closeLabel": { "alias": "closeLabel"; "required": false; "isSignal": true; }; "showActions": { "alias": "showActions"; "required": false; "isSignal": true; }; "titleId": { "alias": "titleId"; "required": false; "isSignal": true; }; "descId": { "alias": "descId"; "required": false; "isSignal": true; }; }, { "closeClick": "closeClick"; }, never, ["*", "[cmpDialogActions]"], true, never>;
54
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Dialog layout type — mirrors the Figma "Dialog" organism `Type` property
3
+ * (file VFBn7KCDy3FSIlvhNo3ylq, 873:9194).
4
+ *
5
+ * - `'modal-leading-icon'` — header row with an optional leading icon + title
6
+ * and a close button, a projected body, and a
7
+ * full-width split action footer. Widest surface.
8
+ * - `'modal-centered-icon'` — a centered icon badge above a centered title +
9
+ * description, with a full-width split action footer.
10
+ * - `'alert'` — compact: left-aligned title + description with the
11
+ * actions right-aligned. Narrowest surface.
12
+ */
13
+ export type DialogVariant = 'modal-leading-icon' | 'modal-centered-icon' | 'alert';
@@ -0,0 +1,87 @@
1
+ import { OnDestroy } from '@angular/core';
2
+ import { DialogVariant } from './dialog-types';
3
+ import * as i0 from "@angular/core";
4
+ /** How a dialog was closed — surfaced by the `closed` output. */
5
+ export type DialogCloseReason = 'programmatic' | 'backdrop' | 'escape' | 'close-button';
6
+ /**
7
+ * A themeable modal dialog built on `@angular/cdk/dialog` (centered, scrimmed, focus-trapped).
8
+ *
9
+ * Figma: Core Components — "Dialog" organism (file VFBn7KCDy3FSIlvhNo3ylq, 873:9194).
10
+ *
11
+ * One component, switched by `variant`:
12
+ * - `modal-leading-icon` — leading icon + title header, projected body, split footer.
13
+ * - `modal-centered-icon` — centered icon badge, centered title + description, split footer.
14
+ * - `alert` — compact title + description, right-aligned footer.
15
+ *
16
+ * Open state is a two-way `[(open)]` model wrapped around the CDK `Dialog` service. The
17
+ * CDK dialog container provides `role="dialog"`, `aria-modal`, the focus trap, initial
18
+ * focus (`autoFocus: 'dialog'`) and focus restoration. The dialog closes on Escape /
19
+ * backdrop click (when `dismissible`); those are handled here so `closed` can report a
20
+ * reason. Title/description come from inputs; project the body as default content and each
21
+ * action button with the `cmpDialogActions` attribute (the footer lays them out — split
22
+ * full-width for modals, right-aligned for alerts).
23
+ *
24
+ * <compsych-dialog [(open)]="showDialog" variant="modal-leading-icon"
25
+ * icon="globe" title="Update your details">
26
+ * <p>Body content…</p>
27
+ * <compsych-button cmpDialogActions variant="outlined" fullWidth label="Cancel" (click)="showDialog = false" />
28
+ * <compsych-button cmpDialogActions variant="filled" fullWidth label="Save" (click)="save()" />
29
+ * </compsych-dialog>
30
+ *
31
+ * Consumers must load `@angular/cdk/overlay-prebuilt.css` (overlay positioning) and the
32
+ * `@compsych-ui-components/shared` design tokens globally. The scrim color is injected by
33
+ * the dialog itself — no extra stylesheet import is needed.
34
+ */
35
+ export declare class DialogComponent implements OnDestroy {
36
+ /** Two-way open state. Set to `true` to show the dialog, `false` to close it. */
37
+ readonly open: import("@angular/core").ModelSignal<boolean>;
38
+ /** Layout type. Defaults to `modal-leading-icon`. */
39
+ readonly variant: import("@angular/core").InputSignal<DialogVariant>;
40
+ /**
41
+ * Optional width override — any CSS length (e.g. `'1000px'`). Defaults to the variant
42
+ * width (800px modal / 600px alert). Always clamped to the viewport on small screens.
43
+ */
44
+ readonly width: import("@angular/core").InputSignal<string>;
45
+ /** Heading text. Also drives the accessible name via `aria-labelledby`. */
46
+ readonly title: import("@angular/core").InputSignal<string>;
47
+ /** Supporting text under the title (rendered for `centered` and `alert` variants). */
48
+ readonly description: import("@angular/core").InputSignal<string>;
49
+ /** Lucide icon name — the leading header icon (`leading`) or centered badge glyph (`centered`). */
50
+ readonly icon: import("@angular/core").InputSignal<string>;
51
+ /**
52
+ * When true (default) the dialog shows a close button and closes on Escape / backdrop click.
53
+ * When false, the dialog is a forced choice — provide a focusable action (e.g. a
54
+ * `[cmpDialogActions]` button) so keyboard users can dismiss it (WCAG 2.1.2, no keyboard trap).
55
+ */
56
+ readonly dismissible: import("@angular/core").InputSignal<boolean>;
57
+ /** Accessible label for the close button. */
58
+ readonly closeLabel: import("@angular/core").InputSignal<string>;
59
+ /** Accessible name used when no `title` is provided (e.g. a fully custom body). */
60
+ readonly ariaLabel: import("@angular/core").InputSignal<string>;
61
+ /** Renders the action footer. Set false to hide it when there are no actions. */
62
+ readonly showActions: import("@angular/core").InputSignal<boolean>;
63
+ /** Emits after the dialog has been opened and shown. */
64
+ readonly opened: import("@angular/core").OutputEmitterRef<void>;
65
+ /** Emits after the dialog has closed, with the reason it closed. */
66
+ readonly closed: import("@angular/core").OutputEmitterRef<DialogCloseReason>;
67
+ /** The dialog surface template, projected into the CDK dialog container when open. */
68
+ private panelTemplate;
69
+ private readonly dialog;
70
+ private readonly overlay;
71
+ private readonly directionality;
72
+ private readonly viewContainerRef;
73
+ private dialogRef?;
74
+ private closeReason;
75
+ private readonly _ids;
76
+ protected readonly titleId: string;
77
+ protected readonly descId: string;
78
+ constructor();
79
+ ngOnDestroy(): void;
80
+ /** Close request from the close button. */
81
+ protected requestClose(): void;
82
+ private closeWith;
83
+ private attach;
84
+ private detach;
85
+ static ɵfac: i0.ɵɵFactoryDeclaration<DialogComponent, never>;
86
+ static ɵcmp: i0.ɵɵComponentDeclaration<DialogComponent, "compsych-dialog", never, { "open": { "alias": "open"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "description": { "alias": "description"; "required": false; "isSignal": true; }; "icon": { "alias": "icon"; "required": false; "isSignal": true; }; "dismissible": { "alias": "dismissible"; "required": false; "isSignal": true; }; "closeLabel": { "alias": "closeLabel"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "showActions": { "alias": "showActions"; "required": false; "isSignal": true; }; }, { "open": "openChange"; "opened": "opened"; "closed": "closed"; }, never, ["*", "[cmpDialogActions]"], true, never>;
87
+ }
@@ -0,0 +1,55 @@
1
+ import { TemplateRef, Type } from '@angular/core';
2
+ import { CompsychDialogRef } from './dialog-ref';
3
+ import { DialogVariant } from './dialog-types';
4
+ import * as i0 from "@angular/core";
5
+ /** Configuration for {@link DialogService.open}. */
6
+ export interface CompsychDialogConfig<D = unknown> {
7
+ /** Layout type. Defaults to `modal-leading-icon`. */
8
+ variant?: DialogVariant;
9
+ /** Heading text (drives the accessible name via `aria-labelledby`). */
10
+ title?: string;
11
+ /** Supporting text (rendered for `centered` / `alert` variants). */
12
+ description?: string;
13
+ /** Lucide icon name (leading header icon / centered badge glyph). */
14
+ icon?: string;
15
+ /** When true (default) shows a close button and closes on Escape / backdrop click. */
16
+ dismissible?: boolean;
17
+ /** Accessible label for the close button. */
18
+ closeLabel?: string;
19
+ /** Accessible name used when no `title` is provided. */
20
+ ariaLabel?: string;
21
+ /** Width override — any CSS length. Defaults to the variant width, viewport-clamped. */
22
+ width?: string;
23
+ /** Whether to render the projected actions footer. */
24
+ showActions?: boolean;
25
+ /** Data injected into the opened component via the CDK `DIALOG_DATA` token. */
26
+ data?: D;
27
+ /** Extra class(es) for the overlay pane. */
28
+ panelClass?: string | string[];
29
+ }
30
+ /**
31
+ * Opens a component or template as a modal dialog inside the compsych-dialog chrome,
32
+ * imperatively (like Angular Material's `MatDialog`). Built on `@angular/cdk/dialog`.
33
+ *
34
+ * The opened content is placed in the dialog body; the header (icon/title/close) and
35
+ * behavior come from the config. The opened component can inject the CDK `DialogRef`
36
+ * (to close, optionally with a result) and `DIALOG_DATA` (to read `config.data`) — both
37
+ * re-exported from `@compsych-ui-components/angular`.
38
+ *
39
+ * const ref = dialogService.open(MyComponent, {
40
+ * title: 'Edit details', variant: 'modal-leading-icon', icon: 'globe', data: { id },
41
+ * });
42
+ * ref.closed.subscribe((result) => { ... });
43
+ *
44
+ * Requires `@angular/cdk/overlay-prebuilt.css` + the `@compsych-ui-components/shared` tokens
45
+ * loaded globally. The scrim color is injected by the dialog — no extra stylesheet needed.
46
+ */
47
+ export declare class DialogService {
48
+ private readonly dialog;
49
+ private readonly overlay;
50
+ private readonly directionality;
51
+ /** Opens `content` as a modal dialog. Returns a {@link CompsychDialogRef} (close / closed). */
52
+ open<R = unknown, D = unknown, C = unknown>(content: Type<C> | TemplateRef<C>, config?: CompsychDialogConfig<D>): CompsychDialogRef<R>;
53
+ static ɵfac: i0.ɵɵFactoryDeclaration<DialogService, never>;
54
+ static ɵprov: i0.ɵɵInjectableDeclaration<DialogService>;
55
+ }
@@ -1,10 +1,26 @@
1
1
  import { EventEmitter } from '@angular/core';
2
2
  import { ControlValueAccessor, NgControl } from '@angular/forms';
3
+ import { ButtonVariant } from '../button/button';
3
4
  import * as i0 from "@angular/core";
4
5
  /** Size variant of a `compsych-text-input`. Controls input height, padding, and font size. */
5
6
  export type TextInputSize = 'small' | 'medium' | 'large';
6
7
  /** Native input type. */
7
8
  export type TextInputType = 'text' | 'password';
9
+ /** Configuration for the optional button rendered at the right of the label row. */
10
+ export interface TextInputLabelButton {
11
+ /** Stable identifier emitted by `labelButtonClick` when clicked. */
12
+ id: string;
13
+ /** Text displayed on the button. */
14
+ label: string;
15
+ /** Visual style of the button. Defaults to `'text'`. */
16
+ variant?: ButtonVariant;
17
+ /** Lucide icon name shown before the label. */
18
+ leadingIcon?: string;
19
+ /** Lucide icon name shown after the label. */
20
+ trailingIcon?: string;
21
+ /** Hides the label and renders a square icon-only button. Requires `leadingIcon`. */
22
+ iconOnly?: boolean;
23
+ }
8
24
  /**
9
25
  * A labelled text input that wraps a native `<input>` element.
10
26
  * Implements `ControlValueAccessor` so it works with both reactive forms
@@ -40,6 +56,30 @@ export declare class TextInputComponent implements ControlValueAccessor {
40
56
  * Forwarded to `aria-describedby` on the native `<input>`.
41
57
  */
42
58
  ariaDescribedBy?: string;
59
+ /** Text displayed below the input. Shown in red when the input is in error state. */
60
+ supportingText: string;
61
+ /**
62
+ * Static error text shown in red when the input is in error state.
63
+ * Used when the input is outside a form (with `[error]="true"`).
64
+ * When inside a form, prefer `errorMessages` for per-validator messages.
65
+ */
66
+ errorMessage: string;
67
+ /**
68
+ * Map of Angular validator error keys to display strings.
69
+ * The component reads `ngControl.errors` to determine which validator failed
70
+ * and shows the matching message in red below the input.
71
+ * Example: `{ required: 'Username is required', minlength: 'Min 8 characters' }`
72
+ */
73
+ errorMessages: Record<string, string>;
74
+ private _labelButton;
75
+ /**
76
+ * JSON string configuring the optional button at the right of the label row.
77
+ * Hidden when empty or omitted. Example: `'{"id":"show","label":"Show"}'`
78
+ * Clicking emits the button's `id` via the `labelButtonClick` output.
79
+ */
80
+ set labelButton(json: string);
81
+ /** @internal Template access to the parsed label button config. */
82
+ protected get parsedLabelButton(): TextInputLabelButton | null;
43
83
  /**
44
84
  * Adds a blue asterisk after the label. When used in a form, this is set
45
85
  * automatically if the bound `FormControl` has `Validators.required`.
@@ -59,11 +99,16 @@ export declare class TextInputComponent implements ControlValueAccessor {
59
99
  readonly: boolean;
60
100
  /** Emits the new string value whenever the user types. For use outside Angular forms; inside forms use the `FormControl` value stream. */
61
101
  readonly valueChange: EventEmitter<string>;
102
+ /** Emits the label button's `id` when it is clicked. */
103
+ readonly labelButtonClick: EventEmitter<string>;
62
104
  get inputId(): string;
63
105
  /** True when the bound FormControl is invalid and touched, or when `error` is explicitly set. */
64
106
  get hasError(): boolean;
65
107
  /** True when `required` is set explicitly, or when the bound FormControl has Validators.required. */
66
108
  get isRequired(): boolean;
109
+ private get activeErrorMessage();
110
+ get displayedSupportingText(): string;
111
+ get describedBy(): string | null;
67
112
  get wrapperClasses(): string;
68
113
  writeValue(value: string | null): void;
69
114
  registerOnChange(fn: (value: string) => void): void;
@@ -72,8 +117,9 @@ export declare class TextInputComponent implements ControlValueAccessor {
72
117
  setDisabledState(isDisabled: boolean): void;
73
118
  protected onInput(event: Event): void;
74
119
  protected onBlur(): void;
120
+ protected onLabelButtonClick(): void;
75
121
  static ɵfac: i0.ɵɵFactoryDeclaration<TextInputComponent, never>;
76
- static ɵcmp: i0.ɵɵComponentDeclaration<TextInputComponent, "compsych-text-input", never, { "label": { "alias": "label"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "value": { "alias": "value"; "required": false; }; "type": { "alias": "type"; "required": false; }; "size": { "alias": "size"; "required": false; }; "name": { "alias": "name"; "required": false; }; "id": { "alias": "id"; "required": false; }; "ariaDescribedBy": { "alias": "ariaDescribedBy"; "required": false; }; "required": { "alias": "required"; "required": false; }; "error": { "alias": "error"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; }, { "valueChange": "valueChange"; }, never, never, true, never>;
122
+ static ɵcmp: i0.ɵɵComponentDeclaration<TextInputComponent, "compsych-text-input", never, { "label": { "alias": "label"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "value": { "alias": "value"; "required": false; }; "type": { "alias": "type"; "required": false; }; "size": { "alias": "size"; "required": false; }; "name": { "alias": "name"; "required": false; }; "id": { "alias": "id"; "required": false; }; "ariaDescribedBy": { "alias": "ariaDescribedBy"; "required": false; }; "supportingText": { "alias": "supportingText"; "required": false; }; "errorMessage": { "alias": "errorMessage"; "required": false; }; "errorMessages": { "alias": "errorMessages"; "required": false; }; "labelButton": { "alias": "labelButton"; "required": false; }; "required": { "alias": "required"; "required": false; }; "error": { "alias": "error"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; }, { "valueChange": "valueChange"; "labelButtonClick": "labelButtonClick"; }, never, never, true, never>;
77
123
  static ngAcceptInputType_required: unknown;
78
124
  static ngAcceptInputType_error: unknown;
79
125
  static ngAcceptInputType_disabled: unknown;
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@compsych-ui-components/angular",
3
- "version": "7.0.9",
3
+ "version": "7.0.11",
4
4
  "description": "Angular UI components for compsych",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/"
8
8
  },
9
9
  "peerDependencies": {
10
+ "@angular/cdk": ">=17.0.0",
10
11
  "@angular/common": ">=17.0.0",
11
12
  "@angular/core": ">=17.0.0",
12
13
  "@compsych-ui-components/shared": "*"