@nanahoshi/mona-ui 0.25.1 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/chart/README.md +2 -2
- package/command/package.json +4 -0
- package/docs/auto-complete.md +733 -0
- package/docs/avatar.md +220 -0
- package/docs/breadcrumb.md +320 -0
- package/docs/button-group.md +392 -0
- package/docs/button.md +256 -0
- package/docs/calendar.md +515 -0
- package/docs/card.md +292 -0
- package/docs/chart-bar.md +714 -0
- package/docs/chart-financial.md +567 -0
- package/docs/chart-funnel.md +546 -0
- package/docs/chart-heatmap.md +535 -0
- package/docs/chart-line-area.md +462 -0
- package/docs/chart-pie.md +645 -0
- package/docs/chart-radar.md +518 -0
- package/docs/chart-radial.md +658 -0
- package/docs/chart-scatter.md +479 -0
- package/docs/chart-treemap.md +651 -0
- package/docs/chart.md +2465 -0
- package/docs/checkbox.md +374 -0
- package/docs/chip.md +339 -0
- package/docs/circular-progress-bar.md +287 -0
- package/docs/collapsible.md +308 -0
- package/docs/color-gradient.md +336 -0
- package/docs/color-palette.md +317 -0
- package/docs/color-picker.md +387 -0
- package/docs/combo-box.md +764 -0
- package/docs/command.md +582 -0
- package/docs/contextmenu.md +530 -0
- package/docs/date-picker.md +251 -0
- package/docs/datetime-picker.md +284 -0
- package/docs/decimal-textbox.md +260 -0
- package/docs/dialog.md +822 -0
- package/docs/dropdown-button.md +507 -0
- package/docs/dropdown-list.md +779 -0
- package/docs/editor.md +374 -0
- package/docs/expansion-panel.md +348 -0
- package/docs/fieldset.md +217 -0
- package/docs/forms.md +162 -0
- package/docs/grid.md +2053 -0
- package/docs/input.md +197 -0
- package/docs/installation.md +54 -0
- package/docs/introduction.md +46 -0
- package/docs/label.md +340 -0
- package/docs/list-box.md +637 -0
- package/docs/list-view.md +584 -0
- package/docs/menubar.md +559 -0
- package/docs/multi-select.md +765 -0
- package/docs/notification.md +460 -0
- package/docs/numeric-textbox.md +301 -0
- package/docs/otp-input.md +539 -0
- package/docs/pager.md +513 -0
- package/docs/placeholder.md +176 -0
- package/docs/popover.md +423 -0
- package/docs/popup-menu.md +658 -0
- package/docs/popup.md +617 -0
- package/docs/progress-bar.md +368 -0
- package/docs/radio-button.md +451 -0
- package/docs/range-slider.md +367 -0
- package/docs/rating.md +518 -0
- package/docs/scroll-view.md +375 -0
- package/docs/segmented.md +434 -0
- package/docs/sheet.md +348 -0
- package/docs/sidebar.md +1126 -0
- package/docs/skeleton.md +181 -0
- package/docs/slider.md +423 -0
- package/docs/spinner.md +370 -0
- package/docs/split-button.md +522 -0
- package/docs/splitter.md +342 -0
- package/docs/stepper.md +539 -0
- package/docs/switch.md +340 -0
- package/docs/tabs.md +542 -0
- package/docs/textarea.md +196 -0
- package/docs/textbox.md +332 -0
- package/docs/theming.md +403 -0
- package/docs/time-picker.md +254 -0
- package/docs/tooltip-directive.md +340 -0
- package/docs/tooltip.md +321 -0
- package/docs/tree-view.md +1018 -0
- package/docs/window.md +663 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +8 -0
- package/fesm2022/nanahoshi-mona-ui-button.mjs +12 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +212 -66
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +7 -2
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +9 -6
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
- package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
- package/i18n/catalogs/en-US.messages.json +10 -0
- package/internal/popup-menu/package.json +4 -0
- package/llms.txt +133 -0
- package/locales/ar-sa/ar-sa.messages.json +10 -0
- package/locales/de-de/de-de.messages.json +10 -0
- package/locales/es-es/es-es.messages.json +10 -0
- package/locales/fr-fr/fr-fr.messages.json +10 -0
- package/locales/id-id/id-id.messages.json +10 -0
- package/locales/it-it/it-it.messages.json +10 -0
- package/locales/ja-jp/ja-jp.messages.json +10 -0
- package/locales/ko-kr/ko-kr.messages.json +10 -0
- package/locales/pt-br/pt-br.messages.json +10 -0
- package/locales/ru-ru/ru-ru.messages.json +10 -0
- package/locales/tr-tr/tr-tr.messages.json +10 -0
- package/locales/zh-cn/zh-cn.messages.json +10 -0
- package/locales/zh-tw/zh-tw.messages.json +10 -0
- package/package.json +9 -1
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
- package/types/nanahoshi-mona-ui-button.d.ts +12 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
- package/types/nanahoshi-mona-ui-chart.d.ts +250 -20
- package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-command.d.ts +253 -0
- package/types/nanahoshi-mona-ui-common.d.ts +17 -1
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
- package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
- package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
- package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
- package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
- package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
- package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
- package/types/nanahoshi-mona-ui-label.d.ts +1 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
- package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
- package/types/nanahoshi-mona-ui-list.d.ts +1 -1
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
- package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
- package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
- package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
- package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
- package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
- package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
- package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
- package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
- package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
- package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
- package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
- package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
- package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
- package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
- package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
- package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
- package/types/nanahoshi-mona-ui-window.d.ts +66 -1
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
# Range Slider
|
|
2
|
+
|
|
3
|
+
> A two-handle slider for selecting a numeric interval.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/slider`
|
|
6
|
+
|
|
7
|
+
**Selector:** `mona-range-slider`
|
|
8
|
+
|
|
9
|
+
`RangeSliderComponent` is a two-handle range input that lets the user select a numeric interval by dragging either handle, clicking the track, or using keyboard navigation. It integrates with Angular signal forms via `FormValueControl<[number, number]>`.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Use `RangeSliderComponent` when the user must select both a lower and upper bound simultaneously — for example, a price filter, a date window, or a speed range.
|
|
14
|
+
|
|
15
|
+
**Use RangeSlider instead of Slider when:**
|
|
16
|
+
|
|
17
|
+
- The user needs to constrain both ends of a range
|
|
18
|
+
- Two independent values must stay ordered (lower ≤ upper)
|
|
19
|
+
|
|
20
|
+
**Use Slider when:**
|
|
21
|
+
|
|
22
|
+
- The user selects a single value within a fixed lower bound
|
|
23
|
+
|
|
24
|
+
A user change always writes a sorted `[min, max]` tuple. Dragging a handle stops at the other handle, as the keyboard does.
|
|
25
|
+
|
|
26
|
+
## Import & Quick Start
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { RangeSliderComponent } from "@nanahoshi/mona-ui/slider";
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Direct value binding:**
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<mona-range-slider [(value)]="priceRange" aria-labelledby="price-label"></mona-range-slider>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Signal forms integration:**
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { signal } from "@angular/core";
|
|
42
|
+
import { form, FormField } from "@angular/forms/signals";
|
|
43
|
+
|
|
44
|
+
protected readonly filterForm = form(signal({ price: [0, 100] as [number, number] }));
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<mona-range-slider [formField]="filterForm.price" aria-labelledby="price-label"></mona-range-slider>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Anatomy
|
|
52
|
+
|
|
53
|
+
`RangeSliderComponent` shares the same structural template directives as `SliderComponent`.
|
|
54
|
+
|
|
55
|
+
### Custom handle
|
|
56
|
+
|
|
57
|
+
`monaSliderHandleTemplate` applies to **both** handles. The implicit variable is the current value of the respective handle:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { RangeSliderComponent, SliderHandleTemplateDirective } from "@nanahoshi/mona-ui/slider";
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
<mona-range-slider [(value)]="range" aria-labelledby="range-label">
|
|
65
|
+
<ng-template monaSliderHandleTemplate let-value>
|
|
66
|
+
<span class="badge">{{ value }}</span>
|
|
67
|
+
</ng-template>
|
|
68
|
+
</mona-range-slider>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Custom tick labels
|
|
72
|
+
|
|
73
|
+
`monaSliderTickValueTemplate` replaces default numeric labels. Only takes effect when both `showTicks` and `showLabels` are `true`.
|
|
74
|
+
|
|
75
|
+
## Examples
|
|
76
|
+
|
|
77
|
+
### Tick marks and labels
|
|
78
|
+
|
|
79
|
+
`aria-labelledby` names the group, and each handle reads it before its own name.
|
|
80
|
+
|
|
81
|
+
`ticks-example.component.ts`
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { Component, signal } from "@angular/core";
|
|
85
|
+
import { RangeSliderComponent } from "@nanahoshi/mona-ui/slider";
|
|
86
|
+
|
|
87
|
+
@Component({
|
|
88
|
+
selector: "app-range-slider-ticks-example",
|
|
89
|
+
imports: [RangeSliderComponent],
|
|
90
|
+
templateUrl: "./ticks-example.component.html"
|
|
91
|
+
})
|
|
92
|
+
export class RangeSliderTicksExampleComponent {
|
|
93
|
+
protected readonly price = signal<[number, number]>([200, 700]);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`ticks-example.component.html`
|
|
98
|
+
|
|
99
|
+
```html
|
|
100
|
+
<div class="flex max-w-md flex-col gap-2">
|
|
101
|
+
<span id="price-label" class="text-sm font-medium">Price</span>
|
|
102
|
+
<mona-range-slider
|
|
103
|
+
aria-labelledby="price-label"
|
|
104
|
+
[labelStep]="2"
|
|
105
|
+
[maxValue]="1000"
|
|
106
|
+
[showLabels]="true"
|
|
107
|
+
[showTicks]="true"
|
|
108
|
+
[step]="100"
|
|
109
|
+
[(value)]="price" />
|
|
110
|
+
<span class="text-sm">From {{ price()[0] }} to {{ price()[1] }}</span>
|
|
111
|
+
</div>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Vertical orientation
|
|
115
|
+
|
|
116
|
+
`vertical-example.component.ts`
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { Component, signal } from "@angular/core";
|
|
120
|
+
import { RangeSliderComponent } from "@nanahoshi/mona-ui/slider";
|
|
121
|
+
|
|
122
|
+
@Component({
|
|
123
|
+
selector: "app-range-slider-vertical-example",
|
|
124
|
+
imports: [RangeSliderComponent],
|
|
125
|
+
templateUrl: "./vertical-example.component.html"
|
|
126
|
+
})
|
|
127
|
+
export class RangeSliderVerticalExampleComponent {
|
|
128
|
+
protected readonly temperature = signal<[number, number]>([18, 24]);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`vertical-example.component.html`
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<div class="flex items-center gap-4">
|
|
136
|
+
<mona-range-slider
|
|
137
|
+
aria-label="Comfort range"
|
|
138
|
+
aria-label-end="Highest temperature"
|
|
139
|
+
aria-label-start="Lowest temperature"
|
|
140
|
+
orientation="vertical"
|
|
141
|
+
[maxValue]="30"
|
|
142
|
+
[minValue]="10"
|
|
143
|
+
[(value)]="temperature" />
|
|
144
|
+
<span class="text-sm">Comfort range: {{ temperature()[0] }} °C to {{ temperature()[1] }} °C</span>
|
|
145
|
+
</div>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Signal forms
|
|
149
|
+
|
|
150
|
+
`forms-example.component.ts`
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { Component, signal } from "@angular/core";
|
|
154
|
+
import { form, FormField } from "@angular/forms/signals";
|
|
155
|
+
import { LabelComponent } from "@nanahoshi/mona-ui/label";
|
|
156
|
+
import { RangeSliderComponent } from "@nanahoshi/mona-ui/slider";
|
|
157
|
+
|
|
158
|
+
interface FilterModel {
|
|
159
|
+
hours: [number, number];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@Component({
|
|
163
|
+
selector: "app-range-slider-forms-example",
|
|
164
|
+
imports: [FormField, LabelComponent, RangeSliderComponent],
|
|
165
|
+
templateUrl: "./forms-example.component.html"
|
|
166
|
+
})
|
|
167
|
+
export class RangeSliderFormsExampleComponent {
|
|
168
|
+
readonly #model = signal<FilterModel>({ hours: [9, 17] });
|
|
169
|
+
protected readonly filter = form(this.#model);
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
`forms-example.component.html`
|
|
174
|
+
|
|
175
|
+
```html
|
|
176
|
+
<div class="flex max-w-md flex-col gap-2">
|
|
177
|
+
<mona-label text="Opening hours">
|
|
178
|
+
<mona-range-slider [formField]="filter.hours" [maxValue]="24" />
|
|
179
|
+
</mona-label>
|
|
180
|
+
<span class="text-sm">Open from {{ filter.hours().value()[0] }}:00 to {{ filter.hours().value()[1] }}:00</span>
|
|
181
|
+
</div>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Overlapping handles
|
|
185
|
+
|
|
186
|
+
When the two handles share the same value, the upper handle is on top by default, and a handle moved onto the other stays on top. The direction you drag in decides which handle moves, so neither can get stuck.
|
|
187
|
+
|
|
188
|
+
### Disabled state
|
|
189
|
+
|
|
190
|
+
```html
|
|
191
|
+
<mona-range-slider [disabled]="true" [value]="[20, 80]" aria-labelledby="range-label"></mona-range-slider>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Read-only state
|
|
195
|
+
|
|
196
|
+
`readonly` blocks dragging, track clicks and keys. Both handles stay focusable and readable, and get `aria-readonly="true"`. With `[formField]`, the signal forms `readonly` rule writes it.
|
|
197
|
+
|
|
198
|
+
```html
|
|
199
|
+
<mona-range-slider readonly [value]="[20, 80]" aria-labelledby="range-label"></mona-range-slider>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Custom accessible handle labels
|
|
203
|
+
|
|
204
|
+
The primary (lower) handle defaults to the localized `"Minimum value"` and the secondary (upper) handle defaults to the localized `"Maximum value"`. Override with `aria-label-start` and `aria-label-end`:
|
|
205
|
+
|
|
206
|
+
```html
|
|
207
|
+
<mona-range-slider
|
|
208
|
+
[(value)]="priceRange"
|
|
209
|
+
aria-label-start="Minimum price"
|
|
210
|
+
aria-label-end="Maximum price">
|
|
211
|
+
</mona-range-slider>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Behavior
|
|
215
|
+
|
|
216
|
+
### Values Out of Range
|
|
217
|
+
|
|
218
|
+
The range slider never writes a corrected value on its own. A value that is out of range, off the step grid or unsorted is shown at the nearest valid values, and the model keeps its own until the user changes it. The next user change saves a valid tuple. This way a `maxValue` that loads late can't overwrite saved data.
|
|
219
|
+
|
|
220
|
+
In development, the range slider warns once per instance when this happens, including for a `maxValue` that loads late. It also warns once when the minimum isn't lower than the maximum.
|
|
221
|
+
|
|
222
|
+
`maxValue` can always be reached, even when it isn't a whole number of steps from `minValue`.
|
|
223
|
+
|
|
224
|
+
## Forms Integration
|
|
225
|
+
|
|
226
|
+
`RangeSliderComponent` implements `FormValueControl<[number, number]>` from `@angular/forms/signals`. Connect it using the `[formField]` binding, as in [Signal forms](#signal-forms).
|
|
227
|
+
|
|
228
|
+
`FormField` writes `value`, `disabled`, `invalid`, `readonly` and `touched`. Don't set those on the same element, because Angular rejects the template. The `touch` output fires when either handle loses focus, marking the field as touched.
|
|
229
|
+
|
|
230
|
+
`RangeSliderComponent` doesn't implement `ControlValueAccessor`. `[(ngModel)]` binds to its `value` model through Angular's support for custom controls. Prefer `[formField]`.
|
|
231
|
+
|
|
232
|
+
## Accessibility
|
|
233
|
+
|
|
234
|
+
`RangeSliderComponent` has role `group` and renders two focusable `div` elements each with `role="slider"`. Each handle's range ends at the other handle.
|
|
235
|
+
|
|
236
|
+
| Attribute | When present | Value |
|
|
237
|
+
|--------------------|-----------------------------------|---------------------------------------------------------------|
|
|
238
|
+
| `role` | Always (each handle) | `"slider"` |
|
|
239
|
+
| `aria-valuemin` | Always | Lower handle: `minValue`. Upper handle: the lower handle's value |
|
|
240
|
+
| `aria-valuemax` | Always | Lower handle: the upper handle's value. Upper handle: `maxValue` |
|
|
241
|
+
| `aria-valuenow` | Always | Current value of that handle |
|
|
242
|
+
| `aria-valuetext` | When `ariaValueText` is provided | Return value of the provided function for that handle's value |
|
|
243
|
+
| `aria-orientation` | Always | `"horizontal"` or `"vertical"` |
|
|
244
|
+
| `aria-disabled` | When disabled | `true` |
|
|
245
|
+
| `aria-readonly` | When read-only | `true` |
|
|
246
|
+
| `aria-invalid` | When `invalid` and `touched` | `true` |
|
|
247
|
+
| `aria-describedby` | When `aria-describedby` is set | The given id, on each handle |
|
|
248
|
+
| `tabindex` | Always | `0` (enabled) or `-1` (disabled) |
|
|
249
|
+
|
|
250
|
+
The range slider has no required state, because ARIA doesn't allow one on role `slider`. It has no `min` and `max` inputs either, so use `minValue` and `maxValue`.
|
|
251
|
+
|
|
252
|
+
**Accessible name:**
|
|
253
|
+
|
|
254
|
+
Each handle has its own name, from `aria-label-start` and `aria-label-end` (defaults: the localized `"Minimum value"` / `"Maximum value"`).
|
|
255
|
+
|
|
256
|
+
- `aria-labelledby` labels the group, and each handle reads it before its own name, such as "Price Minimum value". A `mona-label` with `text` around it, or bound with `[for]="ref"`, does the same. A click on a wrapping caption focuses the lower handle.
|
|
257
|
+
- `aria-label` names the group only. The handles keep just their own names.
|
|
258
|
+
|
|
259
|
+
A string `for` can't work, because the range slider has no native input.
|
|
260
|
+
|
|
261
|
+
### Keyboard Interaction
|
|
262
|
+
|
|
263
|
+
Each handle is independently focusable. Tab to switch between handles; the same key bindings apply to whichever handle has focus. A handle stops at the other one.
|
|
264
|
+
|
|
265
|
+
| Key | Action |
|
|
266
|
+
|-----------------------------------|--------------------------------------------------------|
|
|
267
|
+
| `ArrowRight` / `ArrowUp` | Increase focused handle value by `step` |
|
|
268
|
+
| `ArrowLeft` / `ArrowDown` | Decrease focused handle value by `step` |
|
|
269
|
+
| `Shift` + `ArrowRight`/`ArrowUp` | Increase by `step × shiftMultiplier` |
|
|
270
|
+
| `Shift` + `ArrowLeft`/`ArrowDown` | Decrease by `step × shiftMultiplier` |
|
|
271
|
+
| `Home` | Move focused handle toward `minValue` |
|
|
272
|
+
| `End` | Move focused handle toward `maxValue` |
|
|
273
|
+
| `PageUp` | Increase by 10% of the total range, at least `step` |
|
|
274
|
+
| `PageDown` | Decrease by 10% of the total range, at least `step` |
|
|
275
|
+
|
|
276
|
+
In RTL, `ArrowLeft` increases and `ArrowRight` decreases.
|
|
277
|
+
|
|
278
|
+
## API
|
|
279
|
+
|
|
280
|
+
Everything below is imported from `@nanahoshi/mona-ui/slider`.
|
|
281
|
+
|
|
282
|
+
### `RangeSliderComponent`
|
|
283
|
+
|
|
284
|
+
**Selector:** `mona-range-slider`
|
|
285
|
+
**Implements:** `FormValueControl<[number, number]>`
|
|
286
|
+
|
|
287
|
+
#### Inputs
|
|
288
|
+
|
|
289
|
+
| Name | Type | Default | Description |
|
|
290
|
+
| --- | --- | --- | --- |
|
|
291
|
+
| `aria-describedby` | `string \| null` | `null` | Id of an element that describes the control, such as an error message. On a range slider it describes each handle. |
|
|
292
|
+
| `aria-label` | `string \| null` | `null` | Accessible name of the control. On a range slider it names the group holding both handles. |
|
|
293
|
+
| `aria-label-end` | `string \| null` | `null` | Accessible name for the upper-value (secondary) handle. |
|
|
294
|
+
| `aria-label-start` | `string \| null` | `null` | Accessible name for the lower-value (primary) handle. |
|
|
295
|
+
| `aria-labelledby` | `string \| null` | `null` | Id of the element that labels the control. On a range slider each handle reads it before its own name. |
|
|
296
|
+
| `ariaValueText` | `((value: number) => string) \| null` | `null` | Human-readable override for the `aria-valuenow` announcement. Pass a function that receives the current value and returns the string to announce. |
|
|
297
|
+
| `disabled` | `boolean` | `false` | Renders the component with reduced visual emphasis and removes pointer interaction. |
|
|
298
|
+
| `handleClasses` | `string \| string[]` | `[]` | Additional CSS classes to apply to the slider handle. |
|
|
299
|
+
| `handleStyles` | `Partial<CSSStyleDeclaration>` | `{}` | Additional inline styles to apply to the slider handle. |
|
|
300
|
+
| `invalid` | `boolean` | `false` | Marks the control as invalid for form validation purposes, reflecting `aria-invalid` on the handle element once the control is touched. |
|
|
301
|
+
| `labelPosition` | `SliderLabelPosition` | `"after"` | Position of the label relative to the component. |
|
|
302
|
+
| `labelStep` | `number` | `1` | Controls which tick labels are shown — only every n<sup>th</sup> label is rendered. |
|
|
303
|
+
| `largeTickStep` | `number \| null` | `null` | Controls which ticks render at large size — only every n<sup>th</sup> tick is enlarged. Pass `null` to disable large ticks. |
|
|
304
|
+
| `maxValue` | `number` | `10` | Upper bound of the value range. Must be greater than `minValue`. |
|
|
305
|
+
| `minValue` | `number` | `0` | Lower bound of the value range. |
|
|
306
|
+
| `orientation` | `Orientation` | `"horizontal"` | Layout orientation of the component. |
|
|
307
|
+
| `readonly` | `boolean` | `false` | Prevents value changes while the control stays focusable and readable. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
|
|
308
|
+
| `rounded` | `"full" \| "large" \| "medium" \| "none" \| "small"` | `"full"` | Border-radius preset applied to the slider handle. |
|
|
309
|
+
| `selectionBackground` | `string \| Partial<CSSStyleDeclaration> \| null` | `null` | Background color of the filled selection area between the minimum and the current value. Accepts a CSS color string or a `CSSStyleDeclaration` partial. |
|
|
310
|
+
| `shiftMultiplier` | `number` | `10` | Multiplier applied to the step when the user holds Shift while pressing an arrow key. |
|
|
311
|
+
| `showLabels` | `boolean` | `false` | Displays value labels alongside tick marks. Only takes effect when `showTicks` is `true`. |
|
|
312
|
+
| `showTicks` | `boolean` | `false` | Displays tick marks at each step position along the track. |
|
|
313
|
+
| `smallTickStep` | `number` | `1` | Controls how many ticks are visible — only every n<sup>th</sup> tick is rendered. |
|
|
314
|
+
| `step` | `number` | `1` | Distance between the values the control can take. `maxValue` can always be reached, even when it isn't a whole number of steps from `minValue`. |
|
|
315
|
+
| `touched` | `boolean` | `false` | Marks the slider as touched. Error styling requires both `invalid` and `touched` to be `true`. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive. |
|
|
316
|
+
| `trackBackground` | `string \| Partial<CSSStyleDeclaration> \| null` | `null` | Background color of the unfilled track portion. Accepts a CSS color string or a `CSSStyleDeclaration` partial. |
|
|
317
|
+
| `trackSize` | `string \| number` | `undefined` | Width (vertical orientation) or height (horizontal orientation) of the track. Accepts a pixel number or any CSS length string. |
|
|
318
|
+
| `value` (two-way) | `[number, number]` | `[0, 10]` | Selected range as `[minimum, maximum]`. A value out of range, off the step grid or unsorted is shown at the nearest valid values, and the model keeps its own until the user changes it. A development warning reports it. |
|
|
319
|
+
|
|
320
|
+
#### Outputs
|
|
321
|
+
|
|
322
|
+
| Name | Type | Description |
|
|
323
|
+
| --- | --- | --- |
|
|
324
|
+
| `touch` | `void` | Emitted when a handle loses focus. A click on the track moves focus to the handle first. |
|
|
325
|
+
| `valueChange` | `[number, number]` | Emitted when `value` changes. |
|
|
326
|
+
|
|
327
|
+
#### Methods
|
|
328
|
+
|
|
329
|
+
| Signature | Description |
|
|
330
|
+
| --- | --- |
|
|
331
|
+
| `focus(options?: FocusOptions): void` | Moves focus to the lower handle. Does nothing while disabled. |
|
|
332
|
+
|
|
333
|
+
### `SliderHandleTemplateDirective`
|
|
334
|
+
|
|
335
|
+
**Selector:** `ng-template[monaSliderHandleTemplate]`
|
|
336
|
+
|
|
337
|
+
#### Template context
|
|
338
|
+
|
|
339
|
+
| Name | Type |
|
|
340
|
+
| --- | --- |
|
|
341
|
+
| `$implicit` | `number` |
|
|
342
|
+
|
|
343
|
+
### `SliderTickValueTemplateDirective`
|
|
344
|
+
|
|
345
|
+
**Selector:** `ng-template[monaSliderTickValueTemplate]`
|
|
346
|
+
|
|
347
|
+
#### Template context
|
|
348
|
+
|
|
349
|
+
| Name | Type |
|
|
350
|
+
| --- | --- |
|
|
351
|
+
| `$implicit` | `number` |
|
|
352
|
+
|
|
353
|
+
### Types
|
|
354
|
+
|
|
355
|
+
#### `SliderLabelPosition`
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
type SliderLabelPosition = "before" | "after";
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### `Orientation`
|
|
362
|
+
|
|
363
|
+
From `@nanahoshi/mona-ui/common`.
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
type Orientation = "horizontal" | "vertical";
|
|
367
|
+
```
|