@ckui/core 0.1.0-next.0 → 0.1.0-next.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.
- package/README.md +121 -0
- package/fesm2022/ckui-core-button.mjs +5 -13
- package/fesm2022/ckui-core-button.mjs.map +1 -1
- package/fesm2022/ckui-core-dialog.mjs +907 -0
- package/fesm2022/ckui-core-dialog.mjs.map +1 -0
- package/fesm2022/ckui-core-field.mjs +6 -10
- package/fesm2022/ckui-core-field.mjs.map +1 -1
- package/fesm2022/ckui-core-internal.mjs +732 -8
- package/fesm2022/ckui-core-internal.mjs.map +1 -1
- package/fesm2022/ckui-core-segmented.mjs +352 -0
- package/fesm2022/ckui-core-segmented.mjs.map +1 -0
- package/fesm2022/ckui-core-toast.mjs +883 -0
- package/fesm2022/ckui-core-toast.mjs.map +1 -0
- package/fesm2022/ckui-core.mjs +3 -1
- package/fesm2022/ckui-core.mjs.map +1 -1
- package/package.json +13 -1
- package/styles/tokens.css +3 -0
- package/types/ckui-core-button.d.ts +0 -1
- package/types/ckui-core-dialog.d.ts +219 -0
- package/types/ckui-core-field.d.ts +0 -1
- package/types/ckui-core-internal.d.ts +188 -8
- package/types/ckui-core-segmented.d.ts +98 -0
- package/types/ckui-core-toast.d.ts +97 -0
- package/types/ckui-core.d.ts +2 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { Signal } from "@angular/core";
|
|
2
|
+
import { Injector, ModelSignal, Provider, Signal, TemplateRef, Type } from "@angular/core";
|
|
3
|
+
import { ControlValueAccessor } from "@angular/forms";
|
|
4
|
+
import { FormValueControl } from "@angular/forms/signals";
|
|
5
|
+
import { ComponentType } from "@angular/cdk/portal";
|
|
3
6
|
/** Returns an id that is unique within the running page, e.g. `ck-field-3`. */
|
|
4
7
|
export declare function createCkId(prefix: string): string;
|
|
5
8
|
/** Viewport and user-preference signals. All `false` on the server, where nothing can match. */
|
|
@@ -18,18 +21,42 @@ export declare class CkMedia {
|
|
|
18
21
|
static ɵfac: i0.ɵɵFactoryDeclaration<CkMedia, never>;
|
|
19
22
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
20
23
|
}
|
|
21
|
-
|
|
24
|
+
type Politeness = 'polite' | 'assertive';
|
|
25
|
+
/**
|
|
26
|
+
* Screen-reader announcements through one shared live region. The CDK live region keeps only the
|
|
27
|
+
* last message, so announcements made in the same tick are collected and spoken as one message, in
|
|
28
|
+
* order (joined with ". "); it is assertive if any of them is. A batch that follows within 150 ms
|
|
29
|
+
* of the previous hand-over (the previous one may not be read out yet, and the CDK would replace
|
|
30
|
+
* it) is spoken together with the previous text, again in order and assertive if either is; after
|
|
31
|
+
* a longer pause only the new text is written. The region is hidden visually by the CDK styles,
|
|
32
|
+
* which this service loads itself.
|
|
33
|
+
*/
|
|
22
34
|
export declare class CkAnnouncer {
|
|
23
35
|
private readonly liveAnnouncer;
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
private pending;
|
|
37
|
+
private waiters;
|
|
38
|
+
private scheduled;
|
|
39
|
+
private readonly view;
|
|
40
|
+
private last;
|
|
41
|
+
constructor();
|
|
42
|
+
/**
|
|
43
|
+
* Resolves once the message is in the live region. A blank message does nothing. Messages from
|
|
44
|
+
* the same tick share one live-region update and one promise result.
|
|
45
|
+
*/
|
|
46
|
+
announce(message: string, politeness?: Politeness): Promise<void>;
|
|
47
|
+
/** Empties the live region and drops announcements that have not been written yet. */
|
|
26
48
|
clear(): void;
|
|
49
|
+
private flush;
|
|
50
|
+
private release;
|
|
27
51
|
static ɵfac: i0.ɵɵFactoryDeclaration<CkAnnouncer, never>;
|
|
28
52
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
29
53
|
}
|
|
30
54
|
interface CkFocusTrap {
|
|
31
|
-
/**
|
|
32
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Remembers the focused element, then focuses `initialFocus()` if it returns an element that takes
|
|
57
|
+
* focus, else the first tabbable one inside. Resolves `false` if nothing could be focused.
|
|
58
|
+
*/
|
|
59
|
+
activate(initialFocus?: () => HTMLElement | null): Promise<boolean>;
|
|
33
60
|
/** Destroys the trap and gives focus back if the remembered element is still connected. Safe to call repeatedly. */
|
|
34
61
|
release(): void;
|
|
35
62
|
}
|
|
@@ -41,7 +68,7 @@ export declare class CkFocusTrapFactory {
|
|
|
41
68
|
static ɵfac: i0.ɵɵFactoryDeclaration<CkFocusTrapFactory, never>;
|
|
42
69
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
43
70
|
}
|
|
44
|
-
type CkIconName = 'check' | 'chevron-down' | 'chevron-end' | 'close' | 'minus';
|
|
71
|
+
type CkIconName = 'alert-octagon' | 'alert-triangle' | 'check' | 'chevron-down' | 'chevron-end' | 'close' | 'info' | 'minus' | 'plus';
|
|
45
72
|
/** Decorative icon at the surrounding font size and colour. The control carries its own accessible name. */
|
|
46
73
|
export declare class CkIcon {
|
|
47
74
|
readonly name: import("@angular/core").InputSignal<CkIconName>;
|
|
@@ -55,4 +82,157 @@ export declare class CkIcon {
|
|
|
55
82
|
};
|
|
56
83
|
}, {}, never, never, true, never>;
|
|
57
84
|
}
|
|
58
|
-
|
|
85
|
+
/** Reference-counted `inert`: an element stays inert until every hold on it is released. */
|
|
86
|
+
export declare class CkInert {
|
|
87
|
+
private readonly document;
|
|
88
|
+
private readonly holds;
|
|
89
|
+
/**
|
|
90
|
+
* Makes the elements inert and returns the release function (safe to call more than once).
|
|
91
|
+
* An element that was already inert keeps its own attribute value when the last hold ends.
|
|
92
|
+
*/
|
|
93
|
+
hold(elements: Iterable<Element>): () => void;
|
|
94
|
+
/** Body children that an overlay hides from the user: all but `keep`, exempt elements and non-rendered tags. */
|
|
95
|
+
backgroundElements(keep: Element): Element[];
|
|
96
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CkInert, never>;
|
|
97
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Base for components that edit one value.
|
|
101
|
+
*
|
|
102
|
+
* Reactive Forms, `ngModel` and Signal Forms all talk to the component through the
|
|
103
|
+
* `ControlValueAccessor` registered by `provideCkValueAccessor`: Angular's `[formField]` prefers a
|
|
104
|
+
* value accessor on the same node over the `value` model contract, so only that one path is ever
|
|
105
|
+
* active. The `value` model and `disabled` input are for standalone use (`[(value)]`) and for the
|
|
106
|
+
* template.
|
|
107
|
+
*
|
|
108
|
+
* `value` is `undefined` until something sets it; a subclass with a `null` default reads
|
|
109
|
+
* `value() ?? null`.
|
|
110
|
+
*/
|
|
111
|
+
export declare abstract class CkValueControl<T> implements ControlValueAccessor, FormValueControl<T> {
|
|
112
|
+
readonly value: ModelSignal<T>;
|
|
113
|
+
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
114
|
+
/**
|
|
115
|
+
* Only ever becomes `true` here: `markAsUntouched()` and `reset()` do not travel through a value
|
|
116
|
+
* accessor. Do not style from it; read the form's own state (`ng-touched`, the field's `touched()`).
|
|
117
|
+
*/
|
|
118
|
+
readonly touched: ModelSignal<boolean>;
|
|
119
|
+
private readonly controlDisabled;
|
|
120
|
+
private onChange;
|
|
121
|
+
private onTouched;
|
|
122
|
+
/** The `disabled` input or the forms API (`control.disable()`, a disabled field) says so. */
|
|
123
|
+
protected readonly isDisabled: import("@angular/core").Signal<boolean>;
|
|
124
|
+
writeValue(value: T): void;
|
|
125
|
+
registerOnChange(onChange: (value: T) => void): void;
|
|
126
|
+
registerOnTouched(onTouched: () => void): void;
|
|
127
|
+
setDisabledState(isDisabled: boolean): void;
|
|
128
|
+
/** A change made by the user. Ignored while disabled or when the value is the current one. */
|
|
129
|
+
protected commit(value: T): void;
|
|
130
|
+
/** Call when focus leaves the whole control, not a part of it. */
|
|
131
|
+
protected markTouched(): void;
|
|
132
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CkValueControl<any>, never>;
|
|
133
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CkValueControl<any>, never, never, {
|
|
134
|
+
"value": {
|
|
135
|
+
"alias": "value";
|
|
136
|
+
"required": false;
|
|
137
|
+
"isSignal": true;
|
|
138
|
+
};
|
|
139
|
+
"disabled": {
|
|
140
|
+
"alias": "disabled";
|
|
141
|
+
"required": false;
|
|
142
|
+
"isSignal": true;
|
|
143
|
+
};
|
|
144
|
+
"touched": {
|
|
145
|
+
"alias": "touched";
|
|
146
|
+
"required": false;
|
|
147
|
+
"isSignal": true;
|
|
148
|
+
};
|
|
149
|
+
}, {
|
|
150
|
+
"value": "valueChange";
|
|
151
|
+
"touched": "touchedChange";
|
|
152
|
+
}, never, never, true, never>;
|
|
153
|
+
}
|
|
154
|
+
/** Registers the component as a value accessor: `providers: [provideCkValueAccessor(CkSegmented)]`. */
|
|
155
|
+
export declare function provideCkValueAccessor(type: Type<unknown>): Provider;
|
|
156
|
+
type CkOverlayMode = 'auto' | 'modal' | 'sheet';
|
|
157
|
+
type CkOverlayDismissReason = 'escape' | 'backdrop' | 'swipe';
|
|
158
|
+
interface CkOverlayConfig {
|
|
159
|
+
/** `auto` becomes a sheet when `CkMedia.sheet()` is true at the moment of opening. Default `auto`. */
|
|
160
|
+
mode?: CkOverlayMode;
|
|
161
|
+
/** Escape, a click on the backdrop and a swipe down may close the overlay. Default `true`. */
|
|
162
|
+
dismissible?: boolean;
|
|
163
|
+
/** A sheet as tall as the viewport allows instead of as tall as its content. */
|
|
164
|
+
fullHeight?: boolean;
|
|
165
|
+
panelClass?: string | string[];
|
|
166
|
+
/** Default `dialog`. */
|
|
167
|
+
role?: 'dialog' | 'alertdialog';
|
|
168
|
+
ariaLabel?: string;
|
|
169
|
+
ariaLabelledBy?: string;
|
|
170
|
+
ariaDescribedBy?: string;
|
|
171
|
+
/**
|
|
172
|
+
* Called when the user asks to dismiss (Escape, backdrop, swipe) a dismissible overlay. It is
|
|
173
|
+
* expected to call `handle.close()` straight away; without it the host closes the overlay itself.
|
|
174
|
+
* A sheet that is still open after a swipe snaps back.
|
|
175
|
+
*/
|
|
176
|
+
onDismissRequest?: (reason: CkOverlayDismissReason) => void;
|
|
177
|
+
/**
|
|
178
|
+
* Picks the element that takes focus once the overlay has rendered. Without it, or when it
|
|
179
|
+
* returns `null` or something that cannot take focus, the first tabbable element does.
|
|
180
|
+
*/
|
|
181
|
+
initialFocus?: () => HTMLElement | null;
|
|
182
|
+
}
|
|
183
|
+
interface CkOverlayHandle {
|
|
184
|
+
/** The mode resolved when the overlay opened. */
|
|
185
|
+
readonly mode: 'modal' | 'sheet';
|
|
186
|
+
/** The element that carries `role`, `aria-modal` and the labels; set `aria-labelledby` here when the title appears later. */
|
|
187
|
+
readonly panel: HTMLElement;
|
|
188
|
+
/** Resolves once the opening animation and the initial focus are done. */
|
|
189
|
+
readonly opened: Promise<void>;
|
|
190
|
+
/** Resolves once the overlay is detached. */
|
|
191
|
+
readonly closed: Promise<void>;
|
|
192
|
+
/** Animates out, then detaches. Repeated calls return the same promise. */
|
|
193
|
+
close(): Promise<void>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Opens modal dialogs and bottom sheets on the CDK overlay: backdrop, scroll lock, focus trap and
|
|
197
|
+
* restore, `inert` background, Escape / backdrop / swipe dismissal and the open and close animation.
|
|
198
|
+
*/
|
|
199
|
+
export declare class CkOverlayHost {
|
|
200
|
+
private readonly overlay;
|
|
201
|
+
private readonly overlayContainer;
|
|
202
|
+
private readonly media;
|
|
203
|
+
private readonly inert;
|
|
204
|
+
private readonly focusTraps;
|
|
205
|
+
private readonly injector;
|
|
206
|
+
private readonly document;
|
|
207
|
+
private readonly isBrowser;
|
|
208
|
+
/** Open overlays, topmost last. A closing overlay has already left it. */
|
|
209
|
+
private readonly stack;
|
|
210
|
+
private readonly entries;
|
|
211
|
+
private scrollStrategy;
|
|
212
|
+
private scrollLocks;
|
|
213
|
+
private listening;
|
|
214
|
+
constructor();
|
|
215
|
+
open<C>(content: ComponentType<C> | TemplateRef<unknown>, config?: CkOverlayConfig, injector?: Injector): CkOverlayHandle;
|
|
216
|
+
/** Focus did not return to where it came from (opener disabled, inert or gone): find it a home. */
|
|
217
|
+
private restoreFocus;
|
|
218
|
+
private contentPortal;
|
|
219
|
+
/** What the server gets: nothing is rendered, and the overlay counts as closed. */
|
|
220
|
+
private inertHandle;
|
|
221
|
+
private lockScroll;
|
|
222
|
+
private unlockScroll;
|
|
223
|
+
private listen;
|
|
224
|
+
private readonly onKeydown;
|
|
225
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CkOverlayHost, never>;
|
|
226
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
227
|
+
}
|
|
228
|
+
interface CkNameSources {
|
|
229
|
+
/** Count `title` as a name. */
|
|
230
|
+
readonly title: boolean;
|
|
231
|
+
/** Count the element's own visible text (not `aria-hidden` or `hidden` parts). */
|
|
232
|
+
readonly text: boolean;
|
|
233
|
+
/** Count the text of the `<label>` elements of a form control. */
|
|
234
|
+
readonly labels?: boolean;
|
|
235
|
+
}
|
|
236
|
+
/** Whether the element has an accessible name: a label attribute, a label reference or readable text. */
|
|
237
|
+
export declare function hasAccessibleName(element: Element, sources: CkNameSources): boolean;
|
|
238
|
+
export type { CkFocusTrap, CkIconName, CkNameSources, CkOverlayConfig, CkOverlayDismissReason, CkOverlayHandle, CkOverlayMode };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Signal } from "@angular/core";
|
|
3
|
+
import { CkSize } from "@ckui/core";
|
|
4
|
+
import { CkValueControl } from "@ckui/core/internal";
|
|
5
|
+
/** The part of a `ck-segment` its group reads, so the two files need not import each other's classes. */
|
|
6
|
+
interface CkSegmentRef {
|
|
7
|
+
readonly element: HTMLElement;
|
|
8
|
+
readonly value: () => unknown;
|
|
9
|
+
readonly unavailable: Signal<boolean>;
|
|
10
|
+
}
|
|
11
|
+
/** What a `ck-segment` needs from its group. */
|
|
12
|
+
interface CkSegmentedContext {
|
|
13
|
+
/** The group is disabled by its input or by the forms API. */
|
|
14
|
+
readonly groupDisabled: Signal<boolean>;
|
|
15
|
+
/** The group's one tab stop, or `null` when nothing can take focus. */
|
|
16
|
+
readonly tabStop: Signal<CkSegmentRef | null>;
|
|
17
|
+
isChecked(value: unknown): boolean;
|
|
18
|
+
select(segment: CkSegmentRef): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* One option of a `ck-segmented`. Its content is projected: text, an icon (a direct `svg` child, always shown before the text), or both. An icon-only
|
|
22
|
+
* segment needs an `aria-label`.
|
|
23
|
+
*/
|
|
24
|
+
export declare class CkSegment<T = unknown> {
|
|
25
|
+
readonly value: import("@angular/core").InputSignal<T>;
|
|
26
|
+
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
27
|
+
/** @internal Used by `ck-segmented`. */
|
|
28
|
+
readonly element: HTMLElement;
|
|
29
|
+
protected readonly group: CkSegmentedContext;
|
|
30
|
+
/** @internal Used by `ck-segmented`. */
|
|
31
|
+
readonly checked: import("@angular/core").Signal<boolean>;
|
|
32
|
+
/** @internal Used by `ck-segmented`: disabled by itself or by its group. */
|
|
33
|
+
readonly unavailable: import("@angular/core").Signal<boolean>;
|
|
34
|
+
/** A segment the template has just created has no value yet, though its group already reads it. */
|
|
35
|
+
private readonly bound;
|
|
36
|
+
/** An unavailable segment has no tabindex at all, so a click cannot focus it either. */
|
|
37
|
+
protected readonly tabIndex: import("@angular/core").Signal<0 | -1 | null>;
|
|
38
|
+
constructor();
|
|
39
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CkSegment<any>, never>;
|
|
40
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CkSegment<any>, "ck-segment", never, {
|
|
41
|
+
"value": {
|
|
42
|
+
"alias": "value";
|
|
43
|
+
"required": true;
|
|
44
|
+
"isSignal": true;
|
|
45
|
+
};
|
|
46
|
+
"disabled": {
|
|
47
|
+
"alias": "disabled";
|
|
48
|
+
"required": false;
|
|
49
|
+
"isSignal": true;
|
|
50
|
+
};
|
|
51
|
+
}, {}, never, ["svg, ck-icon", "*"], true, never>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A group of mutually exclusive options that behaves as one radio group: one tab stop, the arrow
|
|
55
|
+
* keys move and select. Direction comes from the `dir` attribute (`:dir(rtl)`), not from the CSS
|
|
56
|
+
* `direction` property. The value is the `value` of the selected `ck-segment`, or `null`.
|
|
57
|
+
*/
|
|
58
|
+
export declare class CkSegmented<T = unknown> extends CkValueControl<T | null> implements CkSegmentedContext {
|
|
59
|
+
/** `undefined` uses the size from `provideCkui`. */
|
|
60
|
+
readonly size: import("@angular/core").InputSignal<CkSize | undefined>;
|
|
61
|
+
/** Stretches the group to the width of its container; by default it is as wide as its segments. */
|
|
62
|
+
readonly fullWidth: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
63
|
+
private readonly config;
|
|
64
|
+
private readonly element;
|
|
65
|
+
private readonly segments;
|
|
66
|
+
protected readonly modifierClasses: import("@angular/core").Signal<string>;
|
|
67
|
+
private readonly current;
|
|
68
|
+
protected readonly checkedIndex: import("@angular/core").Signal<number>;
|
|
69
|
+
/** @internal Used by `ck-segment`. */
|
|
70
|
+
readonly groupDisabled: import("@angular/core").Signal<boolean>;
|
|
71
|
+
/** @internal Used by `ck-segment`. The checked segment, else the first one that can be used. */
|
|
72
|
+
readonly tabStop: import("@angular/core").Signal<CkSegmentRef | null>;
|
|
73
|
+
constructor();
|
|
74
|
+
/** @internal Used by `ck-segment`. */
|
|
75
|
+
isChecked(value: unknown): boolean;
|
|
76
|
+
/** @internal Used by `ck-segment`. */
|
|
77
|
+
select(segment: CkSegmentRef): void;
|
|
78
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
79
|
+
/** The segment a navigation key leads to, or `null` for a key that does not navigate. */
|
|
80
|
+
private targetOf;
|
|
81
|
+
protected onFocusOut(event: FocusEvent): void;
|
|
82
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CkSegmented<any>, never>;
|
|
83
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CkSegmented<any>, "ck-segmented", never, {
|
|
84
|
+
"size": {
|
|
85
|
+
"alias": "size";
|
|
86
|
+
"required": false;
|
|
87
|
+
"isSignal": true;
|
|
88
|
+
};
|
|
89
|
+
"fullWidth": {
|
|
90
|
+
"alias": "fullWidth";
|
|
91
|
+
"required": false;
|
|
92
|
+
"isSignal": true;
|
|
93
|
+
};
|
|
94
|
+
}, {}, ["segments"], ["*"], true, never>;
|
|
95
|
+
}
|
|
96
|
+
/** Everything a template needs for a segmented control: `imports: [CK_SEGMENTED_IMPORTS]`. */
|
|
97
|
+
export declare const CK_SEGMENTED_IMPORTS: readonly [typeof CkSegmented, typeof CkSegment];
|
|
98
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { EnvironmentProviders } from "@angular/core";
|
|
3
|
+
import { CkSize } from "@ckui/core";
|
|
4
|
+
type CkToastPosition = 'top' | 'bottom';
|
|
5
|
+
type CkToastAlign = 'center' | 'end';
|
|
6
|
+
interface CkToastConfig {
|
|
7
|
+
/** Screen edge the toasts stack against. Default `bottom`. */
|
|
8
|
+
position?: CkToastPosition;
|
|
9
|
+
/** Default `center` on a narrow viewport and `end` otherwise, decided each time the stack is laid out. */
|
|
10
|
+
align?: CkToastAlign;
|
|
11
|
+
/** Toasts shown at once; later ones wait until a slot frees. A positive whole number, default 3. */
|
|
12
|
+
max?: number;
|
|
13
|
+
/** Size of the action and dismiss buttons. Default: the size from `provideCkui`. */
|
|
14
|
+
size?: CkSize;
|
|
15
|
+
}
|
|
16
|
+
/** Configures where toasts appear, how many show at once and the size of their buttons. */
|
|
17
|
+
export declare function provideCkToast(config?: CkToastConfig): EnvironmentProviders;
|
|
18
|
+
type CkToastTone = 'neutral' | 'success' | 'warning' | 'danger';
|
|
19
|
+
type CkToastDismissReason = 'timeout' | 'user' | 'action' | 'replaced' | 'programmatic';
|
|
20
|
+
interface CkToastAction {
|
|
21
|
+
/** Visible label and accessible name of the button. */
|
|
22
|
+
label: string;
|
|
23
|
+
/** Runs when the button is activated; the toast then closes with the reason `action`. */
|
|
24
|
+
run: () => void;
|
|
25
|
+
}
|
|
26
|
+
interface CkToastOptions {
|
|
27
|
+
/** Plain text; it is never parsed as HTML. */
|
|
28
|
+
message: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
/** Default `neutral`. */
|
|
31
|
+
tone?: CkToastTone;
|
|
32
|
+
action?: CkToastAction;
|
|
33
|
+
/**
|
|
34
|
+
* Milliseconds until the toast closes by itself. Default 5000. A toast with an `action` or tone
|
|
35
|
+
* `danger` stays until dismissed unless a duration is given. `null`, `0`, a negative or a
|
|
36
|
+
* non-finite number mean "stay until dismissed".
|
|
37
|
+
*/
|
|
38
|
+
duration?: number | null;
|
|
39
|
+
/** A toast with the id of one that is still open replaces it in place instead of stacking. */
|
|
40
|
+
id?: string;
|
|
41
|
+
}
|
|
42
|
+
/** What a `CkToastRef` calls into; supplied by `CkToast`, not by consumers. */
|
|
43
|
+
interface CkToastRefControls {
|
|
44
|
+
readonly dismissed: Promise<CkToastDismissReason>;
|
|
45
|
+
dismiss(): void;
|
|
46
|
+
update(options: Partial<CkToastOptions>): void;
|
|
47
|
+
}
|
|
48
|
+
/** Controls one toast. Returned by `CkToast.show`; never constructed directly. */
|
|
49
|
+
export declare class CkToastRef {
|
|
50
|
+
/** Resolves once, with the reason the toast closed. `replaced` when a toast with the same `id` took its place. */
|
|
51
|
+
readonly dismissed: Promise<CkToastDismissReason>;
|
|
52
|
+
private readonly controls;
|
|
53
|
+
constructor(controls: CkToastRefControls);
|
|
54
|
+
/** Closes the toast with the reason `programmatic`. Does nothing once it is closed or replaced. */
|
|
55
|
+
dismiss(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Changes the shown content and restarts the timer. A key passed as `undefined` removes the title
|
|
58
|
+
* or action, or restores the default duration; `id` cannot change. Text that changes is announced
|
|
59
|
+
* again. Does nothing once the toast is closed or replaced.
|
|
60
|
+
*/
|
|
61
|
+
update(options: Partial<CkToastOptions>): void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Shows short messages in a stack at the edge of the screen. Announces each one to screen readers,
|
|
65
|
+
* stays open for an action or a danger message, and pauses while the user reads it.
|
|
66
|
+
*/
|
|
67
|
+
export declare class CkToast {
|
|
68
|
+
private readonly store;
|
|
69
|
+
private readonly document;
|
|
70
|
+
private readonly appRef;
|
|
71
|
+
private readonly environmentInjector;
|
|
72
|
+
private readonly isBrowser;
|
|
73
|
+
private host;
|
|
74
|
+
private hostElement;
|
|
75
|
+
/** The element that had focus before it entered the toast host, where it goes back to. */
|
|
76
|
+
private focusOrigin;
|
|
77
|
+
constructor();
|
|
78
|
+
/**
|
|
79
|
+
* Shows a toast and returns the ref that controls it. A blank message with no title shows
|
|
80
|
+
* nothing. On the server nothing is shown and `dismissed` resolves as `programmatic` at once.
|
|
81
|
+
*/
|
|
82
|
+
show(options: CkToastOptions): CkToastRef;
|
|
83
|
+
/** Closes every toast, queued ones included, with the reason `programmatic`. */
|
|
84
|
+
dismissAll(): void;
|
|
85
|
+
private ensureHost;
|
|
86
|
+
private readonly onFocusIn;
|
|
87
|
+
/**
|
|
88
|
+
* A toast that holds focus is about to leave: focus goes to the same button of the next toast
|
|
89
|
+
* (else the previous one), else back to where it came from, else into the open modal overlay.
|
|
90
|
+
* Without any of these focus is left alone.
|
|
91
|
+
*/
|
|
92
|
+
private moveFocusAway;
|
|
93
|
+
private tryFocus;
|
|
94
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CkToast, never>;
|
|
95
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
96
|
+
}
|
|
97
|
+
export type { CkToastAction, CkToastAlign, CkToastConfig, CkToastDismissReason, CkToastOptions, CkToastPosition, CkToastTone };
|
package/types/ckui-core.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ export declare const CK_SIZES: readonly CkSize[];
|
|
|
4
4
|
/** Built-in strings. Each package adds its keys; consumers pass a `Partial`. */
|
|
5
5
|
interface CkLabels {
|
|
6
6
|
close: string;
|
|
7
|
+
dismiss: string;
|
|
7
8
|
loading: string;
|
|
8
9
|
noResults: string;
|
|
10
|
+
notifications: string;
|
|
9
11
|
}
|
|
10
12
|
export declare const CK_DEFAULT_LABELS: Readonly<CkLabels>;
|
|
11
13
|
export declare const CK_LABELS: InjectionToken<Signal<CkLabels>>;
|