ngwr 16.7.1 → 16.9.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/charts/donut-chart/styles/_index.scss +9 -3
- package/charts/meter-group/styles/_index.scss +8 -1
- package/charts/sparkline/styles/_index.scss +6 -3
- package/command-palette/styles/_index.scss +10 -0
- package/descriptions/styles/_index.scss +91 -0
- package/fesm2022/ngwr-anchor.mjs +48 -10
- package/fesm2022/ngwr-anchor.mjs.map +1 -1
- package/fesm2022/ngwr-carousel.mjs +3 -2
- package/fesm2022/ngwr-carousel.mjs.map +1 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +3 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
- package/fesm2022/ngwr-charts-core.mjs +17 -0
- package/fesm2022/ngwr-charts-core.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart-testing.mjs +27 -0
- package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart.mjs +54 -6
- package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group-testing.mjs +27 -0
- package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group.mjs +54 -6
- package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
- package/fesm2022/ngwr-charts-sparkline-testing.mjs +27 -0
- package/fesm2022/ngwr-charts-sparkline-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-sparkline.mjs +45 -4
- package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
- package/fesm2022/ngwr-checkbox.mjs +38 -3
- package/fesm2022/ngwr-checkbox.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +4 -3
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-command-palette.mjs +39 -19
- package/fesm2022/ngwr-command-palette.mjs.map +1 -1
- package/fesm2022/ngwr-compare.mjs +4 -0
- package/fesm2022/ngwr-compare.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +7 -2
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-cookie.mjs +6 -3
- package/fesm2022/ngwr-cookie.mjs.map +1 -1
- package/fesm2022/ngwr-date-stamp-testing.mjs +3 -0
- package/fesm2022/ngwr-date-stamp-testing.mjs.map +1 -1
- package/fesm2022/ngwr-date-stamp.mjs +81 -4
- package/fesm2022/ngwr-date-stamp.mjs.map +1 -1
- package/fesm2022/ngwr-date.mjs +16 -2
- package/fesm2022/ngwr-date.mjs.map +1 -1
- package/fesm2022/ngwr-density.mjs +4 -3
- package/fesm2022/ngwr-density.mjs.map +1 -1
- package/fesm2022/ngwr-descriptions.mjs +77 -20
- package/fesm2022/ngwr-descriptions.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +10 -7
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +12 -0
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +14 -8
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +1 -0
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload.mjs +4 -5
- package/fesm2022/ngwr-file-upload.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-hotkey.mjs +10 -5
- package/fesm2022/ngwr-hotkey.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ar.mjs +18 -5
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +18 -5
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +18 -5
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +18 -5
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +18 -5
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +18 -5
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +18 -5
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +18 -5
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +18 -5
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +18 -5
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +18 -5
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-kk.mjs +18 -5
- package/fesm2022/ngwr-i18n-kk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +18 -5
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +18 -5
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +18 -5
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +18 -5
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +18 -5
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +18 -5
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +18 -5
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +18 -5
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +18 -5
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +18 -5
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +18 -5
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +7 -6
- package/fesm2022/ngwr-i18n.mjs.map +1 -1
- package/fesm2022/ngwr-image-cropper-testing.mjs +33 -0
- package/fesm2022/ngwr-image-cropper-testing.mjs.map +1 -1
- package/fesm2022/ngwr-image-cropper.mjs +536 -30
- package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +33 -10
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input-otp.mjs +24 -10
- package/fesm2022/ngwr-input-otp.mjs.map +1 -1
- package/fesm2022/ngwr-input.mjs +2 -2
- package/fesm2022/ngwr-input.mjs.map +1 -1
- package/fesm2022/ngwr-knob.mjs +5 -0
- package/fesm2022/ngwr-knob.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +5 -3
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-mention.mjs +2 -0
- package/fesm2022/ngwr-mention.mjs.map +1 -1
- package/fesm2022/ngwr-meta.mjs +43 -8
- package/fesm2022/ngwr-meta.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +51 -2
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +1 -1
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +160 -8
- package/fesm2022/ngwr-pipes.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm.mjs +2 -2
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-qr.mjs +65 -7
- package/fesm2022/ngwr-qr.mjs.map +1 -1
- package/fesm2022/ngwr-schema-form.mjs +2 -2
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-scroll.mjs +1 -2
- package/fesm2022/ngwr-scroll.mjs.map +1 -1
- package/fesm2022/ngwr-slider.mjs +22 -17
- package/fesm2022/ngwr-slider.mjs.map +1 -1
- package/fesm2022/ngwr-speed-dial.mjs +30 -1
- package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
- package/fesm2022/ngwr-statistic.mjs +1 -1
- package/fesm2022/ngwr-stepper-testing.mjs +7 -1
- package/fesm2022/ngwr-stepper-testing.mjs.map +1 -1
- package/fesm2022/ngwr-stepper.mjs +55 -4
- package/fesm2022/ngwr-stepper.mjs.map +1 -1
- package/fesm2022/ngwr-switch.mjs +33 -3
- package/fesm2022/ngwr-switch.mjs.map +1 -1
- package/fesm2022/ngwr-timeline.mjs +4 -0
- package/fesm2022/ngwr-timeline.mjs.map +1 -1
- package/fesm2022/ngwr-toolbar.mjs +171 -16
- package/fesm2022/ngwr-toolbar.mjs.map +1 -1
- package/fesm2022/ngwr-tour.mjs +8 -3
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-transfer.mjs +3 -2
- package/fesm2022/ngwr-transfer.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +1 -1
- package/fesm2022/ngwr-utils.mjs +46 -8
- package/fesm2022/ngwr-utils.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-virtual-scroll.mjs +2 -2
- package/fesm2022/ngwr-virtual-scroll.mjs.map +1 -1
- package/i18n/ar.json +18 -5
- package/i18n/cs.json +18 -5
- package/i18n/de.json +18 -5
- package/i18n/en.json +18 -5
- package/i18n/es.json +18 -5
- package/i18n/fr.json +18 -5
- package/i18n/he.json +18 -5
- package/i18n/hi.json +18 -5
- package/i18n/id.json +18 -5
- package/i18n/it.json +18 -5
- package/i18n/ja.json +18 -5
- package/i18n/kk.json +18 -5
- package/i18n/ko.json +18 -5
- package/i18n/nl.json +18 -5
- package/i18n/pl.json +18 -5
- package/i18n/pt.json +18 -5
- package/i18n/ru.json +18 -5
- package/i18n/sv.json +18 -5
- package/i18n/tr.json +18 -5
- package/i18n/uk.json +18 -5
- package/i18n/vi.json +18 -5
- package/i18n/zh-TW.json +18 -5
- package/i18n/zh.json +18 -5
- package/image-cropper/styles/_index.scss +30 -1
- package/llms-full.txt +9 -9
- package/package.json +1 -1
- package/schematics/use/rule.js +1 -0
- package/schematics/use/symbol-map.json +2 -0
- package/skills/ngwr/SKILL.md +2 -2
- package/stepper/styles/_index.scss +33 -0
- package/tour/styles/_index.scss +11 -7
- package/types/ngwr-anchor.d.ts +14 -1
- package/types/ngwr-charts-donut-chart-testing.d.ts +32 -3
- package/types/ngwr-charts-donut-chart.d.ts +45 -6
- package/types/ngwr-charts-meter-group-testing.d.ts +29 -1
- package/types/ngwr-charts-meter-group.d.ts +43 -4
- package/types/ngwr-charts-sparkline-testing.d.ts +32 -2
- package/types/ngwr-charts-sparkline.d.ts +42 -3
- package/types/ngwr-checkbox.d.ts +14 -0
- package/types/ngwr-color-picker-testing.d.ts +1 -1
- package/types/ngwr-command-palette.d.ts +2 -1
- package/types/ngwr-date-stamp-testing.d.ts +2 -0
- package/types/ngwr-date-stamp.d.ts +41 -2
- package/types/ngwr-date.d.ts +3 -1
- package/types/ngwr-descriptions.d.ts +33 -5
- package/types/ngwr-dialog.d.ts +11 -6
- package/types/ngwr-directives.d.ts +1 -0
- package/types/ngwr-drawer.d.ts +12 -4
- package/types/ngwr-file-upload.d.ts +1 -1
- package/types/ngwr-form.d.ts +4 -0
- package/types/ngwr-hotkey.d.ts +2 -0
- package/types/ngwr-image-cropper-testing.d.ts +33 -1
- package/types/ngwr-image-cropper.d.ts +214 -6
- package/types/ngwr-input-number.d.ts +14 -2
- package/types/ngwr-input-otp.d.ts +2 -0
- package/types/ngwr-lightbox.d.ts +1 -0
- package/types/ngwr-meta.d.ts +13 -1
- package/types/ngwr-overlay.d.ts +20 -1
- package/types/ngwr-pipes.d.ts +125 -1
- package/types/ngwr-qr.d.ts +17 -0
- package/types/ngwr-slider.d.ts +3 -1
- package/types/ngwr-speed-dial.d.ts +10 -0
- package/types/ngwr-stepper-testing.d.ts +10 -0
- package/types/ngwr-stepper.d.ts +47 -1
- package/types/ngwr-switch.d.ts +13 -0
- package/types/ngwr-toolbar.d.ts +27 -0
- package/types/ngwr-transfer.d.ts +2 -0
- package/types/ngwr-utils.d.ts +61 -2
- package/types/ngwr-version.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-slider.mjs","names":[],"sources":["../../../projects/lib/slider/slider.ts","../../../projects/lib/slider/slider.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport type { ElementRef } from '@angular/core';\nimport {\n Component,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n untracked,\n viewChild,\n} from '@angular/core';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { WR_FORM_FIELD, useFormFieldAria } from 'ngwr/form';\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrClamp, wrRound, wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrSliderMark, WrSliderSize, WrSliderValue } from './types';\n\n/** Trim float drift from step calculations. */\n\n/**\n * Numeric slider with optional dual-thumb range mode.\n *\n * A signal-forms native control: it implements `FormValueControl<WrSliderValue>`,\n * so `[formField]` binds straight to its `value` model — no\n * `ControlValueAccessor` in between. `[(value)]` works standalone. The value\n * shape depends on `range`: `number` (default) or `[number, number]` when\n * `range=\"true\"`.\n *\n * Keyboard: ← / → adjust by `step`; ↑ / ↓ same; Shift+arrow by `step × 10`;\n * Home / End jump to min / max; PageUp / PageDown by `step × 10`.\n * With `snapToMarks` every one of those keys moves one mark instead, and\n * Home / End land on the first and the last mark.\n *\n * Reading direction: the arrows follow the VISUAL track, so under `dir=\"rtl\"`\n * → moves toward the lower end and ← toward the higher one, and a drag reads\n * its ratio from the right edge. ↑ / ↓, PageUp / PageDown and Home / End are\n * unchanged — they name a value, not a side of the screen.\n *\n * `orientation=\"vertical\"` runs the track from the bottom (min) to the top\n * (max). → then raises the value like ↑ and ← lowers it like ↓, in both\n * reading directions.\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-slider [formField]=\"form.volume\" min=\"0\" max=\"100\" step=\"5\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-slider [(value)]=\"range\" range min=\"0\" max=\"1000\" step=\"10\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/slider\n */\n@Component({\n selector: 'wr-slider',\n templateUrl: './slider.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-slider', '[class]': 'classes()', '(focusout)': 'onFocusOut($event)' },\n})\nexport class WrSlider implements FormValueControl<WrSliderValue> {\n // Typed `WrSliderValue | undefined` (not `number`) to satisfy the reserved\n // `FormUiControl` min/max slots, which are keyed to the control's value type.\n // The transform still coerces to a plain number, so the bounds stay numeric\n // at runtime; `minValue`/`maxValue` narrow them back for arithmetic.\n /** Lower bound. @default 0 */\n readonly min = input<WrSliderValue | undefined>(0, { transform: (v: unknown): number => coerceNumberProperty(v, 0) });\n /** Upper bound. @default 100 */\n readonly max = input<WrSliderValue | undefined>(100, {\n transform: (v: unknown): number => coerceNumberProperty(v, 100),\n });\n\n /** Resolved numeric lower bound for internal arithmetic. */\n private readonly minValue = computed(() => {\n const m = this.min();\n return typeof m === 'number' ? m : 0;\n });\n /** Resolved numeric upper bound for internal arithmetic. */\n private readonly maxValue = computed(() => {\n const m = this.max();\n return typeof m === 'number' ? m : 100;\n });\n\n /** Step size for keyboard and drag. @default 1 */\n readonly step = input(1, { transform: (v: unknown): number => Math.max(0.0001, coerceNumberProperty(v, 1)) });\n /** Render two thumbs and emit `[low, high]`. @default false */\n readonly range = input(false, { transform: coerceBooleanProperty });\n /**\n * Disable interaction. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse value changes while the thumbs stay focusable and the value still\n * submits. Bound automatically from the field's readonly state when used with\n * `[formField]`.\n *\n * The thumbs keep their tab stop and keep announcing their value — arrow keys,\n * Home / End and the pointer simply move nothing — which is the whole\n * difference from `disabled`, where they would leave the tab order entirely.\n * Mirrored as `aria-readonly`, which role `slider` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n /** Render the current value below the track. @default true */\n readonly showValue = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Maps a value to the text of the value label, and to `aria-valuetext` on\n * the thumb, so a screen reader hears what the label shows. In range mode\n * each end is mapped on its own. Unset, the label prints the number and the\n * thumb announces `aria-valuenow`.\n *\n * @example\n * ```html\n * <wr-slider [max]=\"24\" [labelWith]=\"hour\" [(value)]=\"start\" />\n * ```\n */\n readonly labelWith = input<(value: number) => string>();\n\n /**\n * Stops drawn on the track: a tick at each `value`, and its `label` under the\n * track when it has one. A mark outside `[min, max]` is not drawn. The thumb\n * announces the label of the mark it stands on as `aria-valuetext`, ahead of\n * `labelWith`.\n *\n * @example\n * ```html\n * <wr-slider [marks]=\"[{ value: 0, label: 'Low' }, { value: 50 }, { value: 100, label: 'High' }]\" />\n * ```\n */\n readonly marks = input<readonly WrSliderMark[]>([]);\n\n /**\n * Restrict the value to the marks: a drag lands on the nearest one and the\n * keyboard moves from mark to mark, whatever `step` says. Without marks it\n * does nothing.\n *\n * @default false\n */\n readonly snapToMarks = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Axis of the track. `vertical` runs from the bottom (min) to the top (max),\n * as tall as `--wr-slider-vertical-height`, with the value and the marks'\n * labels beside it.\n *\n * @default 'horizontal'\n */\n readonly orientation = input<'horizontal' | 'vertical'>('horizontal');\n\n /**\n * Control size: the track's thickness, the thumb, the marks and both kinds\n * of label text.\n *\n * @default 'md'\n */\n readonly size = input<WrSliderSize>('md');\n\n /**\n * Accessible name of the thumb — the single one, or the LOWER one in range\n * mode. Falls back to `slider.label` / `slider.lower`.\n */\n readonly ariaLabel = input<string | null>(null);\n\n /** Accessible name of the upper thumb in range mode. Falls back to `slider.upper`. */\n readonly upperLabel = input<string | null>(null);\n\n /**\n * A thumb projects no text, so these ARE the accessible names — and they were\n * hard-coded English with no key behind them, so every slider on a page\n * announced the same untranslated \"Value\" whatever it controlled.\n *\n * Range mode reads `ariaLabel` as the LOWER end rather than as the whole\n * control: a name given once must land on something, and naming both thumbs\n * the same thing would read two different values under one name.\n */\n private readonly singleLabel = useI18nText(this.ariaLabel, 'slider.label', 'Value');\n private readonly lowerLabel = useI18nText(this.ariaLabel, 'slider.lower', 'Lower value');\n protected readonly resolvedUpperLabel = useI18nText(this.upperLabel, 'slider.upper', 'Upper value');\n protected readonly resolvedLowLabel = computed(() => (this.range() ? this.lowerLabel() : this.singleLabel()));\n\n private readonly field = inject(WR_FORM_FIELD, { optional: true });\n\n /**\n * Id the surrounding `<wr-form-field>`'s `<label for>` points at, put on the\n * single thumb — the LOWER one in range mode, the same end `ariaLabel` names.\n *\n * The field renders its label before it can see what was projected into it, so\n * the id travels the other way and the control adopts it, exactly as\n * `[wrInput]` does. Without this the `for` named an element that was nowhere\n * in the document: clicking the label did nothing, and the field's own text\n * reached the thumb through no path at all.\n *\n * It lands on the THUMB rather than on the host because only a labelable\n * element can be a label's target, and `<wr-slider>` is not one — a `for`\n * pointing at the host would resolve and still name nothing. The thumb is a\n * real `<button>`, so it is.\n *\n * What this does NOT change is the thumb's name: an `aria-label` outranks a\n * `<label>` in the accname order, and the thumb keeps its own because the\n * field cannot promise it has one to give — `<wr-form-field>` renders a label\n * only when `label` is set, and a slider that traded a generic name for no\n * name would be the worse bug. Set `[ariaLabel]` to the field's label where\n * the two should read alike.\n */\n protected readonly thumbId = computed(() => this.field?.controlId() ?? null);\n\n /**\n * The field's error message, wired to the thumb the same way `wrInput` wires it\n * to its native element.\n *\n * Without this the messages `<wr-form-field>` renders are visible and nothing\n * else: a screen reader on the thumb never learns the field is invalid, nor\n * what the message says. `aria-invalid` is keyed on the message EXISTING rather\n * than on `errorKeys()`, because the field only publishes an id once it is\n * showing something — announcing \"invalid\" while pointing at nothing is worse\n * than staying quiet.\n */\n // Through the shared helper, not a local pair: the hint is described by\n // `hintId`, which only `useFormFieldAria()` composes, and `aria-invalid` keys\n // on the error COUNT rather than on \"something is described\". Hand-rolled here,\n // these three announced the error and never the hint — and `<input wrInput>` is\n // the control the report was filed against.\n private readonly fieldAria = useFormFieldAria();\n protected readonly describedBy = this.fieldAria.describedBy;\n\n /**\n * The field's own label, when it renders one — `null` otherwise, and `null`\n * when `[ariaLabel]` was set deliberately.\n *\n * `aria-label` outranks a `<label for>` in the accname order, so without this\n * every slider in a form announced the generic `slider.value` default: three\n * sliders under three different labels, all called \"Value\". Nothing catches\n * it — the control HAS a name, so axe is satisfied — and it fails WCAG 2.5.3,\n * where the visible label has to be IN the accessible name.\n *\n * SINGLE thumb only, and deliberately: a range has two, and pointing both at\n * one label would name them identically, which is worse than the generic\n * pair they carry now. Naming a range's thumbs after their field needs\n * `aria-labelledby` to carry two ids — the field's and a hidden one per thumb\n * — which is more machinery than this is worth until someone asks for it.\n */\n protected readonly labelledBy = computed(() =>\n this.ariaLabel() || this.range() ? null : this.fieldAria.labelledBy()\n );\n\n /** `null` once `aria-labelledby` is carrying the name — see {@link labelledBy}. */\n protected readonly lowNameLabel = computed(() => (this.labelledBy() ? null : this.resolvedLowLabel()));\n protected readonly ariaInvalid = this.fieldAria.ariaInvalid;\n\n /**\n * Current value. Bound by `[formField]`, or two-way via `[(value)]`. Shape\n * follows `range`: a plain `number`, or `[low, high]` in range mode.\n */\n readonly value = model<WrSliderValue>(0);\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n protected readonly low = signal(0);\n /**\n * The high thumb's cell. Its literal default stands in for `maxValue()`,\n * which cannot be read at field-initialisation time — see `highSeeded` and\n * the constructor effect.\n */\n protected readonly high = signal(100);\n\n /**\n * Whether `high` has ever been told a real value by the model.\n *\n * `<wr-slider range [min]=\"200\" [max]=\"300\" />` binds no value, so the model\n * holds its own scalar default and the tuple branch below never runs: `high`\n * kept the literal 100, which is not inside every `[min, max]`. The thumb\n * rendered off the track and the first interaction committed `[low, 100]` —\n * a value the slider itself calls out of range.\n */\n private highSeeded = false;\n\n protected readonly track = viewChild.required<ElementRef<HTMLElement>>('track');\n private readonly lowThumb = viewChild.required<ElementRef<HTMLButtonElement>>('lowThumb');\n\n /**\n * Ambient reading direction. Optional so a bare `TestBed` — or any consumer\n * that never set a direction — needs no provider; `Directionality` is\n * root-provided, so `null` only ever means \"nobody asked\", which is LTR.\n *\n * Nothing caches a direction-derived value: the thumbs are painted with\n * `inset-inline-start`, so the track mirrors from CSS alone, and `isRtl()` is\n * read inside the event handlers. A runtime flip therefore needs no\n * subscription to `Directionality.change`.\n */\n private readonly dir = inject(Directionality, { optional: true });\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-slider--${size}`);\n if (this.range()) parts.push('wr-slider--range');\n if (this.vertical()) parts.push('wr-slider--vertical');\n if (this.disabled()) parts.push('wr-slider--disabled');\n else if (this.readonly()) parts.push('wr-slider--readonly');\n return parts.join(' ');\n });\n\n protected readonly vertical = computed(() => this.orientation() === 'vertical');\n\n protected readonly lowPercent = computed(() => this.percentOf(this.low()));\n protected readonly highPercent = computed(() => this.percentOf(this.high()));\n\n /** Offset of the fill from the track's START edge — the left one in LTR, the right one in RTL. */\n protected readonly fillStart = computed(() => (this.range() ? this.lowPercent() : 0));\n protected readonly fillWidth = computed(() =>\n this.range() ? this.highPercent() - this.lowPercent() : this.lowPercent()\n );\n\n /** The marks inside the bounds, in value order: what is drawn and what `snapToMarks` walks. */\n protected readonly visibleMarks = computed(() =>\n this.marks()\n .filter(mark => mark.value >= this.minValue() && mark.value <= this.maxValue())\n .sort((a, b) => a.value - b.value)\n .map(mark => ({ ...mark, percent: this.percentOf(mark.value) }))\n );\n protected readonly labelledMarks = computed(() => this.visibleMarks().filter(mark => !!mark.label));\n\n private readonly snapping = computed(() => this.snapToMarks() && this.visibleMarks().length > 0);\n\n /**\n * `aria-valuetext` of the lower thumb: the label of the mark it stands on,\n * else `labelWith`, else `null` so the number announces as is.\n */\n protected readonly lowText = computed<string | null>(() => this.textOf(this.low()));\n /** `aria-valuetext` of the upper thumb, see {@link lowText}. */\n protected readonly highText = computed<string | null>(() => this.textOf(this.high()));\n\n /** Where the value label sits along a vertical track: beside the thumb, or midway between two. */\n protected readonly labelPercent = computed(() =>\n this.range() ? (this.lowPercent() + this.highPercent()) / 2 : this.lowPercent()\n );\n\n protected readonly label = computed(() => {\n const low = this.lowText() ?? `${this.low()}`;\n return this.range() ? `${low} – ${this.highText() ?? this.high()}` : low;\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('slider');\n // Keep the internal thumbs in sync with external writes to `value`\n // (the old `writeValue`): split the tuple / clamp into the low & high cells.\n // The cells are clamped and the MODEL IS NOT TOUCHED, and the asymmetry is\n // deliberate. A thumb cannot render outside its own track, so the display\n // has no choice — but writing that clamp back into `value` would erase the\n // error it represents: under `[formField]` the bounds reach this component\n // only through the schema's `min()` / `max()` rules (binding `[min]` beside\n // `[formField]` is an NG8022 compile error), so the write-back deleted the\n // out-of-range value those rules exist to report, and marked a pristine\n // form dirty on first paint besides. The first real interaction emits an\n // in-range number through `emitChange` and the two agree from then on.\n effect(() => {\n const v = this.value();\n\n if (Array.isArray(v)) {\n const tuple = v as readonly [number, number];\n const a = this.clampToBounds(tuple[0]);\n const b = this.clampToBounds(tuple[1]);\n // ORDERED, and only for the display — the same asymmetry as the clamp\n // above, for the same reason. An external `[80, 20]` used to seed\n // `low = 80` and `high = 20`, which made each thumb report an\n // `aria-valuenow` outside its OWN `aria-valuemin`/`aria-valuemax` (the\n // two bound each other), and left the fill with a start and no width,\n // so a range that is real simply vanished.\n //\n // This does not contradict the recorded contract that an edit to one\n // end is never reordered: that one is scoped to \"while the user is\n // still on it\", and ordering settles when the interaction ends. An\n // external write IS the end — there is no interaction in progress.\n const lo = Math.min(a, b);\n const hi = Math.max(a, b);\n this.low.set(lo);\n this.high.set(hi);\n this.highSeeded = true;\n return;\n }\n\n if (typeof v !== 'number') return;\n const lo = this.clampToBounds(v);\n this.low.set(lo);\n\n if (!this.range()) return;\n\n // Range mode holding a scalar: the high thumb has never been told\n // anything, and its literal default is not inside every `[min, max]`.\n // Seed it at the top of the range — which is what the 100 meant back when\n // the bounds were 0–100. The MODEL is left alone here too; the shape it\n // holds is the consumer's business until they move a thumb.\n this.high.set(this.highSeeded ? this.clampToBounds(untracked(this.high)) : this.maxValue());\n this.highSeeded = true;\n });\n }\n\n /**\n * Focus the slider — what Signal Forms calls to focus this control, from\n * `focusBoundControl()`. The host carries no tab stop, so the call goes to\n * the thumb, and in range mode to the LOWER one: the first in the tab order,\n * and the one that carries the field's id and error description.\n */\n focus(options?: FocusOptions): void {\n this.lowThumb().nativeElement.focus(options);\n }\n\n // Interaction\n\n protected onPointerDown(event: PointerEvent, thumb: 'low' | 'high'): void {\n if (this.disabled() || this.readonly()) return;\n event.preventDefault();\n const target = event.currentTarget as HTMLElement;\n target.setPointerCapture(event.pointerId);\n // `preventDefault` above also suppresses the default focus, so the arrows\n // did nothing after a mouse drag until the thumb was found again with Tab —\n // while a click on the bare TRACK focused it. Synchronously, not through\n // `focusThumb`: `event.currentTarget` is already the thumb, so that\n // helper's `queueMicrotask` would only defer a focus nothing is waiting on.\n target.focus();\n\n const move = (e: PointerEvent): void => this.updateFromEvent(e, thumb);\n const cleanup = (e: PointerEvent): void => {\n target.releasePointerCapture(e.pointerId);\n target.removeEventListener('pointermove', move);\n target.removeEventListener('pointerup', cleanup);\n target.removeEventListener('pointercancel', cleanup);\n this.touch.emit();\n };\n\n target.addEventListener('pointermove', move);\n target.addEventListener('pointerup', cleanup);\n // `pointercancel` is never followed by a `pointerup`, so without this the\n // move listener outlived the drag: the thumb kept following a pointer that\n // was merely hovering over it, with no button held.\n target.addEventListener('pointercancel', cleanup);\n this.updateFromEvent(event, thumb);\n }\n\n protected onTrackPointerDown(event: PointerEvent): void {\n if (this.disabled() || this.readonly()) return;\n if ((event.target as HTMLElement).closest('.wr-slider__thumb')) return;\n const thumb = this.nearestThumb(event);\n this.updateFromEvent(event, thumb);\n this.focusThumb(thumb);\n }\n\n protected onKey(event: KeyboardEvent, thumb: 'low' | 'high'): void {\n if (this.disabled() || this.readonly()) return;\n const big = event.shiftKey || event.key === 'PageUp' || event.key === 'PageDown' ? 10 : 1;\n const delta = this.step() * big;\n const current = thumb === 'low' ? this.low() : this.high();\n // The horizontal arrows name a SIDE of the track, so they follow the\n // reading direction; every other key names a value and does not. A\n // vertical track has no inline side to name.\n const inline = this.isRtl() && !this.vertical() ? -1 : 1;\n let direction = 0;\n let next: number | null = null;\n\n switch (event.key) {\n case 'ArrowRight':\n direction = inline;\n break;\n case 'ArrowLeft':\n direction = -inline;\n break;\n case 'ArrowUp':\n case 'PageUp':\n direction = 1;\n break;\n case 'ArrowDown':\n case 'PageDown':\n direction = -1;\n break;\n case 'Home':\n next = this.minValue();\n break;\n case 'End':\n next = this.maxValue();\n break;\n }\n\n if (direction) next = this.snapping() ? this.adjacentMark(current, direction) : current + direction * delta;\n if (next === null) return;\n event.preventDefault();\n this.setThumb(thumb, next);\n this.emitChange();\n this.touch.emit();\n }\n\n /**\n * A bound field learns it may show its validation copy from `touch`, and\n * pointer-up plus a value-changing keypress cannot be the only sources: a\n * slider tabbed into and out of without an arrow press left the field\n * untouched forever — which is exactly the case `touched` exists for, and\n * what this output has always documented itself as doing. `wr-knob` and\n * `wr-rating` bind `(blur)` on the one element they own; this component has\n * two thumbs, so it listens for the bubbling `focusout` on its host instead\n * — and ignores the one that only moves focus from one thumb to the other.\n */\n protected onFocusOut(event: FocusEvent): void {\n if (this.track().nativeElement.contains(event.relatedTarget as Node | null)) return;\n this.touch.emit();\n }\n\n // Internals\n\n private isRtl(): boolean {\n return this.dir?.value === 'rtl';\n }\n\n /**\n * The value under a pointer, measured along the track's INLINE axis, or up\n * from its bottom edge when vertical.\n *\n * The offset is taken from whichever edge the track starts at — the left one\n * in LTR, the right one in RTL — so the whole component needs the direction\n * in exactly one place. Measuring from `rect.left` regardless would read 0 at\n * the visual maximum of a mirrored track.\n */\n private valueAt(event: PointerEvent): number {\n const rect = this.track().nativeElement.getBoundingClientRect();\n const inline = this.isRtl() ? rect.right - event.clientX : event.clientX - rect.left;\n const ratio = wrClamp(this.vertical() ? (rect.bottom - event.clientY) / rect.height : inline / rect.width, 0, 1);\n return this.minValue() + ratio * (this.maxValue() - this.minValue());\n }\n\n private updateFromEvent(event: PointerEvent, thumb: 'low' | 'high'): void {\n this.setThumb(thumb, this.valueAt(event));\n this.emitChange();\n }\n\n /**\n * Which thumb a track click grabs: the one nearest the pointer ON SCREEN.\n *\n * Value distance is the same thing as visual distance once {@link valueAt}\n * has mirrored the ratio — in RTL the low thumb is the RIGHT one, and a click\n * near the right edge lands close to `low` in value space too.\n */\n private nearestThumb(event: PointerEvent): 'low' | 'high' {\n if (!this.range()) return 'low';\n const raw = this.valueAt(event);\n return Math.abs(raw - this.low()) <= Math.abs(raw - this.high()) ? 'low' : 'high';\n }\n\n private focusThumb(thumb: 'low' | 'high'): void {\n queueMicrotask(() => {\n const root = this.track().nativeElement;\n const el = root.querySelector<HTMLElement>(`.wr-slider__thumb--${thumb}`);\n el?.focus();\n });\n }\n\n private setThumb(thumb: 'low' | 'high', raw: number): void {\n const stepped = this.snap(raw);\n if (thumb === 'low') {\n const next = this.range() ? Math.min(stepped, this.high()) : stepped;\n this.low.set(next);\n } else {\n this.high.set(Math.max(stepped, this.low()));\n }\n }\n\n private snap(value: number): number {\n if (this.snapping()) return this.nearestMark(value);\n const stepped = Math.round((value - this.minValue()) / this.step()) * this.step() + this.minValue();\n return this.clampToBounds(wrRound(stepped, 6));\n }\n\n private nearestMark(value: number): number {\n return this.visibleMarks().reduce((best, mark) =>\n Math.abs(mark.value - value) < Math.abs(best.value - value) ? mark : best\n ).value;\n }\n\n /** The next mark above or below `value`; `value` itself when there is none, which `snap` then settles. */\n private adjacentMark(value: number, direction: number): number {\n const marks = this.visibleMarks();\n const next =\n direction > 0 ? marks.find(mark => mark.value > value) : [...marks].reverse().find(mark => mark.value < value);\n return next?.value ?? value;\n }\n\n private textOf(value: number): string | null {\n const mark = this.labelledMarks().find(({ value: at }) => at === value);\n return mark?.label ?? this.labelWith()?.(value) ?? null;\n }\n\n protected isActiveMark(value: number): boolean {\n return this.range() ? value >= this.low() && value <= this.high() : value <= this.low();\n }\n\n private clampToBounds(v: number): number {\n return wrClamp(v, this.minValue(), this.maxValue());\n }\n\n private percentOf(v: number): number {\n const span = this.maxValue() - this.minValue();\n if (span <= 0) return 0;\n return ((v - this.minValue()) / span) * 100;\n }\n\n private emitChange(): void {\n const value: WrSliderValue = this.range() ? [this.low(), this.high()] : this.low();\n this.value.set(value);\n }\n}\n","<div #track class=\"wr-slider__track\" (pointerdown)=\"onTrackPointerDown($event)\">\n <!--\n Positioned on the INLINE axis, not with `left`: `inset-inline-start` is the\n same edge in LTR and mirrors under `dir=\"rtl\"`, so the track paints itself\n the right way round without the component reading a direction to draw.\n A vertical track measures every part up from `bottom` instead.\n -->\n <span\n class=\"wr-slider__fill\"\n [style.inset-inline-start.%]=\"vertical() ? null : fillStart()\"\n [style.width.%]=\"vertical() ? null : fillWidth()\"\n [style.bottom.%]=\"vertical() ? fillStart() : null\"\n [style.height.%]=\"vertical() ? fillWidth() : null\"\n ></span>\n\n @for (mark of visibleMarks(); track $index) {\n <span\n class=\"wr-slider__mark\"\n [class.wr-slider__mark--active]=\"isActiveMark(mark.value)\"\n [attr.data-value]=\"mark.value\"\n [style.inset-inline-start.%]=\"vertical() ? null : mark.percent\"\n [style.bottom.%]=\"vertical() ? mark.percent : null\"\n ></span>\n }\n\n <button\n #lowThumb\n type=\"button\"\n class=\"wr-slider__thumb wr-slider__thumb--low\"\n role=\"slider\"\n [attr.id]=\"thumbId()\"\n [style.inset-inline-start.%]=\"vertical() ? null : lowPercent()\"\n [style.bottom.%]=\"vertical() ? lowPercent() : null\"\n [disabled]=\"disabled()\"\n [attr.aria-valuemin]=\"min()\"\n [attr.aria-valuemax]=\"range() ? high() : max()\"\n [attr.aria-valuenow]=\"low()\"\n [attr.aria-valuetext]=\"lowText()\"\n [attr.aria-orientation]=\"vertical() ? 'vertical' : null\"\n [attr.aria-label]=\"lowNameLabel()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.aria-invalid]=\"ariaInvalid()\"\n (pointerdown)=\"onPointerDown($event, 'low')\"\n (keydown)=\"onKey($event, 'low')\"\n ></button>\n\n @if (range()) {\n <button\n type=\"button\"\n class=\"wr-slider__thumb wr-slider__thumb--high\"\n role=\"slider\"\n [style.inset-inline-start.%]=\"vertical() ? null : highPercent()\"\n [style.bottom.%]=\"vertical() ? highPercent() : null\"\n [disabled]=\"disabled()\"\n [attr.aria-valuemin]=\"low()\"\n [attr.aria-valuemax]=\"max()\"\n [attr.aria-valuenow]=\"high()\"\n [attr.aria-valuetext]=\"highText()\"\n [attr.aria-orientation]=\"vertical() ? 'vertical' : null\"\n [attr.aria-label]=\"resolvedUpperLabel()\"\n [attr.aria-readonly]=\"readonly() || null\"\n (pointerdown)=\"onPointerDown($event, 'high')\"\n (keydown)=\"onKey($event, 'high')\"\n ></button>\n }\n</div>\n\n@if (labelledMarks().length) {\n <!-- Hidden from assistive tech: the thumb announces the label of the mark it stands on. -->\n <div class=\"wr-slider__mark-labels\" aria-hidden=\"true\">\n @for (mark of labelledMarks(); track $index) {\n <span\n class=\"wr-slider__mark-label\"\n [attr.data-value]=\"mark.value\"\n [style.inset-inline-start.%]=\"vertical() ? null : mark.percent\"\n [style.bottom.%]=\"vertical() ? mark.percent : null\"\n >{{ mark.label }}</span\n >\n }\n </div>\n}\n\n@if (showValue()) {\n <div class=\"wr-slider__label\" [style.bottom.%]=\"vertical() ? labelPercent() : null\">{{ label() }}</div>\n}\n"],"mappings":";;;;;;;;;;;;;AAyEA,IAAa,WAAb,MAAa,SAAQ;CAMV,MAAM,MAAiC,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,MAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,qBAAqB,GAAG,CAAC;CAAC,CAAA;CAEzG,MAAM,MAAiC,KAAG;EAAA,GAAA,YAAA,EAAA,WAAA,MAAA,+BAAA,CAAA;EACjD,YAAY,MAAuB,qBAAqB,GAAG,GAAG;CAAC,CAAA;CAIhD,WAAW,eAAc;EACxC,MAAM,IAAI,KAAK,IAAG;EAClB,OAAO,OAAO,MAAM,WAAW,IAAI;CACrC,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAEe,WAAW,eAAc;EACxC,MAAM,IAAI,KAAK,IAAG;EAClB,OAAO,OAAO,MAAM,WAAW,IAAI;CACrC,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAGO,OAAO,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,OAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,KAAK,IAAI,MAAQ,qBAAqB,GAAG,CAAC,CAAC;CAAC,CAAA;CAEjG,QAAQ,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,QAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAOvD,WAA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EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-slider.mjs","names":[],"sources":["../../../projects/lib/slider/slider.ts","../../../projects/lib/slider/slider.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport type { ElementRef } from '@angular/core';\nimport {\n Component,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n untracked,\n viewChild,\n} from '@angular/core';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { WR_FORM_FIELD, useFormFieldAria } from 'ngwr/form';\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrClamp, wrRound, wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrSliderMark, WrSliderSize, WrSliderValue } from './types';\n\n/** Trim float drift from step calculations. */\n\n/**\n * Numeric slider with optional dual-thumb range mode.\n *\n * A signal-forms native control: it implements `FormValueControl<WrSliderValue>`,\n * so `[formField]` binds straight to its `value` model — no\n * `ControlValueAccessor` in between. `[(value)]` works standalone. The value\n * shape depends on `range`: `number` (default) or `[number, number]` when\n * `range=\"true\"`.\n *\n * Keyboard: ← / → adjust by `step`; ↑ / ↓ same; Shift+arrow by `step × 10`;\n * Home / End jump to min / max; PageUp / PageDown by `step × 10`.\n * With `snapToMarks` every one of those keys moves one mark instead, and\n * Home / End land on the first and the last mark.\n *\n * Reading direction: the arrows follow the VISUAL track, so under `dir=\"rtl\"`\n * → moves toward the lower end and ← toward the higher one, and a drag reads\n * its ratio from the right edge. ↑ / ↓, PageUp / PageDown and Home / End are\n * unchanged — they name a value, not a side of the screen.\n *\n * `orientation=\"vertical\"` runs the track from the bottom (min) to the top\n * (max). → then raises the value like ↑ and ← lowers it like ↓, in both\n * reading directions.\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-slider [formField]=\"form.volume\" min=\"0\" max=\"100\" step=\"5\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-slider [(value)]=\"range\" range min=\"0\" max=\"1000\" step=\"10\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/slider\n */\n@Component({\n selector: 'wr-slider',\n templateUrl: './slider.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-slider', '[class]': 'classes()', '(focusout)': 'onFocusOut($event)' },\n})\nexport class WrSlider implements FormValueControl<WrSliderValue> {\n // Typed `WrSliderValue | undefined` (not `number`) to satisfy the reserved\n // `FormUiControl` min/max slots, which are keyed to the control's value type.\n // The transform still coerces to a plain number, so the bounds stay numeric\n // at runtime; `minValue`/`maxValue` narrow them back for arithmetic.\n /** Lower bound. @default 0 */\n readonly min = input<WrSliderValue | undefined>(0, { transform: (v: unknown): number => coerceNumberProperty(v, 0) });\n /** Upper bound. @default 100 */\n readonly max = input<WrSliderValue | undefined>(100, {\n transform: (v: unknown): number => coerceNumberProperty(v, 100),\n });\n\n /** Resolved numeric lower bound for internal arithmetic. */\n private readonly minValue = computed(() => {\n const m = this.min();\n return typeof m === 'number' ? m : 0;\n });\n /** Resolved numeric upper bound for internal arithmetic. */\n private readonly maxValue = computed(() => {\n const m = this.max();\n return typeof m === 'number' ? m : 100;\n });\n\n /** Step size for keyboard and drag. @default 1 */\n readonly step = input(1, { transform: (v: unknown): number => Math.max(0.0001, coerceNumberProperty(v, 1)) });\n /** Render two thumbs and emit `[low, high]`. @default false */\n readonly range = input(false, { transform: coerceBooleanProperty });\n /**\n * Disable interaction. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse value changes while the thumbs stay focusable and the value still\n * submits. Bound automatically from the field's readonly state when used with\n * `[formField]`.\n *\n * The thumbs keep their tab stop and keep announcing their value — arrow keys,\n * Home / End and the pointer simply move nothing — which is the whole\n * difference from `disabled`, where they would leave the tab order entirely.\n * Mirrored as `aria-readonly`, which role `slider` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n /** Render the current value below the track. @default true */\n readonly showValue = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Maps a value to the text of the value label, and to `aria-valuetext` on\n * the thumb, so a screen reader hears what the label shows. In range mode\n * each end is mapped on its own. Unset, the label prints the number and the\n * thumb announces `aria-valuenow`.\n *\n * @example\n * ```html\n * <wr-slider [max]=\"24\" [labelWith]=\"hour\" [(value)]=\"start\" />\n * ```\n */\n readonly labelWith = input<(value: number) => string>();\n\n /**\n * Stops drawn on the track: a tick at each `value`, and its `label` under the\n * track when it has one. A mark outside `[min, max]` is not drawn. The thumb\n * announces the label of the mark it stands on as `aria-valuetext`, ahead of\n * `labelWith`.\n *\n * @example\n * ```html\n * <wr-slider [marks]=\"[{ value: 0, label: 'Low' }, { value: 50 }, { value: 100, label: 'High' }]\" />\n * ```\n */\n readonly marks = input<readonly WrSliderMark[]>([]);\n\n /**\n * Restrict the value to the marks: a drag lands on the nearest one and the\n * keyboard moves from mark to mark, whatever `step` says. Without marks it\n * does nothing.\n *\n * @default false\n */\n readonly snapToMarks = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Axis of the track. `vertical` runs from the bottom (min) to the top (max),\n * as tall as `--wr-slider-vertical-height`, with the value and the marks'\n * labels beside it.\n *\n * @default 'horizontal'\n */\n readonly orientation = input<'horizontal' | 'vertical'>('horizontal');\n\n /**\n * Control size: the track's thickness, the thumb, the marks and both kinds\n * of label text.\n *\n * @default 'md'\n */\n readonly size = input<WrSliderSize>('md');\n\n /**\n * Accessible name of the thumb — the single one, or the LOWER one in range\n * mode. Falls back to `slider.label` / `slider.lower`.\n */\n readonly ariaLabel = input<string | null>(null);\n\n /** Accessible name of the upper thumb in range mode. Falls back to `slider.upper`. */\n readonly upperLabel = input<string | null>(null);\n\n /**\n * A thumb projects no text, so these ARE the accessible names — and they were\n * hard-coded English with no key behind them, so every slider on a page\n * announced the same untranslated \"Value\" whatever it controlled.\n *\n * Range mode reads `ariaLabel` as the LOWER end rather than as the whole\n * control: a name given once must land on something, and naming both thumbs\n * the same thing would read two different values under one name.\n */\n private readonly singleLabel = useI18nText(this.ariaLabel, 'slider.label', 'Value');\n private readonly lowerLabel = useI18nText(this.ariaLabel, 'slider.lower', 'Lower value');\n protected readonly resolvedUpperLabel = useI18nText(this.upperLabel, 'slider.upper', 'Upper value');\n protected readonly resolvedLowLabel = computed(() => (this.range() ? this.lowerLabel() : this.singleLabel()));\n\n private readonly field = inject(WR_FORM_FIELD, { optional: true });\n\n /**\n * Id the surrounding `<wr-form-field>`'s `<label for>` points at, put on the\n * single thumb — the LOWER one in range mode, the same end `ariaLabel` names.\n *\n * The field renders its label before it can see what was projected into it, so\n * the id travels the other way and the control adopts it, exactly as\n * `[wrInput]` does. Without this the `for` named an element that was nowhere\n * in the document: clicking the label did nothing, and the field's own text\n * reached the thumb through no path at all.\n *\n * It lands on the THUMB rather than on the host because only a labelable\n * element can be a label's target, and `<wr-slider>` is not one — a `for`\n * pointing at the host would resolve and still name nothing. The thumb is a\n * real `<button>`, so it is.\n *\n * What this does NOT change is the thumb's name: an `aria-label` outranks a\n * `<label>` in the accname order, and the thumb keeps its own because the\n * field cannot promise it has one to give — `<wr-form-field>` renders a label\n * only when `label` is set, and a slider that traded a generic name for no\n * name would be the worse bug. Set `[ariaLabel]` to the field's label where\n * the two should read alike.\n */\n protected readonly thumbId = computed(() => this.field?.controlId() ?? null);\n\n /**\n * The field's error message, wired to the thumb the same way `wrInput` wires it\n * to its native element.\n *\n * Without this the messages `<wr-form-field>` renders are visible and nothing\n * else: a screen reader on the thumb never learns the field is invalid, nor\n * what the message says. `aria-invalid` is keyed on the message EXISTING rather\n * than on `errorKeys()`, because the field only publishes an id once it is\n * showing something — announcing \"invalid\" while pointing at nothing is worse\n * than staying quiet.\n */\n // Through the shared helper, not a local pair: the hint is described by\n // `hintId`, which only `useFormFieldAria()` composes, and `aria-invalid` keys\n // on the error COUNT rather than on \"something is described\". Hand-rolled here,\n // these three announced the error and never the hint — and `<input wrInput>` is\n // the control the report was filed against.\n private readonly fieldAria = useFormFieldAria();\n protected readonly describedBy = this.fieldAria.describedBy;\n\n /**\n * The field's own label, when it renders one — `null` otherwise, and `null`\n * when `[ariaLabel]` was set deliberately.\n *\n * `aria-label` outranks a `<label for>` in the accname order, so without this\n * every slider in a form announced the generic `slider.value` default: three\n * sliders under three different labels, all called \"Value\". Nothing catches\n * it — the control HAS a name, so axe is satisfied — and it fails WCAG 2.5.3,\n * where the visible label has to be IN the accessible name.\n *\n * SINGLE thumb only, and deliberately: a range has two, and pointing both at\n * one label would name them identically, which is worse than the generic\n * pair they carry now. Naming a range's thumbs after their field needs\n * `aria-labelledby` to carry two ids — the field's and a hidden one per thumb\n * — which is more machinery than this is worth until someone asks for it.\n */\n protected readonly labelledBy = computed(() =>\n this.ariaLabel() || this.range() ? null : this.fieldAria.labelledBy()\n );\n\n /** `null` once `aria-labelledby` is carrying the name — see {@link labelledBy}. */\n protected readonly lowNameLabel = computed(() => (this.labelledBy() ? null : this.resolvedLowLabel()));\n protected readonly ariaInvalid = this.fieldAria.ariaInvalid;\n\n /**\n * Current value. Bound by `[formField]`, or two-way via `[(value)]`. Shape\n * follows `range`: a plain `number`, or `[low, high]` in range mode.\n */\n readonly value = model<WrSliderValue>(0);\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n protected readonly low = signal(0);\n /**\n * The high thumb's cell. Its literal default stands in for `maxValue()`,\n * which cannot be read at field-initialisation time — see `highSeeded` and\n * the constructor effect.\n */\n protected readonly high = signal(100);\n\n /**\n * Whether `high` has ever been told a real value by the model.\n *\n * `<wr-slider range [min]=\"200\" [max]=\"300\" />` binds no value, so the model\n * holds its own scalar default and the tuple branch below never runs: `high`\n * kept the literal 100, which is not inside every `[min, max]`. The thumb\n * rendered off the track and the first interaction committed `[low, 100]` —\n * a value the slider itself calls out of range.\n */\n private highSeeded = false;\n\n protected readonly track = viewChild.required<ElementRef<HTMLElement>>('track');\n private readonly lowThumb = viewChild.required<ElementRef<HTMLButtonElement>>('lowThumb');\n\n /**\n * Ambient reading direction. Optional so a bare `TestBed` — or any consumer\n * that never set a direction — needs no provider; `Directionality` is\n * root-provided, so `null` only ever means \"nobody asked\", which is LTR.\n *\n * Nothing caches a direction-derived value: the thumbs are painted with\n * `inset-inline-start`, so the track mirrors from CSS alone, and `isRtl()` is\n * read inside the event handlers. A runtime flip therefore needs no\n * subscription to `Directionality.change`.\n */\n private readonly dir = inject(Directionality, { optional: true });\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-slider--${size}`);\n if (this.range()) parts.push('wr-slider--range');\n if (this.vertical()) parts.push('wr-slider--vertical');\n if (this.disabled()) parts.push('wr-slider--disabled');\n else if (this.readonly()) parts.push('wr-slider--readonly');\n return parts.join(' ');\n });\n\n protected readonly vertical = computed(() => this.orientation() === 'vertical');\n\n protected readonly lowPercent = computed(() => this.percentOf(this.low()));\n protected readonly highPercent = computed(() => this.percentOf(this.high()));\n\n /** Offset of the fill from the track's START edge — the left one in LTR, the right one in RTL. */\n protected readonly fillStart = computed(() => (this.range() ? this.lowPercent() : 0));\n protected readonly fillWidth = computed(() =>\n this.range() ? this.highPercent() - this.lowPercent() : this.lowPercent()\n );\n\n /** The marks inside the bounds, in value order: what is drawn and what `snapToMarks` walks. */\n protected readonly visibleMarks = computed(() =>\n this.marks()\n .filter(mark => mark.value >= this.minValue() && mark.value <= this.maxValue())\n .sort((a, b) => a.value - b.value)\n .map(mark => ({ ...mark, percent: this.percentOf(mark.value) }))\n );\n protected readonly labelledMarks = computed(() => this.visibleMarks().filter(mark => !!mark.label));\n\n private readonly snapping = computed(() => this.snapToMarks() && this.visibleMarks().length > 0);\n\n /**\n * `aria-valuetext` of the lower thumb: the label of the mark it stands on,\n * else `labelWith`, else `null` so the number announces as is.\n */\n protected readonly lowText = computed<string | null>(() => this.textOf(this.low()));\n /** `aria-valuetext` of the upper thumb, see {@link lowText}. */\n protected readonly highText = computed<string | null>(() => this.textOf(this.high()));\n\n /** Where the value label sits along a vertical track: beside the thumb, or midway between two. */\n protected readonly labelPercent = computed(() =>\n this.range() ? (this.lowPercent() + this.highPercent()) / 2 : this.lowPercent()\n );\n\n protected readonly label = computed(() => {\n const low = this.lowText() ?? `${this.low()}`;\n return this.range() ? `${low} – ${this.highText() ?? this.high()}` : low;\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('slider');\n // Keep the internal thumbs in sync with external writes to `value`\n // (the old `writeValue`): split the tuple / clamp into the low & high cells.\n // The cells are clamped and the MODEL IS NOT TOUCHED, and the asymmetry is\n // deliberate. A thumb cannot render outside its own track, so the display\n // has no choice — but writing that clamp back into `value` would erase the\n // error it represents: under `[formField]` the bounds reach this component\n // only through the schema's `min()` / `max()` rules (binding `[min]` beside\n // `[formField]` is an NG8022 compile error), so the write-back deleted the\n // out-of-range value those rules exist to report, and marked a pristine\n // form dirty on first paint besides. The first real interaction emits an\n // in-range number through `emitChange` and the two agree from then on.\n effect(() => {\n const v = this.value();\n\n if (Array.isArray(v)) {\n const tuple = v as readonly [number, number];\n const a = this.clampToBounds(tuple[0]);\n const b = this.clampToBounds(tuple[1]);\n // ORDERED, and only for the display — the same asymmetry as the clamp\n // above, for the same reason. An external `[80, 20]` used to seed\n // `low = 80` and `high = 20`, which made each thumb report an\n // `aria-valuenow` outside its OWN `aria-valuemin`/`aria-valuemax` (the\n // two bound each other), and left the fill with a start and no width,\n // so a range that is real simply vanished.\n //\n // This does not contradict the recorded contract that an edit to one\n // end is never reordered: that one is scoped to \"while the user is\n // still on it\", and ordering settles when the interaction ends. An\n // external write IS the end — there is no interaction in progress.\n const lo = Math.min(a, b);\n const hi = Math.max(a, b);\n this.low.set(lo);\n this.high.set(hi);\n this.highSeeded = true;\n return;\n }\n\n if (typeof v !== 'number') return;\n const lo = this.clampToBounds(v);\n this.low.set(lo);\n\n if (!this.range()) return;\n\n // Range mode holding a scalar: the high thumb has never been told\n // anything, and its literal default is not inside every `[min, max]`.\n // Seed it at the top of the range — which is what the 100 meant back when\n // the bounds were 0–100. The MODEL is left alone here too; the shape it\n // holds is the consumer's business until they move a thumb.\n this.high.set(this.highSeeded ? this.clampToBounds(untracked(this.high)) : this.maxValue());\n this.highSeeded = true;\n });\n }\n\n /**\n * Focus the slider — what Signal Forms calls to focus this control, from\n * `focusBoundControl()`. The host carries no tab stop, so the call goes to\n * the thumb, and in range mode to the LOWER one: the first in the tab order,\n * and the one that carries the field's id and error description.\n */\n focus(options?: FocusOptions): void {\n this.lowThumb().nativeElement.focus(options);\n }\n\n // Interaction\n\n protected onPointerDown(event: PointerEvent, thumb: 'low' | 'high'): void {\n this.startDrag(event, event.currentTarget as HTMLElement, thumb);\n }\n\n protected onTrackPointerDown(event: PointerEvent): void {\n if (this.disabled() || this.readonly() || !this.isPrimaryPress(event)) return;\n if ((event.target as HTMLElement).closest('.wr-slider__thumb')) return;\n const thumb = this.nearestThumb(event);\n const el = this.track().nativeElement.querySelector<HTMLElement>(`.wr-slider__thumb--${thumb}`);\n if (el) this.startDrag(event, el, thumb);\n }\n\n /** Primary button of the primary pointer: a right-click or a second finger starts nothing. */\n private isPrimaryPress(event: PointerEvent): boolean {\n return event.button === 0 && event.isPrimary !== false;\n }\n\n private startDrag(event: PointerEvent, target: HTMLElement, thumb: 'low' | 'high'): void {\n if (this.disabled() || this.readonly() || !this.isPrimaryPress(event)) return;\n event.preventDefault();\n target.setPointerCapture?.(event.pointerId);\n // `preventDefault` above also suppresses the default focus, so the arrows\n // did nothing after a mouse drag until the thumb was found again with Tab.\n target.focus();\n\n const move = (e: PointerEvent): void => {\n if (e.pointerId !== event.pointerId) return;\n if (this.disabled() || this.readonly()) return;\n this.updateFromEvent(e, thumb);\n };\n const cleanup = (e: PointerEvent): void => {\n if (e.pointerId !== event.pointerId) return;\n target.releasePointerCapture?.(e.pointerId);\n target.removeEventListener('pointermove', move);\n target.removeEventListener('pointerup', cleanup);\n target.removeEventListener('pointercancel', cleanup);\n this.touch.emit();\n };\n\n target.addEventListener('pointermove', move);\n target.addEventListener('pointerup', cleanup);\n // `pointercancel` is never followed by a `pointerup`, so without this the\n // move listener outlived the drag: the thumb kept following a pointer that\n // was merely hovering over it, with no button held.\n target.addEventListener('pointercancel', cleanup);\n this.updateFromEvent(event, thumb);\n }\n\n protected onKey(event: KeyboardEvent, thumb: 'low' | 'high'): void {\n if (this.disabled() || this.readonly()) return;\n const big = event.shiftKey || event.key === 'PageUp' || event.key === 'PageDown' ? 10 : 1;\n const delta = this.step() * big;\n const current = thumb === 'low' ? this.low() : this.high();\n // The horizontal arrows name a SIDE of the track, so they follow the\n // reading direction; every other key names a value and does not. A\n // vertical track has no inline side to name.\n const inline = this.isRtl() && !this.vertical() ? -1 : 1;\n let direction = 0;\n let next: number | null = null;\n\n switch (event.key) {\n case 'ArrowRight':\n direction = inline;\n break;\n case 'ArrowLeft':\n direction = -inline;\n break;\n case 'ArrowUp':\n case 'PageUp':\n direction = 1;\n break;\n case 'ArrowDown':\n case 'PageDown':\n direction = -1;\n break;\n case 'Home':\n next = this.minValue();\n break;\n case 'End':\n next = this.maxValue();\n break;\n }\n\n if (direction) next = this.snapping() ? this.adjacentMark(current, direction) : current + direction * delta;\n if (next === null) return;\n event.preventDefault();\n this.setThumb(thumb, next);\n this.emitChange();\n this.touch.emit();\n }\n\n /**\n * A bound field learns it may show its validation copy from `touch`, and\n * pointer-up plus a value-changing keypress cannot be the only sources: a\n * slider tabbed into and out of without an arrow press left the field\n * untouched forever — which is exactly the case `touched` exists for, and\n * what this output has always documented itself as doing. `wr-knob` and\n * `wr-rating` bind `(blur)` on the one element they own; this component has\n * two thumbs, so it listens for the bubbling `focusout` on its host instead\n * — and ignores the one that only moves focus from one thumb to the other.\n */\n protected onFocusOut(event: FocusEvent): void {\n if (this.track().nativeElement.contains(event.relatedTarget as Node | null)) return;\n this.touch.emit();\n }\n\n // Internals\n\n private isRtl(): boolean {\n return this.dir?.value === 'rtl';\n }\n\n /**\n * The value under a pointer, measured along the track's INLINE axis, or up\n * from its bottom edge when vertical.\n *\n * The offset is taken from whichever edge the track starts at — the left one\n * in LTR, the right one in RTL — so the whole component needs the direction\n * in exactly one place. Measuring from `rect.left` regardless would read 0 at\n * the visual maximum of a mirrored track.\n */\n private valueAt(event: PointerEvent): number {\n const rect = this.track().nativeElement.getBoundingClientRect();\n const inline = this.isRtl() ? rect.right - event.clientX : event.clientX - rect.left;\n const ratio = wrClamp(this.vertical() ? (rect.bottom - event.clientY) / rect.height : inline / rect.width, 0, 1);\n return this.minValue() + ratio * (this.maxValue() - this.minValue());\n }\n\n private updateFromEvent(event: PointerEvent, thumb: 'low' | 'high'): void {\n this.setThumb(thumb, this.valueAt(event));\n this.emitChange();\n }\n\n /**\n * Which thumb a track click grabs: the one nearest the pointer ON SCREEN.\n *\n * Value distance is the same thing as visual distance once {@link valueAt}\n * has mirrored the ratio — in RTL the low thumb is the RIGHT one, and a click\n * near the right edge lands close to `low` in value space too.\n */\n private nearestThumb(event: PointerEvent): 'low' | 'high' {\n if (!this.range()) return 'low';\n const raw = this.valueAt(event);\n return Math.abs(raw - this.low()) <= Math.abs(raw - this.high()) ? 'low' : 'high';\n }\n\n private setThumb(thumb: 'low' | 'high', raw: number): void {\n const stepped = this.snap(raw);\n if (thumb === 'low') {\n const next = this.range() ? Math.min(stepped, this.high()) : stepped;\n this.low.set(next);\n } else {\n this.high.set(Math.max(stepped, this.low()));\n }\n }\n\n private snap(value: number): number {\n if (this.snapping()) return this.nearestMark(value);\n const stepped = Math.round((value - this.minValue()) / this.step()) * this.step() + this.minValue();\n return this.clampToBounds(wrRound(stepped, 6));\n }\n\n private nearestMark(value: number): number {\n return this.visibleMarks().reduce((best, mark) =>\n Math.abs(mark.value - value) < Math.abs(best.value - value) ? mark : best\n ).value;\n }\n\n /** The next mark above or below `value`; `value` itself when there is none, which `snap` then settles. */\n private adjacentMark(value: number, direction: number): number {\n const marks = this.visibleMarks();\n const next =\n direction > 0 ? marks.find(mark => mark.value > value) : [...marks].reverse().find(mark => mark.value < value);\n return next?.value ?? value;\n }\n\n private textOf(value: number): string | null {\n const mark = this.labelledMarks().find(({ value: at }) => at === value);\n return mark?.label ?? this.labelWith()?.(value) ?? null;\n }\n\n protected isActiveMark(value: number): boolean {\n return this.range() ? value >= this.low() && value <= this.high() : value <= this.low();\n }\n\n private clampToBounds(v: number): number {\n return wrClamp(v, this.minValue(), this.maxValue());\n }\n\n private percentOf(v: number): number {\n const span = this.maxValue() - this.minValue();\n if (span <= 0) return 0;\n return ((v - this.minValue()) / span) * 100;\n }\n\n private emitChange(): void {\n const value: WrSliderValue = this.range() ? [this.low(), this.high()] : this.low();\n this.value.set(value);\n }\n}\n","<div #track class=\"wr-slider__track\" (pointerdown)=\"onTrackPointerDown($event)\">\n <!--\n Positioned on the INLINE axis, not with `left`: `inset-inline-start` is the\n same edge in LTR and mirrors under `dir=\"rtl\"`, so the track paints itself\n the right way round without the component reading a direction to draw.\n A vertical track measures every part up from `bottom` instead.\n -->\n <span\n class=\"wr-slider__fill\"\n [style.inset-inline-start.%]=\"vertical() ? null : fillStart()\"\n [style.width.%]=\"vertical() ? null : fillWidth()\"\n [style.bottom.%]=\"vertical() ? fillStart() : null\"\n [style.height.%]=\"vertical() ? fillWidth() : null\"\n ></span>\n\n @for (mark of visibleMarks(); track $index) {\n <span\n class=\"wr-slider__mark\"\n [class.wr-slider__mark--active]=\"isActiveMark(mark.value)\"\n [attr.data-value]=\"mark.value\"\n [style.inset-inline-start.%]=\"vertical() ? null : mark.percent\"\n [style.bottom.%]=\"vertical() ? mark.percent : null\"\n ></span>\n }\n\n <button\n #lowThumb\n type=\"button\"\n class=\"wr-slider__thumb wr-slider__thumb--low\"\n role=\"slider\"\n [attr.id]=\"thumbId()\"\n [style.inset-inline-start.%]=\"vertical() ? null : lowPercent()\"\n [style.bottom.%]=\"vertical() ? lowPercent() : null\"\n [disabled]=\"disabled()\"\n [attr.aria-valuemin]=\"min()\"\n [attr.aria-valuemax]=\"range() ? high() : max()\"\n [attr.aria-valuenow]=\"low()\"\n [attr.aria-valuetext]=\"lowText()\"\n [attr.aria-orientation]=\"vertical() ? 'vertical' : null\"\n [attr.aria-label]=\"lowNameLabel()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.aria-invalid]=\"ariaInvalid()\"\n (pointerdown)=\"onPointerDown($event, 'low')\"\n (keydown)=\"onKey($event, 'low')\"\n ></button>\n\n @if (range()) {\n <button\n type=\"button\"\n class=\"wr-slider__thumb wr-slider__thumb--high\"\n role=\"slider\"\n [style.inset-inline-start.%]=\"vertical() ? null : highPercent()\"\n [style.bottom.%]=\"vertical() ? highPercent() : null\"\n [disabled]=\"disabled()\"\n [attr.aria-valuemin]=\"low()\"\n [attr.aria-valuemax]=\"max()\"\n [attr.aria-valuenow]=\"high()\"\n [attr.aria-valuetext]=\"highText()\"\n [attr.aria-orientation]=\"vertical() ? 'vertical' : null\"\n [attr.aria-label]=\"resolvedUpperLabel()\"\n [attr.aria-readonly]=\"readonly() || null\"\n (pointerdown)=\"onPointerDown($event, 'high')\"\n (keydown)=\"onKey($event, 'high')\"\n ></button>\n }\n</div>\n\n@if (labelledMarks().length) {\n <!-- Hidden from assistive tech: the thumb announces the label of the mark it stands on. -->\n <div class=\"wr-slider__mark-labels\" aria-hidden=\"true\">\n @for (mark of labelledMarks(); track $index) {\n <span\n class=\"wr-slider__mark-label\"\n [attr.data-value]=\"mark.value\"\n [style.inset-inline-start.%]=\"vertical() ? null : mark.percent\"\n [style.bottom.%]=\"vertical() ? mark.percent : null\"\n >{{ mark.label }}</span\n >\n }\n </div>\n}\n\n@if (showValue()) {\n <div class=\"wr-slider__label\" [style.bottom.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AAA,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { Component, ElementRef, ViewEncapsulation, computed, effect, inject, input, model, output, viewChild } from "@angular/core";
|
|
2
|
+
import { Component, ElementRef, ViewEncapsulation, afterRenderEffect, computed, effect, inject, input, model, output, viewChild } from "@angular/core";
|
|
3
3
|
import { coerceBooleanProperty } from "@angular/cdk/coercion";
|
|
4
4
|
import { wrCheckStyles } from "ngwr/utils";
|
|
5
5
|
import { useI18nText } from "ngwr/i18n";
|
|
@@ -26,6 +26,10 @@ var WrSpeedDial = class WrSpeedDial {
|
|
|
26
26
|
...ngDevMode ? { debugName: "safeArea" } : /* istanbul ignore next */ {},
|
|
27
27
|
transform: coerceBooleanProperty
|
|
28
28
|
});
|
|
29
|
+
closeOnOutsideClick = input(false, {
|
|
30
|
+
...ngDevMode ? { debugName: "closeOnOutsideClick" } : /* istanbul ignore next */ {},
|
|
31
|
+
transform: coerceBooleanProperty
|
|
32
|
+
});
|
|
29
33
|
pick = output();
|
|
30
34
|
menuId = `wr-speed-dial-menu-${++menuUid}`;
|
|
31
35
|
triggerEl = viewChild("trigger", ...ngDevMode ? [{ debugName: "triggerEl" }] : /* istanbul ignore next */ []);
|
|
@@ -35,6 +39,16 @@ var WrSpeedDial = class WrSpeedDial {
|
|
|
35
39
|
effect(() => {
|
|
36
40
|
if (this.disabled() && this.open()) this.open.set(false);
|
|
37
41
|
});
|
|
42
|
+
afterRenderEffect((onCleanup) => {
|
|
43
|
+
if (!this.open() || !this.closeOnOutsideClick()) return;
|
|
44
|
+
const doc = this.host.nativeElement.ownerDocument;
|
|
45
|
+
const onDown = (event) => {
|
|
46
|
+
if (event.composedPath().includes(this.host.nativeElement)) return;
|
|
47
|
+
this.open.set(false);
|
|
48
|
+
};
|
|
49
|
+
doc.addEventListener("pointerdown", onDown, true);
|
|
50
|
+
onCleanup(() => doc.removeEventListener("pointerdown", onDown, true));
|
|
51
|
+
});
|
|
38
52
|
}
|
|
39
53
|
classes = computed(() => {
|
|
40
54
|
const parts = [`wr-speed-dial--${this.direction()}`];
|
|
@@ -125,6 +139,13 @@ var WrSpeedDial = class WrSpeedDial {
|
|
|
125
139
|
isSignal: true,
|
|
126
140
|
isRequired: false,
|
|
127
141
|
transformFunction: null
|
|
142
|
+
},
|
|
143
|
+
closeOnOutsideClick: {
|
|
144
|
+
classPropertyName: "closeOnOutsideClick",
|
|
145
|
+
publicName: "closeOnOutsideClick",
|
|
146
|
+
isSignal: true,
|
|
147
|
+
isRequired: false,
|
|
148
|
+
transformFunction: null
|
|
128
149
|
}
|
|
129
150
|
},
|
|
130
151
|
outputs: {
|
|
@@ -234,6 +255,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
234
255
|
required: false
|
|
235
256
|
}]
|
|
236
257
|
}],
|
|
258
|
+
closeOnOutsideClick: [{
|
|
259
|
+
type: i0.Input,
|
|
260
|
+
args: [{
|
|
261
|
+
isSignal: true,
|
|
262
|
+
alias: "closeOnOutsideClick",
|
|
263
|
+
required: false
|
|
264
|
+
}]
|
|
265
|
+
}],
|
|
237
266
|
pick: [{
|
|
238
267
|
type: i0.Output,
|
|
239
268
|
args: ["pick"]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-speed-dial.mjs","names":[],"sources":["../../../projects/lib/speed-dial/speed-dial.ts","../../../projects/lib/speed-dial/speed-dial.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n ElementRef,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n viewChild,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { WrIcon, type WrIconName } from 'ngwr/icon';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrSpeedDialAction, WrSpeedDialDirection } from './types';\n\nlet menuUid = 0;\n\n/**\n * Floating action button that expands into a fan of secondary actions on click.\n * Place inside a positioned container or near `position: fixed` — the component\n * itself doesn't pin to the viewport.\n *\n * @example\n * ```html\n * <wr-speed-dial\n * [actions]=\"[\n * { id: 'new', label: 'New', icon: 'add' },\n * { id: 'edit', label: 'Edit', icon: 'cog' }\n * ]\"\n * (pick)=\"onPick($event)\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/speed-dial\n */\n@Component({\n selector: 'wr-speed-dial',\n templateUrl: './speed-dial.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-speed-dial', '[class]': 'classes()', '(keydown)': 'onKeydown($event)' },\n imports: [WrIcon],\n})\nexport class WrSpeedDial {\n /**\n * The buttons that fan out when the dial opens, in order from the trigger\n * outwards. Each needs a label: it is the accessible name as well as the tooltip.\n */\n readonly actions = input<readonly WrSpeedDialAction[]>([]);\n\n /**\n * Accessible name of the trigger. Falls back to `speedDial.label`, then\n * `'Actions'` — the trigger is icon-only, so without this it has no name at all.\n */\n readonly triggerLabel = input<string | null>(null);\n\n protected readonly resolvedTriggerLabel = useI18nText(this.triggerLabel, 'speedDial.label', 'Actions');\n\n /** Direction the actions fan out. @default 'up' */\n readonly direction = input<WrSpeedDialDirection>('up');\n\n /** Two-way bindable open state. @default false */\n readonly open = model(false);\n\n /** Icon for the main trigger button. @default 'add' */\n readonly icon = input<WrIconName>('add');\n\n /** Disable interaction. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Pad the host toward the dial `direction` with `env(safe-area-inset-*)`.\n * Only matters when the consumer pins the dial to that edge of the\n * viewport; otherwise it has no effect. @default false\n */\n readonly safeArea = input(false, { transform: coerceBooleanProperty });\n\n /** Fires when the user picks one of the actions. */\n readonly pick = output<WrSpeedDialAction>();\n\n /** Id the trigger's `aria-controls` points at. */\n protected readonly menuId = `wr-speed-dial-menu-${++menuUid}`;\n\n protected readonly triggerEl = viewChild<ElementRef<HTMLButtonElement>>('trigger');\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('speed-dial');\n // A disabled trigger cannot be pressed, and the trigger is the only way to close\n // the dial — so being disabled while open left it fanned out with no way back.\n effect(() => {\n if (this.disabled() && this.open()) this.open.set(false);\n });\n }\n\n protected readonly classes = computed(() => {\n const parts = [`wr-speed-dial--${this.direction()}`];\n if (this.open()) parts.push('wr-speed-dial--open');\n if (this.disabled()) parts.push('wr-speed-dial--disabled');\n if (this.safeArea()) parts.push('wr-speed-dial--safe-area');\n return parts.join(' ');\n });\n\n protected onTrigger(): void {\n if (this.disabled()) return;\n this.open.update(v => !v);\n }\n\n protected onPick(action: WrSpeedDialAction): void {\n if (this.disabled()) return;\n this.open.set(false);\n // Take the focus back before the action goes — the collapsed wrapper turns\n // `visibility: hidden`, and a browser blurs an element it hides, so the caret\n // landed on `<body>` and the next Tab restarted at the top of the document.\n // Escape already did this; the SUCCESS path did not.\n //\n // Before the emit, not after: `pick` is where a consumer opens a dialog or\n // navigates, and such a handler moves focus itself — focusing afterwards would\n // yank the caret back onto the trigger. `wr-dropdown` sequences it the same way.\n //\n // Only when the caret is inside the dial: Safari does not focus a button on\n // mouse-down, so an unguarded call would steal it from wherever the user is.\n if (this.host.nativeElement.contains(this.host.nativeElement.ownerDocument.activeElement)) {\n this.triggerEl()?.nativeElement.focus();\n }\n this.pick.emit(action);\n }\n\n /**\n * Escape closes the dial and hands the caret back. The actions are ordinary buttons\n * in the tab order, so without this a keyboard user who opened the dial had to tab\n * through every action to leave it.\n */\n protected onKeydown(event: KeyboardEvent): void {\n if (event.key !== 'Escape' || !this.open()) return;\n event.preventDefault();\n this.open.set(false);\n this.triggerEl()?.nativeElement.focus();\n }\n\n /**\n * First GLYPH of the label, for an action with no icon. `charAt(0)` returns one\n * UTF-16 code unit, which cuts an astral character (an emoji) in half and renders a\n * replacement character.\n */\n protected initial(label: string): string {\n return [...label][0] ?? '';\n }\n}\n\nexport type { WrSpeedDialAction, WrSpeedDialDirection } from './types';\n","<button\n #trigger\n type=\"button\"\n class=\"wr-speed-dial__trigger\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"menuId\"\n [attr.aria-label]=\"resolvedTriggerLabel()\"\n [disabled]=\"disabled()\"\n (click)=\"onTrigger()\"\n>\n <wr-icon [name]=\"icon()\" />\n</button>\n\n<!--\n A LIST of buttons, deliberately not a `role=\"menu\"`. The dial used to announce\n aria-haspopup=\"menu\" over role=\"menuitem\" buttons while handling no menu key at\n all — no arrows, no Home/End, no focus moving in on open — and the actions were\n N tab stops rather than the pattern's one. That role also puts a screen reader\n into focus mode, so the arrow keys it promises stop reading the page and then do\n nothing here. The structure now says what the component does: a disclosure\n button (aria-expanded / aria-controls) revealing ordinary buttons that Tab\n reaches and Enter activates, with Escape as the way back.\n\n `role=\"list\"` is written out because `list-style: none` (styles/_index.scss)\n drops the implicit list semantics in Safari.\n-->\n<ul class=\"wr-speed-dial__actions\" role=\"list\" [attr.id]=\"menuId\">\n @for (action of actions(); track action.id) {\n <li class=\"wr-speed-dial__action-wrap\" [style.--wr-speed-dial-i]=\"$index + 1\">\n <button\n type=\"button\"\n class=\"wr-speed-dial__action\"\n [attr.aria-label]=\"action.label\"\n [title]=\"action.label\"\n [disabled]=\"disabled()\"\n (click)=\"onPick(action)\"\n >\n @if (action.icon) {\n <wr-icon [name]=\"action.icon\" />\n } @else {\n <span>{{ initial(action.label) }}</span>\n }\n </button>\n </li>\n }\n</ul>\n"],"mappings":";;;;;;;;;;;;AA2BA,IAAI,UAAU;AA2Bd,IAAa,cAAb,MAAa,YAAW;CAKb,UAAU,MAAoC,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAMjD,eAAe,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,eAAA,CAAA,+BAAA,CAAA,C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GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,YAAA;EAAA,CAAA;EAAA,MAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,MAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,MAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,WAAS,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-speed-dial.mjs","names":[],"sources":["../../../projects/lib/speed-dial/speed-dial.ts","../../../projects/lib/speed-dial/speed-dial.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n ElementRef,\n ViewEncapsulation,\n afterRenderEffect,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n viewChild,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { WrIcon, type WrIconName } from 'ngwr/icon';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrSpeedDialAction, WrSpeedDialDirection } from './types';\n\nlet menuUid = 0;\n\n/**\n * Floating action button that expands into a fan of secondary actions on click.\n * Place inside a positioned container or near `position: fixed` — the component\n * itself doesn't pin to the viewport.\n *\n * @example\n * ```html\n * <wr-speed-dial\n * [actions]=\"[\n * { id: 'new', label: 'New', icon: 'add' },\n * { id: 'edit', label: 'Edit', icon: 'cog' }\n * ]\"\n * (pick)=\"onPick($event)\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/speed-dial\n */\n@Component({\n selector: 'wr-speed-dial',\n templateUrl: './speed-dial.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-speed-dial', '[class]': 'classes()', '(keydown)': 'onKeydown($event)' },\n imports: [WrIcon],\n})\nexport class WrSpeedDial {\n /**\n * The buttons that fan out when the dial opens, in order from the trigger\n * outwards. Each needs a label: it is the accessible name as well as the tooltip.\n */\n readonly actions = input<readonly WrSpeedDialAction[]>([]);\n\n /**\n * Accessible name of the trigger. Falls back to `speedDial.label`, then\n * `'Actions'` — the trigger is icon-only, so without this it has no name at all.\n */\n readonly triggerLabel = input<string | null>(null);\n\n protected readonly resolvedTriggerLabel = useI18nText(this.triggerLabel, 'speedDial.label', 'Actions');\n\n /** Direction the actions fan out. @default 'up' */\n readonly direction = input<WrSpeedDialDirection>('up');\n\n /** Two-way bindable open state. @default false */\n readonly open = model(false);\n\n /** Icon for the main trigger button. @default 'add' */\n readonly icon = input<WrIconName>('add');\n\n /** Disable interaction. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Pad the host toward the dial `direction` with `env(safe-area-inset-*)`.\n * Only matters when the consumer pins the dial to that edge of the\n * viewport; otherwise it has no effect. @default false\n */\n readonly safeArea = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Close the open dial on a pointer press outside it. Focus stays where the\n * user clicked. @default false\n */\n readonly closeOnOutsideClick = input(false, { transform: coerceBooleanProperty });\n\n /** Fires when the user picks one of the actions. */\n readonly pick = output<WrSpeedDialAction>();\n\n /** Id the trigger's `aria-controls` points at. */\n protected readonly menuId = `wr-speed-dial-menu-${++menuUid}`;\n\n protected readonly triggerEl = viewChild<ElementRef<HTMLButtonElement>>('trigger');\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('speed-dial');\n // A disabled trigger cannot be pressed, and the trigger is the only way to close\n // the dial — so being disabled while open left it fanned out with no way back.\n effect(() => {\n if (this.disabled() && this.open()) this.open.set(false);\n });\n // After render only: there is no document to listen on the server.\n afterRenderEffect(onCleanup => {\n if (!this.open() || !this.closeOnOutsideClick()) return;\n const doc = this.host.nativeElement.ownerDocument;\n const onDown = (event: Event): void => {\n // The path, not the target: an open shadow root retargets the event to its host.\n if (event.composedPath().includes(this.host.nativeElement)) return;\n this.open.set(false);\n };\n doc.addEventListener('pointerdown', onDown, true);\n onCleanup(() => doc.removeEventListener('pointerdown', onDown, true));\n });\n }\n\n protected readonly classes = computed(() => {\n const parts = [`wr-speed-dial--${this.direction()}`];\n if (this.open()) parts.push('wr-speed-dial--open');\n if (this.disabled()) parts.push('wr-speed-dial--disabled');\n if (this.safeArea()) parts.push('wr-speed-dial--safe-area');\n return parts.join(' ');\n });\n\n protected onTrigger(): void {\n if (this.disabled()) return;\n this.open.update(v => !v);\n }\n\n protected onPick(action: WrSpeedDialAction): void {\n if (this.disabled()) return;\n this.open.set(false);\n // Take the focus back before the action goes — the collapsed wrapper turns\n // `visibility: hidden`, and a browser blurs an element it hides, so the caret\n // landed on `<body>` and the next Tab restarted at the top of the document.\n // Escape already did this; the SUCCESS path did not.\n //\n // Before the emit, not after: `pick` is where a consumer opens a dialog or\n // navigates, and such a handler moves focus itself — focusing afterwards would\n // yank the caret back onto the trigger. `wr-dropdown` sequences it the same way.\n //\n // Only when the caret is inside the dial: Safari does not focus a button on\n // mouse-down, so an unguarded call would steal it from wherever the user is.\n if (this.host.nativeElement.contains(this.host.nativeElement.ownerDocument.activeElement)) {\n this.triggerEl()?.nativeElement.focus();\n }\n this.pick.emit(action);\n }\n\n /**\n * Escape closes the dial and hands the caret back. The actions are ordinary buttons\n * in the tab order, so without this a keyboard user who opened the dial had to tab\n * through every action to leave it.\n */\n protected onKeydown(event: KeyboardEvent): void {\n if (event.key !== 'Escape' || !this.open()) return;\n event.preventDefault();\n this.open.set(false);\n this.triggerEl()?.nativeElement.focus();\n }\n\n /**\n * First GLYPH of the label, for an action with no icon. `charAt(0)` returns one\n * UTF-16 code unit, which cuts an astral character (an emoji) in half and renders a\n * replacement character.\n */\n protected initial(label: string): string {\n return [...label][0] ?? '';\n }\n}\n\nexport type { WrSpeedDialAction, WrSpeedDialDirection } from './types';\n","<button\n #trigger\n type=\"button\"\n class=\"wr-speed-dial__trigger\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"menuId\"\n [attr.aria-label]=\"resolvedTriggerLabel()\"\n [disabled]=\"disabled()\"\n (click)=\"onTrigger()\"\n>\n <wr-icon [name]=\"icon()\" />\n</button>\n\n<!--\n A LIST of buttons, deliberately not a `role=\"menu\"`. The dial used to announce\n aria-haspopup=\"menu\" over role=\"menuitem\" buttons while handling no menu key at\n all — no arrows, no Home/End, no focus moving in on open — and the actions were\n N tab stops rather than the pattern's one. That role also puts a screen reader\n into focus mode, so the arrow keys it promises stop reading the page and then do\n nothing here. The structure now says what the component does: a disclosure\n button (aria-expanded / aria-controls) revealing ordinary buttons that Tab\n reaches and Enter activates, with Escape as the way back.\n\n `role=\"list\"` is written out because `list-style: none` (styles/_index.scss)\n drops the implicit list semantics in Safari.\n-->\n<ul class=\"wr-speed-dial__actions\" role=\"list\" [attr.id]=\"menuId\">\n @for (action of actions(); track action.id) {\n <li class=\"wr-speed-dial__action-wrap\" [style.--wr-speed-dial-i]=\"$index + 1\">\n <button\n type=\"button\"\n class=\"wr-speed-dial__action\"\n [attr.aria-label]=\"action.label\"\n [title]=\"action.label\"\n [disabled]=\"disabled()\"\n (click)=\"onPick(action)\"\n >\n @if (action.icon) {\n <wr-icon [name]=\"action.icon\" />\n } @else {\n <span>{{ initial(action.label) }}</span>\n }\n </button>\n </li>\n }\n</ul>\n"],"mappings":";;;;;;;;;;;;AA4BA,IAAI,UAAU;AA2Bd,IAAa,cAA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AA,CAAA;EAAA,MAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,MAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,WAAS,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -5,8 +5,8 @@ import { isPlatformBrowser } from "@angular/common";
|
|
|
5
5
|
import { wrCheckStyles, wrNumAttr } from "ngwr/utils";
|
|
6
6
|
import { useI18nFormatter, useI18nText } from "ngwr/i18n";
|
|
7
7
|
import { WrPlatform } from "ngwr/platform";
|
|
8
|
-
import { WrCountUp } from "ngwr/counter";
|
|
9
8
|
import { wrSplitDuration } from "ngwr/pipes";
|
|
9
|
+
import { WrCountUp } from "ngwr/counter";
|
|
10
10
|
/**
|
|
11
11
|
* @license
|
|
12
12
|
*
|
|
@@ -17,7 +17,7 @@ function wrStepperHarnessText(text) {
|
|
|
17
17
|
var WrStepHarness = class WrStepHarness extends ComponentHarness {
|
|
18
18
|
static hostSelector = ".wr-stepper__header";
|
|
19
19
|
static with(options = {}) {
|
|
20
|
-
return new HarnessPredicate(WrStepHarness, options).addOption("label", options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label)).addOption("active", options.active, async (harness, active) => await harness.isActive() === active).addOption("completed", options.completed, async (harness, completed) => await harness.isCompleted() === completed).addOption("disabled", options.disabled, async (harness, disabled) => await harness.isDisabled() === disabled).addOption("reachable", options.reachable, async (harness, reachable) => await harness.isReachable() === reachable).addOption("optional", options.optional, async (harness, optional) => await harness.isOptional() === optional);
|
|
20
|
+
return new HarnessPredicate(WrStepHarness, options).addOption("label", options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label)).addOption("active", options.active, async (harness, active) => await harness.isActive() === active).addOption("completed", options.completed, async (harness, completed) => await harness.isCompleted() === completed).addOption("disabled", options.disabled, async (harness, disabled) => await harness.isDisabled() === disabled).addOption("reachable", options.reachable, async (harness, reachable) => await harness.isReachable() === reachable).addOption("optional", options.optional, async (harness, optional) => await harness.isOptional() === optional).addOption("status", options.status, async (harness, status) => await harness.getStatus() === status);
|
|
21
21
|
}
|
|
22
22
|
button = this.locatorFor("button.wr-stepper__header-button");
|
|
23
23
|
async getLabel() {
|
|
@@ -39,6 +39,12 @@ var WrStepHarness = class WrStepHarness extends ComponentHarness {
|
|
|
39
39
|
async isCompleted() {
|
|
40
40
|
return (await this.host()).hasClass("wr-stepper__header--completed");
|
|
41
41
|
}
|
|
42
|
+
async getStatus() {
|
|
43
|
+
const host = await this.host();
|
|
44
|
+
if (await host.hasClass("wr-stepper__header--error")) return "error";
|
|
45
|
+
if (await host.hasClass("wr-stepper__header--warning")) return "warning";
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
42
48
|
async isDisabled() {
|
|
43
49
|
return (await this.host()).hasClass("wr-stepper__header--disabled");
|
|
44
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-stepper-testing.mjs","names":[],"sources":["../../../projects/lib/stepper/testing/wr-stepper-harness-text.ts","../../../projects/lib/stepper/testing/wr-step-harness.ts","../../../projects/lib/stepper/testing/wr-stepper-harness.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\n/**\n * Collapse the whitespace inside a header or a step body to the line a user reads.\n *\n * `TestElement.text()` only trims the ends, and neither of the two things read here\n * is one text node: a header's label span holds the label, the \"optional\" badge and\n * the description as siblings, and a step body is whatever the consumer projected.\n * The template's own indentation is not the problem — Angular's default\n * `preserveWhitespaces: false` drops whitespace-only text nodes at compile time —\n * but a value carrying a newline is, and so is a consumer app compiled with\n * `preserveWhitespaces: true`. Every run becomes one space so a spec can assert the\n * rendered line either way.\n */\nexport function wrStepperHarnessText(text: string): string {\n return text.replace(/\\s+/g, ' ').trim();\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrStepHarnessFilters } from './types';\nimport { wrStepperHarnessText } from './wr-stepper-harness-text';\n\n/**\n * Test harness for one step of a `<wr-stepper>` — the step as the HEADER STRIP\n * publishes it: its label, its state, and the one control that navigates to it.\n *\n * A step is two pieces of DOM in two different places. The `<wr-step>` the consumer\n * wrote is projected into the stepper's body region; the header this harness hosts on\n * is generated next to it, in the `<ol>` above. Nothing links the two — no\n * `aria-controls`, no id on the body — so `WrStepperHarness.getActiveStepText()` is\n * where the body is read, and this answers what the wizard says about the step.\n *\n * Two states that look alike here are deliberately separate, because the component\n * treats them separately: {@link isDisabled} is the step's own `disabled` input\n * (switched off, whatever else happens), and {@link isReachable} is whether a click\n * would land right now — which a `linear` stepper takes away from every step ahead of\n * the gate without disabling any of them.\n *\n * @example\n * ```ts\n * const [review] = await stepper.getSteps({ label: 'Review' });\n *\n * expect(await review.isOptional()).toBe(true);\n * expect(await review.isReachable()).toBe(false);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrStepHarness extends ComponentHarness {\n /**\n * The header `<li>`, which is the whole step as far as the strip is concerned.\n *\n * Not `.wr-stepper__header-button`: the state modifiers (`--active`, `--completed`,\n * `--disabled`) land on the `<li>`, and the button is a child of it.\n */\n static hostSelector = '.wr-stepper__header';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrStepHarnessFilters = {}): HarnessPredicate<WrStepHarness> {\n return new HarnessPredicate(WrStepHarness, options)\n .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))\n .addOption('active', options.active, async (harness, active) => (await harness.isActive()) === active)\n .addOption(\n 'completed',\n options.completed,\n async (harness, completed) => (await harness.isCompleted()) === completed\n )\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled)\n .addOption(\n 'reachable',\n options.reachable,\n async (harness, reachable) => (await harness.isReachable()) === reachable\n )\n .addOption('optional', options.optional, async (harness, optional) => (await harness.isOptional()) === optional);\n }\n\n private readonly button = this.locatorFor('button.wr-stepper__header-button');\n\n /**\n * The step's label, and only the label.\n *\n * The \"optional\" badge and the description are siblings of the label text inside\n * the same span, so both are excluded — a step addressed by label should be\n * addressable whether or not it also carries a description.\n */\n async getLabel(): Promise<string> {\n const label = await this.locatorFor('.wr-stepper__label')();\n return wrStepperHarnessText(\n await label.text({ exclude: '.wr-stepper__optional, .wr-stepper__description, .wr-stepper__sr-only' })\n );\n }\n\n /** The secondary line under the label, or `null` when the step defines none. */\n async getDescription(): Promise<string | null> {\n const description = await this.locatorForOptional('.wr-stepper__description')();\n return description ? wrStepperHarnessText(await description.text()) : null;\n }\n\n /** Whether the header flags the step as optional. */\n async isOptional(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-stepper__optional')()) !== null;\n }\n\n /**\n * What a screen reader announces for the header button.\n *\n * The indicator is excluded because it is `aria-hidden`: the step number and the\n * completed tick are decoration, deliberately, since the label and\n * `aria-current=\"step\"` already carry what they would repeat. What IS announced is\n * the label plus the \"optional\" badge and the description — so this is the method\n * that notices when one of those stops being part of the name.\n */\n async getAccessibleName(): Promise<string> {\n const button = await this.button();\n return wrStepperHarnessText(await button.text({ exclude: '.wr-stepper__indicator' }));\n }\n\n /**\n * Whether this is the step the wizard is showing.\n *\n * From `aria-current=\"step\"` rather than the `--active` class, because that is the\n * only place the wizard's position is published to a screen reader, and the two can\n * only ever disagree by way of a bug.\n */\n async isActive(): Promise<boolean> {\n return (await (await this.button()).getAttribute('aria-current')) === 'step';\n }\n\n /**\n * Whether the step is shown as done.\n *\n * Read from the `--completed` class, and there is no ARIA alternative to prefer:\n * completion reaches the page as that class plus a tick glyph that is\n * `aria-hidden`, so a screen-reader user hears the label and nothing else. The\n * class is the whole of what exists.\n *\n * Completion is derived from the active index — every step before it — unless a\n * step's own `completed` input overrides it, which is how a `linear` wizard opens\n * its gate. So a step after the active one can be completed too.\n */\n async isCompleted(): Promise<boolean> {\n return (await this.host()).hasClass('wr-stepper__header--completed');\n }\n\n /**\n * Whether the step is switched off by its own `disabled` input.\n *\n * The `--disabled` class is exactly that input, which is why it is read here rather\n * than the button's `disabled`: the button is also disabled for a step that is\n * merely behind a `linear` gate, and those are different facts about the wizard.\n * See {@link isReachable} for the one about right now.\n */\n async isDisabled(): Promise<boolean> {\n return (await this.host()).hasClass('wr-stepper__header--disabled');\n }\n\n /**\n * Whether a click on this header would move the wizard here.\n *\n * Read from the button's `disabled` PROPERTY, because that is the enforcement and\n * not the paint: the component disables the header for a step its own input\n * switched off AND for one a `linear` gate has not opened yet. It is also what puts\n * the header in or out of the tab order — a `disabled` button cannot be focused at\n * all, so an unreachable step is off the keyboard entirely rather than focusable and\n * inert the way `aria-disabled` would leave it.\n */\n async isReachable(): Promise<boolean> {\n return !(await (await this.button()).getProperty<boolean>('disabled'));\n }\n\n /**\n * Navigate to this step by clicking its header, the way a user does.\n *\n * A click, not a keypress: the header is a real `<button>`, so Enter and Space\n * activate it through the browser's native activation — behaviour jsdom does not\n * implement, leaving nothing for a key to drive. A no-arg CDK click needs no\n * coordinate and no hit test, so the absent layout costs nothing here.\n *\n * Throws when the header refuses, rather than clicking and resolving quietly: the\n * component's guard would drop the click and the wizard would still be showing the\n * old step three assertions later. Reach for `WrStepperHarness.goTo()` when you\n * want the failure to name WHICH earlier step is holding the gate shut.\n */\n async select(): Promise<void> {\n if (!(await this.isReachable())) {\n throw new Error(\n `WrStepHarness.select(): the header for \"${await this.getLabel()}\" refuses a click — the step carries ` +\n '`disabled`, or the stepper is `linear` and an earlier step has not reported itself complete.'\n );\n }\n await (await this.button()).click();\n }\n\n /** Move keyboard focus to the header. A header that is not reachable cannot take it. */\n async focus(): Promise<void> {\n return (await this.button()).focus();\n }\n\n /** Whether the header currently has focus. */\n async isFocused(): Promise<boolean> {\n return (await this.button()).isFocused();\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrStepHarnessFilters, WrStepperHarnessFilters } from './types';\nimport { WrStepHarness } from './wr-step-harness';\nimport { wrStepperHarnessText } from './wr-stepper-harness-text';\n\n/**\n * Test harness for `<wr-stepper>` — the root of a two-part family with\n * {@link WrStepHarness}, which is one step of it.\n *\n * Steps are addressed by their index or their LABEL, the two things a consumer can\n * see; there is no key or id on a `<wr-step>` to address it by.\n *\n * Navigation here always goes through the HEADER STRIP, because that is the only\n * control the component renders — a wizard's Next and Back buttons are the\n * consumer's own, and they call `WrStepper.next()` / `prev()`. That distinction is\n * not cosmetic: the imperative API does NOT consult `linear`, so it walks straight\n * past a gate that refuses the equivalent header click. {@link next} and\n * {@link goTo} therefore refuse exactly where a user would be refused, and a spec\n * covering the wizard's own buttons should drive those buttons (through their own\n * harness) instead of these.\n *\n * @example\n * ```ts\n * const wizard = await loader.getHarness(WrStepperHarness);\n *\n * expect(await wizard.getStepLabels()).toEqual(['Account', 'Address', 'Review']);\n * expect(await wizard.canGoTo(2)).toBe(false);\n * await wizard.goToLabel('Address');\n * expect(await wizard.getActiveStepText()).toBe('Address body');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrStepperHarness extends ComponentHarness {\n static hostSelector = 'wr-stepper';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrStepperHarnessFilters = {}): HarnessPredicate<WrStepperHarness> {\n return new HarnessPredicate(WrStepperHarness, options)\n .addOption('stepLabel', options.stepLabel, async (harness, label) => {\n for (const stepLabel of await harness.getStepLabels()) {\n if (await HarnessPredicate.stringMatches(stepLabel, label)) return true;\n }\n return false;\n })\n .addOption(\n 'orientation',\n options.orientation,\n async (harness, orientation) => (await harness.getOrientation()) === orientation\n )\n .addOption('linear', options.linear, async (harness, linear) => (await harness.isLinear()) === linear);\n }\n\n private readonly headerList = this.locatorFor('ol.wr-stepper__headers');\n\n /**\n * The layout direction the stepper was ASKED for.\n *\n * Unusually for this library both values carry a class, so neither is read as the\n * absence of the other. What the class cannot tell you is how the strip actually\n * laid itself out: a `responsive` horizontal stepper drops to the vertical layout\n * when its own box is too narrow, and that reflow is a container query — the class\n * never changes. No unit test can see the difference in any case, jsdom having no\n * layout at all; assert the opt-in with {@link isResponsive} instead.\n */\n async getOrientation(): Promise<'horizontal' | 'vertical'> {\n return (await (await this.host()).hasClass('wr-stepper--vertical')) ? 'vertical' : 'horizontal';\n }\n\n /** Whether the stepper locks the steps after the last completed one. */\n async isLinear(): Promise<boolean> {\n return (await this.host()).hasClass('wr-stepper--linear');\n }\n\n /** Whether the stepper may reflow to the vertical layout in a narrow container. */\n async isResponsive(): Promise<boolean> {\n return (await this.host()).hasClass('wr-stepper--responsive');\n }\n\n /**\n * The role the header strip announces — `list`.\n *\n * An `<ol>` is a list already, so the explicit role looks redundant and is not: the\n * stylesheet removes the markers, and Safari drops list semantics from a list with\n * `list-style: none`. Losing it costs the \"list, 3 items\" a VoiceOver user hears,\n * which is how they learn how long the wizard is before starting it.\n */\n async getListRole(): Promise<string | null> {\n return (await this.headerList()).getAttribute('role');\n }\n\n /** The wizard's steps, in order. */\n async getSteps(filters: WrStepHarnessFilters = {}): Promise<WrStepHarness[]> {\n return this.locatorForAll(WrStepHarness.with(filters))();\n }\n\n /** The label of every step, in order. */\n async getStepLabels(): Promise<string[]> {\n const steps = await this.getSteps();\n return Promise.all(steps.map(step => step.getLabel()));\n }\n\n /**\n * The index of the step the wizard is showing, from the header announcing\n * `aria-current=\"step\"`.\n *\n * Throws when no header does, which is a state a stepper can genuinely be in: one\n * with no `<wr-step>` children renders its (empty) header strip and no body. A `-1`\n * here would be read as \"the first step\" by the next line of a spec. An\n * out-of-range `active` is NOT such a state — `WrStepper` clamps the two-way model\n * back into the step list, not only inside `goTo()`.\n */\n async getActiveIndex(): Promise<number> {\n const steps = await this.getSteps();\n for (let index = 0; index < steps.length; index++) {\n if (await steps[index].isActive()) return index;\n }\n\n throw new Error(\n 'WrStepperHarness.getActiveIndex(): no header announces `aria-current=\"step\"` — this stepper has ' +\n 'no <wr-step> children, so there is no step for it to be on. An out-of-range `active` cannot ' +\n 'produce this: WrStepper clamps the bound index to the step list.'\n );\n }\n\n /** The label of the step the wizard is showing. Throws when there is no current step. */\n async getActiveLabel(): Promise<string> {\n const steps = await this.getSteps();\n return steps[await this.getActiveIndex()].getLabel();\n }\n\n /** The labels of the steps shown as done, in order. Derived completion and overrides both. */\n async getCompletedLabels(): Promise<string[]> {\n const steps = await this.getSteps({ completed: true });\n return Promise.all(steps.map(step => step.getLabel()));\n }\n\n /**\n * The labels of the headers a Tab press can reach, in order.\n *\n * A stepper does NOT rove focus: unlike a tab strip, the header list is not one tab\n * stop with arrow keys inside it — every reachable header is its own stop, and the\n * component authors no `tabindex` at all. So the question \"which step is active\" has\n * two different answers, and this is the other one: the current step is not\n * necessarily in this list. A step disabled by its own input keeps\n * `aria-current=\"step\"` while its button drops out of the tab order entirely, and a\n * `linear` stepper takes every locked header off the keyboard the same way.\n */\n async getTabStopLabels(): Promise<string[]> {\n const steps = await this.getSteps({ reachable: true });\n return Promise.all(steps.map(step => step.getLabel()));\n }\n\n /** The label of the header that currently has focus, or `null` when focus is elsewhere. */\n async getFocusedLabel(): Promise<string | null> {\n for (const step of await this.getSteps()) {\n if (await step.isFocused()) return step.getLabel();\n }\n return null;\n }\n\n /**\n * Whether the wizard would let a user navigate to this step right now — the question\n * a `linear` stepper exists to answer `false` to.\n *\n * Throws for an index that is not a step, rather than answering `false`: \"you cannot\n * go there\" and \"there is no there\" are different findings.\n */\n async canGoTo(index: number): Promise<boolean> {\n return (await this.stepAt(index)).isReachable();\n }\n\n /**\n * Navigate to the step at `index` by clicking its header.\n *\n * Throws when the wizard refuses, naming the cause — the step's own `disabled`, or\n * the `linear` gate and which earlier step is holding it shut. Silence would be\n * worse than a failure here: the component drops a click on a locked header without\n * a sound, so a spec would go on to assert against the step it was already showing.\n */\n async goTo(index: number): Promise<void> {\n const step = await this.stepAt(index);\n\n if (!(await step.isReachable())) {\n throw new Error(\n `WrStepperHarness.goTo(${index}): the header for \"${await step.getLabel()}\" refuses a click — ` +\n `${await this.refusal(index)}. Note that \\`WrStepper.goTo()\\` and \\`next()\\` move anyway: the gate is ` +\n \"on the header click, so a wizard's own Next button has to check for itself.\"\n );\n }\n\n await step.select();\n\n if (!(await step.isActive())) {\n throw new Error(\n `WrStepperHarness.goTo(${index}): the header for \"${await step.getLabel()}\" was clicked and the wizard ` +\n 'is still showing another step — its `active` model reached nothing, so a two-way `[(active)]` binding ' +\n 'is overwriting it or the click is not wired.'\n );\n }\n }\n\n /**\n * Navigate to the step with this label — a string matches exactly, a RegExp is\n * tested. Throws naming the labels that do exist when nothing matches.\n */\n async goToLabel(label: string | RegExp): Promise<void> {\n const labels = await this.getStepLabels();\n for (let index = 0; index < labels.length; index++) {\n if (await HarnessPredicate.stringMatches(labels[index], label)) return this.goTo(index);\n }\n\n throw new Error(\n `WrStepperHarness.goToLabel(): no step is labelled ${JSON.stringify(String(label))}. This wizard has: ` +\n `${labels.join(', ')}.`\n );\n }\n\n /**\n * Move to the next step through its header — subject to the same gate a user is.\n *\n * In a `linear` wizard that gate is shut until the CURRENT step reports itself\n * complete (its own `completed` input; derived completion only ever covers steps\n * before the active one), so this throws there. That is not the harness being\n * strict: it is the header a user has, and the reason a linear wizard needs its own\n * Next button, which calls `WrStepper.next()` and is not gated at all.\n *\n * Throws on the last step, where the component's own `next()` clamps in silence.\n */\n async next(): Promise<void> {\n const index = await this.getActiveIndex();\n const steps = await this.getSteps();\n\n if (index === steps.length - 1) {\n throw new Error(\n `WrStepperHarness.next(): the wizard is already on its last step (\"${await steps[index].getLabel()}\") — ` +\n 'there is nothing after it. `WrStepper.next()` clamps silently instead of saying so.'\n );\n }\n\n await this.goTo(index + 1);\n }\n\n /**\n * Move to the previous step through its header. Throws on the first step, where\n * `WrStepper.prev()` clamps in silence.\n *\n * Going back is normally allowed even in a `linear` wizard — every step at or before\n * the active one is reachable — but a step its own input disabled stays out of\n * reach in both directions.\n */\n async previous(): Promise<void> {\n const index = await this.getActiveIndex();\n\n if (index === 0) {\n throw new Error(\n 'WrStepperHarness.previous(): the wizard is already on its first step — there is nothing before it. ' +\n '`WrStepper.prev()` clamps silently instead of saying so.'\n );\n }\n\n await this.goTo(index - 1);\n }\n\n /**\n * The text of the step body the wizard is showing.\n *\n * Which body shows is CSS-only: every `<wr-step>` renders, and the stepper hides all\n * but one with `display: none` through the `--active` class. So this reads the class,\n * and in a unit test it has to — jsdom loads no stylesheet, which makes\n * `fixture.nativeElement.textContent` the text of ALL the steps at once and any\n * \"is the body showing\" assertion built on it meaningless.\n */\n async getActiveStepText(): Promise<string> {\n const active = await this.locatorForOptional('.wr-stepper__body .wr-step--active')();\n if (!active) {\n throw new Error(\n 'WrStepperHarness.getActiveStepText(): no step body is showing — the bound `active` index is outside ' +\n 'the step list, or this stepper has no <wr-step> children.'\n );\n }\n return wrStepperHarnessText(await active.text());\n }\n\n /**\n * The text of EVERY step body, in order, showing or not.\n *\n * The list being complete is the point: a step is hidden by a class rather than\n * dropped by an `@if`, so it mounts once and keeps its state — a half-filled form on\n * step 1 is still filled after a trip to step 3. Anything that turned the body into\n * a conditional block would keep every other assertion in a spec passing and quietly\n * reset the wizard.\n */\n async getStepTexts(): Promise<string[]> {\n const bodies = await this.locatorForAll('.wr-stepper__body > wr-step')();\n return Promise.all(bodies.map(async body => wrStepperHarnessText(await body.text())));\n }\n\n /** The step at `index`, or a failure that says how long the wizard is. */\n private async stepAt(index: number): Promise<WrStepHarness> {\n const steps = await this.getSteps();\n const step = steps[index];\n if (!step) {\n throw new Error(\n `WrStepperHarness: there is no step ${index} — this wizard has ${steps.length} ` +\n `${steps.length === 1 ? 'step' : 'steps'}${steps.length ? `: ${(await this.getStepLabels()).join(', ')}` : ''}.`\n );\n }\n return step;\n }\n\n /** Why the header at `index` is refusing a click, in the component's own order of causes. */\n private async refusal(index: number): Promise<string> {\n const steps = await this.getSteps();\n\n // The step's own input wins in the component too: `isReachable()` answers `false`\n // for a disabled step before it ever looks at the gate.\n if (await steps[index].isDisabled()) return 'the step carries `disabled`';\n\n if (await this.isLinear()) {\n for (let before = 0; before < index; before++) {\n if (!(await steps[before].isCompleted())) {\n return (\n 'the stepper is `linear` and step ' +\n `${before + 1} (\"${await steps[before].getLabel()}\") has not reported itself complete`\n );\n }\n }\n }\n\n return 'its header button is disabled';\n }\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,qBAAqB,MAAY;CAC/C,OAAO,KAAK,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAI;AACvC;;;;;;;ACiBA,IAAa,gBAAb,MAAa,sBAAsB,iBAAgB;CAOjD,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAgC,CAAA,GAAE;EAC5C,OAAO,IAAI,iBAAiB,eAAe,OAAO,CAAC,CAChD,UAAU,SAAS,QAAQ,QAAQ,SAAS,UAAU,iBAAiB,cAAc,QAAQ,SAAQ,GAAI,KAAK,CAAC,CAAC,CAChH,UAAU,UAAU,QAAQ,QAAQ,OAAO,SAAS,WAAY,MAAM,QAAQ,SAAQ,MAAQ,MAAM,CAAC,CACrG,UACC,aACA,QAAQ,WACR,OAAO,SAAS,cAAe,MAAM,QAAQ,YAAW,MAAQ,SAAS,CAC1E,CACA,UAAU,YAAY,QAAQ,UAAU,OAAO,SAAS,aAAc,MAAM,QAAQ,WAAU,MAAQ,QAAQ,CAAC,CAC/G,UACC,aACA,QAAQ,WACR,OAAO,SAAS,cAAe,MAAM,QAAQ,YAAW,MAAQ,SAAS,CAC1E,CACA,UAAU,YAAY,QAAQ,UAAU,OAAO,SAAS,aAAc,MAAM,QAAQ,WAAU,MAAQ,QAAQ;CACnH;CAEiB,SAAS,KAAK,WAAW,kCAAkC;CAS5E,M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MAAM,MAAM,CAAC,WAAU,GAAI,OAAO;EAE5C,IAAI,MAAM,KAAK,SAAQ,GACrB;QAAK,IAAI,SAAS,GAAG,SAAS,OAAO,UACnC,IAAI,CAAE,MAAM,MAAM,OAAO,CAAC,YAAW,GACnC,OACE,sCACG,SAAS,EAAC,KAAM,MAAM,MAAM,OAAO,CAAC,SAAQ,EAAE;EAGvD;EAGF,OAAO;CACT"}
|
|
1
|
+
{"version":3,"file":"ngwr-stepper-testing.mjs","names":[],"sources":["../../../projects/lib/stepper/testing/wr-stepper-harness-text.ts","../../../projects/lib/stepper/testing/wr-step-harness.ts","../../../projects/lib/stepper/testing/wr-stepper-harness.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\n/**\n * Collapse the whitespace inside a header or a step body to the line a user reads.\n *\n * `TestElement.text()` only trims the ends, and neither of the two things read here\n * is one text node: a header's label span holds the label, the \"optional\" badge and\n * the description as siblings, and a step body is whatever the consumer projected.\n * The template's own indentation is not the problem — Angular's default\n * `preserveWhitespaces: false` drops whitespace-only text nodes at compile time —\n * but a value carrying a newline is, and so is a consumer app compiled with\n * `preserveWhitespaces: true`. Every run becomes one space so a spec can assert the\n * rendered line either way.\n */\nexport function wrStepperHarnessText(text: string): string {\n return text.replace(/\\s+/g, ' ').trim();\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrStepStatus } from 'ngwr/stepper';\n\nimport type { WrStepHarnessFilters } from './types';\nimport { wrStepperHarnessText } from './wr-stepper-harness-text';\n\n/**\n * Test harness for one step of a `<wr-stepper>` — the step as the HEADER STRIP\n * publishes it: its label, its state, and the one control that navigates to it.\n *\n * A step is two pieces of DOM in two different places. The `<wr-step>` the consumer\n * wrote is projected into the stepper's body region; the header this harness hosts on\n * is generated next to it, in the `<ol>` above. Nothing links the two — no\n * `aria-controls`, no id on the body — so `WrStepperHarness.getActiveStepText()` is\n * where the body is read, and this answers what the wizard says about the step.\n *\n * Two states that look alike here are deliberately separate, because the component\n * treats them separately: {@link isDisabled} is the step's own `disabled` input\n * (switched off, whatever else happens), and {@link isReachable} is whether a click\n * would land right now — which a `linear` stepper takes away from every step ahead of\n * the gate without disabling any of them.\n *\n * @example\n * ```ts\n * const [review] = await stepper.getSteps({ label: 'Review' });\n *\n * expect(await review.isOptional()).toBe(true);\n * expect(await review.isReachable()).toBe(false);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrStepHarness extends ComponentHarness {\n /**\n * The header `<li>`, which is the whole step as far as the strip is concerned.\n *\n * Not `.wr-stepper__header-button`: the state modifiers (`--active`, `--completed`,\n * `--disabled`) land on the `<li>`, and the button is a child of it.\n */\n static hostSelector = '.wr-stepper__header';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrStepHarnessFilters = {}): HarnessPredicate<WrStepHarness> {\n return new HarnessPredicate(WrStepHarness, options)\n .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))\n .addOption('active', options.active, async (harness, active) => (await harness.isActive()) === active)\n .addOption(\n 'completed',\n options.completed,\n async (harness, completed) => (await harness.isCompleted()) === completed\n )\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled)\n .addOption(\n 'reachable',\n options.reachable,\n async (harness, reachable) => (await harness.isReachable()) === reachable\n )\n .addOption('optional', options.optional, async (harness, optional) => (await harness.isOptional()) === optional)\n .addOption('status', options.status, async (harness, status) => (await harness.getStatus()) === status);\n }\n\n private readonly button = this.locatorFor('button.wr-stepper__header-button');\n\n /**\n * The step's label, and only the label.\n *\n * The \"optional\" badge and the description are siblings of the label text inside\n * the same span, so both are excluded — a step addressed by label should be\n * addressable whether or not it also carries a description.\n */\n async getLabel(): Promise<string> {\n const label = await this.locatorFor('.wr-stepper__label')();\n return wrStepperHarnessText(\n await label.text({ exclude: '.wr-stepper__optional, .wr-stepper__description, .wr-stepper__sr-only' })\n );\n }\n\n /** The secondary line under the label, or `null` when the step defines none. */\n async getDescription(): Promise<string | null> {\n const description = await this.locatorForOptional('.wr-stepper__description')();\n return description ? wrStepperHarnessText(await description.text()) : null;\n }\n\n /** Whether the header flags the step as optional. */\n async isOptional(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-stepper__optional')()) !== null;\n }\n\n /**\n * What a screen reader announces for the header button.\n *\n * The indicator is excluded because it is `aria-hidden`: the step number and the\n * completed tick are decoration, deliberately, since the label and\n * `aria-current=\"step\"` already carry what they would repeat. What IS announced is\n * the label plus the \"optional\" badge and the description — so this is the method\n * that notices when one of those stops being part of the name.\n */\n async getAccessibleName(): Promise<string> {\n const button = await this.button();\n return wrStepperHarnessText(await button.text({ exclude: '.wr-stepper__indicator' }));\n }\n\n /**\n * Whether this is the step the wizard is showing.\n *\n * From `aria-current=\"step\"` rather than the `--active` class, because that is the\n * only place the wizard's position is published to a screen reader, and the two can\n * only ever disagree by way of a bug.\n */\n async isActive(): Promise<boolean> {\n return (await (await this.button()).getAttribute('aria-current')) === 'step';\n }\n\n /**\n * Whether the step is shown as done.\n *\n * Read from the `--completed` class, and there is no ARIA alternative to prefer:\n * completion reaches the page as that class plus a tick glyph that is\n * `aria-hidden`, so a screen-reader user hears the label and nothing else. The\n * class is the whole of what exists.\n *\n * Completion is derived from the active index — every step before it — unless a\n * step's own `completed` input overrides it, which is how a `linear` wizard opens\n * its gate. So a step after the active one can be completed too.\n */\n async isCompleted(): Promise<boolean> {\n return (await this.host()).hasClass('wr-stepper__header--completed');\n }\n\n /**\n * The problem the step flags in its header, or `null` when it flags none.\n *\n * Read from the `--error` / `--warning` class, the same way {@link isCompleted}\n * is. The word a screen reader hears for it is in {@link getAccessibleName}.\n */\n async getStatus(): Promise<WrStepStatus | null> {\n const host = await this.host();\n if (await host.hasClass('wr-stepper__header--error')) return 'error';\n if (await host.hasClass('wr-stepper__header--warning')) return 'warning';\n return null;\n }\n\n /**\n * Whether the step is switched off by its own `disabled` input.\n *\n * The `--disabled` class is exactly that input, which is why it is read here rather\n * than the button's `disabled`: the button is also disabled for a step that is\n * merely behind a `linear` gate, and those are different facts about the wizard.\n * See {@link isReachable} for the one about right now.\n */\n async isDisabled(): Promise<boolean> {\n return (await this.host()).hasClass('wr-stepper__header--disabled');\n }\n\n /**\n * Whether a click on this header would move the wizard here.\n *\n * Read from the button's `disabled` PROPERTY, because that is the enforcement and\n * not the paint: the component disables the header for a step its own input\n * switched off AND for one a `linear` gate has not opened yet. It is also what puts\n * the header in or out of the tab order — a `disabled` button cannot be focused at\n * all, so an unreachable step is off the keyboard entirely rather than focusable and\n * inert the way `aria-disabled` would leave it.\n */\n async isReachable(): Promise<boolean> {\n return !(await (await this.button()).getProperty<boolean>('disabled'));\n }\n\n /**\n * Navigate to this step by clicking its header, the way a user does.\n *\n * A click, not a keypress: the header is a real `<button>`, so Enter and Space\n * activate it through the browser's native activation — behaviour jsdom does not\n * implement, leaving nothing for a key to drive. A no-arg CDK click needs no\n * coordinate and no hit test, so the absent layout costs nothing here.\n *\n * Throws when the header refuses, rather than clicking and resolving quietly: the\n * component's guard would drop the click and the wizard would still be showing the\n * old step three assertions later. Reach for `WrStepperHarness.goTo()` when you\n * want the failure to name WHICH earlier step is holding the gate shut.\n */\n async select(): Promise<void> {\n if (!(await this.isReachable())) {\n throw new Error(\n `WrStepHarness.select(): the header for \"${await this.getLabel()}\" refuses a click — the step carries ` +\n '`disabled`, or the stepper is `linear` and an earlier step has not reported itself complete.'\n );\n }\n await (await this.button()).click();\n }\n\n /** Move keyboard focus to the header. A header that is not reachable cannot take it. */\n async focus(): Promise<void> {\n return (await this.button()).focus();\n }\n\n /** Whether the header currently has focus. */\n async isFocused(): Promise<boolean> {\n return (await this.button()).isFocused();\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrStepHarnessFilters, WrStepperHarnessFilters } from './types';\nimport { WrStepHarness } from './wr-step-harness';\nimport { wrStepperHarnessText } from './wr-stepper-harness-text';\n\n/**\n * Test harness for `<wr-stepper>` — the root of a two-part family with\n * {@link WrStepHarness}, which is one step of it.\n *\n * Steps are addressed by their index or their LABEL, the two things a consumer can\n * see; there is no key or id on a `<wr-step>` to address it by.\n *\n * Navigation here always goes through the HEADER STRIP, because that is the only\n * control the component renders — a wizard's Next and Back buttons are the\n * consumer's own, and they call `WrStepper.next()` / `prev()`. That distinction is\n * not cosmetic: the imperative API does NOT consult `linear`, so it walks straight\n * past a gate that refuses the equivalent header click. {@link next} and\n * {@link goTo} therefore refuse exactly where a user would be refused, and a spec\n * covering the wizard's own buttons should drive those buttons (through their own\n * harness) instead of these.\n *\n * @example\n * ```ts\n * const wizard = await loader.getHarness(WrStepperHarness);\n *\n * expect(await wizard.getStepLabels()).toEqual(['Account', 'Address', 'Review']);\n * expect(await wizard.canGoTo(2)).toBe(false);\n * await wizard.goToLabel('Address');\n * expect(await wizard.getActiveStepText()).toBe('Address body');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrStepperHarness extends ComponentHarness {\n static hostSelector = 'wr-stepper';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrStepperHarnessFilters = {}): HarnessPredicate<WrStepperHarness> {\n return new HarnessPredicate(WrStepperHarness, options)\n .addOption('stepLabel', options.stepLabel, async (harness, label) => {\n for (const stepLabel of await harness.getStepLabels()) {\n if (await HarnessPredicate.stringMatches(stepLabel, label)) return true;\n }\n return false;\n })\n .addOption(\n 'orientation',\n options.orientation,\n async (harness, orientation) => (await harness.getOrientation()) === orientation\n )\n .addOption('linear', options.linear, async (harness, linear) => (await harness.isLinear()) === linear);\n }\n\n private readonly headerList = this.locatorFor('ol.wr-stepper__headers');\n\n /**\n * The layout direction the stepper was ASKED for.\n *\n * Unusually for this library both values carry a class, so neither is read as the\n * absence of the other. What the class cannot tell you is how the strip actually\n * laid itself out: a `responsive` horizontal stepper drops to the vertical layout\n * when its own box is too narrow, and that reflow is a container query — the class\n * never changes. No unit test can see the difference in any case, jsdom having no\n * layout at all; assert the opt-in with {@link isResponsive} instead.\n */\n async getOrientation(): Promise<'horizontal' | 'vertical'> {\n return (await (await this.host()).hasClass('wr-stepper--vertical')) ? 'vertical' : 'horizontal';\n }\n\n /** Whether the stepper locks the steps after the last completed one. */\n async isLinear(): Promise<boolean> {\n return (await this.host()).hasClass('wr-stepper--linear');\n }\n\n /** Whether the stepper may reflow to the vertical layout in a narrow container. */\n async isResponsive(): Promise<boolean> {\n return (await this.host()).hasClass('wr-stepper--responsive');\n }\n\n /**\n * The role the header strip announces — `list`.\n *\n * An `<ol>` is a list already, so the explicit role looks redundant and is not: the\n * stylesheet removes the markers, and Safari drops list semantics from a list with\n * `list-style: none`. Losing it costs the \"list, 3 items\" a VoiceOver user hears,\n * which is how they learn how long the wizard is before starting it.\n */\n async getListRole(): Promise<string | null> {\n return (await this.headerList()).getAttribute('role');\n }\n\n /** The wizard's steps, in order. */\n async getSteps(filters: WrStepHarnessFilters = {}): Promise<WrStepHarness[]> {\n return this.locatorForAll(WrStepHarness.with(filters))();\n }\n\n /** The label of every step, in order. */\n async getStepLabels(): Promise<string[]> {\n const steps = await this.getSteps();\n return Promise.all(steps.map(step => step.getLabel()));\n }\n\n /**\n * The index of the step the wizard is showing, from the header announcing\n * `aria-current=\"step\"`.\n *\n * Throws when no header does, which is a state a stepper can genuinely be in: one\n * with no `<wr-step>` children renders its (empty) header strip and no body. A `-1`\n * here would be read as \"the first step\" by the next line of a spec. An\n * out-of-range `active` is NOT such a state — `WrStepper` clamps the two-way model\n * back into the step list, not only inside `goTo()`.\n */\n async getActiveIndex(): Promise<number> {\n const steps = await this.getSteps();\n for (let index = 0; index < steps.length; index++) {\n if (await steps[index].isActive()) return index;\n }\n\n throw new Error(\n 'WrStepperHarness.getActiveIndex(): no header announces `aria-current=\"step\"` — this stepper has ' +\n 'no <wr-step> children, so there is no step for it to be on. An out-of-range `active` cannot ' +\n 'produce this: WrStepper clamps the bound index to the step list.'\n );\n }\n\n /** The label of the step the wizard is showing. Throws when there is no current step. */\n async getActiveLabel(): Promise<string> {\n const steps = await this.getSteps();\n return steps[await this.getActiveIndex()].getLabel();\n }\n\n /** The labels of the steps shown as done, in order. Derived completion and overrides both. */\n async getCompletedLabels(): Promise<string[]> {\n const steps = await this.getSteps({ completed: true });\n return Promise.all(steps.map(step => step.getLabel()));\n }\n\n /**\n * The labels of the headers a Tab press can reach, in order.\n *\n * A stepper does NOT rove focus: unlike a tab strip, the header list is not one tab\n * stop with arrow keys inside it — every reachable header is its own stop, and the\n * component authors no `tabindex` at all. So the question \"which step is active\" has\n * two different answers, and this is the other one: the current step is not\n * necessarily in this list. A step disabled by its own input keeps\n * `aria-current=\"step\"` while its button drops out of the tab order entirely, and a\n * `linear` stepper takes every locked header off the keyboard the same way.\n */\n async getTabStopLabels(): Promise<string[]> {\n const steps = await this.getSteps({ reachable: true });\n return Promise.all(steps.map(step => step.getLabel()));\n }\n\n /** The label of the header that currently has focus, or `null` when focus is elsewhere. */\n async getFocusedLabel(): Promise<string | null> {\n for (const step of await this.getSteps()) {\n if (await step.isFocused()) return step.getLabel();\n }\n return null;\n }\n\n /**\n * Whether the wizard would let a user navigate to this step right now — the question\n * a `linear` stepper exists to answer `false` to.\n *\n * Throws for an index that is not a step, rather than answering `false`: \"you cannot\n * go there\" and \"there is no there\" are different findings.\n */\n async canGoTo(index: number): Promise<boolean> {\n return (await this.stepAt(index)).isReachable();\n }\n\n /**\n * Navigate to the step at `index` by clicking its header.\n *\n * Throws when the wizard refuses, naming the cause — the step's own `disabled`, or\n * the `linear` gate and which earlier step is holding it shut. Silence would be\n * worse than a failure here: the component drops a click on a locked header without\n * a sound, so a spec would go on to assert against the step it was already showing.\n */\n async goTo(index: number): Promise<void> {\n const step = await this.stepAt(index);\n\n if (!(await step.isReachable())) {\n throw new Error(\n `WrStepperHarness.goTo(${index}): the header for \"${await step.getLabel()}\" refuses a click — ` +\n `${await this.refusal(index)}. Note that \\`WrStepper.goTo()\\` and \\`next()\\` move anyway: the gate is ` +\n \"on the header click, so a wizard's own Next button has to check for itself.\"\n );\n }\n\n await step.select();\n\n if (!(await step.isActive())) {\n throw new Error(\n `WrStepperHarness.goTo(${index}): the header for \"${await step.getLabel()}\" was clicked and the wizard ` +\n 'is still showing another step — its `active` model reached nothing, so a two-way `[(active)]` binding ' +\n 'is overwriting it or the click is not wired.'\n );\n }\n }\n\n /**\n * Navigate to the step with this label — a string matches exactly, a RegExp is\n * tested. Throws naming the labels that do exist when nothing matches.\n */\n async goToLabel(label: string | RegExp): Promise<void> {\n const labels = await this.getStepLabels();\n for (let index = 0; index < labels.length; index++) {\n if (await HarnessPredicate.stringMatches(labels[index], label)) return this.goTo(index);\n }\n\n throw new Error(\n `WrStepperHarness.goToLabel(): no step is labelled ${JSON.stringify(String(label))}. This wizard has: ` +\n `${labels.join(', ')}.`\n );\n }\n\n /**\n * Move to the next step through its header — subject to the same gate a user is.\n *\n * In a `linear` wizard that gate is shut until the CURRENT step reports itself\n * complete (its own `completed` input; derived completion only ever covers steps\n * before the active one), so this throws there. That is not the harness being\n * strict: it is the header a user has, and the reason a linear wizard needs its own\n * Next button, which calls `WrStepper.next()` and is not gated at all.\n *\n * Throws on the last step, where the component's own `next()` clamps in silence.\n */\n async next(): Promise<void> {\n const index = await this.getActiveIndex();\n const steps = await this.getSteps();\n\n if (index === steps.length - 1) {\n throw new Error(\n `WrStepperHarness.next(): the wizard is already on its last step (\"${await steps[index].getLabel()}\") — ` +\n 'there is nothing after it. `WrStepper.next()` clamps silently instead of saying so.'\n );\n }\n\n await this.goTo(index + 1);\n }\n\n /**\n * Move to the previous step through its header. Throws on the first step, where\n * `WrStepper.prev()` clamps in silence.\n *\n * Going back is normally allowed even in a `linear` wizard — every step at or before\n * the active one is reachable — but a step its own input disabled stays out of\n * reach in both directions.\n */\n async previous(): Promise<void> {\n const index = await this.getActiveIndex();\n\n if (index === 0) {\n throw new Error(\n 'WrStepperHarness.previous(): the wizard is already on its first step — there is nothing before it. ' +\n '`WrStepper.prev()` clamps silently instead of saying so.'\n );\n }\n\n await this.goTo(index - 1);\n }\n\n /**\n * The text of the step body the wizard is showing.\n *\n * Which body shows is CSS-only: every `<wr-step>` renders, and the stepper hides all\n * but one with `display: none` through the `--active` class. So this reads the class,\n * and in a unit test it has to — jsdom loads no stylesheet, which makes\n * `fixture.nativeElement.textContent` the text of ALL the steps at once and any\n * \"is the body showing\" assertion built on it meaningless.\n */\n async getActiveStepText(): Promise<string> {\n const active = await this.locatorForOptional('.wr-stepper__body .wr-step--active')();\n if (!active) {\n throw new Error(\n 'WrStepperHarness.getActiveStepText(): no step body is showing — the bound `active` index is outside ' +\n 'the step list, or this stepper has no <wr-step> children.'\n );\n }\n return wrStepperHarnessText(await active.text());\n }\n\n /**\n * The text of EVERY step body, in order, showing or not.\n *\n * The list being complete is the point: a step is hidden by a class rather than\n * dropped by an `@if`, so it mounts once and keeps its state — a half-filled form on\n * step 1 is still filled after a trip to step 3. Anything that turned the body into\n * a conditional block would keep every other assertion in a spec passing and quietly\n * reset the wizard.\n */\n async getStepTexts(): Promise<string[]> {\n const bodies = await this.locatorForAll('.wr-stepper__body > wr-step')();\n return Promise.all(bodies.map(async body => wrStepperHarnessText(await body.text())));\n }\n\n /** The step at `index`, or a failure that says how long the wizard is. */\n private async stepAt(index: number): Promise<WrStepHarness> {\n const steps = await this.getSteps();\n const step = steps[index];\n if (!step) {\n throw new Error(\n `WrStepperHarness: there is no step ${index} — this wizard has ${steps.length} ` +\n `${steps.length === 1 ? 'step' : 'steps'}${steps.length ? `: ${(await this.getStepLabels()).join(', ')}` : ''}.`\n );\n }\n return step;\n }\n\n /** Why the header at `index` is refusing a click, in the component's own order of causes. */\n private async refusal(index: number): Promise<string> {\n const steps = await this.getSteps();\n\n // The step's own input wins in the component too: `isReachable()` answers `false`\n // for a disabled step before it ever looks at the gate.\n if (await steps[index].isDisabled()) return 'the step carries `disabled`';\n\n if (await this.isLinear()) {\n for (let before = 0; before < index; before++) {\n if (!(await steps[before].isCompleted())) {\n return (\n 'the stepper is `linear` and step ' +\n `${before + 1} (\"${await steps[before].getLabel()}\") has not reported itself complete`\n );\n }\n }\n }\n\n return 'its header button is disabled';\n }\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,qBAAqB,MAAY;CAC/C,OAAO,KAAK,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAI;AACvC;;;;;;;ACmBA,IAAa,gBAAb,MAAa,sBAAsB,iBAAgB;CAOjD,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAgC,CAAA,GAAE;EAC5C,OAAO,IAAI,iBAAiB,eAAe,OAAO,CAAC,CAChD,UAAU,SAAS,QAAQ,QAAQ,SAAS,UAAU,iBAAiB,cAAc,QAAQ,SAAQ,GAAI,KAAK,CAAC,CAAC,CAChH,UAAU,UAAU,QAAQ,QAAQ,OAAO,SAAS,WAAY,MAAM,QAAQ,SAAQ,MAAQ,MAAM,CAAC,CACrG,UACC,aACA,QAAQ,WACR,OAAO,SAAS,cAAe,MAAM,QAAQ,YAAW,MAAQ,SAAS,CAC1E,CACA,UAAU,YAAY,QAAQ,UAAU,OAAO,SAAS,aAAc,MAAM,QAAQ,WAAU,MAAQ,QAAQ,CAAC,CAC/G,UACC,aACA,QAAQ,WACR,OAAO,SAAS,cAAe,MAAM,QAAQ,YAAW,MAAQ,SAAS,CAC1E,CACA,UAAU,YAAY,QAAQ,UAAU,OAAO,SAAS,aAAc,MAAM,QAAQ,WAAU,MAAQ,QAAQ,CAAC,CAC/G,UAAU,UAAU,QAAQ,QAAQ,OAAO,SAAS,WAAY,MAAM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