@ckui/core 0.1.0-next.0 → 0.1.0-next.2
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 +239 -0
- package/fesm2022/ckui-core-badge.mjs +169 -0
- package/fesm2022/ckui-core-badge.mjs.map +1 -0
- package/fesm2022/ckui-core-button.mjs +5 -13
- package/fesm2022/ckui-core-button.mjs.map +1 -1
- package/fesm2022/ckui-core-dialog.mjs +908 -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-overlay.mjs +468 -0
- package/fesm2022/ckui-core-internal-overlay.mjs.map +1 -0
- package/fesm2022/ckui-core-internal.mjs +271 -8
- package/fesm2022/ckui-core-internal.mjs.map +1 -1
- package/fesm2022/ckui-core-progress.mjs +165 -0
- package/fesm2022/ckui-core-progress.mjs.map +1 -0
- package/fesm2022/ckui-core-segmented.mjs +528 -0
- package/fesm2022/ckui-core-segmented.mjs.map +1 -0
- package/fesm2022/ckui-core-stepper.mjs +842 -0
- package/fesm2022/ckui-core-stepper.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 +5 -1
- package/fesm2022/ckui-core.mjs.map +1 -1
- package/package.json +29 -1
- package/styles/tokens.css +3 -0
- package/types/ckui-core-badge.d.ts +44 -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-overlay.d.ts +76 -0
- package/types/ckui-core-internal.d.ts +115 -8
- package/types/ckui-core-progress.d.ts +43 -0
- package/types/ckui-core-segmented.d.ts +124 -0
- package/types/ckui-core-stepper.d.ts +186 -0
- package/types/ckui-core-toast.d.ts +97 -0
- package/types/ckui-core.d.ts +4 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { Signal } from "@angular/core";
|
|
2
|
+
import { ModelSignal, Provider, Signal, Type } from "@angular/core";
|
|
3
|
+
import { ControlValueAccessor } from "@angular/forms";
|
|
4
|
+
import { FormValueControl } from "@angular/forms/signals";
|
|
3
5
|
/** Returns an id that is unique within the running page, e.g. `ck-field-3`. */
|
|
4
6
|
export declare function createCkId(prefix: string): string;
|
|
5
7
|
/** Viewport and user-preference signals. All `false` on the server, where nothing can match. */
|
|
@@ -18,18 +20,42 @@ export declare class CkMedia {
|
|
|
18
20
|
static ɵfac: i0.ɵɵFactoryDeclaration<CkMedia, never>;
|
|
19
21
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
20
22
|
}
|
|
21
|
-
|
|
23
|
+
type Politeness = 'polite' | 'assertive';
|
|
24
|
+
/**
|
|
25
|
+
* Screen-reader announcements through one shared live region. The CDK live region keeps only the
|
|
26
|
+
* last message, so announcements made in the same tick are collected and spoken as one message, in
|
|
27
|
+
* order (joined with ". "); it is assertive if any of them is. A batch that follows within 150 ms
|
|
28
|
+
* of the previous hand-over (the previous one may not be read out yet, and the CDK would replace
|
|
29
|
+
* it) is spoken together with the previous text, again in order and assertive if either is; after
|
|
30
|
+
* a longer pause only the new text is written. The region is hidden visually by the CDK styles,
|
|
31
|
+
* which this service loads itself.
|
|
32
|
+
*/
|
|
22
33
|
export declare class CkAnnouncer {
|
|
23
34
|
private readonly liveAnnouncer;
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
private pending;
|
|
36
|
+
private waiters;
|
|
37
|
+
private scheduled;
|
|
38
|
+
private readonly view;
|
|
39
|
+
private last;
|
|
40
|
+
constructor();
|
|
41
|
+
/**
|
|
42
|
+
* Resolves once the message is in the live region. A blank message does nothing. Messages from
|
|
43
|
+
* the same tick share one live-region update and one promise result.
|
|
44
|
+
*/
|
|
45
|
+
announce(message: string, politeness?: Politeness): Promise<void>;
|
|
46
|
+
/** Empties the live region and drops announcements that have not been written yet. */
|
|
26
47
|
clear(): void;
|
|
48
|
+
private flush;
|
|
49
|
+
private release;
|
|
27
50
|
static ɵfac: i0.ɵɵFactoryDeclaration<CkAnnouncer, never>;
|
|
28
51
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
29
52
|
}
|
|
30
53
|
interface CkFocusTrap {
|
|
31
|
-
/**
|
|
32
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Remembers the focused element, then focuses `initialFocus()` if it returns an element that takes
|
|
56
|
+
* focus, else the first tabbable one inside. Resolves `false` if nothing could be focused.
|
|
57
|
+
*/
|
|
58
|
+
activate(initialFocus?: () => HTMLElement | null): Promise<boolean>;
|
|
33
59
|
/** Destroys the trap and gives focus back if the remembered element is still connected. Safe to call repeatedly. */
|
|
34
60
|
release(): void;
|
|
35
61
|
}
|
|
@@ -41,7 +67,7 @@ export declare class CkFocusTrapFactory {
|
|
|
41
67
|
static ɵfac: i0.ɵɵFactoryDeclaration<CkFocusTrapFactory, never>;
|
|
42
68
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
43
69
|
}
|
|
44
|
-
type CkIconName = 'check' | 'chevron-down' | 'chevron-end' | 'close' | 'minus';
|
|
70
|
+
type CkIconName = 'alert-octagon' | 'alert-triangle' | 'check' | 'chevron-down' | 'chevron-end' | 'close' | 'info' | 'minus' | 'plus';
|
|
45
71
|
/** Decorative icon at the surrounding font size and colour. The control carries its own accessible name. */
|
|
46
72
|
export declare class CkIcon {
|
|
47
73
|
readonly name: import("@angular/core").InputSignal<CkIconName>;
|
|
@@ -55,4 +81,85 @@ export declare class CkIcon {
|
|
|
55
81
|
};
|
|
56
82
|
}, {}, never, never, true, never>;
|
|
57
83
|
}
|
|
58
|
-
|
|
84
|
+
/** Reference-counted `inert`: an element stays inert until every hold on it is released. */
|
|
85
|
+
export declare class CkInert {
|
|
86
|
+
private readonly document;
|
|
87
|
+
private readonly holds;
|
|
88
|
+
/**
|
|
89
|
+
* Makes the elements inert and returns the release function (safe to call more than once).
|
|
90
|
+
* An element that was already inert keeps its own attribute value when the last hold ends.
|
|
91
|
+
*/
|
|
92
|
+
hold(elements: Iterable<Element>): () => void;
|
|
93
|
+
/** Body children that an overlay hides from the user: all but `keep`, exempt elements and non-rendered tags. */
|
|
94
|
+
backgroundElements(keep: Element): Element[];
|
|
95
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CkInert, never>;
|
|
96
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Base for components that edit one value.
|
|
100
|
+
*
|
|
101
|
+
* Reactive Forms, `ngModel` and Signal Forms all talk to the component through the
|
|
102
|
+
* `ControlValueAccessor` registered by `provideCkValueAccessor`: Angular's `[formField]` prefers a
|
|
103
|
+
* value accessor on the same node over the `value` model contract, so only that one path is ever
|
|
104
|
+
* active. The `value` model and `disabled` input are for standalone use (`[(value)]`) and for the
|
|
105
|
+
* template.
|
|
106
|
+
*
|
|
107
|
+
* `value` is `undefined` until something sets it; a subclass with a `null` default reads
|
|
108
|
+
* `value() ?? null`.
|
|
109
|
+
*/
|
|
110
|
+
export declare abstract class CkValueControl<T> implements ControlValueAccessor, FormValueControl<T> {
|
|
111
|
+
readonly value: ModelSignal<T>;
|
|
112
|
+
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
113
|
+
/**
|
|
114
|
+
* Only ever becomes `true` here: `markAsUntouched()` and `reset()` do not travel through a value
|
|
115
|
+
* accessor. Do not style from it; read the form's own state (`ng-touched`, the field's `touched()`).
|
|
116
|
+
*/
|
|
117
|
+
readonly touched: ModelSignal<boolean>;
|
|
118
|
+
private readonly controlDisabled;
|
|
119
|
+
private onChange;
|
|
120
|
+
private onTouched;
|
|
121
|
+
/** The `disabled` input or the forms API (`control.disable()`, a disabled field) says so. */
|
|
122
|
+
protected readonly isDisabled: import("@angular/core").Signal<boolean>;
|
|
123
|
+
writeValue(value: T): void;
|
|
124
|
+
registerOnChange(onChange: (value: T) => void): void;
|
|
125
|
+
registerOnTouched(onTouched: () => void): void;
|
|
126
|
+
setDisabledState(isDisabled: boolean): void;
|
|
127
|
+
/** A change made by the user. Ignored while disabled or when the value is the current one. */
|
|
128
|
+
protected commit(value: T): void;
|
|
129
|
+
/** Call when focus leaves the whole control, not a part of it. */
|
|
130
|
+
protected markTouched(): void;
|
|
131
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CkValueControl<any>, never>;
|
|
132
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CkValueControl<any>, never, never, {
|
|
133
|
+
"value": {
|
|
134
|
+
"alias": "value";
|
|
135
|
+
"required": false;
|
|
136
|
+
"isSignal": true;
|
|
137
|
+
};
|
|
138
|
+
"disabled": {
|
|
139
|
+
"alias": "disabled";
|
|
140
|
+
"required": false;
|
|
141
|
+
"isSignal": true;
|
|
142
|
+
};
|
|
143
|
+
"touched": {
|
|
144
|
+
"alias": "touched";
|
|
145
|
+
"required": false;
|
|
146
|
+
"isSignal": true;
|
|
147
|
+
};
|
|
148
|
+
}, {
|
|
149
|
+
"value": "valueChange";
|
|
150
|
+
"touched": "touchedChange";
|
|
151
|
+
}, never, never, true, never>;
|
|
152
|
+
}
|
|
153
|
+
/** Registers the component as a value accessor: `providers: [provideCkValueAccessor(CkSegmented)]`. */
|
|
154
|
+
export declare function provideCkValueAccessor(type: Type<unknown>): Provider;
|
|
155
|
+
interface CkNameSources {
|
|
156
|
+
/** Count `title` as a name. */
|
|
157
|
+
readonly title: boolean;
|
|
158
|
+
/** Count the element's own visible text (not `aria-hidden` or `hidden` parts). */
|
|
159
|
+
readonly text: boolean;
|
|
160
|
+
/** Count the text of the `<label>` elements of a form control. */
|
|
161
|
+
readonly labels?: boolean;
|
|
162
|
+
}
|
|
163
|
+
/** Whether the element has an accessible name: a label attribute, a label reference or readable text. */
|
|
164
|
+
export declare function hasAccessibleName(element: Element, sources: CkNameSources): boolean;
|
|
165
|
+
export type { CkFocusTrap, CkIconName, CkNameSources };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
/**
|
|
3
|
+
* A horizontal progress bar. A number `value` fills the track up to `value / max`; `null` (or a
|
|
4
|
+
* value that is not a number) shows an indeterminate bar. It is not a live region: announce
|
|
5
|
+
* milestones yourself.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CkProgress {
|
|
8
|
+
/**
|
|
9
|
+
* The progress, from 0 to `max`. Below 0 counts as 0 and above `max` as `max`. `null`,
|
|
10
|
+
* `undefined` and `NaN` show an indeterminate bar without `aria-valuenow`.
|
|
11
|
+
*/
|
|
12
|
+
readonly value: import("@angular/core").InputSignal<number | null | undefined>;
|
|
13
|
+
/** The value that means done. Anything that is not a number above 0 counts as 100. */
|
|
14
|
+
readonly max: import("@angular/core").InputSignal<number>;
|
|
15
|
+
/** Text for `aria-valuetext`, such as "Step 2 of 7". Without it assistive technology reads the percentage. */
|
|
16
|
+
readonly valueText: import("@angular/core").InputSignal<string | undefined>;
|
|
17
|
+
private readonly element;
|
|
18
|
+
/** @internal */
|
|
19
|
+
protected readonly limit: import("@angular/core").Signal<number>;
|
|
20
|
+
/** The clamped value, or `null` while the bar is indeterminate. */
|
|
21
|
+
protected readonly current: import("@angular/core").Signal<number | null>;
|
|
22
|
+
protected readonly indeterminate: import("@angular/core").Signal<boolean>;
|
|
23
|
+
protected readonly fraction: import("@angular/core").Signal<number>;
|
|
24
|
+
constructor();
|
|
25
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CkProgress, never>;
|
|
26
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CkProgress, "ck-progress", never, {
|
|
27
|
+
"value": {
|
|
28
|
+
"alias": "value";
|
|
29
|
+
"required": false;
|
|
30
|
+
"isSignal": true;
|
|
31
|
+
};
|
|
32
|
+
"max": {
|
|
33
|
+
"alias": "max";
|
|
34
|
+
"required": false;
|
|
35
|
+
"isSignal": true;
|
|
36
|
+
};
|
|
37
|
+
"valueText": {
|
|
38
|
+
"alias": "valueText";
|
|
39
|
+
"required": false;
|
|
40
|
+
"isSignal": true;
|
|
41
|
+
};
|
|
42
|
+
}, {}, never, never, true, never>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
* Segments are as wide as an equal share or their label, whichever is larger. Only when the labels
|
|
59
|
+
* cannot fit at all do they share the width equally and truncate with an ellipsis.
|
|
60
|
+
*/
|
|
61
|
+
export declare class CkSegmented<T = unknown> extends CkValueControl<T | null> implements CkSegmentedContext {
|
|
62
|
+
/** `undefined` uses the size from `provideCkui`. */
|
|
63
|
+
readonly size: import("@angular/core").InputSignal<CkSize | undefined>;
|
|
64
|
+
/** Stretches the group to the width of its container; by default it is as wide as its segments. */
|
|
65
|
+
readonly fullWidth: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
66
|
+
private readonly config;
|
|
67
|
+
private readonly element;
|
|
68
|
+
private readonly segments;
|
|
69
|
+
protected readonly modifierClasses: import("@angular/core").Signal<string>;
|
|
70
|
+
private readonly current;
|
|
71
|
+
protected readonly checkedIndex: import("@angular/core").Signal<number>;
|
|
72
|
+
/** The grid column of the checked segment, which the indicator is placed in. */
|
|
73
|
+
protected readonly column: import("@angular/core").Signal<number | null>;
|
|
74
|
+
/** Equal columns with truncated labels: the labels do not fit at their natural width. */
|
|
75
|
+
protected readonly compact: import("@angular/core").WritableSignal<boolean>;
|
|
76
|
+
private readonly media;
|
|
77
|
+
private readonly browser;
|
|
78
|
+
private destroyed;
|
|
79
|
+
private shownSegment;
|
|
80
|
+
private slide;
|
|
81
|
+
private observer;
|
|
82
|
+
private mutations;
|
|
83
|
+
private fonts;
|
|
84
|
+
/** @internal Used by `ck-segment`. */
|
|
85
|
+
readonly groupDisabled: import("@angular/core").Signal<boolean>;
|
|
86
|
+
/** @internal Used by `ck-segment`. The checked segment, else the first one that can be used. */
|
|
87
|
+
readonly tabStop: import("@angular/core").Signal<CkSegmentRef | null>;
|
|
88
|
+
constructor();
|
|
89
|
+
/** Slides the indicator after the layout moved it, unless it appears or motion is reduced. */
|
|
90
|
+
private slideTo;
|
|
91
|
+
/** Watches the group, its segments and their content, and switches the compact layout. */
|
|
92
|
+
private fit;
|
|
93
|
+
/**
|
|
94
|
+
* A label that changes (text, language, font) moves no box once the group is compact, so the
|
|
95
|
+
* resize observer is blind to it: watch the text itself and the fonts that finish loading.
|
|
96
|
+
*/
|
|
97
|
+
private watchContent;
|
|
98
|
+
private readonly onFontsLoaded;
|
|
99
|
+
private measure;
|
|
100
|
+
/** @internal Used by `ck-segment`. */
|
|
101
|
+
isChecked(value: unknown): boolean;
|
|
102
|
+
/** @internal Used by `ck-segment`. */
|
|
103
|
+
select(segment: CkSegmentRef): void;
|
|
104
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
105
|
+
/** The segment a navigation key leads to, or `null` for a key that does not navigate. */
|
|
106
|
+
private targetOf;
|
|
107
|
+
protected onFocusOut(event: FocusEvent): void;
|
|
108
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CkSegmented<any>, never>;
|
|
109
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CkSegmented<any>, "ck-segmented", never, {
|
|
110
|
+
"size": {
|
|
111
|
+
"alias": "size";
|
|
112
|
+
"required": false;
|
|
113
|
+
"isSignal": true;
|
|
114
|
+
};
|
|
115
|
+
"fullWidth": {
|
|
116
|
+
"alias": "fullWidth";
|
|
117
|
+
"required": false;
|
|
118
|
+
"isSignal": true;
|
|
119
|
+
};
|
|
120
|
+
}, {}, ["segments"], ["*"], true, never>;
|
|
121
|
+
}
|
|
122
|
+
/** Everything a template needs for a segmented control: `imports: [CK_SEGMENTED_IMPORTS]`. */
|
|
123
|
+
export declare const CK_SEGMENTED_IMPORTS: readonly [typeof CkSegmented, typeof CkSegment];
|
|
124
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { CkSize } from "@ckui/core";
|
|
2
|
+
import { CkValueControl } from "@ckui/core/internal";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
type Direction = 1 | -1;
|
|
5
|
+
/**
|
|
6
|
+
* A number field with a minus and a plus button. The value is a real text input with the
|
|
7
|
+
* `spinbutton` role: type a number (committed on Enter or blur, snapped to `step` and clamped to
|
|
8
|
+
* `min` / `max`), use the arrow keys, or press the buttons, which repeat while held. An empty
|
|
9
|
+
* field is `null`. The buttons are outside the tab order; the input is the one tab stop.
|
|
10
|
+
*
|
|
11
|
+
* Name it with `aria-label` or `aria-labelledby` on `ck-stepper`, or wrap it in a `<label>`. The
|
|
12
|
+
* attributes are inputs here and move to the input element.
|
|
13
|
+
*
|
|
14
|
+
* The input comes first in the DOM, so a wrapping `<label>` names it rather than a button; the
|
|
15
|
+
* minus button is moved in front of it with CSS `order`.
|
|
16
|
+
*/
|
|
17
|
+
export declare class CkStepper extends CkValueControl<number | null> {
|
|
18
|
+
/** Smallest value. Without it the value has no lower limit. When above `max`, `min` wins. */
|
|
19
|
+
readonly min: import("@angular/core").InputSignalWithTransform<number | null, unknown>;
|
|
20
|
+
/** Largest value. Without it the value has no upper limit. */
|
|
21
|
+
readonly max: import("@angular/core").InputSignalWithTransform<number | null, unknown>;
|
|
22
|
+
/** Distance between values, counted from `min` (else 0). Not a number above 0 counts as 1. */
|
|
23
|
+
readonly step: import("@angular/core").InputSignalWithTransform<number | null, unknown>;
|
|
24
|
+
/** What Page Up and Page Down move by. Default: 10 steps. */
|
|
25
|
+
readonly largeStep: import("@angular/core").InputSignalWithTransform<number | null, unknown>;
|
|
26
|
+
/** Text after the value, part of the value text for assistive technology: `W` reads "250 W". */
|
|
27
|
+
readonly unit: import("@angular/core").InputSignal<string>;
|
|
28
|
+
/** `undefined` uses the size from `provideCkui`. */
|
|
29
|
+
readonly size: import("@angular/core").InputSignal<CkSize | undefined>;
|
|
30
|
+
/** The value can be read and focused, but not typed or stepped. */
|
|
31
|
+
readonly readonly: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
32
|
+
/** Replaces the label of the minus button ("FTP minus 5"). */
|
|
33
|
+
readonly decrementLabel: import("@angular/core").InputSignal<string>;
|
|
34
|
+
/** Replaces the label of the plus button ("FTP plus 5"). */
|
|
35
|
+
readonly incrementLabel: import("@angular/core").InputSignal<string>;
|
|
36
|
+
/** The accessible name of the input. Moves from the host to the input element. */
|
|
37
|
+
readonly ariaLabel: import("@angular/core").InputSignal<string | null>;
|
|
38
|
+
/** The ids of the elements that name the input. Moves from the host to the input element. */
|
|
39
|
+
readonly ariaLabelledby: import("@angular/core").InputSignal<string | null>;
|
|
40
|
+
/** The ids of a hint or error for the input. Moves from the host to the input element. */
|
|
41
|
+
readonly ariaDescribedby: import("@angular/core").InputSignal<string | null>;
|
|
42
|
+
private readonly config;
|
|
43
|
+
private readonly labels;
|
|
44
|
+
private readonly locale;
|
|
45
|
+
private readonly media;
|
|
46
|
+
private readonly document;
|
|
47
|
+
private readonly browser;
|
|
48
|
+
private readonly element;
|
|
49
|
+
private readonly inputRef;
|
|
50
|
+
/** Typed text that is not committed yet. */
|
|
51
|
+
protected editing: boolean;
|
|
52
|
+
/** The text last written into the input, so the render after a commit does not redo it. */
|
|
53
|
+
private shown;
|
|
54
|
+
private holding;
|
|
55
|
+
/** Set by an accepted pointerdown on a button; the click that follows it must not step again. */
|
|
56
|
+
private pressed;
|
|
57
|
+
private stopWatchingRelease;
|
|
58
|
+
private repeatTimer;
|
|
59
|
+
private repeatElapsed;
|
|
60
|
+
private repeatDirection;
|
|
61
|
+
protected readonly modifierClasses: import("@angular/core").Signal<string>;
|
|
62
|
+
/** The decimal keypad has no minus sign, so a range that allows negatives gets the text one. */
|
|
63
|
+
protected readonly inputMode: import("@angular/core").Signal<"decimal" | "text">;
|
|
64
|
+
protected readonly stepSize: import("@angular/core").Signal<number>;
|
|
65
|
+
/** The limits, with `max` raised to `min` when they cross. */
|
|
66
|
+
protected readonly bounds: import("@angular/core").Signal<{
|
|
67
|
+
min: number | null;
|
|
68
|
+
max: number | null;
|
|
69
|
+
}>;
|
|
70
|
+
private readonly digits;
|
|
71
|
+
private readonly grid;
|
|
72
|
+
private readonly largeDelta;
|
|
73
|
+
private readonly separators;
|
|
74
|
+
/** The committed value, `null` for none (or anything that is not a finite number). */
|
|
75
|
+
protected readonly current: import("@angular/core").Signal<number | null>;
|
|
76
|
+
private format;
|
|
77
|
+
protected readonly displayValue: import("@angular/core").Signal<string>;
|
|
78
|
+
protected readonly valueText: import("@angular/core").Signal<string | null>;
|
|
79
|
+
/** Width of the value in characters, from the formatted limits (else the value), at least 3. */
|
|
80
|
+
protected readonly chars: import("@angular/core").Signal<number>;
|
|
81
|
+
protected readonly decrementText: import("@angular/core").Signal<string>;
|
|
82
|
+
protected readonly incrementText: import("@angular/core").Signal<string>;
|
|
83
|
+
private readonly locked;
|
|
84
|
+
protected readonly decrementBlocked: import("@angular/core").Signal<boolean>;
|
|
85
|
+
protected readonly incrementBlocked: import("@angular/core").Signal<boolean>;
|
|
86
|
+
constructor();
|
|
87
|
+
private watchConfiguration;
|
|
88
|
+
/** Writes text into the input and drops any uncommitted typing. */
|
|
89
|
+
private show;
|
|
90
|
+
/** The value arrows and buttons start from: the typed text when valid, else the value. */
|
|
91
|
+
private base;
|
|
92
|
+
/** Moves by `count` steps from the base. Returns whether the committed value changed. */
|
|
93
|
+
private stepBy;
|
|
94
|
+
/** Commits a value from the user and shows what the control then holds. */
|
|
95
|
+
private settle;
|
|
96
|
+
private commitText;
|
|
97
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
98
|
+
protected onFocusOut(event: FocusEvent): void;
|
|
99
|
+
/** A click on the field around the value (the unit, the padding) focuses the input. */
|
|
100
|
+
protected focusInput(event: Event): void;
|
|
101
|
+
/** The press starts on pointerdown, so the first step happens at once and a hold can repeat. */
|
|
102
|
+
protected onPress(event: PointerEvent, direction: Direction): void;
|
|
103
|
+
/** A pointer that has moved off the button no longer holds it. */
|
|
104
|
+
protected onPressMove(event: PointerEvent): void;
|
|
105
|
+
/** The browser took the pointer away: no click follows. */
|
|
106
|
+
protected onPressCancel(): void;
|
|
107
|
+
/**
|
|
108
|
+
* The click after a pointer press was handled on pointerdown and is skipped. A click without a
|
|
109
|
+
* pointerdown (keyboard, a screen reader's activation, `button.click()`) steps once here.
|
|
110
|
+
*/
|
|
111
|
+
protected onButtonClick(direction: Direction): void;
|
|
112
|
+
private scheduleRepeat;
|
|
113
|
+
/**
|
|
114
|
+
* On a coarse pointer the input is not focused during a press, so the window losing focus and
|
|
115
|
+
* the document turning hidden are the only signals that the finger will not be released here.
|
|
116
|
+
*/
|
|
117
|
+
private watchRelease;
|
|
118
|
+
private unwatchRelease;
|
|
119
|
+
private clearRepeat;
|
|
120
|
+
/** Release, cancel, lost capture, leave, blur, hidden, a bound or a lock: stops, counts as touched. */
|
|
121
|
+
protected endPress(): void;
|
|
122
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CkStepper, never>;
|
|
123
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CkStepper, "ck-stepper", never, {
|
|
124
|
+
"min": {
|
|
125
|
+
"alias": "min";
|
|
126
|
+
"required": false;
|
|
127
|
+
"isSignal": true;
|
|
128
|
+
};
|
|
129
|
+
"max": {
|
|
130
|
+
"alias": "max";
|
|
131
|
+
"required": false;
|
|
132
|
+
"isSignal": true;
|
|
133
|
+
};
|
|
134
|
+
"step": {
|
|
135
|
+
"alias": "step";
|
|
136
|
+
"required": false;
|
|
137
|
+
"isSignal": true;
|
|
138
|
+
};
|
|
139
|
+
"largeStep": {
|
|
140
|
+
"alias": "largeStep";
|
|
141
|
+
"required": false;
|
|
142
|
+
"isSignal": true;
|
|
143
|
+
};
|
|
144
|
+
"unit": {
|
|
145
|
+
"alias": "unit";
|
|
146
|
+
"required": false;
|
|
147
|
+
"isSignal": true;
|
|
148
|
+
};
|
|
149
|
+
"size": {
|
|
150
|
+
"alias": "size";
|
|
151
|
+
"required": false;
|
|
152
|
+
"isSignal": true;
|
|
153
|
+
};
|
|
154
|
+
"readonly": {
|
|
155
|
+
"alias": "readonly";
|
|
156
|
+
"required": false;
|
|
157
|
+
"isSignal": true;
|
|
158
|
+
};
|
|
159
|
+
"decrementLabel": {
|
|
160
|
+
"alias": "decrementLabel";
|
|
161
|
+
"required": false;
|
|
162
|
+
"isSignal": true;
|
|
163
|
+
};
|
|
164
|
+
"incrementLabel": {
|
|
165
|
+
"alias": "incrementLabel";
|
|
166
|
+
"required": false;
|
|
167
|
+
"isSignal": true;
|
|
168
|
+
};
|
|
169
|
+
"ariaLabel": {
|
|
170
|
+
"alias": "aria-label";
|
|
171
|
+
"required": false;
|
|
172
|
+
"isSignal": true;
|
|
173
|
+
};
|
|
174
|
+
"ariaLabelledby": {
|
|
175
|
+
"alias": "aria-labelledby";
|
|
176
|
+
"required": false;
|
|
177
|
+
"isSignal": true;
|
|
178
|
+
};
|
|
179
|
+
"ariaDescribedby": {
|
|
180
|
+
"alias": "aria-describedby";
|
|
181
|
+
"required": false;
|
|
182
|
+
"isSignal": true;
|
|
183
|
+
};
|
|
184
|
+
}, {}, never, never, true, never>;
|
|
185
|
+
}
|
|
186
|
+
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,12 @@ 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
|
+
decrement: string;
|
|
8
|
+
dismiss: string;
|
|
9
|
+
increment: string;
|
|
7
10
|
loading: string;
|
|
8
11
|
noResults: string;
|
|
12
|
+
notifications: string;
|
|
9
13
|
}
|
|
10
14
|
export declare const CK_DEFAULT_LABELS: Readonly<CkLabels>;
|
|
11
15
|
export declare const CK_LABELS: InjectionToken<Signal<CkLabels>>;
|