(direction: 1 | -1)
| 224 | } |
| 225 | |
| 226 | #adjust(direction: 1 | -1) { |
| 227 | const ctx = this.#seg(); |
| 228 | if (!ctx) return; |
| 229 | const { segment } = ctx; |
| 230 | const raw = this.#segmentValues[segment.type]; |
| 231 | const isBlank = !raw || raw.replace(/_/g, '') === ''; |
| 232 | const num = Number.parseInt((raw || '0').replace(/_/g, '0'), 10) || 0; |
| 233 | const bounds = segmentBounds( |
| 234 | segment.type, |
| 235 | parse(this.#segmentValues), |
| 236 | this.#minDate, |
| 237 | this.#maxDate |
| 238 | ); |
| 239 | |
| 240 | let next: number; |
| 241 | if (isBlank) { |
| 242 | next = direction === 1 ? bounds.min : bounds.max; |
| 243 | } else { |
| 244 | next = Math.max(Math.min(bounds.max, num + direction), bounds.min); |
| 245 | } |
| 246 | |
| 247 | this.#segmentValues = { |
| 248 | ...this.#segmentValues, |
| 249 | [segment.type]: next.toString().padStart(segment.len, '0'), |
| 250 | }; |
| 251 | this.#segmentSelected = true; |
| 252 | this.#pendingTensDigit = null; |
| 253 | this.#refresh(); |
| 254 | } |
| 255 | |
| 256 | #onCursor(key?: string) { |
| 257 | if (!key) return; |
no test coverage detected