@compsych-ui-components/angular 7.0.10 → 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,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
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@compsych-ui-components/angular",
3
- "version": "7.0.10",
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": "*"