@wildmason/aegis 2.0.0 → 2.1.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.
|
@@ -482,6 +482,178 @@ declare class Toggle {
|
|
|
482
482
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<Toggle, "wm-toggle", never, { "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; }, never, never, true, never>;
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
+
/** How the track itself is drawn. See the `track` input. */
|
|
486
|
+
type WmSliderTrack = 'rail' | 'segmented';
|
|
487
|
+
/** A stop on the grid. A tick outside min..max is not drawn. */
|
|
488
|
+
interface WmSliderTick {
|
|
489
|
+
value: number;
|
|
490
|
+
/** Optional caption under the tick. Ticks without one draw as a bare mark. */
|
|
491
|
+
label?: string;
|
|
492
|
+
/**
|
|
493
|
+
* Visual weight. `major` is the default and draws a full mark; `minor` draws a
|
|
494
|
+
* shorter, lighter one. Two levels are what let a dense range carry a readable
|
|
495
|
+
* grid — a labelled major every 10 with a minor every 5 — without the grid
|
|
496
|
+
* having to match the step.
|
|
497
|
+
*/
|
|
498
|
+
level?: 'major' | 'minor';
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Computes the grid from the live range. Use it when the stops are not a fixed
|
|
502
|
+
* list and not a constant interval — a logarithmic scale, or a grid that changes
|
|
503
|
+
* with the bounds.
|
|
504
|
+
*/
|
|
505
|
+
type WmSliderTickFn = (ctx: {
|
|
506
|
+
min: number;
|
|
507
|
+
max: number;
|
|
508
|
+
step: number;
|
|
509
|
+
}) => WmSliderTick[];
|
|
510
|
+
/** One tick after it has been measured against the current range. */
|
|
511
|
+
interface ResolvedTick extends WmSliderTick {
|
|
512
|
+
level: 'major' | 'minor';
|
|
513
|
+
fraction: number;
|
|
514
|
+
left: string;
|
|
515
|
+
passed: boolean;
|
|
516
|
+
}
|
|
517
|
+
/** One block of a segmented track, bounded by two adjacent grid stops. */
|
|
518
|
+
interface Segment {
|
|
519
|
+
from: number;
|
|
520
|
+
to: number;
|
|
521
|
+
span: number;
|
|
522
|
+
/** How far the value has travelled into this block, 0..1. */
|
|
523
|
+
fill: number;
|
|
524
|
+
passed: boolean;
|
|
525
|
+
current: boolean;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* WmSlider — Continuous value selection along a bounded range.
|
|
529
|
+
*
|
|
530
|
+
* Built on a native `<input type="range">`. The native control is the whole
|
|
531
|
+
* interaction: pointer drag, touch, arrow keys, Home/End, Page Up/Page Down,
|
|
532
|
+
* RTL mirroring and the implicit `role="slider"` with `aria-valuenow` all come
|
|
533
|
+
* from the browser rather than from hand-written handlers. Aegis styles the
|
|
534
|
+
* track and thumb through the range pseudo-elements, so there is no invisible
|
|
535
|
+
* overlay input and no drag maths to get wrong.
|
|
536
|
+
*
|
|
537
|
+
* When to use:
|
|
538
|
+
* - A bounded value where the approximate position matters more than the exact
|
|
539
|
+
* number (volume, opacity, zoom, a brightness or threshold setting)
|
|
540
|
+
* - A value the user wants to sweep through and preview as it changes
|
|
541
|
+
*
|
|
542
|
+
* When NOT to use:
|
|
543
|
+
* - An exact number the user knows before they start typing it → <wm-number-input>
|
|
544
|
+
* - Fewer than about five discrete choices → <wm-select> or a pill tab group
|
|
545
|
+
* - An unbounded value — a slider has to have a min and a max
|
|
546
|
+
*
|
|
547
|
+
* Value pipeline: every value, whether it arrives from a two-way binding, a
|
|
548
|
+
* form, or a drag, is clamped into min..max and snapped onto the step grid
|
|
549
|
+
* measured FROM MIN. The snapped value is written back, so the binding, the
|
|
550
|
+
* form control and the thumb never disagree.
|
|
551
|
+
*
|
|
552
|
+
* Accessibility:
|
|
553
|
+
* - The native input is the focusable control and carries the slider role.
|
|
554
|
+
* - `ariaLabel` is required unless visible surrounding text names the control.
|
|
555
|
+
* - `formatValue` also drives `aria-valuetext`, so a screen reader announces
|
|
556
|
+
* "40 percent" rather than "40" when the raw number means nothing alone.
|
|
557
|
+
* - Ticks and the value readout are decoration; the native value is the truth.
|
|
558
|
+
*
|
|
559
|
+
* Form integration:
|
|
560
|
+
* <!-- Template-driven -->
|
|
561
|
+
* <wm-slider [(ngModel)]="volume" [min]="0" [max]="100" />
|
|
562
|
+
*
|
|
563
|
+
* <!-- Reactive -->
|
|
564
|
+
* <wm-slider formControlName="opacity" [min]="0" [max]="1" [step]="0.05" />
|
|
565
|
+
*
|
|
566
|
+
* <!-- Two-way signal binding, no forms -->
|
|
567
|
+
* <wm-slider [(value)]="volume" ariaLabel="Volume" />
|
|
568
|
+
*/
|
|
569
|
+
declare class WmSlider implements ControlValueAccessor {
|
|
570
|
+
/** Two-way bindable value. Always reads back clamped and snapped to the step grid. */
|
|
571
|
+
readonly value: _angular_core.ModelSignal<number>;
|
|
572
|
+
/** Lower bound, inclusive. */
|
|
573
|
+
readonly min: _angular_core.InputSignal<number>;
|
|
574
|
+
/** Upper bound, inclusive. Values never exceed it, even when it is off the step grid. */
|
|
575
|
+
readonly max: _angular_core.InputSignal<number>;
|
|
576
|
+
/** Grid spacing, measured from `min`. Use 0 for a continuous slider. */
|
|
577
|
+
readonly step: _angular_core.InputSignal<number>;
|
|
578
|
+
/** Disables the control from the template. Reactive forms set this independently. */
|
|
579
|
+
readonly disabled: _angular_core.InputSignal<boolean>;
|
|
580
|
+
/** Accessible name. Required unless visible text already names the control. */
|
|
581
|
+
readonly ariaLabel: _angular_core.InputSignal<string>;
|
|
582
|
+
/** Shows a live readout beside the rail. */
|
|
583
|
+
readonly showValue: _angular_core.InputSignal<boolean>;
|
|
584
|
+
/**
|
|
585
|
+
* Renders the value for humans. Also sets `aria-valuetext`, so pass one
|
|
586
|
+
* whenever the bare number would not be understood on its own.
|
|
587
|
+
*/
|
|
588
|
+
readonly formatValue: _angular_core.InputSignal<(value: number) => string>;
|
|
589
|
+
/**
|
|
590
|
+
* How the track is drawn. `rail` is one continuous bar. `segmented` breaks it
|
|
591
|
+
* into blocks bounded by the grid stops, and the block holding the value fills
|
|
592
|
+
* partially — so a segmented track does not have to mean one block per step,
|
|
593
|
+
* and survives a dense range that one-block-per-step cannot.
|
|
594
|
+
*/
|
|
595
|
+
readonly track: _angular_core.InputSignal<WmSliderTrack>;
|
|
596
|
+
/**
|
|
597
|
+
* The grid, in one of three shapes:
|
|
598
|
+
* - a **number** — a stop every N, measured from `min`
|
|
599
|
+
* - an **array** of {@link WmSliderTick} — explicit stops, with labels and levels
|
|
600
|
+
* - a **{@link WmSliderTickFn}** — computed from the live range
|
|
601
|
+
*
|
|
602
|
+
* Whatever the shape, the result is clamped to the range, sorted, and
|
|
603
|
+
* de-duplicated. The same resolved grid draws the marks AND bounds the blocks
|
|
604
|
+
* of a segmented track, so the two renderings cannot disagree.
|
|
605
|
+
*
|
|
606
|
+
* The grid is deliberately independent of `step`: a 0–100 slider stepping by 1
|
|
607
|
+
* carries 101 reachable values and should still draw about 11 marks.
|
|
608
|
+
*/
|
|
609
|
+
readonly ticks: _angular_core.InputSignal<number | WmSliderTickFn | WmSliderTick[]>;
|
|
610
|
+
/** Set by reactive forms through setDisabledState, independent of the input. */
|
|
611
|
+
private readonly formDisabled;
|
|
612
|
+
protected readonly isDisabled: _angular_core.Signal<boolean>;
|
|
613
|
+
/** Position of the thumb across the span, 0..1, as a CSS-ready string. */
|
|
614
|
+
protected readonly fraction: _angular_core.Signal<string>;
|
|
615
|
+
protected readonly displayValue: _angular_core.Signal<string>;
|
|
616
|
+
/**
|
|
617
|
+
* Every string the readout can show at a grid stop, de-duplicated.
|
|
618
|
+
*
|
|
619
|
+
* The shell is `1fr auto`, so a readout column sized by the CURRENT value
|
|
620
|
+
* takes its width from the rail and gives it back on the next value — the bar
|
|
621
|
+
* moves while you drag it. Rendering these hidden in the readout's own grid
|
|
622
|
+
* cell makes the browser reserve the widest of them once, with no measuring.
|
|
623
|
+
*
|
|
624
|
+
* Only LABELLED stops contribute. An unlabelled stop is a position rather
|
|
625
|
+
* than a word, and a numeric readout is already bounded by tabular numerals
|
|
626
|
+
* and the two endpoints — so a 101-mark grid reserves two slots, not 101.
|
|
627
|
+
*/
|
|
628
|
+
protected readonly valueCandidates: _angular_core.Signal<string[]>;
|
|
629
|
+
/** Null unless a formatter is set — a valuetext echoing valuenow is noise. */
|
|
630
|
+
protected readonly valueText: _angular_core.Signal<string>;
|
|
631
|
+
/** The declared grid, before it is measured against the range. */
|
|
632
|
+
private readonly declaredTicks;
|
|
633
|
+
protected readonly resolvedTicks: _angular_core.Signal<ResolvedTick[]>;
|
|
634
|
+
/**
|
|
635
|
+
* Blocks of a segmented track. The boundaries are the grid stops plus the two
|
|
636
|
+
* ends of the range, so the blocks are the intervals BETWEEN stops — which is
|
|
637
|
+
* what a block can honestly represent. Each one is sized by its own span, so
|
|
638
|
+
* an uneven grid produces uneven blocks rather than lying about the scale.
|
|
639
|
+
*/
|
|
640
|
+
protected readonly segments: _angular_core.Signal<Segment[]>;
|
|
641
|
+
protected readonly hasTickLabels: _angular_core.Signal<boolean>;
|
|
642
|
+
private onChangeFn;
|
|
643
|
+
protected onTouchedFn: () => void;
|
|
644
|
+
constructor();
|
|
645
|
+
writeValue(value: number | null): void;
|
|
646
|
+
registerOnChange(fn: (value: number) => void): void;
|
|
647
|
+
registerOnTouched(fn: () => void): void;
|
|
648
|
+
setDisabledState(isDisabled: boolean): void;
|
|
649
|
+
protected onRangeInput(event: Event): void;
|
|
650
|
+
/** Clamps into min..max, then snaps onto the step grid measured from min. */
|
|
651
|
+
private resolve;
|
|
652
|
+
private fractionOf;
|
|
653
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<WmSlider, never>;
|
|
654
|
+
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
|
+
}
|
|
656
|
+
|
|
485
657
|
/**
|
|
486
658
|
* GhostField — transparent-until-hover wrapper for inline-editable fields.
|
|
487
659
|
*
|
|
@@ -1090,5 +1262,5 @@ declare class WmRichTooltip {
|
|
|
1090
1262
|
*/
|
|
1091
1263
|
declare function onViewportChange(handler: () => void): () => void;
|
|
1092
1264
|
|
|
1093
|
-
export { Checkbox, GhostField, NumberInput, PageHeader, Toggle, WmAnchoredScrollStrategy, WmAutoFocus, WmButton, WmCombobox, WmDialog, WmModal, WmPopover, WmRichTooltip, WmRichTooltipContent, WmRichTooltipTrigger, WmSelect, WmTab, WmTabs, WmToastContainer, WmToastService, WmTooltip, onViewportChange };
|
|
1094
|
-
export type { ButtonSize, ButtonVariant, ComboboxOption, DialogSize, SelectOption, Toast, ToastType, WmTooltipPosition, WmTooltipRelation };
|
|
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 };
|
package/package.json
CHANGED