@reliability-design/web 1.4.6 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +246 -49
- package/dist/components/rel-accordion/README.md +133 -132
- package/dist/components/rel-alert/README.md +145 -141
- package/dist/components/rel-autocomplete/README.md +172 -61
- package/dist/components/rel-avatar/README.md +118 -130
- package/dist/components/rel-badge/README.md +97 -93
- package/dist/components/rel-breadcrumb/README.md +96 -102
- package/dist/components/rel-button/README.md +190 -130
- package/dist/components/rel-calendar/README.md +109 -109
- package/dist/components/rel-card/README.md +75 -94
- package/dist/components/rel-cardmedia/README.md +100 -127
- package/dist/components/rel-carousel/README.md +186 -166
- package/dist/components/rel-checkbox/README.md +96 -75
- package/dist/components/rel-chip/README.md +138 -121
- package/dist/components/rel-container/README.md +107 -99
- package/dist/components/rel-date-picker/README.md +200 -289
- package/dist/components/rel-divider/README.md +88 -100
- package/dist/components/rel-drawer/README.md +187 -200
- package/dist/components/rel-kbd/README.md +141 -151
- package/dist/components/rel-layout/README.md +34 -0
- package/dist/components/rel-menu/README.md +180 -151
- package/dist/components/rel-menubar/README.md +218 -329
- package/dist/components/rel-otp/README.md +171 -440
- package/dist/components/rel-pagination/README.md +100 -424
- package/dist/components/rel-popover/README.md +203 -568
- package/dist/components/rel-progress/README.md +88 -110
- package/dist/components/rel-radio/README.md +131 -138
- package/dist/components/rel-range-picker/README.md +165 -0
- package/dist/components/rel-resizable/README.md +199 -140
- package/dist/components/rel-segmented-button/README.md +156 -141
- package/dist/components/rel-select/README.md +156 -93
- package/dist/components/rel-sheet/README.md +168 -224
- package/dist/components/rel-skeleton/README.md +104 -0
- package/dist/components/rel-slider/README.md +131 -135
- package/dist/components/rel-snackbar/README.md +168 -134
- package/dist/components/rel-stepper/README.md +162 -160
- package/dist/components/rel-switch/README.md +117 -102
- package/dist/components/rel-tab/README.md +173 -163
- package/dist/components/rel-textfield/README.md +176 -69
- package/dist/components/rel-time-picker/README.md +122 -157
- package/dist/components/rel-toast/README.md +165 -148
- package/dist/components/rel-tooltip/README.md +119 -111
- package/dist/components/rel-upload/README.md +220 -0
- package/dist/index.d.mts +1726 -447
- package/dist/index.d.ts +1726 -447
- package/dist/index.js +13715 -10870
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14018 -11163
- package/dist/index.mjs.map +1 -1
- package/dist/styles/focus-ring.ts +84 -0
- package/dist/styles/vars.css +892 -866
- package/dist/{vars-XNMTSRVN.css → vars-DXX6QOAG.css} +892 -866
- package/package.json +3 -2
- package/dist/components/rel-accordion/rel-accordion.ts +0 -336
- package/dist/components/rel-alert/rel-alert.ts +0 -305
- package/dist/components/rel-autocomplete/rel-autocomplete.ts +0 -720
- package/dist/components/rel-avatar/rel-avatar.ts +0 -142
- package/dist/components/rel-badge/rel-badge.ts +0 -175
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +0 -106
- package/dist/components/rel-button/rel-button.ts +0 -560
- package/dist/components/rel-calendar/index.ts +0 -1
- package/dist/components/rel-calendar/rel-calendar.ts +0 -565
- package/dist/components/rel-card/rel-card.ts +0 -88
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +0 -88
- package/dist/components/rel-carousel/index.ts +0 -1
- package/dist/components/rel-carousel/rel-carousel.ts +0 -723
- package/dist/components/rel-chart/README.md +0 -286
- package/dist/components/rel-chart/index.ts +0 -1
- package/dist/components/rel-chart/rel-chart.ts +0 -754
- package/dist/components/rel-checkbox/rel-checkbox.ts +0 -382
- package/dist/components/rel-chip/rel-chip.ts +0 -483
- package/dist/components/rel-container/rel-container.ts +0 -95
- package/dist/components/rel-date-picker/date-format.test.ts +0 -43
- package/dist/components/rel-date-picker/date-format.ts +0 -47
- package/dist/components/rel-date-picker/date-parse.test.ts +0 -116
- package/dist/components/rel-date-picker/date-parse.ts +0 -178
- package/dist/components/rel-date-picker/index.ts +0 -1
- package/dist/components/rel-date-picker/rel-date-picker.ts +0 -1676
- package/dist/components/rel-divider/rel-divider.ts +0 -54
- package/dist/components/rel-drawer/index.ts +0 -1
- package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -27
- package/dist/components/rel-drawer/rel-drawer.ts +0 -607
- package/dist/components/rel-kbd/rel-kbd.ts +0 -188
- package/dist/components/rel-layout/rel-layout.ts +0 -49
- package/dist/components/rel-menu/rel-menu.ts +0 -541
- package/dist/components/rel-menubar/index.ts +0 -2
- package/dist/components/rel-menubar/rel-menubar-menu.css +0 -3
- package/dist/components/rel-menubar/rel-menubar-menu.ts +0 -17
- package/dist/components/rel-menubar/rel-menubar.ts +0 -777
- package/dist/components/rel-nav-menu/README.md +0 -289
- package/dist/components/rel-nav-menu/index.ts +0 -3
- package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +0 -243
- package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +0 -72
- package/dist/components/rel-nav-menu/rel-nav-menu.ts +0 -270
- package/dist/components/rel-navbar/README.md +0 -126
- package/dist/components/rel-navbar/rel-navbar.ts +0 -105
- package/dist/components/rel-otp/index.ts +0 -1
- package/dist/components/rel-otp/rel-otp.ts +0 -527
- package/dist/components/rel-pagination/index.ts +0 -1
- package/dist/components/rel-pagination/rel-pagination.ts +0 -522
- package/dist/components/rel-popover/index.ts +0 -2
- package/dist/components/rel-popover/rel-popover-content.ts +0 -81
- package/dist/components/rel-popover/rel-popover.ts +0 -475
- package/dist/components/rel-progress/rel-progress.ts +0 -234
- package/dist/components/rel-radio/rel-radio.ts +0 -481
- package/dist/components/rel-range-picker/rel-range-picker.ts +0 -1688
- package/dist/components/rel-resizable/index.ts +0 -3
- package/dist/components/rel-resizable/rel-resizable-group.ts +0 -405
- package/dist/components/rel-resizable/rel-resizable-handle.ts +0 -150
- package/dist/components/rel-resizable/rel-resizable-panel.ts +0 -58
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +0 -217
- package/dist/components/rel-select/rel-select.ts +0 -1416
- package/dist/components/rel-sheet/rel-sheet.ts +0 -610
- package/dist/components/rel-sidebar/README.md +0 -209
- package/dist/components/rel-sidebar/rel-sidebar.ts +0 -1191
- package/dist/components/rel-skeleton/rel-skeleton.ts +0 -143
- package/dist/components/rel-slider/rel-slider.ts +0 -673
- package/dist/components/rel-snackbar/rel-snackbar.ts +0 -329
- package/dist/components/rel-stepper/rel-stepper.ts +0 -567
- package/dist/components/rel-switch/rel-switch.ts +0 -199
- package/dist/components/rel-tab/rel-tab.ts +0 -264
- package/dist/components/rel-table/README.md +0 -178
- package/dist/components/rel-table/rel-table-body.ts +0 -22
- package/dist/components/rel-table/rel-table-caption.ts +0 -30
- package/dist/components/rel-table/rel-table-cell.ts +0 -43
- package/dist/components/rel-table/rel-table-footer.ts +0 -24
- package/dist/components/rel-table/rel-table-head.ts +0 -47
- package/dist/components/rel-table/rel-table-header.ts +0 -22
- package/dist/components/rel-table/rel-table-row.ts +0 -37
- package/dist/components/rel-table/rel-table.ts +0 -62
- package/dist/components/rel-textfield/rel-textfield.ts +0 -1054
- package/dist/components/rel-time-picker/rel-time-picker.ts +0 -1482
- package/dist/components/rel-time-picker/time-parse.test.ts +0 -67
- package/dist/components/rel-time-picker/time-parse.ts +0 -85
- package/dist/components/rel-toast/rel-toast.ts +0 -206
- package/dist/components/rel-tooltip/rel-tooltip.ts +0 -193
- package/dist/components/rel-topbar/rel-topbar-actions.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar-brand.ts +0 -54
- package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +0 -69
- package/dist/components/rel-topbar/rel-topbar-dropdown.ts +0 -31
- package/dist/components/rel-topbar/rel-topbar-item.ts +0 -324
- package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar-profile.ts +0 -243
- package/dist/components/rel-topbar/rel-topbar-utilities.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar.ts +0 -446
- package/dist/components/rel-upload/UPLOAD-DESIGN-CHANGES.md +0 -134
- package/dist/components/rel-upload/rel-upload-actions.ts +0 -163
- package/dist/components/rel-upload/rel-upload.ts +0 -968
|
@@ -1,673 +0,0 @@
|
|
|
1
|
-
import { LitElement, html, css, nothing } from "lit";
|
|
2
|
-
import { customElement, property, state } from "lit/decorators.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* "continuous"/"discrete" are the legacy tick-mode values; Figma's Type axis
|
|
6
|
-
* adds "default" (alias of continuous) and "range" (dual-thumb interval).
|
|
7
|
-
*/
|
|
8
|
-
export type SliderType = "continuous" | "discrete" | "default" | "range";
|
|
9
|
-
export type TrackStyle = "solid" | "dotted";
|
|
10
|
-
|
|
11
|
-
@customElement("rel-slider")
|
|
12
|
-
export class RelSlider extends LitElement {
|
|
13
|
-
@property({ type: String, reflect: true }) type: SliderType = "continuous";
|
|
14
|
-
|
|
15
|
-
/** Figma Size axis (S/M/L): scales track, thumb and ticks. */
|
|
16
|
-
@property({ type: String, reflect: true }) size: "sm" | "md" | "lg" = "md";
|
|
17
|
-
|
|
18
|
-
@property({ type: Number }) min: number = 0;
|
|
19
|
-
|
|
20
|
-
@property({ type: Number }) max: number = 100;
|
|
21
|
-
|
|
22
|
-
@property({ type: Number }) step: number = 1;
|
|
23
|
-
|
|
24
|
-
@property({ type: Boolean }) disabled: boolean = false;
|
|
25
|
-
|
|
26
|
-
@property({ type: String }) track: TrackStyle = "solid";
|
|
27
|
-
|
|
28
|
-
@property({ type: Boolean }) showTickLabels: boolean = false;
|
|
29
|
-
|
|
30
|
-
@property({ type: Boolean }) showBubble: boolean = true;
|
|
31
|
-
|
|
32
|
-
@property({ type: Number }) value: number = 0;
|
|
33
|
-
|
|
34
|
-
/** Upper value when type="range" (attribute value-end). */
|
|
35
|
-
@property({ type: Number, attribute: "value-end" }) valueEnd: number = 100;
|
|
36
|
-
|
|
37
|
-
@property({ type: String, attribute: "field-aria-label" }) fieldAriaLabel?: string;
|
|
38
|
-
|
|
39
|
-
@state() private ticks: number[] = [];
|
|
40
|
-
|
|
41
|
-
private _onChange: (value: number) => void = () => {};
|
|
42
|
-
private _onTouched: () => void = () => {};
|
|
43
|
-
|
|
44
|
-
static styles = css`
|
|
45
|
-
:host {
|
|
46
|
-
color: var(--rel-text-default);
|
|
47
|
-
--track-height: 8px;
|
|
48
|
-
--thumb-size: 20px;
|
|
49
|
-
--thumb-stroke: 7px;
|
|
50
|
-
--thumb-halo-color: var(--rel-border-default);
|
|
51
|
-
--tick-size: 4px;
|
|
52
|
-
--shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
|
|
53
|
-
--halo: 0 2px 0 var(--rel-bg-neutral-elevated-1), 0 6px 10px rgba(0, 0, 0, 0.07);
|
|
54
|
-
--marker-width: 24px;
|
|
55
|
-
--marker-height: 28px;
|
|
56
|
-
|
|
57
|
-
display: block;
|
|
58
|
-
font-family: var(--rel-label-md-font-family);
|
|
59
|
-
font-weight: var(--rel-label-md-font-weight);
|
|
60
|
-
font-size: var(--rel-label-md-font-size);
|
|
61
|
-
line-height: var(--rel-label-md-line-height);
|
|
62
|
-
letter-spacing: var(--rel-label-md-letter-spacing);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/* Figma Size axis: S = 6px track / 16px thumb · M = 8/20 · L = 10/24 */
|
|
66
|
-
:host([size="sm"]) {
|
|
67
|
-
--track-height: 6px;
|
|
68
|
-
--thumb-size: 16px;
|
|
69
|
-
--tick-size: 4px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
:host([size="md"]) {
|
|
73
|
-
--track-height: 8px;
|
|
74
|
-
--thumb-size: 20px;
|
|
75
|
-
--tick-size: 5px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
:host([size="lg"]) {
|
|
79
|
-
--track-height: 10px;
|
|
80
|
-
--thumb-size: 24px;
|
|
81
|
-
--tick-size: 6px;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.rel-slider {
|
|
85
|
-
position: relative;
|
|
86
|
-
width: 100%;
|
|
87
|
-
height: 60px;
|
|
88
|
-
user-select: none;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/* Track */
|
|
92
|
-
.track {
|
|
93
|
-
position: absolute;
|
|
94
|
-
top: 50%;
|
|
95
|
-
left: 0;
|
|
96
|
-
width: 100%;
|
|
97
|
-
height: var(--track-height);
|
|
98
|
-
background: var(--rel-bg-neutral-elevated-3);
|
|
99
|
-
border-radius: 2px;
|
|
100
|
-
transform: translateY(-50%);
|
|
101
|
-
pointer-events: none;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.track-active {
|
|
105
|
-
position: absolute;
|
|
106
|
-
top: 50%;
|
|
107
|
-
left: 0;
|
|
108
|
-
height: var(--track-height);
|
|
109
|
-
background: var(--rel-text-default);
|
|
110
|
-
border-radius: 2px;
|
|
111
|
-
transform: translateY(-50%);
|
|
112
|
-
pointer-events: none;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.track-active.dotted {
|
|
116
|
-
background: radial-gradient(
|
|
117
|
-
circle,
|
|
118
|
-
var(--rel-text-default) 0 2px,
|
|
119
|
-
transparent 2px
|
|
120
|
-
) 0 50%/var(--rel-spacing-sm) 5px repeat-x;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/* Range mode: pointer interaction is handled by the container so each
|
|
124
|
-
thumb can be grabbed; the native inputs stay for keyboard/AT. */
|
|
125
|
-
.rel-slider.range .slider-input {
|
|
126
|
-
pointer-events: none;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.rel-slider.range {
|
|
130
|
-
touch-action: none;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/* Input */
|
|
134
|
-
.slider-input {
|
|
135
|
-
-webkit-appearance: none;
|
|
136
|
-
appearance: none;
|
|
137
|
-
position: absolute;
|
|
138
|
-
top: 0;
|
|
139
|
-
width: 100%;
|
|
140
|
-
left: 0;
|
|
141
|
-
height: 100%;
|
|
142
|
-
background: transparent;
|
|
143
|
-
outline: none;
|
|
144
|
-
cursor: pointer;
|
|
145
|
-
z-index: 2;
|
|
146
|
-
margin: 0;
|
|
147
|
-
padding: 0;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.slider-input::-webkit-slider-runnable-track {
|
|
151
|
-
background: transparent;
|
|
152
|
-
height: 100%;
|
|
153
|
-
border: none;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.slider-input::-moz-range-track {
|
|
157
|
-
background: transparent;
|
|
158
|
-
height: 100%;
|
|
159
|
-
border: none;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.slider-input::slider-track {
|
|
163
|
-
background: transparent;
|
|
164
|
-
height: 100%;
|
|
165
|
-
border: none;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/* Hide native thumb */
|
|
169
|
-
.slider-input::-webkit-slider-thumb {
|
|
170
|
-
-webkit-appearance: none;
|
|
171
|
-
appearance: none;
|
|
172
|
-
width: 1px;
|
|
173
|
-
height: 1px;
|
|
174
|
-
background: transparent;
|
|
175
|
-
border: none;
|
|
176
|
-
cursor: pointer;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.slider-input::-moz-range-thumb {
|
|
180
|
-
width: 1px;
|
|
181
|
-
height: 1px;
|
|
182
|
-
background: transparent;
|
|
183
|
-
border: none;
|
|
184
|
-
cursor: pointer;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.slider-input::slider-thumb {
|
|
188
|
-
width: 1px;
|
|
189
|
-
height: 1px;
|
|
190
|
-
background: transparent;
|
|
191
|
-
border: none;
|
|
192
|
-
cursor: pointer;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
.slider-input:focus-visible ~ .thumb-container .custom-thumb {
|
|
196
|
-
box-shadow: 0 0 0 var(--thumb-stroke) var(--thumb-halo-color),
|
|
197
|
-
var(--shadow), var(--halo);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
@media (prefers-reduced-motion: reduce) {
|
|
201
|
-
.custom-thumb,
|
|
202
|
-
.tick {
|
|
203
|
-
transition: none;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/* Custom Thumb Container */
|
|
208
|
-
.thumb-container {
|
|
209
|
-
position: absolute;
|
|
210
|
-
left: 0;
|
|
211
|
-
top: 50%;
|
|
212
|
-
transform: translate(-50%, calc(-100% + var(--thumb-size) / 2));
|
|
213
|
-
pointer-events: none;
|
|
214
|
-
z-index: 5;
|
|
215
|
-
display: flex;
|
|
216
|
-
flex-direction: column;
|
|
217
|
-
align-items: center;
|
|
218
|
-
gap: 0;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/* Value Marker */
|
|
222
|
-
.value-marker {
|
|
223
|
-
width: var(--marker-width);
|
|
224
|
-
height: var(--marker-height);
|
|
225
|
-
margin-bottom: var(--rel-spacing-3xs);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.value-marker text {
|
|
229
|
-
font-family: var(--rel-label-sm-font-family);
|
|
230
|
-
font-weight: var(--rel-label-sm-font-weight);
|
|
231
|
-
font-size: var(--rel-label-sm-font-size);
|
|
232
|
-
line-height: var(--rel-label-sm-line-height);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
.value-marker svg {
|
|
236
|
-
width: 100%;
|
|
237
|
-
height: 100%;
|
|
238
|
-
display: block;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/* Custom Thumb */
|
|
242
|
-
.custom-thumb {
|
|
243
|
-
width: var(--thumb-size);
|
|
244
|
-
height: var(--thumb-size);
|
|
245
|
-
background: var(--rel-border-strong);
|
|
246
|
-
border-radius: 50%;
|
|
247
|
-
transition: box-shadow 0.15s ease;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
.slider-input:hover:not(:disabled) ~ .thumb-container .custom-thumb {
|
|
251
|
-
box-shadow: 0 0 0 var(--thumb-stroke) var(--rel-action-overlay-hover),
|
|
252
|
-
var(--shadow), var(--halo);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
.slider-input:active ~ .thumb-container .custom-thumb {
|
|
256
|
-
box-shadow: 0 0 0 var(--thumb-stroke) var(--rel-action-overlay-pressed),
|
|
257
|
-
var(--shadow), var(--halo);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/* Ticks */
|
|
261
|
-
.ticks {
|
|
262
|
-
position: absolute;
|
|
263
|
-
top: 50%;
|
|
264
|
-
left: 0;
|
|
265
|
-
width: 100%;
|
|
266
|
-
transform: translateY(-50%);
|
|
267
|
-
pointer-events: none;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.tick {
|
|
271
|
-
position: absolute;
|
|
272
|
-
width: var(--tick-size);
|
|
273
|
-
height: var(--tick-size);
|
|
274
|
-
background: var(--rel-text-default);
|
|
275
|
-
border-radius: 50%;
|
|
276
|
-
transform: translate(-50%, -50%);
|
|
277
|
-
transition: background 0.2s;
|
|
278
|
-
z-index: 3;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
.tick.active {
|
|
282
|
-
background: var(--rel-bg-neutral);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/* Tick labels */
|
|
286
|
-
.tick-labels {
|
|
287
|
-
position: absolute;
|
|
288
|
-
top: calc(50% + var(--tick-size) + var(--rel-spacing-2xs));
|
|
289
|
-
left: 0;
|
|
290
|
-
width: 100%;
|
|
291
|
-
color: var(--rel-text-label);
|
|
292
|
-
pointer-events: none;
|
|
293
|
-
font-family: var(--rel-label-xs-font-family);
|
|
294
|
-
font-weight: var(--rel-label-xs-font-weight);
|
|
295
|
-
font-size: var(--rel-label-xs-font-size);
|
|
296
|
-
line-height: var(--rel-label-xs-line-height);
|
|
297
|
-
letter-spacing: var(--rel-label-xs-letter-spacing);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
.tick-label {
|
|
301
|
-
position: absolute;
|
|
302
|
-
transform: translateX(-50%);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/* Disabled State */
|
|
306
|
-
.rel-slider.disabled .track {
|
|
307
|
-
background: var(--rel-border-default);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
.rel-slider.disabled .track-active {
|
|
311
|
-
background: var(--rel-text-placeholder);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
.rel-slider.disabled .track-active.dotted {
|
|
315
|
-
background: radial-gradient(
|
|
316
|
-
circle,
|
|
317
|
-
var(--rel-bg-neutral-elevated-1) 0 1px,
|
|
318
|
-
transparent 1px
|
|
319
|
-
)
|
|
320
|
-
center/var(--rel-spacing-sm) 4px repeat-x,
|
|
321
|
-
var(--rel-text-placeholder);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
.rel-slider.disabled .tick {
|
|
325
|
-
background: var(--rel-text-placeholder);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
.rel-slider.disabled .tick-label {
|
|
329
|
-
color: var(--rel-text-placeholder);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
.rel-slider.disabled .slider-input {
|
|
333
|
-
cursor: not-allowed;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
.rel-slider.disabled .custom-thumb {
|
|
337
|
-
background: var(--rel-text-placeholder);
|
|
338
|
-
box-shadow: none;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
.rel-slider.disabled .slider-input:active ~ .thumb-container .custom-thumb,
|
|
342
|
-
.rel-slider.disabled .slider-input:focus-visible ~ .thumb-container .custom-thumb {
|
|
343
|
-
box-shadow: none;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
.rel-slider.disabled .value-marker svg path {
|
|
347
|
-
fill: var(--rel-text-placeholder);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/* Dark mode overrides */
|
|
351
|
-
:host-context([data-theme="dark"]),
|
|
352
|
-
:host-context(.dark) {
|
|
353
|
-
--thumb-halo-color: var(--rel-border-default);
|
|
354
|
-
--halo: 0 2px 0 var(--rel-bg-neutral-elevated-2),
|
|
355
|
-
0 6px 10px rgba(0, 0, 0, 0.3);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
`;
|
|
359
|
-
|
|
360
|
-
connectedCallback() {
|
|
361
|
-
super.connectedCallback();
|
|
362
|
-
this.setupTicks();
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
updated(changedProperties: Map<string, any>) {
|
|
366
|
-
if (
|
|
367
|
-
changedProperties.has("type") ||
|
|
368
|
-
changedProperties.has("min") ||
|
|
369
|
-
changedProperties.has("max") ||
|
|
370
|
-
changedProperties.has("step")
|
|
371
|
-
) {
|
|
372
|
-
this.setupTicks();
|
|
373
|
-
}
|
|
374
|
-
if (
|
|
375
|
-
changedProperties.has("value") ||
|
|
376
|
-
changedProperties.has("valueEnd") ||
|
|
377
|
-
changedProperties.has("type")
|
|
378
|
-
) {
|
|
379
|
-
this.updateActiveWidth();
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
private get isRange(): boolean {
|
|
384
|
-
return this.type === "range";
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
private get percentage(): number {
|
|
388
|
-
if (this.max === this.min) return 0;
|
|
389
|
-
return ((this.value - this.min) / (this.max - this.min)) * 100;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
private get percentageEnd(): number {
|
|
393
|
-
if (this.max === this.min) return 0;
|
|
394
|
-
return ((this.valueEnd - this.min) / (this.max - this.min)) * 100;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
private dragThumb: "start" | "end" | null = null;
|
|
398
|
-
|
|
399
|
-
private valueFromPointer(e: PointerEvent): number {
|
|
400
|
-
const el = this.shadowRoot?.querySelector(".rel-slider") as HTMLElement;
|
|
401
|
-
if (!el) return this.min;
|
|
402
|
-
const rect = el.getBoundingClientRect();
|
|
403
|
-
const pct = Math.min(1, Math.max(0, (e.clientX - rect.left) / rect.width));
|
|
404
|
-
let v = this.min + pct * (this.max - this.min);
|
|
405
|
-
v = Math.round(v / this.step) * this.step;
|
|
406
|
-
return Math.min(this.max, Math.max(this.min, v));
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
private onRangePointerDown(e: PointerEvent) {
|
|
410
|
-
if (!this.isRange || this.disabled) return;
|
|
411
|
-
const v = this.valueFromPointer(e);
|
|
412
|
-
this.dragThumb =
|
|
413
|
-
Math.abs(v - this.value) <= Math.abs(v - this.valueEnd) ? "start" : "end";
|
|
414
|
-
(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);
|
|
415
|
-
this.applyRangeValue(v);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
private onRangePointerMove(e: PointerEvent) {
|
|
419
|
-
if (!this.dragThumb) return;
|
|
420
|
-
this.applyRangeValue(this.valueFromPointer(e));
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
private onRangePointerUp() {
|
|
424
|
-
this.dragThumb = null;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
private applyRangeValue(v: number) {
|
|
428
|
-
if (this.dragThumb === "start") {
|
|
429
|
-
this.value = Math.min(v, this.valueEnd);
|
|
430
|
-
} else if (this.dragThumb === "end") {
|
|
431
|
-
this.valueEnd = Math.max(v, this.value);
|
|
432
|
-
}
|
|
433
|
-
this.updateActiveWidth();
|
|
434
|
-
this.emitRangeChange();
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
private emitRangeChange() {
|
|
438
|
-
this.dispatchEvent(
|
|
439
|
-
new CustomEvent("rel-change", {
|
|
440
|
-
detail: { value: this.value, valueEnd: this.valueEnd },
|
|
441
|
-
bubbles: true,
|
|
442
|
-
composed: true,
|
|
443
|
-
})
|
|
444
|
-
);
|
|
445
|
-
this._onChange(this.value);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
private onRangeInputStart(ev: Event) {
|
|
449
|
-
const next = Number((ev.target as HTMLInputElement).value);
|
|
450
|
-
this.value = Math.min(next, this.valueEnd);
|
|
451
|
-
this.updateActiveWidth();
|
|
452
|
-
this.emitRangeChange();
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
private onRangeInputEnd(ev: Event) {
|
|
456
|
-
const next = Number((ev.target as HTMLInputElement).value);
|
|
457
|
-
this.valueEnd = Math.max(next, this.value);
|
|
458
|
-
this.updateActiveWidth();
|
|
459
|
-
this.emitRangeChange();
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
private setupTicks() {
|
|
463
|
-
if (this.type !== "discrete") {
|
|
464
|
-
this.ticks = [];
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
const step = Math.max(1, this.step);
|
|
469
|
-
const ticks: number[] = [];
|
|
470
|
-
for (let v = this.min; v <= this.max; v += step) {
|
|
471
|
-
ticks.push(v);
|
|
472
|
-
}
|
|
473
|
-
if (ticks[ticks.length - 1] !== this.max) {
|
|
474
|
-
ticks.push(this.max);
|
|
475
|
-
}
|
|
476
|
-
this.ticks = ticks;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
private getTickLeftPct(tick: number): number {
|
|
480
|
-
const pct = ((tick - this.min) / (this.max - this.min)) * 100;
|
|
481
|
-
return Math.round(pct * 1000) / 1000;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
private isTickActive(tick: number): boolean {
|
|
485
|
-
return tick <= this.value;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
private onInput(ev: Event) {
|
|
489
|
-
const el = ev.target as HTMLInputElement;
|
|
490
|
-
let next = Number(el.value);
|
|
491
|
-
|
|
492
|
-
if (this.type === "discrete") {
|
|
493
|
-
const snapped =
|
|
494
|
-
Math.round((next - this.min) / this.step) * this.step + this.min;
|
|
495
|
-
next = Math.min(this.max, Math.max(this.min, snapped));
|
|
496
|
-
el.value = String(next);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
this.value = next;
|
|
500
|
-
this.updateActiveWidth();
|
|
501
|
-
this.dispatchEvent(
|
|
502
|
-
new CustomEvent("rel-change", {
|
|
503
|
-
detail: { value: this.value },
|
|
504
|
-
bubbles: true,
|
|
505
|
-
composed: true,
|
|
506
|
-
})
|
|
507
|
-
);
|
|
508
|
-
this._onChange(this.value);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
registerOnChange(fn: (value: number) => void): void { this._onChange = fn; }
|
|
512
|
-
registerOnTouched(fn: () => void): void { this._onTouched = fn; }
|
|
513
|
-
writeValue(value: number): void { this.value = value; }
|
|
514
|
-
|
|
515
|
-
private updateActiveWidth() {
|
|
516
|
-
const activeEl = this.shadowRoot?.querySelector(".track-active") as HTMLDivElement;
|
|
517
|
-
if (!activeEl) return;
|
|
518
|
-
|
|
519
|
-
if (this.isRange) {
|
|
520
|
-
activeEl.style.left = `${this.percentage}%`;
|
|
521
|
-
activeEl.style.width = `${Math.max(0, this.percentageEnd - this.percentage)}%`;
|
|
522
|
-
} else if (this.type === "discrete") {
|
|
523
|
-
const stepPercent = (this.step / (this.max - this.min)) * 100;
|
|
524
|
-
const snappedPct = Math.round(this.percentage / stepPercent) * stepPercent;
|
|
525
|
-
activeEl.style.width = `${snappedPct}%`;
|
|
526
|
-
} else {
|
|
527
|
-
activeEl.style.width = `${this.percentage}%`;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
private renderThumbContainer(pct: number = this.percentage, val: number = this.value) {
|
|
532
|
-
return html`
|
|
533
|
-
<div class="thumb-container" style="left: ${pct}%">
|
|
534
|
-
${this.showBubble ? html`
|
|
535
|
-
<div class="value-marker">
|
|
536
|
-
<svg viewBox="0 0 24 32" xmlns="http://www.w3.org/2000/svg">
|
|
537
|
-
<path
|
|
538
|
-
d="M12 0C18.6274 0 24 5.37258 24 12C24 21 12 32 12 32C12 32 0 21 0 12C0 5.37258 5.37258 0 12 0Z"
|
|
539
|
-
fill="var(--rel-bg-neutral-inverse-2)" />
|
|
540
|
-
<text
|
|
541
|
-
x="12"
|
|
542
|
-
y="16"
|
|
543
|
-
text-anchor="middle"
|
|
544
|
-
fill="var(--rel-text-inverse)"
|
|
545
|
-
font-size="12"
|
|
546
|
-
font-family="Poppins"
|
|
547
|
-
font-weight="600">
|
|
548
|
-
${val}
|
|
549
|
-
</text>
|
|
550
|
-
</svg>
|
|
551
|
-
</div>
|
|
552
|
-
` : ""}
|
|
553
|
-
<div part="thumb" class="custom-thumb"></div>
|
|
554
|
-
</div>
|
|
555
|
-
`;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
private renderTicks() {
|
|
559
|
-
if (this.type !== "discrete") return "";
|
|
560
|
-
|
|
561
|
-
return html`
|
|
562
|
-
<div class="ticks">
|
|
563
|
-
${this.ticks.map(
|
|
564
|
-
(tick) => html`
|
|
565
|
-
<div
|
|
566
|
-
class="tick ${this.isTickActive(tick) ? "active" : ""}"
|
|
567
|
-
style="left: ${this.getTickLeftPct(tick)}%"></div>
|
|
568
|
-
`
|
|
569
|
-
)}
|
|
570
|
-
</div>
|
|
571
|
-
`;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
private renderTickLabels() {
|
|
575
|
-
if (this.type !== "discrete" || !this.showTickLabels) return "";
|
|
576
|
-
|
|
577
|
-
return html`
|
|
578
|
-
<div class="tick-labels">
|
|
579
|
-
${this.ticks.map(
|
|
580
|
-
(tick) => html`
|
|
581
|
-
<div
|
|
582
|
-
class="tick-label"
|
|
583
|
-
style="left: ${this.getTickLeftPct(tick)}%">
|
|
584
|
-
${tick}
|
|
585
|
-
</div>
|
|
586
|
-
`
|
|
587
|
-
)}
|
|
588
|
-
</div>
|
|
589
|
-
`;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
render() {
|
|
593
|
-
const sliderClasses = [
|
|
594
|
-
"rel-slider",
|
|
595
|
-
this.disabled ? "disabled" : "",
|
|
596
|
-
this.type === "discrete" ? "has-ticks" : "",
|
|
597
|
-
this.isRange ? "range" : "",
|
|
598
|
-
]
|
|
599
|
-
.filter(Boolean)
|
|
600
|
-
.join(" ");
|
|
601
|
-
|
|
602
|
-
const trackActiveClasses = [
|
|
603
|
-
"track-active",
|
|
604
|
-
this.track === "dotted" ? "dotted" : "",
|
|
605
|
-
]
|
|
606
|
-
.filter(Boolean)
|
|
607
|
-
.join(" ");
|
|
608
|
-
|
|
609
|
-
if (this.isRange) {
|
|
610
|
-
return html`
|
|
611
|
-
<div
|
|
612
|
-
class="${sliderClasses}"
|
|
613
|
-
@pointerdown="${this.onRangePointerDown}"
|
|
614
|
-
@pointermove="${this.onRangePointerMove}"
|
|
615
|
-
@pointerup="${this.onRangePointerUp}"
|
|
616
|
-
@pointercancel="${this.onRangePointerUp}"
|
|
617
|
-
>
|
|
618
|
-
<div part="track" class="track"></div>
|
|
619
|
-
<div class="${trackActiveClasses}"></div>
|
|
620
|
-
|
|
621
|
-
<input
|
|
622
|
-
class="slider-input"
|
|
623
|
-
type="range"
|
|
624
|
-
aria-label="${this.fieldAriaLabel ? `${this.fieldAriaLabel} minimum` : "Minimum value"}"
|
|
625
|
-
.min="${String(this.min)}"
|
|
626
|
-
.max="${String(this.max)}"
|
|
627
|
-
.step="${String(this.step)}"
|
|
628
|
-
.value="${String(this.value)}"
|
|
629
|
-
?disabled="${this.disabled}"
|
|
630
|
-
@input="${this.onRangeInputStart}"
|
|
631
|
-
@blur="${() => this._onTouched()}" />
|
|
632
|
-
<input
|
|
633
|
-
class="slider-input"
|
|
634
|
-
type="range"
|
|
635
|
-
aria-label="${this.fieldAriaLabel ? `${this.fieldAriaLabel} maximum` : "Maximum value"}"
|
|
636
|
-
.min="${String(this.min)}"
|
|
637
|
-
.max="${String(this.max)}"
|
|
638
|
-
.step="${String(this.step)}"
|
|
639
|
-
.value="${String(this.valueEnd)}"
|
|
640
|
-
?disabled="${this.disabled}"
|
|
641
|
-
@input="${this.onRangeInputEnd}"
|
|
642
|
-
@blur="${() => this._onTouched()}" />
|
|
643
|
-
|
|
644
|
-
${this.renderThumbContainer(this.percentage, this.value)}
|
|
645
|
-
${this.renderThumbContainer(this.percentageEnd, this.valueEnd)}
|
|
646
|
-
</div>
|
|
647
|
-
`;
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
return html`
|
|
651
|
-
<div class="${sliderClasses}">
|
|
652
|
-
<div part="track" class="track"></div>
|
|
653
|
-
<div class="${trackActiveClasses}"></div>
|
|
654
|
-
|
|
655
|
-
<input
|
|
656
|
-
class="slider-input"
|
|
657
|
-
type="range"
|
|
658
|
-
aria-label="${this.fieldAriaLabel || nothing}"
|
|
659
|
-
.min="${String(this.min)}"
|
|
660
|
-
.max="${String(this.max)}"
|
|
661
|
-
.step="${this.type === 'discrete' ? String(this.step) : '1'}"
|
|
662
|
-
.value="${String(this.value)}"
|
|
663
|
-
?disabled="${this.disabled}"
|
|
664
|
-
@input="${this.onInput}"
|
|
665
|
-
@blur="${() => this._onTouched()}" />
|
|
666
|
-
|
|
667
|
-
${this.renderThumbContainer()}
|
|
668
|
-
${this.renderTicks()}
|
|
669
|
-
${this.renderTickLabels()}
|
|
670
|
-
</div>
|
|
671
|
-
`;
|
|
672
|
-
}
|
|
673
|
-
}
|