@wildmason/aegis 2.1.0 → 2.2.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/CHANGELOG.md +301 -1
- package/dist/fesm2022/wildmason-aegis.mjs +589 -40
- package/dist/fesm2022/wildmason-aegis.mjs.map +1 -1
- package/dist/types/wildmason-aegis.d.ts +371 -24
- package/inputs.css +85 -6
- package/package.json +6 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
-
import { ElementRef, AfterViewInit, TemplateRef, OnDestroy } from '@angular/core';
|
|
2
|
+
import { ElementRef, AfterViewInit, TemplateRef, Signal, OnDestroy } from '@angular/core';
|
|
3
3
|
import { ScrollStrategy, OverlayRef, ConnectedPosition } from '@angular/cdk/overlay';
|
|
4
4
|
import { ControlValueAccessor } from '@angular/forms';
|
|
5
5
|
import * as rxjs from 'rxjs';
|
|
@@ -9,7 +9,16 @@ import * as rxjs from 'rxjs';
|
|
|
9
9
|
*
|
|
10
10
|
* Owns the fixed backdrop, centering, keyboard/pointer dismissal AND the focus trap,
|
|
11
11
|
* so individual modal components don't need to repeat this logic or add their own
|
|
12
|
-
* HostListeners.
|
|
12
|
+
* HostListeners. The consumer supplies the whole panel: its surface, size, header
|
|
13
|
+
* and close control.
|
|
14
|
+
*
|
|
15
|
+
* ## wm-modal or wm-dialog
|
|
16
|
+
*
|
|
17
|
+
* Reach for `wm-dialog` first. It is a complete dialog — header, title wired to
|
|
18
|
+
* `aria-labelledby`, close button, padded scrolling body — and it is not limited to
|
|
19
|
+
* its `size` presets: `--wm-dialog-width` sets any width (Helm uses up to 960px).
|
|
20
|
+
* Use `wm-modal` when that chrome is wrong for the surface: a two-pane browser, a
|
|
21
|
+
* command palette, a panel with its own toolbar or its own scroll regions.
|
|
13
22
|
*
|
|
14
23
|
* ## Focus is trapped here, and it has to be
|
|
15
24
|
*
|
|
@@ -28,8 +37,9 @@ import * as rxjs from 'rxjs';
|
|
|
28
37
|
*
|
|
29
38
|
* Usage:
|
|
30
39
|
* <wm-modal [visible]="visible()" (dismiss)="close()">
|
|
31
|
-
* <div class="
|
|
32
|
-
*
|
|
40
|
+
* <div class="panel" role="dialog" aria-modal="true" aria-labelledby="panel-title">
|
|
41
|
+
* <h2 id="panel-title">Browse snapshot</h2>
|
|
42
|
+
* <!-- modal panel content, including a visible close control -->
|
|
33
43
|
* </div>
|
|
34
44
|
* </wm-modal>
|
|
35
45
|
*
|
|
@@ -38,6 +48,11 @@ import * as rxjs from 'rxjs';
|
|
|
38
48
|
*
|
|
39
49
|
* The projected content is wrapped in a stop-propagation container so clicks inside
|
|
40
50
|
* the panel do not bubble up to the backdrop and trigger a dismiss.
|
|
51
|
+
*
|
|
52
|
+
* The backdrop's layout lives in this component's stylesheet, so it needs no utility
|
|
53
|
+
* framework in the consumer. Its colour stays an inline
|
|
54
|
+
* `background: var(--wm-modal-backdrop)`, because consumers detect an open modal
|
|
55
|
+
* with `[style*="--wm-modal-backdrop"]`.
|
|
41
56
|
*/
|
|
42
57
|
declare class WmModal {
|
|
43
58
|
/** Whether the modal is currently open. */
|
|
@@ -46,8 +61,8 @@ declare class WmModal {
|
|
|
46
61
|
dismiss: _angular_core.OutputEmitterRef<void>;
|
|
47
62
|
/**
|
|
48
63
|
* Vertical alignment of the panel within the backdrop.
|
|
49
|
-
* - 'center' (default): panel is
|
|
50
|
-
* - 'top': panel
|
|
64
|
+
* - 'center' (default): panel is centered on both axes
|
|
65
|
+
* - 'top': panel sits 5rem below the top edge, for search/command overlays
|
|
51
66
|
*/
|
|
52
67
|
align: _angular_core.InputSignal<"center" | "top">;
|
|
53
68
|
onEscape(): void;
|
|
@@ -74,21 +89,36 @@ type DialogSize = 'sm' | 'md' | 'lg';
|
|
|
74
89
|
* </div>
|
|
75
90
|
* </wm-dialog>
|
|
76
91
|
*
|
|
92
|
+
* Width:
|
|
93
|
+
* `size` picks a preset (sm 360px, md 480px, lg 640px). For any other width, set the
|
|
94
|
+
* `--wm-dialog-width` custom property on the host; it overrides every preset:
|
|
95
|
+
* <wm-dialog [(isOpen)]="open" title="Line history" style="--wm-dialog-width: 800px">
|
|
96
|
+
* Fluid values work too, e.g. `min(90vw, 48rem)`. Whatever the width, the panel is
|
|
97
|
+
* capped at `calc(100vw - 2rem)` wide and `calc(100dvh - 4rem)` tall.
|
|
98
|
+
*
|
|
99
|
+
* When the dialog chrome itself is wrong for the surface (a two-pane browser, a
|
|
100
|
+
* command palette, a panel with its own toolbar), use `wm-modal` with your own panel.
|
|
101
|
+
*
|
|
77
102
|
* Accessibility:
|
|
78
103
|
* - role="dialog" + aria-modal="true" on the panel
|
|
79
104
|
* - aria-labelledby wired to the title element (when title is set)
|
|
80
|
-
* - Focus is trapped inside the panel when open (cdkTrapFocus)
|
|
105
|
+
* - Focus is trapped inside the panel when open (cdkTrapFocus). Do not add a
|
|
106
|
+
* cdkTrapFocus of your own inside the body; it would nest a second trap.
|
|
81
107
|
* - Escape key closes the dialog
|
|
82
108
|
* - Clicking the backdrop closes the dialog
|
|
83
|
-
* - On close, focus returns to the element that
|
|
84
|
-
* (
|
|
109
|
+
* - On close, focus returns to the element that had it when the dialog opened
|
|
110
|
+
* (cdkTrapFocusAutoCapture records that element and refocuses it when the
|
|
111
|
+
* trap is destroyed)
|
|
85
112
|
*/
|
|
86
113
|
declare class WmDialog {
|
|
87
114
|
/** Two-way binding for open/closed state. */
|
|
88
115
|
isOpen: _angular_core.ModelSignal<boolean>;
|
|
89
116
|
/** Dialog heading text. When set, aria-labelledby is applied automatically. */
|
|
90
117
|
title: _angular_core.InputSignal<string>;
|
|
91
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Panel width preset. sm = 360px, md = 480px (default), lg = 640px.
|
|
120
|
+
* `--wm-dialog-width` on the host overrides every preset.
|
|
121
|
+
*/
|
|
92
122
|
size: _angular_core.InputSignal<DialogSize>;
|
|
93
123
|
close(): void;
|
|
94
124
|
onEscape(): void;
|
|
@@ -200,8 +230,14 @@ declare class WmSelect {
|
|
|
200
230
|
* backdrop, focus-trapping, and ARIA attribute management.
|
|
201
231
|
*
|
|
202
232
|
* Slots:
|
|
203
|
-
* - [trigger] — the anchor element
|
|
204
|
-
*
|
|
233
|
+
* - [trigger] — the anchor element. Put the attribute on the focusable
|
|
234
|
+
* element itself, never on a wrapper or on a component host
|
|
235
|
+
* such as <wm-button>: the ARIA below goes to the element
|
|
236
|
+
* that carries it. For an Aegis-styled trigger, use
|
|
237
|
+
* `<button wmButton trigger>`. Nothing reads
|
|
238
|
+
* `data-popover-trigger`
|
|
239
|
+
* - [content] — the panel body (menu items, form, etc.). The panel carries
|
|
240
|
+
* the role, so the body takes no role of its own
|
|
205
241
|
*
|
|
206
242
|
* Usage:
|
|
207
243
|
* ```html
|
|
@@ -214,16 +250,26 @@ declare class WmSelect {
|
|
|
214
250
|
* align="end"
|
|
215
251
|
* >
|
|
216
252
|
* <button trigger (click)="open.set(!open())">Options</button>
|
|
217
|
-
* <div content
|
|
253
|
+
* <div content>
|
|
218
254
|
* <button role="menuitem" (click)="doThing()">Do thing</button>
|
|
219
255
|
* </div>
|
|
220
256
|
* </wm-popover>
|
|
221
257
|
* ```
|
|
222
258
|
*
|
|
223
259
|
* Accessibility:
|
|
224
|
-
* - Trigger element automatically receives aria-haspopup
|
|
225
|
-
*
|
|
260
|
+
* - Trigger element automatically receives aria-haspopup (from `hasPopup`),
|
|
261
|
+
* aria-expanded and aria-controls, plus role="button" when it has no role.
|
|
262
|
+
* They are rewritten on every change to `isOpen` or `hasPopup`, so the
|
|
263
|
+
* consumer does not bind them
|
|
264
|
+
* - Panel receives the configured role and optional accessible name. The
|
|
265
|
+
* role goes on the panel only: the host element, which wraps the trigger,
|
|
266
|
+
* never carries it, even when a consumer writes `role` as a static attribute
|
|
267
|
+
* - A `dialog` or `alertdialog` panel receives aria-modal="true" while it
|
|
268
|
+
* captures focus (see `trapFocusAutoCapture`)
|
|
226
269
|
* - Focus is trapped inside the open panel (cdkTrapFocus)
|
|
270
|
+
* - A modal panel whose content has nothing tabbable (text only, or a lone
|
|
271
|
+
* disabled button) takes focus itself (tabindex="-1") and keeps it on Tab,
|
|
272
|
+
* so focus is never left on the trigger that aria-modal makes inert
|
|
227
273
|
* - Escape key closes the panel
|
|
228
274
|
* - Backdrop click closes the panel
|
|
229
275
|
*
|
|
@@ -276,6 +322,26 @@ declare class WmPopover {
|
|
|
276
322
|
* auto-restore.
|
|
277
323
|
*/
|
|
278
324
|
readonly trapFocusAutoCapture: _angular_core.InputSignal<boolean>;
|
|
325
|
+
/**
|
|
326
|
+
* `"true"` for a `dialog` or `alertdialog` panel that captures focus, else
|
|
327
|
+
* no attribute.
|
|
328
|
+
*
|
|
329
|
+
* The panel opens over a click-catching backdrop, and a modal panel keeps
|
|
330
|
+
* focus inside itself (see `onAttach` and `onPanelKeydown`), so nothing
|
|
331
|
+
* outside it can be reached until it closes. A dialog that is modal must say
|
|
332
|
+
* so, or a screen reader keeps reading the page behind it. `aria-modal` is
|
|
333
|
+
* defined for those two roles only, so a menu or listbox panel gets no
|
|
334
|
+
* attribute. With `trapFocusAutoCapture` off, focus is meant to stay on the
|
|
335
|
+
* trigger outside the panel, and `aria-modal` would hide that focused
|
|
336
|
+
* trigger from a screen reader, so the panel is not declared modal.
|
|
337
|
+
*/
|
|
338
|
+
protected readonly ariaModal: _angular_core.Signal<string>;
|
|
339
|
+
/**
|
|
340
|
+
* `-1` on a modal panel, so the panel itself can take focus when its content
|
|
341
|
+
* has nothing tabbable. A non-modal panel stays unfocusable: a click on it
|
|
342
|
+
* must not pull focus off a typeahead trigger input.
|
|
343
|
+
*/
|
|
344
|
+
protected readonly panelTabIndex: _angular_core.Signal<number>;
|
|
279
345
|
/** Emitted when the panel should close (backdrop click, Escape key, CDK detach). */
|
|
280
346
|
readonly closed: _angular_core.OutputEmitterRef<void>;
|
|
281
347
|
private readonly renderer;
|
|
@@ -283,9 +349,26 @@ declare class WmPopover {
|
|
|
283
349
|
private readonly cdr;
|
|
284
350
|
protected readonly panelId: string;
|
|
285
351
|
protected readonly panel: _angular_core.Signal<ElementRef<HTMLElement>>;
|
|
352
|
+
private readonly trap;
|
|
286
353
|
constructor();
|
|
287
354
|
protected get positions(): ConnectedPosition[];
|
|
355
|
+
/**
|
|
356
|
+
* Runs after the focus trap's own capture, which CDK defers to the next
|
|
357
|
+
* render. A `[wmAutoFocus]` element takes focus first. Otherwise a modal
|
|
358
|
+
* panel that the trap left without focus takes focus itself. The trap finds
|
|
359
|
+
* nothing to focus when the content has no tabbable element (text only, or a
|
|
360
|
+
* lone disabled button), and it then leaves focus on the trigger, which
|
|
361
|
+
* `aria-modal` has just made inert to a screen reader.
|
|
362
|
+
*/
|
|
288
363
|
protected onAttach(): void;
|
|
364
|
+
/**
|
|
365
|
+
* Tab and Shift+Tab while focus is on a modal panel itself, not on a control
|
|
366
|
+
* inside it. Focus moves to the first or the last tabbable control. With none,
|
|
367
|
+
* focus stays on the panel. The trap's own boundary anchors cannot do this:
|
|
368
|
+
* with nothing tabbable inside, the anchor keeps focus, and the next Tab
|
|
369
|
+
* leaves the overlay for the page behind the backdrop.
|
|
370
|
+
*/
|
|
371
|
+
protected onPanelKeydown(event: KeyboardEvent): void;
|
|
289
372
|
protected onClose(): void;
|
|
290
373
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<WmPopover, never>;
|
|
291
374
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<WmPopover, "wm-popover", never, { "isOpen": { "alias": "isOpen"; "required": false; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; "role": { "alias": "role"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "hasPopup": { "alias": "hasPopup"; "required": false; "isSignal": true; }; "align": { "alias": "align"; "required": false; "isSignal": true; }; "trapFocusAutoCapture": { "alias": "trapFocusAutoCapture"; "required": false; "isSignal": true; }; }, { "closed": "closed"; }, never, ["[trigger]", "[content]"], true, never>;
|
|
@@ -327,21 +410,93 @@ declare class WmTab {
|
|
|
327
410
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<WmTab, "wm-tab", never, { "value": { "alias": "value"; "required": true; "isSignal": true; }; "unavailable": { "alias": "unavailable"; "required": false; "isSignal": true; }; "unavailableReason": { "alias": "unavailableReason"; "required": false; "isSignal": true; }; "separatorBefore": { "alias": "separatorBefore"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
328
411
|
}
|
|
329
412
|
|
|
413
|
+
/**
|
|
414
|
+
* WmTabs — an ARIA tablist of `<wm-tab>` children with a roving tab stop.
|
|
415
|
+
*
|
|
416
|
+
* Usage:
|
|
417
|
+
* <wm-tabs [activeValue]="tool()" ariaLabel="Navigator tools" (select)="tool.set($event)">
|
|
418
|
+
* <wm-tab value="graph">Graph</wm-tab>
|
|
419
|
+
* <wm-tab value="search">Search</wm-tab>
|
|
420
|
+
* </wm-tabs>
|
|
421
|
+
*
|
|
422
|
+
* Selection:
|
|
423
|
+
* - `activeValue` names the selected tab. `null`, or a value no tab carries,
|
|
424
|
+
* selects nothing: every tab reports aria-selected="false" and none paints
|
|
425
|
+
* as active. Use it when the stage shows something that is not any tab's
|
|
426
|
+
* panel, such as a document opened from a second tablist in the same row.
|
|
427
|
+
* - The tablist always keeps exactly one tab stop: the focused tab while
|
|
428
|
+
* focus is inside, otherwise the selected tab, otherwise the first tab that
|
|
429
|
+
* is not unavailable (the first tab when every tab is unavailable).
|
|
430
|
+
* - Arrow keys, Home and End move focus only. A tab is selected on click,
|
|
431
|
+
* Enter or Space, which emit `(select)`; the consumer sets `activeValue`.
|
|
432
|
+
*
|
|
433
|
+
* Accessibility:
|
|
434
|
+
* - `ariaLabel` or `ariaLabelledby` names the inner role="tablist". Name
|
|
435
|
+
* every tablist that shares a surface with another one, or assistive
|
|
436
|
+
* technology cannot tell them apart. `ariaLabelledby` wins when both are
|
|
437
|
+
* set. An `aria-label` attribute on the `<wm-tabs>` host names nothing: the
|
|
438
|
+
* host has no role, so the attribute never reaches the tablist.
|
|
439
|
+
* - Each tab is `id="wm-tab-{value}"` with `aria-controls="wm-panel-{value}"`.
|
|
440
|
+
* Give the panel that id and role="tabpanel". The ids are built from the
|
|
441
|
+
* value alone, so values must be unique across every tablist on the page.
|
|
442
|
+
*/
|
|
330
443
|
declare class WmTabs {
|
|
331
|
-
|
|
332
|
-
|
|
444
|
+
/**
|
|
445
|
+
* Value of the selected tab. `null`, or a value that matches no tab, selects
|
|
446
|
+
* nothing; the tablist still keeps one tab stop (see the class comment).
|
|
447
|
+
*/
|
|
448
|
+
readonly activeValue: _angular_core.InputSignal<string>;
|
|
449
|
+
readonly variant: _angular_core.InputSignal<"line" | "pill">;
|
|
450
|
+
/** Accessible name for the tablist. Ignored while `ariaLabelledby` is set. */
|
|
451
|
+
readonly ariaLabel: _angular_core.InputSignal<string>;
|
|
452
|
+
/**
|
|
453
|
+
* Id of a visible element that names the tablist. Prefer it over
|
|
454
|
+
* `ariaLabel` when a visible caption exists, so the accessible name matches
|
|
455
|
+
* the visible text (WCAG 2.5.3, Label in Name).
|
|
456
|
+
*/
|
|
457
|
+
readonly ariaLabelledby: _angular_core.InputSignal<string>;
|
|
333
458
|
readonly select: _angular_core.OutputEmitterRef<string>;
|
|
334
459
|
protected readonly tabs: _angular_core.Signal<readonly WmTab[]>;
|
|
335
|
-
|
|
336
|
-
|
|
460
|
+
/**
|
|
461
|
+
* Value of the tab that holds focus, or null while focus is outside the
|
|
462
|
+
* tablist. Keyed by value, not index, so a tab added or removed before it
|
|
463
|
+
* cannot move the stop onto a different tab or off the end of the list.
|
|
464
|
+
*/
|
|
465
|
+
protected readonly focusedValue: _angular_core.WritableSignal<string>;
|
|
466
|
+
/** Index of the one tab that is in the page's Tab order. */
|
|
467
|
+
protected readonly tabStop: _angular_core.Signal<number>;
|
|
468
|
+
private readonly host;
|
|
469
|
+
protected selectTab(tab: WmTab): void;
|
|
337
470
|
protected onBlur(): void;
|
|
338
471
|
protected onKeyDown(event: KeyboardEvent, container: HTMLElement): void;
|
|
339
472
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<WmTabs, never>;
|
|
340
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<WmTabs, "wm-tabs", never, { "activeValue": { "alias": "activeValue"; "required": true; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; }, { "select": "select"; }, ["tabs"], never, true, never>;
|
|
473
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<WmTabs, "wm-tabs", never, { "activeValue": { "alias": "activeValue"; "required": true; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "ariaLabelledby"; "required": false; "isSignal": true; }; }, { "select": "select"; }, ["tabs"], never, true, never>;
|
|
341
474
|
}
|
|
342
475
|
|
|
343
|
-
|
|
476
|
+
/**
|
|
477
|
+
* `dashed` is the empty slot: the place a new item goes, at the end of the
|
|
478
|
+
* list it adds to. It sets colour and the dash only; a full-width slot is a
|
|
479
|
+
* `[wmButton]` with the consumer's own width class. For any other quiet
|
|
480
|
+
* action, use `ghost`.
|
|
481
|
+
*/
|
|
482
|
+
type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'destructive' | 'flat' | 'dashed';
|
|
344
483
|
type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
484
|
+
/**
|
|
485
|
+
* WmButton — an Aegis button as an element: `<wm-button variant="ghost">`.
|
|
486
|
+
*
|
|
487
|
+
* The host wraps a real `<button>` and passes it four inputs: `disabled`,
|
|
488
|
+
* `type`, `ariaLabel` (as `aria-label`) and `btnTitle` (as `title`). Nothing
|
|
489
|
+
* else crosses. An attribute, class or directive written on `<wm-button>` stays on
|
|
490
|
+
* the host, which has no role and cannot take focus. When something must reach
|
|
491
|
+
* the element a screen reader and the keyboard use (ARIA state such as
|
|
492
|
+
* `aria-pressed` or `aria-expanded`, `cdkFocusInitial`, an `id` another element
|
|
493
|
+
* points at, a popover `trigger`, `[wmTooltip]`, a class that changes the
|
|
494
|
+
* button's own box), write a native element with `[wmButton]` instead:
|
|
495
|
+
*
|
|
496
|
+
* ```html
|
|
497
|
+
* <button wmButton variant="ghost" [attr.aria-pressed]="wrap()">Wrap</button>
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
345
500
|
declare class WmButton {
|
|
346
501
|
readonly variant: _angular_core.InputSignal<ButtonVariant>;
|
|
347
502
|
readonly size: _angular_core.InputSignal<ButtonSize>;
|
|
@@ -358,6 +513,44 @@ declare class WmButton {
|
|
|
358
513
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<WmButton, "wm-button", never, { "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "iconOnly": { "alias": "iconOnly"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "btnTitle": { "alias": "btnTitle"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
359
514
|
}
|
|
360
515
|
|
|
516
|
+
/**
|
|
517
|
+
* WmButtonDirective — the Aegis button classes on a native `<button>` or `<a>`.
|
|
518
|
+
*
|
|
519
|
+
* It renders exactly the class set `<wm-button>` puts on its inner button, but
|
|
520
|
+
* on the element the consumer writes. That element is the focusable one, so
|
|
521
|
+
* every attribute and directive on it reaches the right place with no
|
|
522
|
+
* forwarding list: ARIA state, `cdkFocusInitial`, `id`, `form`, a popover
|
|
523
|
+
* `trigger`, `[wmTooltip]`, test ids and consumer classes.
|
|
524
|
+
*
|
|
525
|
+
* Use `<wm-button>` by default. Use this when one of those has to land on the
|
|
526
|
+
* button itself (see `WmButton` for what the component forwards).
|
|
527
|
+
*
|
|
528
|
+
* - `variant`, `size` and `iconOnly` mean what they mean on `<wm-button>`.
|
|
529
|
+
* - Classes the consumer writes, static or bound, are kept.
|
|
530
|
+
* - A `<button>` with no `type` gets `type="button"`, the `<wm-button>`
|
|
531
|
+
* default, so it does not submit a surrounding form. A written or bound
|
|
532
|
+
* `type` wins. An `<a>` is left alone.
|
|
533
|
+
* - Everything else is native: write `disabled`, `aria-label` and `title`
|
|
534
|
+
* directly. An `<a>` cannot be disabled.
|
|
535
|
+
*
|
|
536
|
+
* @example
|
|
537
|
+
* <button wmButton variant="ghost" size="sm" [attr.aria-pressed]="wrap()" (click)="toggleWrap()">
|
|
538
|
+
* Wrap lines
|
|
539
|
+
* </button>
|
|
540
|
+
* <button wmButton variant="secondary" cdkFocusInitial (click)="cancel()">Keep editing</button>
|
|
541
|
+
* <a wmButton variant="ghost" href="/back">Back</a>
|
|
542
|
+
*/
|
|
543
|
+
declare class WmButtonDirective {
|
|
544
|
+
readonly variant: _angular_core.InputSignal<ButtonVariant>;
|
|
545
|
+
readonly size: _angular_core.InputSignal<ButtonSize>;
|
|
546
|
+
/** Makes the button square. An icon-only button still needs an `aria-label`. */
|
|
547
|
+
readonly iconOnly: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
548
|
+
protected readonly hostClass: _angular_core.Signal<string>;
|
|
549
|
+
constructor();
|
|
550
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<WmButtonDirective, never>;
|
|
551
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<WmButtonDirective, "button[wmButton], a[wmButton]", never, { "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "iconOnly": { "alias": "iconOnly"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
552
|
+
}
|
|
553
|
+
|
|
361
554
|
/**
|
|
362
555
|
* WmCheckbox — Boolean selection control with optional indeterminate state.
|
|
363
556
|
*
|
|
@@ -541,7 +734,7 @@ interface Segment {
|
|
|
541
734
|
*
|
|
542
735
|
* When NOT to use:
|
|
543
736
|
* - An exact number the user knows before they start typing it → <wm-number-input>
|
|
544
|
-
* - Fewer than about five discrete choices → <wm-
|
|
737
|
+
* - Fewer than about five discrete choices → <wm-toggle-group> or <wm-select>
|
|
545
738
|
* - An unbounded value — a slider has to have a min and a max
|
|
546
739
|
*
|
|
547
740
|
* Value pipeline: every value, whether it arrives from a two-way binding, a
|
|
@@ -654,6 +847,160 @@ declare class WmSlider implements ControlValueAccessor {
|
|
|
654
847
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<WmSlider, "wm-slider", never, { "value": { "alias": "value"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "step": { "alias": "step"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "showValue": { "alias": "showValue"; "required": false; "isSignal": true; }; "formatValue": { "alias": "formatValue"; "required": false; "isSignal": true; }; "track": { "alias": "track"; "required": false; "isSignal": true; }; "ticks": { "alias": "ticks"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; }, never, never, true, never>;
|
|
655
848
|
}
|
|
656
849
|
|
|
850
|
+
/** How the group is drawn. See `WmToggleGroup.appearance`. */
|
|
851
|
+
type WmToggleGroupAppearance = 'segmented' | 'chip';
|
|
852
|
+
/** Control height: `sm` is 24px, `md` is 28px. */
|
|
853
|
+
type WmToggleGroupSize = 'sm' | 'md';
|
|
854
|
+
/**
|
|
855
|
+
* WmToggleGroupItem — one choice in a `<wm-toggle-group>`.
|
|
856
|
+
*
|
|
857
|
+
* The element itself is the `role="radio"`, so anything written on it lands
|
|
858
|
+
* on the control a screen reader and the keyboard use: `aria-label` for an
|
|
859
|
+
* icon-only item, `[wmTooltip]`, `data-testid`, a consumer class.
|
|
860
|
+
*/
|
|
861
|
+
declare class WmToggleGroupItem {
|
|
862
|
+
/**
|
|
863
|
+
* The value the group takes, and emits, when this item is checked. Give
|
|
864
|
+
* every item one.
|
|
865
|
+
*
|
|
866
|
+
* Not `input.required`: the group reads every item's value to place the tab
|
|
867
|
+
* stop, and an item rendered by `@for` has its host bindings run before the
|
|
868
|
+
* next item's inputs are set. A required input throws NG0950 on that read;
|
|
869
|
+
* this one reads `undefined`, the group places the stop without it, and the
|
|
870
|
+
* binding settles when the next item's value arrives in the same pass.
|
|
871
|
+
*/
|
|
872
|
+
readonly value: _angular_core.InputSignal<unknown>;
|
|
873
|
+
/** Takes this item out of the focus order and out of selection. */
|
|
874
|
+
readonly disabled: _angular_core.InputSignal<boolean>;
|
|
875
|
+
protected readonly group: WmToggleGroup<any>;
|
|
876
|
+
/** @internal The item's own element, which carries role="radio". */
|
|
877
|
+
readonly element: HTMLElement;
|
|
878
|
+
protected readonly checked: Signal<boolean>;
|
|
879
|
+
/** @internal Disabled by its own input or by the group. */
|
|
880
|
+
readonly isDisabled: Signal<boolean>;
|
|
881
|
+
/**
|
|
882
|
+
* 0 for the one tab stop, -1 for the rest. A disabled item gets no tabindex
|
|
883
|
+
* at all: -1 would still let a pointer press focus it.
|
|
884
|
+
*/
|
|
885
|
+
protected readonly tabIndex: Signal<0 | -1 | null>;
|
|
886
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<WmToggleGroupItem, never>;
|
|
887
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<WmToggleGroupItem, "wm-toggle-group-item", never, { "value": { "alias": "value"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* WmToggleGroup — a single-select choice among a few options, drawn as joined
|
|
891
|
+
* segments or as separate chips.
|
|
892
|
+
*
|
|
893
|
+
* Usage:
|
|
894
|
+
* <wm-toggle-group [(value)]="strategy" ariaLabel="Pull strategy">
|
|
895
|
+
* <wm-toggle-group-item value="merge">Merge</wm-toggle-group-item>
|
|
896
|
+
* <wm-toggle-group-item value="rebase">Rebase</wm-toggle-group-item>
|
|
897
|
+
* </wm-toggle-group>
|
|
898
|
+
*
|
|
899
|
+
* When to use:
|
|
900
|
+
* - Two to about five mutually exclusive options that should all stay visible:
|
|
901
|
+
* a setting (pull strategy, tab size, config scope), a view mode, a verdict
|
|
902
|
+
* - A single-select filter row → `appearance="chip"`
|
|
903
|
+
*
|
|
904
|
+
* When NOT to use:
|
|
905
|
+
* - Choosing which panel shows → `<wm-tabs>`. A tab controls a panel; a toggle
|
|
906
|
+
* group sets a value
|
|
907
|
+
* - An on/off setting → `<wm-toggle>` or a checkbox
|
|
908
|
+
* - Several options that can be on together → checkboxes
|
|
909
|
+
* - More options than fit on one line → `<wm-select>`
|
|
910
|
+
*
|
|
911
|
+
* Selection:
|
|
912
|
+
* - `value` names the checked item. `null`, or a value no item carries,
|
|
913
|
+
* checks nothing; the group still keeps one tab stop.
|
|
914
|
+
* - `(valueChange)` fires once per user choice and only then: never for a
|
|
915
|
+
* value written from outside, never for the item that is already checked,
|
|
916
|
+
* and never with null. A two-way binding to a signal that cannot hold null
|
|
917
|
+
* therefore type-checks.
|
|
918
|
+
* - Items compare by `Object.is`, so a value keeps its type: `[value]="4"` on
|
|
919
|
+
* an item emits the number 4, not the string "4".
|
|
920
|
+
*
|
|
921
|
+
* Keyboard (the WAI-ARIA APG radio group):
|
|
922
|
+
* - Tab enters the group on one stop: the focused item while focus is inside,
|
|
923
|
+
* otherwise the checked item, otherwise the first item that is not disabled.
|
|
924
|
+
* - Arrow keys move focus AND check, wrapping at both ends and stepping over
|
|
925
|
+
* disabled items. Left and Right swap in a right-to-left layout; Up and Down
|
|
926
|
+
* follow document order. `Home` and `End` go to the first and last items.
|
|
927
|
+
* - `Space` checks the focused item. `Enter` does not, as on a native radio.
|
|
928
|
+
*
|
|
929
|
+
* Accessibility:
|
|
930
|
+
* - The `<wm-toggle-group>` element is the `role="radiogroup"` and each item
|
|
931
|
+
* is a `role="radio"` with `aria-checked`. Name the group with `ariaLabel`,
|
|
932
|
+
* or `ariaLabelledby` when a visible caption exists; `ariaLabelledby` wins.
|
|
933
|
+
* An `aria-label` written straight on the element also works, because the
|
|
934
|
+
* element carries the role.
|
|
935
|
+
* - An icon-only item needs its own `aria-label`, written on the item.
|
|
936
|
+
* - A disabled item keeps `aria-disabled="true"` and leaves the focus order.
|
|
937
|
+
* A disabled group does the same for every item.
|
|
938
|
+
*
|
|
939
|
+
* Form integration: a ControlValueAccessor, so `formControlName`,
|
|
940
|
+
* `[formControl]` and `[(ngModel)]` all work. The control is marked touched
|
|
941
|
+
* when focus leaves the group.
|
|
942
|
+
*/
|
|
943
|
+
declare class WmToggleGroup<T = unknown> implements ControlValueAccessor {
|
|
944
|
+
/** Value of the checked item. `null`, or a value no item carries, checks nothing. */
|
|
945
|
+
readonly value: _angular_core.InputSignal<T>;
|
|
946
|
+
/** The value of the item the user checked. Never null; see the class comment. */
|
|
947
|
+
readonly valueChange: _angular_core.OutputEmitterRef<T>;
|
|
948
|
+
/** Accessible name for the radiogroup. Ignored while `ariaLabelledby` is set. */
|
|
949
|
+
readonly ariaLabel: _angular_core.InputSignal<string>;
|
|
950
|
+
/**
|
|
951
|
+
* Id of a visible element that names the group. Prefer it over `ariaLabel`
|
|
952
|
+
* when a visible caption exists, so the accessible name matches the visible
|
|
953
|
+
* text (WCAG 2.5.3, Label in Name).
|
|
954
|
+
*/
|
|
955
|
+
readonly ariaLabelledby: _angular_core.InputSignal<string>;
|
|
956
|
+
/**
|
|
957
|
+
* `segmented` joins the items in one sunken track, for a setting or a view
|
|
958
|
+
* mode. `chip` spaces them as separate rounded chips that wrap, for a filter
|
|
959
|
+
* row or a verdict.
|
|
960
|
+
*/
|
|
961
|
+
readonly appearance: _angular_core.InputSignal<WmToggleGroupAppearance>;
|
|
962
|
+
readonly size: _angular_core.InputSignal<WmToggleGroupSize>;
|
|
963
|
+
/** Disables every item. Reactive forms set this independently. */
|
|
964
|
+
readonly disabled: _angular_core.InputSignal<boolean>;
|
|
965
|
+
private readonly items;
|
|
966
|
+
private readonly host;
|
|
967
|
+
private readonly staticLabel;
|
|
968
|
+
private readonly staticLabelledby;
|
|
969
|
+
protected readonly accessibleLabelledby: Signal<string>;
|
|
970
|
+
protected readonly accessibleLabel: Signal<string>;
|
|
971
|
+
/** The checked value. Follows `value`, and moves at once on a user choice or a form write. */
|
|
972
|
+
private readonly checkedValue;
|
|
973
|
+
/** Set by reactive forms through setDisabledState, independent of the input. */
|
|
974
|
+
private readonly formDisabled;
|
|
975
|
+
/** @internal */
|
|
976
|
+
readonly isDisabled: Signal<boolean>;
|
|
977
|
+
/**
|
|
978
|
+
* The item that holds focus, or null while focus is outside the group. Kept
|
|
979
|
+
* as the item itself rather than an index, so an item added or removed
|
|
980
|
+
* before it cannot move the stop onto another item.
|
|
981
|
+
*/
|
|
982
|
+
private readonly focusedItem;
|
|
983
|
+
/** @internal The one item in the page's Tab order, or null when none can take focus. */
|
|
984
|
+
readonly tabStop: Signal<WmToggleGroupItem | null>;
|
|
985
|
+
private onChange;
|
|
986
|
+
private onTouched;
|
|
987
|
+
/** @internal */
|
|
988
|
+
isChecked(item: WmToggleGroupItem): boolean;
|
|
989
|
+
/** @internal Checks `item` on a user action. */
|
|
990
|
+
select(item: WmToggleGroupItem): void;
|
|
991
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
992
|
+
protected onFocusIn(event: FocusEvent): void;
|
|
993
|
+
protected onFocusOut(event: FocusEvent): void;
|
|
994
|
+
/** The next item in `direction` that is not disabled, wrapping at both ends. */
|
|
995
|
+
private step;
|
|
996
|
+
writeValue(value: T | null): void;
|
|
997
|
+
registerOnChange(fn: (value: T) => void): void;
|
|
998
|
+
registerOnTouched(fn: () => void): void;
|
|
999
|
+
setDisabledState(isDisabled: boolean): void;
|
|
1000
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<WmToggleGroup<any>, never>;
|
|
1001
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<WmToggleGroup<any>, "wm-toggle-group", never, { "value": { "alias": "value"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "ariaLabelledby"; "required": false; "isSignal": true; }; "appearance": { "alias": "appearance"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "valueChange": "valueChange"; }, ["items"], ["*"], true, never>;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
657
1004
|
/**
|
|
658
1005
|
* GhostField — transparent-until-hover wrapper for inline-editable fields.
|
|
659
1006
|
*
|
|
@@ -1262,5 +1609,5 @@ declare class WmRichTooltip {
|
|
|
1262
1609
|
*/
|
|
1263
1610
|
declare function onViewportChange(handler: () => void): () => void;
|
|
1264
1611
|
|
|
1265
|
-
export { Checkbox, GhostField, NumberInput, PageHeader, Toggle, WmAnchoredScrollStrategy, WmAutoFocus, WmButton, WmCombobox, WmDialog, WmModal, WmPopover, WmRichTooltip, WmRichTooltipContent, WmRichTooltipTrigger, WmSelect, WmSlider, WmTab, WmTabs, WmToastContainer, WmToastService, WmTooltip, onViewportChange };
|
|
1266
|
-
export type { ButtonSize, ButtonVariant, ComboboxOption, DialogSize, SelectOption, Toast, ToastType, WmSliderTick, WmSliderTickFn, WmSliderTrack, WmTooltipPosition, WmTooltipRelation };
|
|
1612
|
+
export { Checkbox, GhostField, NumberInput, PageHeader, Toggle, WmAnchoredScrollStrategy, WmAutoFocus, WmButton, WmButtonDirective, WmCombobox, WmDialog, WmModal, WmPopover, WmRichTooltip, WmRichTooltipContent, WmRichTooltipTrigger, WmSelect, WmSlider, WmTab, WmTabs, WmToastContainer, WmToastService, WmToggleGroup, WmToggleGroupItem, WmTooltip, onViewportChange };
|
|
1613
|
+
export type { ButtonSize, ButtonVariant, ComboboxOption, DialogSize, SelectOption, Toast, ToastType, WmSliderTick, WmSliderTickFn, WmSliderTrack, WmToggleGroupAppearance, WmToggleGroupSize, WmTooltipPosition, WmTooltipRelation };
|