@cdevhub/ngx-tw 0.4.0 → 0.6.0
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 +78 -15
- package/fesm2022/cdevhub-ngx-tw-accordion.mjs +16 -5
- package/fesm2022/cdevhub-ngx-tw-accordion.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-avatar.mjs +26 -15
- package/fesm2022/cdevhub-ngx-tw-avatar.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-badge.mjs +17 -5
- package/fesm2022/cdevhub-ngx-tw-badge.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-breadcrumbs.mjs +27 -6
- package/fesm2022/cdevhub-ngx-tw-breadcrumbs.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-button.mjs +23 -11
- package/fesm2022/cdevhub-ngx-tw-button.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-calendar-luxon.mjs +5 -5
- package/fesm2022/cdevhub-ngx-tw-calendar-luxon.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-calendar-testing.mjs +3 -3
- package/fesm2022/cdevhub-ngx-tw-calendar-testing.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-calendar.mjs +427 -122
- package/fesm2022/cdevhub-ngx-tw-calendar.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-card.mjs +21 -11
- package/fesm2022/cdevhub-ngx-tw-card.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-carousel.mjs +215 -96
- package/fesm2022/cdevhub-ngx-tw-carousel.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-checkbox.mjs +108 -64
- package/fesm2022/cdevhub-ngx-tw-checkbox.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-code-block.mjs +18 -6
- package/fesm2022/cdevhub-ngx-tw-code-block.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-collapsible.mjs +55 -30
- package/fesm2022/cdevhub-ngx-tw-collapsible.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-combobox-testing.mjs +218 -0
- package/fesm2022/cdevhub-ngx-tw-combobox-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-combobox.mjs +236 -211
- package/fesm2022/cdevhub-ngx-tw-combobox.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-command-palette-testing.mjs +200 -0
- package/fesm2022/cdevhub-ngx-tw-command-palette-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-command-palette.mjs +34 -7
- package/fesm2022/cdevhub-ngx-tw-command-palette.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-core.mjs +135 -15
- package/fesm2022/cdevhub-ngx-tw-core.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-date-picker-testing.mjs +203 -0
- package/fesm2022/cdevhub-ngx-tw-date-picker-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-date-picker.mjs +160 -102
- package/fesm2022/cdevhub-ngx-tw-date-picker.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-date-range-picker-testing.mjs +209 -0
- package/fesm2022/cdevhub-ngx-tw-date-range-picker-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-date-range-picker.mjs +182 -107
- package/fesm2022/cdevhub-ngx-tw-date-range-picker.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-dialog-dialog-renderer-DoIhoV3d.mjs +198 -0
- package/fesm2022/cdevhub-ngx-tw-dialog-dialog-renderer-DoIhoV3d.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-dialog-testing.mjs +122 -0
- package/fesm2022/cdevhub-ngx-tw-dialog-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-dialog.mjs +199 -220
- package/fesm2022/cdevhub-ngx-tw-dialog.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-empty-state.mjs +1 -1
- package/fesm2022/cdevhub-ngx-tw-empty-state.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-file-upload-testing.mjs +149 -0
- package/fesm2022/cdevhub-ngx-tw-file-upload-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-file-upload.mjs +57 -67
- package/fesm2022/cdevhub-ngx-tw-file-upload.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-flip-card.mjs +42 -24
- package/fesm2022/cdevhub-ngx-tw-flip-card.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-form-field.mjs +114 -21
- package/fesm2022/cdevhub-ngx-tw-form-field.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-icon.mjs +16 -6
- package/fesm2022/cdevhub-ngx-tw-icon.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-input.mjs +52 -61
- package/fesm2022/cdevhub-ngx-tw-input.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-item.mjs +18 -3
- package/fesm2022/cdevhub-ngx-tw-item.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-menu-testing.mjs +168 -0
- package/fesm2022/cdevhub-ngx-tw-menu-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-menu.mjs +58 -21
- package/fesm2022/cdevhub-ngx-tw-menu.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-number-input.mjs +34 -1
- package/fesm2022/cdevhub-ngx-tw-number-input.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-paginator.mjs +95 -45
- package/fesm2022/cdevhub-ngx-tw-paginator.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-popover.mjs +81 -32
- package/fesm2022/cdevhub-ngx-tw-popover.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-progress-bar.mjs +1 -1
- package/fesm2022/cdevhub-ngx-tw-progress-bar.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-radio.mjs +131 -98
- package/fesm2022/cdevhub-ngx-tw-radio.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-segmented-control.mjs +207 -42
- package/fesm2022/cdevhub-ngx-tw-segmented-control.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-select-testing.mjs +165 -0
- package/fesm2022/cdevhub-ngx-tw-select-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-select.mjs +386 -210
- package/fesm2022/cdevhub-ngx-tw-select.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-sheet-sheet-renderer-CqVJwgmp.mjs +256 -0
- package/fesm2022/cdevhub-ngx-tw-sheet-sheet-renderer-CqVJwgmp.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-sheet-testing.mjs +129 -0
- package/fesm2022/cdevhub-ngx-tw-sheet-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-sheet.mjs +197 -278
- package/fesm2022/cdevhub-ngx-tw-sheet.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-slider.mjs +89 -54
- package/fesm2022/cdevhub-ngx-tw-slider.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-sort.mjs +122 -17
- package/fesm2022/cdevhub-ngx-tw-sort.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-split.mjs +72 -19
- package/fesm2022/cdevhub-ngx-tw-split.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-stat.mjs +63 -25
- package/fesm2022/cdevhub-ngx-tw-stat.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-stepper.mjs +35 -8
- package/fesm2022/cdevhub-ngx-tw-stepper.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-switch.mjs +54 -48
- package/fesm2022/cdevhub-ngx-tw-switch.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-tab-nav.mjs +12 -15
- package/fesm2022/cdevhub-ngx-tw-tab-nav.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-table.mjs +74 -13
- package/fesm2022/cdevhub-ngx-tw-table.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-tabs.mjs +84 -30
- package/fesm2022/cdevhub-ngx-tw-tabs.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-tags-input-testing.mjs +172 -0
- package/fesm2022/cdevhub-ngx-tw-tags-input-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-tags-input.mjs +107 -71
- package/fesm2022/cdevhub-ngx-tw-tags-input.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-textarea.mjs +41 -9
- package/fesm2022/cdevhub-ngx-tw-textarea.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-theme.mjs +257 -45
- package/fesm2022/cdevhub-ngx-tw-theme.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-time-picker-testing.mjs +201 -0
- package/fesm2022/cdevhub-ngx-tw-time-picker-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-time-picker.mjs +184 -77
- package/fesm2022/cdevhub-ngx-tw-time-picker.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-timeline.mjs +110 -27
- package/fesm2022/cdevhub-ngx-tw-timeline.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-toast-toast-renderer-BlDxemsU.mjs +616 -0
- package/fesm2022/cdevhub-ngx-tw-toast-toast-renderer-BlDxemsU.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-toast.mjs +556 -945
- package/fesm2022/cdevhub-ngx-tw-toast.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-tooltip.mjs +102 -15
- package/fesm2022/cdevhub-ngx-tw-tooltip.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-transfer-testing.mjs +219 -0
- package/fesm2022/cdevhub-ngx-tw-transfer-testing.mjs.map +1 -0
- package/fesm2022/cdevhub-ngx-tw-transfer.mjs +88 -69
- package/fesm2022/cdevhub-ngx-tw-transfer.mjs.map +1 -1
- package/fesm2022/cdevhub-ngx-tw-tree.mjs +68 -19
- package/fesm2022/cdevhub-ngx-tw-tree.mjs.map +1 -1
- package/index.json +1 -1
- package/package.json +63 -2
- package/theme/_base.css +13 -0
- package/theme/_dark.css +110 -36
- package/theme/_high-contrast-dark.css +367 -0
- package/theme/_high-contrast.css +13 -2
- package/theme/_light.css +276 -0
- package/theme/_semantic.css +47 -12
- package/theme/_typography.css +17 -0
- package/theme/index.css +86 -7
- package/types/cdevhub-ngx-tw-accordion.d.ts +12 -4
- package/types/cdevhub-ngx-tw-avatar.d.ts +10 -3
- package/types/cdevhub-ngx-tw-button.d.ts +1 -0
- package/types/cdevhub-ngx-tw-calendar-luxon.d.ts +2 -2
- package/types/cdevhub-ngx-tw-calendar-testing.d.ts +1 -1
- package/types/cdevhub-ngx-tw-calendar.d.ts +179 -73
- package/types/cdevhub-ngx-tw-card.d.ts +11 -3
- package/types/cdevhub-ngx-tw-carousel.d.ts +89 -20
- package/types/cdevhub-ngx-tw-checkbox.d.ts +40 -12
- package/types/cdevhub-ngx-tw-code-block.d.ts +11 -2
- package/types/cdevhub-ngx-tw-collapsible.d.ts +32 -5
- package/types/cdevhub-ngx-tw-combobox-testing.d.ts +157 -0
- package/types/cdevhub-ngx-tw-combobox.d.ts +94 -53
- package/types/cdevhub-ngx-tw-command-palette-testing.d.ts +136 -0
- package/types/cdevhub-ngx-tw-command-palette.d.ts +33 -5
- package/types/cdevhub-ngx-tw-core.d.ts +152 -21
- package/types/cdevhub-ngx-tw-date-picker-testing.d.ts +141 -0
- package/types/cdevhub-ngx-tw-date-picker.d.ts +37 -29
- package/types/cdevhub-ngx-tw-date-range-picker-testing.d.ts +148 -0
- package/types/cdevhub-ngx-tw-date-range-picker.d.ts +36 -29
- package/types/cdevhub-ngx-tw-dialog-testing.d.ts +98 -0
- package/types/cdevhub-ngx-tw-dialog.d.ts +89 -19
- package/types/cdevhub-ngx-tw-file-upload-testing.d.ts +120 -0
- package/types/cdevhub-ngx-tw-file-upload.d.ts +8 -10
- package/types/cdevhub-ngx-tw-flip-card.d.ts +18 -11
- package/types/cdevhub-ngx-tw-form-field.d.ts +19 -2
- package/types/cdevhub-ngx-tw-icon.d.ts +3 -3
- package/types/cdevhub-ngx-tw-input.d.ts +5 -8
- package/types/cdevhub-ngx-tw-item.d.ts +2 -0
- package/types/cdevhub-ngx-tw-menu-testing.d.ts +131 -0
- package/types/cdevhub-ngx-tw-menu.d.ts +2 -2
- package/types/cdevhub-ngx-tw-number-input.d.ts +20 -0
- package/types/cdevhub-ngx-tw-paginator.d.ts +58 -24
- package/types/cdevhub-ngx-tw-popover.d.ts +41 -10
- package/types/cdevhub-ngx-tw-progress-bar.d.ts +1 -1
- package/types/cdevhub-ngx-tw-radio.d.ts +68 -25
- package/types/cdevhub-ngx-tw-segmented-control.d.ts +79 -16
- package/types/cdevhub-ngx-tw-select-testing.d.ts +114 -0
- package/types/cdevhub-ngx-tw-select.d.ts +104 -33
- package/types/cdevhub-ngx-tw-sheet-testing.d.ts +104 -0
- package/types/cdevhub-ngx-tw-sheet.d.ts +96 -21
- package/types/cdevhub-ngx-tw-slider.d.ts +79 -25
- package/types/cdevhub-ngx-tw-sort.d.ts +45 -4
- package/types/cdevhub-ngx-tw-split.d.ts +32 -2
- package/types/cdevhub-ngx-tw-stat.d.ts +14 -4
- package/types/cdevhub-ngx-tw-stepper.d.ts +16 -2
- package/types/cdevhub-ngx-tw-switch.d.ts +35 -13
- package/types/cdevhub-ngx-tw-tab-nav.d.ts +7 -6
- package/types/cdevhub-ngx-tw-table.d.ts +53 -10
- package/types/cdevhub-ngx-tw-tabs.d.ts +41 -10
- package/types/cdevhub-ngx-tw-tags-input-testing.d.ts +135 -0
- package/types/cdevhub-ngx-tw-tags-input.d.ts +26 -11
- package/types/cdevhub-ngx-tw-textarea.d.ts +3 -2
- package/types/cdevhub-ngx-tw-theme.d.ts +245 -39
- package/types/cdevhub-ngx-tw-time-picker-testing.d.ts +129 -0
- package/types/cdevhub-ngx-tw-time-picker.d.ts +76 -19
- package/types/cdevhub-ngx-tw-timeline.d.ts +36 -12
- package/types/cdevhub-ngx-tw-toast.d.ts +61 -12
- package/types/cdevhub-ngx-tw-tooltip.d.ts +28 -6
- package/types/cdevhub-ngx-tw-transfer-testing.d.ts +152 -0
- package/types/cdevhub-ngx-tw-transfer.d.ts +21 -8
- package/types/cdevhub-ngx-tw-tree.d.ts +6 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { ComponentHarness, BaseHarnessFilters, HarnessPredicate } from '@angular/cdk/testing';
|
|
2
|
+
import { CalendarHarness } from '@cdevhub/ngx-tw/calendar/testing';
|
|
3
|
+
|
|
4
|
+
/** Filters accepted by `DateRangePickerHarness.with`. */
|
|
5
|
+
interface DateRangePickerHarnessFilters extends BaseHarnessFilters {
|
|
6
|
+
/** Match by the trigger's accessible name. */
|
|
7
|
+
label?: string | RegExp;
|
|
8
|
+
/** Match by the whole text currently rendered in the trigger. */
|
|
9
|
+
triggerText?: string | RegExp;
|
|
10
|
+
/** Match disabled / enabled pickers. */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Harness for `tw-date-range-picker`.
|
|
15
|
+
*
|
|
16
|
+
* Unlike `tw-date-picker`, this component has **no text input**: its trigger is
|
|
17
|
+
* a `button[role="combobox"]` that renders the start label, a separator and the
|
|
18
|
+
* end label as three sibling spans (or a single placeholder span when empty).
|
|
19
|
+
* A range is therefore read, never typed — {@link getStartText} /
|
|
20
|
+
* {@link getEndText} read it, and {@link selectRange} sets it through the
|
|
21
|
+
* calendar.
|
|
22
|
+
*
|
|
23
|
+
* The calendar renders into the CDK overlay, outside the
|
|
24
|
+
* `tw-date-range-picker` host, so it is resolved through
|
|
25
|
+
* `documentRootLocatorFactory()`. A consumer loads this harness from the
|
|
26
|
+
* ordinary fixture loader — no `documentRootLoader` ceremony required.
|
|
27
|
+
*
|
|
28
|
+
* Day-grid navigation is not reimplemented here: {@link getCalendar} returns
|
|
29
|
+
* the `CalendarHarness` from `@cdevhub/ngx-tw/calendar/testing`, which already
|
|
30
|
+
* owns cells, view switching and header paging.
|
|
31
|
+
*/
|
|
32
|
+
declare class DateRangePickerHarness extends ComponentHarness {
|
|
33
|
+
static hostSelector: string;
|
|
34
|
+
private readonly trigger;
|
|
35
|
+
/**
|
|
36
|
+
* The start / separator / end spans, or a single placeholder span when the
|
|
37
|
+
* range is empty. They carry no distinguishing attribute, so position inside
|
|
38
|
+
* the trigger is the only handle — see {@link getStartText}.
|
|
39
|
+
*/
|
|
40
|
+
private readonly triggerSpans;
|
|
41
|
+
/**
|
|
42
|
+
* The inline clear control — the only button in the host that is not the
|
|
43
|
+
* trigger.
|
|
44
|
+
*/
|
|
45
|
+
private readonly clearButton;
|
|
46
|
+
/** Resolves the overlay's calendar, which lives outside this harness's host. */
|
|
47
|
+
private readonly calendar;
|
|
48
|
+
/** Predicate for `locatorFor` / `locatorForAll`. */
|
|
49
|
+
static with(options?: DateRangePickerHarnessFilters): HarnessPredicate<DateRangePickerHarness>;
|
|
50
|
+
/**
|
|
51
|
+
* The trigger's accessible name.
|
|
52
|
+
*
|
|
53
|
+
* Note this is *composed*, not the bare `aria-label`: once a complete range
|
|
54
|
+
* is set the component appends the range to it
|
|
55
|
+
* (`"Report period. Current range: Apr 10 to Apr 15."`). Match with a RegExp
|
|
56
|
+
* in {@link with} if you need it to survive a selection.
|
|
57
|
+
*/
|
|
58
|
+
getLabel(): Promise<string | null>;
|
|
59
|
+
/**
|
|
60
|
+
* The whole text rendered in the trigger, trimmed — start, separator and end
|
|
61
|
+
* run together, or the placeholder when no range is set.
|
|
62
|
+
*/
|
|
63
|
+
getTriggerText(): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* The formatted start date, or `null` when no range is set (the trigger then
|
|
66
|
+
* renders a single placeholder span instead of the start/separator/end
|
|
67
|
+
* triple).
|
|
68
|
+
*/
|
|
69
|
+
getStartText(): Promise<string | null>;
|
|
70
|
+
/** The formatted end date, or `null` when no range is set. */
|
|
71
|
+
getEndText(): Promise<string | null>;
|
|
72
|
+
/** Whether the calendar overlay is open, read from the trigger's `aria-expanded`. */
|
|
73
|
+
isOpen(): Promise<boolean>;
|
|
74
|
+
/** Whether the trigger reports `aria-disabled="true"`. */
|
|
75
|
+
isDisabled(): Promise<boolean>;
|
|
76
|
+
/** Whether the trigger reports `aria-invalid="true"`. */
|
|
77
|
+
isInvalid(): Promise<boolean>;
|
|
78
|
+
/**
|
|
79
|
+
* Whether the trigger reports `aria-required="true"`. Reflects the `required`
|
|
80
|
+
* input *and* a `Validators.required` on a bound control.
|
|
81
|
+
*/
|
|
82
|
+
isRequired(): Promise<boolean>;
|
|
83
|
+
/**
|
|
84
|
+
* Opens the calendar overlay by clicking the trigger. No-op when already
|
|
85
|
+
* open; a disabled picker ignores it, as it does in the browser.
|
|
86
|
+
*/
|
|
87
|
+
open(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Closes the calendar overlay by clicking the trigger again. No-op when
|
|
90
|
+
* already closed.
|
|
91
|
+
*
|
|
92
|
+
* Deliberately not Escape: `tw-date-range-picker` treats Escape as *cancel*
|
|
93
|
+
* and restores the range the overlay opened with, which would make `close()`
|
|
94
|
+
* silently undo a selection. The trigger toggles without that side effect.
|
|
95
|
+
*
|
|
96
|
+
* The overlay runs a leave animation before it detaches, so `isOpen()` flips
|
|
97
|
+
* to `false` immediately while the panel element lingers for a few more
|
|
98
|
+
* frames. Two consequences worth knowing:
|
|
99
|
+
*
|
|
100
|
+
* - Do not assert `getCalendar()` is `null` on the tick after a close; the
|
|
101
|
+
* old panel is still mounted.
|
|
102
|
+
* - An `open()` inside that window does **not** attach a fresh panel — the
|
|
103
|
+
* component sees an overlay ref it has not disposed yet and silently
|
|
104
|
+
* keeps the outgoing one. Let the animation finish before reopening.
|
|
105
|
+
*/
|
|
106
|
+
close(): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* The `CalendarHarness` for the open overlay, or `null` when no overlay is
|
|
109
|
+
* attached. One `tw-calendar` renders all `numberOfMonths` months under a
|
|
110
|
+
* single header, so this is a single harness whatever that input is set to.
|
|
111
|
+
*/
|
|
112
|
+
getCalendar(): Promise<CalendarHarness | null>;
|
|
113
|
+
/**
|
|
114
|
+
* Opens the overlay if needed and clicks the two cells whose text matches
|
|
115
|
+
* `start` then `end` exactly (`'10'`, not `'April 10'`). Throws when either
|
|
116
|
+
* cell is not visible in the current view.
|
|
117
|
+
*
|
|
118
|
+
* With more than one month rendered a day number appears once per month grid;
|
|
119
|
+
* the first match wins, which is the earliest visible month. Page the
|
|
120
|
+
* calendar via {@link getCalendar} first if you need a later one.
|
|
121
|
+
*
|
|
122
|
+
* With `showActions` off this commits and closes on the second click; with it
|
|
123
|
+
* on the range stays pending until {@link clickAction} confirms it.
|
|
124
|
+
*/
|
|
125
|
+
selectRange(start: string, end: string): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Clicks a button in the overlay's action bar (`Today`, `Clear`, `Cancel`,
|
|
128
|
+
* `Apply`) by its visible text. Matching on text rather than position is what
|
|
129
|
+
* keeps this usable when a consumer relabels the actions via `todayLabel` and
|
|
130
|
+
* friends — pass whatever label you configured.
|
|
131
|
+
*
|
|
132
|
+
* Preset entries are excluded: they are `role="option"`, not action buttons.
|
|
133
|
+
* Throws when the overlay is closed or nothing matches.
|
|
134
|
+
*/
|
|
135
|
+
clickAction(label: string | RegExp): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Whether the inline clear control is rendered. It appears only while
|
|
138
|
+
* `showClear` is on, the picker is enabled, and a range is set.
|
|
139
|
+
*/
|
|
140
|
+
hasClearButton(): Promise<boolean>;
|
|
141
|
+
/** Clicks the inline clear control. Throws when none is rendered. */
|
|
142
|
+
clear(): Promise<void>;
|
|
143
|
+
/** @internal Text of one of the start/separator/end spans, or `null` when the trigger is empty. */
|
|
144
|
+
private rangeSpanText;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { DateRangePickerHarness };
|
|
148
|
+
export type { DateRangePickerHarnessFilters };
|
|
@@ -55,21 +55,21 @@ declare class DateRangePickerComponent<D = Date> extends FormFieldControl<TwDate
|
|
|
55
55
|
readonly minDate: _angular_core.InputSignal<D | null>;
|
|
56
56
|
/** Latest selectable date for either endpoint. Presets and calendar cells later than this are rejected or disabled. Defaults to `null`. */
|
|
57
57
|
readonly maxDate: _angular_core.InputSignal<D | null>;
|
|
58
|
-
/** Per-date predicate — return `false` to disable. Applied in both calendars. Presets that fall on a filtered date are skipped. */
|
|
58
|
+
/** Per-date predicate — return `false` to disable. Applied in both calendars. Presets that fall on a filtered date are skipped. Defaults to `null`. */
|
|
59
59
|
readonly dateFilter: _angular_core.InputSignal<DateFilterFn<D> | null>;
|
|
60
60
|
/** Which calendar view opens first — `'day'`, `'month'`, or `'year'`. Defaults to `'day'`. */
|
|
61
61
|
readonly startView: _angular_core.InputSignal<CalendarViewState>;
|
|
62
|
-
/** Date the left calendar focuses on when opened with no value. Falls back to today. Ignored when a value is already set. */
|
|
62
|
+
/** Date the left calendar focuses on when opened with no value. Falls back to today. Ignored when a value is already set. Defaults to `null`. */
|
|
63
63
|
readonly startAt: _angular_core.InputSignal<D | null>;
|
|
64
64
|
/** Display format for each endpoint, passed to `DateAdapter.format()`. When `showTime` is true and this is left at the default, hour/minute (and optional seconds) are folded in automatically. */
|
|
65
65
|
readonly format: _angular_core.InputSignal<unknown>;
|
|
66
66
|
/** Separator rendered between the two formatted endpoints in the trigger. Defaults to `" – "`. */
|
|
67
67
|
readonly rangeSeparator: _angular_core.InputSignal<string>;
|
|
68
|
-
/** Placeholder text shown in the trigger for an empty `start` endpoint. */
|
|
68
|
+
/** Placeholder text shown in the trigger for an empty `start` endpoint. Defaults to `'Start date'`. */
|
|
69
69
|
readonly emptyStartLabel: _angular_core.InputSignal<string>;
|
|
70
|
-
/** Placeholder text shown in the trigger for an empty `end` endpoint. */
|
|
70
|
+
/** Placeholder text shown in the trigger for an empty `end` endpoint. Defaults to `'End date'`. */
|
|
71
71
|
readonly emptyEndLabel: _angular_core.InputSignal<string>;
|
|
72
|
-
/** When set, overrides the composed `${emptyStartLabel}${rangeSeparator}${emptyEndLabel}` placeholder with a single string. */
|
|
72
|
+
/** When set, overrides the composed `${emptyStartLabel}${rangeSeparator}${emptyEndLabel}` placeholder with a single string. Defaults to `undefined`. */
|
|
73
73
|
readonly placeholder: _angular_core.InputSignal<string | undefined>;
|
|
74
74
|
/** When true, the trigger cannot open the overlay and `aria-disabled="true"` is set. Defaults to `false`. */
|
|
75
75
|
readonly disabledInput: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
@@ -83,9 +83,9 @@ declare class DateRangePickerComponent<D = Date> extends FormFieldControl<TwDate
|
|
|
83
83
|
readonly variant: _angular_core.InputSignal<DateRangePickerVariant | undefined>;
|
|
84
84
|
/** How many months the overlay shows side-by-side. `2` is the standard range-picker layout; use `1` for compact contexts. Defaults to `2`. */
|
|
85
85
|
readonly numberOfMonths: _angular_core.InputSignal<DateRangePickerMonths>;
|
|
86
|
-
/** Optional quick-select presets rendered as a vertical list before the calendars. Each preset provides a label and a factory returning a `TwDateRange<D>`. An empty array hides the preset panel. */
|
|
86
|
+
/** Optional quick-select presets rendered as a vertical list before the calendars. Each preset provides a label and a factory returning a `TwDateRange<D>`. An empty array hides the preset panel. Defaults to an empty array. */
|
|
87
87
|
readonly presets: _angular_core.InputSignal<readonly DateRangePreset<D>[]>;
|
|
88
|
-
/** Whether to show a clear-button affordance inside the trigger when a value is set. Defaults to `true
|
|
88
|
+
/** Whether to show a clear-button affordance inside the trigger when a value is set. Defaults to `true` — most form pickers expect the inline clear, matching `<tw-input>`'s clear button; without it consumers must wire one themselves. */
|
|
89
89
|
readonly showClear: _angular_core.InputSignal<boolean>;
|
|
90
90
|
/** Minimum range length in days, inclusive. Commits shorter than this are rejected and surface `calendarRangeTooShort` on the bound `NgControl`. `null` = no minimum. Defaults to `null`. */
|
|
91
91
|
readonly minRangeLength: _angular_core.InputSignal<number | null>;
|
|
@@ -101,11 +101,11 @@ declare class DateRangePickerComponent<D = Date> extends FormFieldControl<TwDate
|
|
|
101
101
|
readonly rangeClickBehavior: _angular_core.InputSignal<RangeClickBehavior>;
|
|
102
102
|
/** Override first day of week (0=Sun, 1=Mon) on the embedded calendar. Falls back to the adapter's default. */
|
|
103
103
|
readonly firstDayOfWeek: _angular_core.InputSignal<number | null>;
|
|
104
|
-
/** Per-instance locale override. Forwarded to the embedded calendar and the underlying `DateAdapter` so the trigger display tracks the picker's locale. Falls back to Angular `LOCALE_ID` when `null`. */
|
|
104
|
+
/** Per-instance locale override. Forwarded to the embedded calendar and the underlying `DateAdapter` so the trigger display tracks the picker's locale. Falls back to Angular `LOCALE_ID` when `null`. Defaults to `null`. */
|
|
105
105
|
readonly locale: _angular_core.InputSignal<string | null>;
|
|
106
|
-
/** Function producing per-cell CSS classes on the embedded calendar. */
|
|
106
|
+
/** Function producing per-cell CSS classes on the embedded calendar. Defaults to `null`. */
|
|
107
107
|
readonly dateClass: _angular_core.InputSignal<DateClassFn<D> | null>;
|
|
108
|
-
/** Optional cell-content template, forwarded to the embedded calendar. Use to customize cell visuals beyond `dateClass`. */
|
|
108
|
+
/** Optional cell-content template, forwarded to the embedded calendar. Use to customize cell visuals beyond `dateClass`. Defaults to `null`. */
|
|
109
109
|
readonly cellTemplate: _angular_core.InputSignal<TemplateRef<{
|
|
110
110
|
$implicit: CalendarCell<D>;
|
|
111
111
|
}> | null>;
|
|
@@ -123,15 +123,15 @@ declare class DateRangePickerComponent<D = Date> extends FormFieldControl<TwDate
|
|
|
123
123
|
readonly minuteStep: _angular_core.InputSignal<number>;
|
|
124
124
|
/** Step for the embedded time-pickers' second fields. Defaults to `1`. */
|
|
125
125
|
readonly secondStep: _angular_core.InputSignal<number>;
|
|
126
|
-
/** Label for the `Today` action in the overlay's action bar. */
|
|
126
|
+
/** Label for the `Today` action in the overlay's action bar. Defaults to `'Today'`. */
|
|
127
127
|
readonly todayLabel: _angular_core.InputSignal<string>;
|
|
128
|
-
/** Label for the `Clear` action in the overlay's action bar. */
|
|
128
|
+
/** Label for the `Clear` action in the overlay's action bar. Defaults to `'Clear'`. */
|
|
129
129
|
readonly clearLabel: _angular_core.InputSignal<string>;
|
|
130
|
-
/** Label for the `Cancel` action in the overlay's action bar. */
|
|
130
|
+
/** Label for the `Cancel` action in the overlay's action bar. Defaults to `'Cancel'`. */
|
|
131
131
|
readonly cancelLabel: _angular_core.InputSignal<string>;
|
|
132
|
-
/** Label for the `Apply` action in the overlay's action bar. */
|
|
132
|
+
/** Label for the `Apply` action in the overlay's action bar. Defaults to `'Apply'`. */
|
|
133
133
|
readonly applyLabel: _angular_core.InputSignal<string>;
|
|
134
|
-
/** Extra class(es) applied to the overlay panel element. `twMerge` resolves conflicts with internal classes. */
|
|
134
|
+
/** Extra class(es) applied to the overlay panel element. `twMerge` resolves conflicts with internal classes. Defaults to an empty string. */
|
|
135
135
|
readonly panelClass: _angular_core.InputSignal<string | readonly string[]>;
|
|
136
136
|
/** CDK scroll strategy for the overlay. Defaults to `'reposition'`. */
|
|
137
137
|
readonly scrollStrategy: _angular_core.InputSignal<"reposition" | "close" | "block">;
|
|
@@ -139,17 +139,17 @@ declare class DateRangePickerComponent<D = Date> extends FormFieldControl<TwDate
|
|
|
139
139
|
readonly offset: _angular_core.InputSignal<number>;
|
|
140
140
|
/** Accessible label for the clear button. Defaults to `'Clear date range'`. */
|
|
141
141
|
readonly clearAriaLabel: _angular_core.InputSignal<string>;
|
|
142
|
-
/** Per-instance override of the `ErrorStateMatcher`. When omitted, uses the injected `TW_ERROR_STATE_MATCHER`. */
|
|
142
|
+
/** Per-instance override of the `ErrorStateMatcher`. When omitted, uses the injected `TW_ERROR_STATE_MATCHER`. Defaults to `undefined`. */
|
|
143
143
|
readonly errorStateMatcher: _angular_core.InputSignal<ErrorStateMatcher | undefined>;
|
|
144
|
-
/** Accessible name for the trigger. Required when no visible label is supplied via `tw-form-field` or an external `aria-labelledby`. Alias: `aria-label`. */
|
|
144
|
+
/** Accessible name for the trigger. Required when no visible label is supplied via `tw-form-field` or an external `aria-labelledby`. Alias: `aria-label`. Defaults to `undefined`. */
|
|
145
145
|
readonly ariaLabel: _angular_core.InputSignal<string | undefined>;
|
|
146
|
-
/** ID of an external element that labels the trigger. Alias: `aria-labelledby`. */
|
|
146
|
+
/** ID of an external element that labels the trigger. Alias: `aria-labelledby`. Defaults to `undefined`. */
|
|
147
147
|
readonly ariaLabelledby: _angular_core.InputSignal<string | undefined>;
|
|
148
|
-
/** Consumer-supplied `aria-describedby` ids. The form-field preserves these when merging hint/error ids. Alias: `aria-describedby`. */
|
|
148
|
+
/** Consumer-supplied `aria-describedby` ids. The form-field preserves these when merging hint/error ids. Alias: `aria-describedby`. Defaults to `undefined`. */
|
|
149
149
|
readonly userAriaDescribedByInput: _angular_core.InputSignal<string | undefined>;
|
|
150
|
-
/** Two-way bound selected range. `null` when no selection. Setting programmatically updates the trigger display and the calendar selection; it does NOT trigger `onChange`. */
|
|
150
|
+
/** Two-way bound selected range. `null` when no selection. Setting programmatically updates the trigger display and the calendar selection; it does NOT trigger `onChange`. Defaults to `null`. */
|
|
151
151
|
readonly value: _angular_core.ModelSignal<TwDateRange<D> | null>;
|
|
152
|
-
/** Two-way bound open state of the overlay. Setting to `true` opens; setting to `false` closes. */
|
|
152
|
+
/** Two-way bound open state of the overlay. Setting to `true` opens; setting to `false` closes. Defaults to `false`. */
|
|
153
153
|
readonly open: _angular_core.ModelSignal<boolean>;
|
|
154
154
|
/** Fires after the overlay's enter animation completes. Payload is the trigger element. */
|
|
155
155
|
readonly opened: _angular_core.OutputEmitterRef<DateRangePickerOpenedEvent>;
|
|
@@ -170,9 +170,6 @@ declare class DateRangePickerComponent<D = Date> extends FormFieldControl<TwDate
|
|
|
170
170
|
private readonly destroyRef;
|
|
171
171
|
private readonly formField;
|
|
172
172
|
private ngControl;
|
|
173
|
-
private readonly parentForm;
|
|
174
|
-
private readonly parentFormGroup;
|
|
175
|
-
private readonly defaultMatcher;
|
|
176
173
|
private readonly triggerRef;
|
|
177
174
|
private readonly uid;
|
|
178
175
|
/** @internal */
|
|
@@ -189,16 +186,16 @@ declare class DateRangePickerComponent<D = Date> extends FormFieldControl<TwDate
|
|
|
189
186
|
readonly focusedSignal: _angular_core.WritableSignal<boolean>;
|
|
190
187
|
private readonly cvaDisabled;
|
|
191
188
|
private readonly describedByIdsSignal;
|
|
192
|
-
private readonly closingSignal;
|
|
193
189
|
private readonly lastValueBeforeOpen;
|
|
194
190
|
private readonly pendingRange;
|
|
195
191
|
private readonly currentView;
|
|
196
|
-
|
|
197
|
-
private readonly
|
|
192
|
+
/** @internal Shared `errorState` / `required` / `errors` derivation — see `wireErrorState`. */
|
|
193
|
+
private readonly errorWiring;
|
|
198
194
|
private onChange;
|
|
199
195
|
private onTouched;
|
|
200
|
-
private
|
|
201
|
-
private
|
|
196
|
+
private overlayInstance;
|
|
197
|
+
private closing;
|
|
198
|
+
private readonly isAttached;
|
|
202
199
|
/** @internal */
|
|
203
200
|
readonly isDisabled: Signal<boolean>;
|
|
204
201
|
/** @internal Effective variant — auto-naked when wrapped in tw-form-field. */
|
|
@@ -250,6 +247,16 @@ declare class DateRangePickerComponent<D = Date> extends FormFieldControl<TwDate
|
|
|
250
247
|
readonly required: Signal<boolean>;
|
|
251
248
|
/** @internal */
|
|
252
249
|
readonly errorState: Signal<boolean>;
|
|
250
|
+
/**
|
|
251
|
+
* @internal Active validation errors map from the bound `NgControl` (or `null` when the
|
|
252
|
+
* control reports none / is unbound). This is what `[twError match="…"]` filters on inside a
|
|
253
|
+
* `<tw-form-field>`; without it every `match`-targeted message — including the
|
|
254
|
+
* `calendarMinDate` / `calendarMaxDate` / `calendarInvalidRange` / `calendarRangeTooShort` /
|
|
255
|
+
* `calendarRangeTooLong` codes this component's `NG_VALIDATORS` apparatus exists to produce —
|
|
256
|
+
* stays permanently hidden. (Authoritative key list: `CalendarValidationErrors` in
|
|
257
|
+
* `calendar.types.ts`.)
|
|
258
|
+
*/
|
|
259
|
+
readonly errors: Signal<Record<string, unknown> | null>;
|
|
253
260
|
/** @internal */
|
|
254
261
|
readonly controlType = "date-range-picker";
|
|
255
262
|
/** @internal */
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ComponentHarness, BaseHarnessFilters, HarnessPredicate } from '@angular/cdk/testing';
|
|
2
|
+
|
|
3
|
+
/** Filters accepted by `DialogHarness.with`. */
|
|
4
|
+
interface DialogHarnessFilters extends BaseHarnessFilters {
|
|
5
|
+
/** Match by the dialog's id — the same value as `TwDialogRef.id`. */
|
|
6
|
+
id?: string | RegExp;
|
|
7
|
+
/** Match by the text of the projected `[twDialogTitle]` element. */
|
|
8
|
+
title?: string | RegExp;
|
|
9
|
+
/** Match by ARIA role — `'dialog'` or `'alertdialog'`. */
|
|
10
|
+
role?: string | RegExp;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Harness for a dialog opened with `TwDialog.open()`.
|
|
14
|
+
*
|
|
15
|
+
* ## Loading it
|
|
16
|
+
*
|
|
17
|
+
* A dialog is **service-opened**, not template-declared: nothing in the test
|
|
18
|
+
* fixture's own DOM represents it, and the container renders into the CDK
|
|
19
|
+
* overlay container on `document.body`. This harness's host *is* that container,
|
|
20
|
+
* so it must be loaded from
|
|
21
|
+
* `TestbedHarnessEnvironment.documentRootLoader(fixture)` — the ordinary
|
|
22
|
+
* `loader(fixture)` searches inside `fixture.nativeElement` and will never find
|
|
23
|
+
* it. This is not the same situation as an overlay *panel* belonging to a
|
|
24
|
+
* template-declared component (`tw-select`, `tw-popover-overlay`, `tw-menu`),
|
|
25
|
+
* where the harness hosts on the in-fixture trigger and reaches its panel
|
|
26
|
+
* internally; there the plain fixture loader is correct.
|
|
27
|
+
*
|
|
28
|
+
* ## Waiting for it
|
|
29
|
+
*
|
|
30
|
+
* `TwDialog` loads its render layer through a dynamic `import()`, so the
|
|
31
|
+
* container does **not** exist synchronously after `open()`. Await the ref's
|
|
32
|
+
* public {@link TwDialogRef.whenComponentReady} before asking for the harness —
|
|
33
|
+
* it resolves once the chunk has landed and the overlay is attached, for
|
|
34
|
+
* template dialogs (with `null`) as well as component dialogs.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const ref = dialog.open(EditorDialog);
|
|
39
|
+
* await ref.whenComponentReady();
|
|
40
|
+
* const rootLoader = TestbedHarnessEnvironment.documentRootLoader(fixture);
|
|
41
|
+
* const harness = await rootLoader.getHarness(DialogHarness);
|
|
42
|
+
* expect(await harness.getTitleText()).toBe('Edit profile');
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
declare class DialogHarness extends ComponentHarness {
|
|
46
|
+
static hostSelector: string;
|
|
47
|
+
private readonly title;
|
|
48
|
+
private readonly content;
|
|
49
|
+
/** Any descendant of the container that currently holds DOM focus. */
|
|
50
|
+
private readonly focusedDescendant;
|
|
51
|
+
/**
|
|
52
|
+
* Overlay backdrops, which are siblings of the dialog's overlay pane rather
|
|
53
|
+
* than descendants of the container — hence the document-root lookup.
|
|
54
|
+
*/
|
|
55
|
+
private readonly backdrops;
|
|
56
|
+
/** Predicate for `locatorFor` / `locatorForAll`. */
|
|
57
|
+
static with(options?: DialogHarnessFilters): HarnessPredicate<DialogHarness>;
|
|
58
|
+
/** The dialog's id. Matches the `id` on the `TwDialogRef` returned by `open()`. */
|
|
59
|
+
getId(): Promise<string | null>;
|
|
60
|
+
/** The dialog's ARIA role — `'dialog'`, or `'alertdialog'` when so configured. */
|
|
61
|
+
getRole(): Promise<string | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Text of the projected `[twDialogTitle]` element, trimmed, or `null` when
|
|
64
|
+
* the dialog's content does not use the title directive.
|
|
65
|
+
*/
|
|
66
|
+
getTitleText(): Promise<string | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Text of the projected `[twDialogContent]` region, trimmed, or `null` when
|
|
69
|
+
* the dialog's content does not use the content directive.
|
|
70
|
+
*/
|
|
71
|
+
getContentText(): Promise<string | null>;
|
|
72
|
+
/**
|
|
73
|
+
* Whether DOM focus currently sits on the dialog container or anywhere inside
|
|
74
|
+
* it — the observable consequence of the CDK focus trap. CDK moves focus
|
|
75
|
+
* asynchronously, so let the fixture settle after opening before asserting.
|
|
76
|
+
*/
|
|
77
|
+
containsFocus(): Promise<boolean>;
|
|
78
|
+
/** Whether the dialog rendered a backdrop. */
|
|
79
|
+
hasBackdrop(): Promise<boolean>;
|
|
80
|
+
/**
|
|
81
|
+
* Clicks the backdrop — the pointer dismiss gesture. Does nothing observable
|
|
82
|
+
* when the dialog was opened with `disableClose: true`, which is exactly how
|
|
83
|
+
* a test asserts that flag.
|
|
84
|
+
*
|
|
85
|
+
* Throws when no backdrop is rendered. With several overlays stacked, the
|
|
86
|
+
* last backdrop in the overlay container is used, i.e. the topmost one.
|
|
87
|
+
*/
|
|
88
|
+
clickBackdrop(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Sends Escape to the dialog — the keyboard dismiss gesture. Like
|
|
91
|
+
* {@link clickBackdrop}, it is deliberately a no-op when the dialog was
|
|
92
|
+
* opened with `disableClose: true`.
|
|
93
|
+
*/
|
|
94
|
+
pressEscape(): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { DialogHarness };
|
|
98
|
+
export type { DialogHarnessFilters };
|
|
@@ -104,17 +104,19 @@ declare class DialogContainer extends CdkDialogContainer<TwDialogConfig> {
|
|
|
104
104
|
/**
|
|
105
105
|
* Reference to a dialog opened via {@link TwDialog.open}. Drives the dialog
|
|
106
106
|
* lifecycle (close, state, observables) and forwards useful overlay streams.
|
|
107
|
+
*
|
|
108
|
+
* The ref is returned **synchronously** from `open()`, but the dialog's render
|
|
109
|
+
* layer (`@angular/cdk/dialog` + the Tailwind container) is loaded through a
|
|
110
|
+
* dynamic `import()`. The ref therefore starts *detached*: `id`, `state`,
|
|
111
|
+
* `close()`, the lifecycle observables, and panel/size mutations all work
|
|
112
|
+
* immediately (mutations are buffered and replayed on attach), but the rendered
|
|
113
|
+
* component instance does not exist yet — read it via {@link whenComponentReady}
|
|
114
|
+
* instead of a synchronous `componentInstance` field.
|
|
107
115
|
*/
|
|
108
116
|
declare class TwDialogRef<R = unknown, C = unknown> {
|
|
109
|
-
private readonly cdkRef;
|
|
110
117
|
readonly config: TwDialogConfig<unknown, R>;
|
|
111
|
-
|
|
112
|
-
/** Unique ID of the dialog. */
|
|
118
|
+
/** Unique ID of the dialog. Generated eagerly by the service, so it is valid the instant `open()` returns. */
|
|
113
119
|
readonly id: string;
|
|
114
|
-
/** Instance of the component rendered inside the dialog, or `null` for template dialogs. */
|
|
115
|
-
componentInstance: C | null;
|
|
116
|
-
/** `ComponentRef` of the content component, or `null` for template dialogs. */
|
|
117
|
-
readonly componentRef: ComponentRef<C> | null;
|
|
118
120
|
/** Current lifecycle state. Reactively readable. */
|
|
119
121
|
readonly state: Signal<DialogState>;
|
|
120
122
|
/** When `true`, close-via-escape and close-via-backdrop are disabled. */
|
|
@@ -123,9 +125,60 @@ declare class TwDialogRef<R = unknown, C = unknown> {
|
|
|
123
125
|
private readonly afterOpenedSubject;
|
|
124
126
|
private readonly beforeClosedSubject;
|
|
125
127
|
private readonly afterClosedSubject;
|
|
128
|
+
private readonly backdropClickSubject;
|
|
129
|
+
private readonly keydownEventsSubject;
|
|
130
|
+
private cdkRef;
|
|
131
|
+
private container;
|
|
132
|
+
private componentInstanceValue;
|
|
133
|
+
private componentRefValue;
|
|
134
|
+
private resolveComponentReady;
|
|
135
|
+
private readonly componentReadyPromise;
|
|
136
|
+
private readonly pendingPanelAdds;
|
|
137
|
+
private readonly pendingPanelRemoves;
|
|
138
|
+
private pendingSize;
|
|
126
139
|
private pendingResult;
|
|
127
140
|
private closeFocusOrigin;
|
|
128
|
-
constructor(
|
|
141
|
+
constructor(id: string, config: TwDialogConfig<unknown, R>);
|
|
142
|
+
/**
|
|
143
|
+
* The Tailwind container instance, or `null` until the dialog has attached.
|
|
144
|
+
* `null` is the normal value for the first tick after `open()` returns,
|
|
145
|
+
* because the render layer is loaded through a dynamic `import()`.
|
|
146
|
+
*
|
|
147
|
+
* Only `state`, `animationStateChanged`, `enterAnimationDuration` and
|
|
148
|
+
* `exitAnimationDuration` are supported reads; the `_`-prefixed members are
|
|
149
|
+
* library-internal wiring and may change without a major bump. Prefer
|
|
150
|
+
* {@link state} and {@link afterOpened} on the ref itself.
|
|
151
|
+
*/
|
|
152
|
+
get containerInstance(): DialogContainer | null;
|
|
153
|
+
/**
|
|
154
|
+
* @internal Wire this facade to its CDK backend. Called from the dialog
|
|
155
|
+
* renderer **inside** `cdkDialog.open()`'s `providers` callback — the same
|
|
156
|
+
* point the constructor ran before deferral — so subscriptions to
|
|
157
|
+
* `animationStateChanged` are in place before the container emits `'open'`.
|
|
158
|
+
*/
|
|
159
|
+
_attach(cdkRef: DialogRef<R, C>, container: DialogContainer): void;
|
|
160
|
+
/** @internal Record the rendered component after `cdkDialog.open()` returns. */
|
|
161
|
+
_setComponent(instance: C | null, ref: ComponentRef<C> | null): void;
|
|
162
|
+
/**
|
|
163
|
+
* Resolves with the rendered content-component instance once the dialog's
|
|
164
|
+
* render chunk has loaded and attached. Resolves `null` for template dialogs,
|
|
165
|
+
* and for a dialog closed before it ever opened.
|
|
166
|
+
*
|
|
167
|
+
* Replaces the former synchronous `componentInstance` field, which cannot be
|
|
168
|
+
* populated before the deferred render chunk lands.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* const ref = dialog.open(EditorDialog);
|
|
173
|
+
* const editor = await ref.whenComponentReady();
|
|
174
|
+
* editor?.focusFirstField();
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
whenComponentReady(): Promise<C | null>;
|
|
178
|
+
/** The rendered component instance, or `null` if not yet attached / a template dialog. Prefer {@link whenComponentReady}. */
|
|
179
|
+
get componentInstance(): C | null;
|
|
180
|
+
/** The rendered `ComponentRef`, or `null` if not yet attached / a template dialog. */
|
|
181
|
+
get componentRef(): ComponentRef<C> | null;
|
|
129
182
|
/**
|
|
130
183
|
* Closes the dialog. The exit animation runs before the overlay is disposed.
|
|
131
184
|
* @param result Value forwarded to `afterClosed()` subscribers.
|
|
@@ -137,15 +190,15 @@ declare class TwDialogRef<R = unknown, C = unknown> {
|
|
|
137
190
|
beforeClosed(): Observable<R | undefined>;
|
|
138
191
|
/** Observable that emits once after the dialog has fully closed and the overlay is disposed. */
|
|
139
192
|
afterClosed(): Observable<R | undefined>;
|
|
140
|
-
/** Backdrop click stream (emits even when `disableClose` is set). */
|
|
193
|
+
/** Backdrop click stream (emits even when `disableClose` is set). Buffered — a subscription made before the dialog attaches receives events once it does. */
|
|
141
194
|
backdropClick(): Observable<MouseEvent>;
|
|
142
|
-
/** Keydown event stream for the overlay. */
|
|
195
|
+
/** Keydown event stream for the overlay. Buffered — a subscription made before the dialog attaches receives events once it does. */
|
|
143
196
|
keydownEvents(): Observable<KeyboardEvent>;
|
|
144
|
-
/** Updates the dialog's width/height. Pass empty string to reset a dimension. */
|
|
197
|
+
/** Updates the dialog's width/height. Pass empty string to reset a dimension. Buffered until attach. */
|
|
145
198
|
updateSize(width?: string | number, height?: string | number): this;
|
|
146
|
-
/** Adds CSS classes to the overlay panel. */
|
|
199
|
+
/** Adds CSS classes to the overlay panel. Buffered until attach. */
|
|
147
200
|
addPanelClass(classes: string | string[]): this;
|
|
148
|
-
/** Removes CSS classes from the overlay panel. */
|
|
201
|
+
/** Removes CSS classes from the overlay panel. Buffered until attach. */
|
|
149
202
|
removePanelClass(classes: string | string[]): this;
|
|
150
203
|
private closeWithOrigin;
|
|
151
204
|
private finishClose;
|
|
@@ -156,13 +209,21 @@ declare class TwDialogRef<R = unknown, C = unknown> {
|
|
|
156
209
|
* trapping, portals, overlay plumbing, and adds a Tailwind container, richer
|
|
157
210
|
* ref API, and animation lifecycle.
|
|
158
211
|
*
|
|
212
|
+
* The rendering layer (`@angular/cdk/dialog` + the Tailwind container) is loaded
|
|
213
|
+
* through a dynamic `import()` on the first `open()` call, so merely registering
|
|
214
|
+
* this service costs nothing in the initial bundle. `open()` still returns its
|
|
215
|
+
* {@link TwDialogRef} synchronously — the dialog is rendered once the chunk
|
|
216
|
+
* lands. Read the rendered component via {@link TwDialogRef.whenComponentReady}.
|
|
217
|
+
*
|
|
159
218
|
* Not `providedIn: 'root'` — register it via {@link provideTwDialog}.
|
|
160
219
|
*/
|
|
161
220
|
declare class TwDialog implements OnDestroy {
|
|
162
|
-
private readonly cdkDialog;
|
|
163
221
|
private readonly injector;
|
|
164
222
|
private readonly defaultOptions;
|
|
165
223
|
private readonly parentDialog;
|
|
224
|
+
/** Cached renderer chunk import — kicked off on the first `open()`. */
|
|
225
|
+
private rendererPromise;
|
|
226
|
+
private destroyed;
|
|
166
227
|
private readonly openDialogsAtThisLevel;
|
|
167
228
|
private readonly afterOpenedSubject;
|
|
168
229
|
private readonly afterAllClosedSubject;
|
|
@@ -179,7 +240,7 @@ declare class TwDialog implements OnDestroy {
|
|
|
179
240
|
* Opens a dialog using the given component or template.
|
|
180
241
|
* @param content Component class or `TemplateRef`.
|
|
181
242
|
* @param config Options merged over the application defaults.
|
|
182
|
-
* @returns Reference controlling the opened dialog.
|
|
243
|
+
* @returns Reference controlling the opened dialog, returned synchronously.
|
|
183
244
|
*/
|
|
184
245
|
open<R = unknown, D = unknown, C = unknown>(content: ComponentType<C> | TemplateRef<C>, config?: TwDialogConfig<D, R>): TwDialogRef<R, C>;
|
|
185
246
|
/** Closes every open dialog managed by this service (and child services). */
|
|
@@ -187,11 +248,22 @@ declare class TwDialog implements OnDestroy {
|
|
|
187
248
|
/** Looks up an open dialog by its id. */
|
|
188
249
|
getDialogById<R = unknown, C = unknown>(id: string): TwDialogRef<R, C> | undefined;
|
|
189
250
|
ngOnDestroy(): void;
|
|
251
|
+
/**
|
|
252
|
+
* @internal Resolves once the renderer chunk has loaded. Exposed for tests,
|
|
253
|
+
* which must await the dynamic import before asserting on rendered DOM.
|
|
254
|
+
*/
|
|
255
|
+
_whenRendered(): Promise<void>;
|
|
256
|
+
/**
|
|
257
|
+
* Render a dialog once the renderer chunk has loaded. The ref was already
|
|
258
|
+
* returned to the caller, so it may have been closed (or the service
|
|
259
|
+
* destroyed) while the import was in flight — both skip the actual open.
|
|
260
|
+
*/
|
|
261
|
+
private renderWhenReady;
|
|
262
|
+
private loadRenderer;
|
|
190
263
|
private registerOpen;
|
|
191
264
|
private unregister;
|
|
192
265
|
private getAfterAllClosedSource;
|
|
193
266
|
private resolveConfig;
|
|
194
|
-
private resolveScrollStrategy;
|
|
195
267
|
static ɵfac: i0.ɵɵFactoryDeclaration<TwDialog, never>;
|
|
196
268
|
static ɵprov: i0.ɵɵInjectableDeclaration<TwDialog>;
|
|
197
269
|
}
|
|
@@ -233,7 +305,6 @@ declare class DialogIconDirective {
|
|
|
233
305
|
declare class DialogTitleDirective implements OnInit, OnDestroy {
|
|
234
306
|
private readonly generatedId;
|
|
235
307
|
private readonly dialogRef;
|
|
236
|
-
private readonly container;
|
|
237
308
|
/** Custom id for the title element. Defaults to a generated unique id. */
|
|
238
309
|
readonly id: i0.InputSignal<string>;
|
|
239
310
|
ngOnInit(): void;
|
|
@@ -254,7 +325,6 @@ declare class DialogSubtitleDirective {
|
|
|
254
325
|
declare class DialogDescriptionDirective implements OnInit, OnDestroy {
|
|
255
326
|
private readonly generatedId;
|
|
256
327
|
private readonly dialogRef;
|
|
257
|
-
private readonly container;
|
|
258
328
|
/** Custom id for the description element. Defaults to a generated unique id. */
|
|
259
329
|
readonly id: i0.InputSignal<string>;
|
|
260
330
|
ngOnInit(): void;
|
|
@@ -289,7 +359,7 @@ declare class DialogActionsDirective {
|
|
|
289
359
|
* `[twDialogClose]` value to pass a result to `afterClosed()` subscribers.
|
|
290
360
|
*/
|
|
291
361
|
declare class DialogCloseDirective {
|
|
292
|
-
/** Value passed to `afterClosed()` when the button is clicked. */
|
|
362
|
+
/** Value passed to `afterClosed()` when the button is clicked. Defaults to `undefined`. */
|
|
293
363
|
readonly twDialogClose: i0.InputSignal<unknown>;
|
|
294
364
|
/** Native button `type`. Defaults to `'button'` to avoid accidental form submission. */
|
|
295
365
|
readonly type: i0.InputSignal<"button" | "submit" | "reset">;
|