@ids-group-ltd/ids-design-system 0.15.3 → 1.0.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/CHANGELOG.md +58 -4
- package/design-system.md +24 -0
- package/eslint/deprecated-api.json +14 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-empty-state.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-search.mjs +3 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-search.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-time-picker.mjs +217 -18
- package/fesm2022/ids-group-ltd-ids-design-system-components-time-picker.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-tooltip.mjs +17 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-tooltip.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components.mjs +13 -3
- package/fesm2022/ids-group-ltd-ids-design-system-components.mjs.map +1 -1
- package/migrations/0.15.1.json +4 -2
- package/migrations/0.15.3.json +14 -4
- package/migrations/1.0.0.json +41 -0
- package/migrations/1.0.1.json +36 -0
- package/package.json +1 -1
- package/schematics/check-overrides/surface.json +1 -1
- package/types/ids-group-ltd-ids-design-system-components-time-picker.d.ts +23 -1
- package/types/ids-group-ltd-ids-design-system-components.d.ts +2 -1
|
@@ -195,6 +195,14 @@ class TimeColumnsComponent {
|
|
|
195
195
|
// One set of values taller than the column, measured after render; AM/PM is two rows and never loops.
|
|
196
196
|
hoursOverflow = signal(false, ...(ngDevMode ? [{ debugName: "hoursOverflow" }] : /* istanbul ignore next */ []));
|
|
197
197
|
minutesOverflow = signal(false, ...(ngDevMode ? [{ debugName: "minutesOverflow" }] : /* istanbul ignore next */ []));
|
|
198
|
+
loopCopiesEachSide = [0, 1, 2, 3];
|
|
199
|
+
userPicked = false;
|
|
200
|
+
pickingByScroll = false;
|
|
201
|
+
userScrolledColumns = new Set();
|
|
202
|
+
// The share of the wheel's scroll distance a column moves: a 100 px notch comes to about one row.
|
|
203
|
+
wheelSpeed = 0.35;
|
|
204
|
+
wheelScrolls = new Map();
|
|
205
|
+
smoothScrolls = new Map();
|
|
198
206
|
hoursLoop = computed(() => this.loops(this.hoursOverflow()), ...(ngDevMode ? [{ debugName: "hoursLoop" }] : /* istanbul ignore next */ []));
|
|
199
207
|
minutesLoop = computed(() => this.loops(this.minutesOverflow()), ...(ngDevMode ? [{ debugName: "minutesLoop" }] : /* istanbul ignore next */ []));
|
|
200
208
|
pickHour = (cell) => this.selectHour(cell);
|
|
@@ -216,6 +224,7 @@ class TimeColumnsComponent {
|
|
|
216
224
|
this.periodEntry();
|
|
217
225
|
untracked(() => {
|
|
218
226
|
this.scrollSelectedIntoView();
|
|
227
|
+
this.userPicked = false;
|
|
219
228
|
requestAnimationFrame(() => this.scrollSelectedIntoView());
|
|
220
229
|
});
|
|
221
230
|
});
|
|
@@ -232,28 +241,166 @@ class TimeColumnsComponent {
|
|
|
232
241
|
if (!element) {
|
|
233
242
|
return false;
|
|
234
243
|
}
|
|
235
|
-
const sets = element.classList.contains('loops')
|
|
244
|
+
const sets = element.classList.contains('loops')
|
|
245
|
+
? this.loopCopiesEachSide.length * 2 + 1
|
|
246
|
+
: 1;
|
|
236
247
|
return element.scrollHeight / sets > element.clientHeight + 1;
|
|
237
248
|
}
|
|
249
|
+
onScroll(event, column, count) {
|
|
250
|
+
const element = event.target;
|
|
251
|
+
this.wrapScroll(element, count);
|
|
252
|
+
if (this.userScrolledColumns.has(element)) {
|
|
253
|
+
this.selectCentred(element, column, count);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
238
256
|
/** Keeps a looping column inside its middle set, so a copy is always beyond either edge. */
|
|
239
|
-
wrapScroll(
|
|
240
|
-
|
|
257
|
+
wrapScroll(column, count) {
|
|
258
|
+
if (this.smoothScrolls.has(column)) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
// A scrollTop write mid-gesture cancels the browser's wheel animation and re-runs snapping, so scrollend wraps; here only a column about to run out of copies.
|
|
262
|
+
const set = this.setHeight(column, count);
|
|
263
|
+
const lastTop = column.scrollHeight - column.clientHeight;
|
|
264
|
+
if (set === 0) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (column.scrollTop < set * 0.25 ||
|
|
268
|
+
column.scrollTop > lastTop - set * 0.25) {
|
|
269
|
+
this.wrapColumn(column, count);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
onUserScroll(event) {
|
|
273
|
+
this.userScrolledColumns.add(event.currentTarget);
|
|
274
|
+
}
|
|
275
|
+
onWheel(event) {
|
|
276
|
+
const column = event.currentTarget;
|
|
241
277
|
const [first, second] = column.children;
|
|
242
|
-
if (
|
|
278
|
+
if (event.ctrlKey || event.deltaY === 0 || !second) {
|
|
243
279
|
return;
|
|
244
280
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
281
|
+
// Snapping pulls a sub-row scroll back to the row it left, so the deltas add up and the column moves by whole rows.
|
|
282
|
+
event.preventDefault();
|
|
283
|
+
this.onUserScroll(event);
|
|
284
|
+
const rowPitch = second.offsetTop - first.offsetTop;
|
|
285
|
+
const pixels = event.deltaMode === WheelEvent.DOM_DELTA_LINE
|
|
286
|
+
? event.deltaY * rowPitch
|
|
287
|
+
: event.deltaY;
|
|
288
|
+
const wheel = this.wheelScrolls.get(column) ?? {
|
|
289
|
+
remainder: 0,
|
|
290
|
+
target: null,
|
|
291
|
+
};
|
|
292
|
+
wheel.remainder += pixels * this.wheelSpeed;
|
|
293
|
+
const rows = Math.trunc(wheel.remainder / rowPitch);
|
|
294
|
+
if (rows !== 0) {
|
|
295
|
+
wheel.remainder -= rows * rowPitch;
|
|
296
|
+
wheel.target = (wheel.target ?? column.scrollTop) + rows * rowPitch;
|
|
297
|
+
this.scrollToWheelTarget(column, wheel.target);
|
|
298
|
+
}
|
|
299
|
+
this.wheelScrolls.set(column, wheel);
|
|
300
|
+
}
|
|
301
|
+
scrollToWheelTarget(column, top) {
|
|
302
|
+
column.scrollTo({
|
|
303
|
+
top,
|
|
304
|
+
behavior: this.prefersReducedMotion() ? 'instant' : 'smooth',
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
onScrollbarGrab(event) {
|
|
308
|
+
if (event.target === event.currentTarget) {
|
|
309
|
+
this.onUserScroll(event);
|
|
248
310
|
}
|
|
249
|
-
|
|
250
|
-
|
|
311
|
+
}
|
|
312
|
+
onScrollEnd(event, column, count) {
|
|
313
|
+
const element = event.target;
|
|
314
|
+
const smooth = this.smoothScrolls.get(element);
|
|
315
|
+
const byUser = this.userScrolledColumns.has(element);
|
|
316
|
+
if (smooth && !byUser && Math.abs(element.scrollTop - smooth.top) > 1) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
this.releaseSmoothScroll(element);
|
|
320
|
+
const wheel = this.wheelScrolls.get(element);
|
|
321
|
+
if (wheel) {
|
|
322
|
+
wheel.target = null;
|
|
323
|
+
}
|
|
324
|
+
this.wrapColumn(element, count);
|
|
325
|
+
if (this.userScrolledColumns.delete(element)) {
|
|
326
|
+
this.selectCentred(element, column, count);
|
|
251
327
|
}
|
|
252
328
|
}
|
|
329
|
+
selectCentred(element, column, count) {
|
|
330
|
+
const cells = this.cellsFor(column);
|
|
331
|
+
const buttons = this.buttonsFor(column)();
|
|
332
|
+
const set = this.setHeight(element, count);
|
|
333
|
+
const centre = element.scrollTop + element.clientHeight / 2;
|
|
334
|
+
let centred = -1;
|
|
335
|
+
let smallestDistance = Infinity;
|
|
336
|
+
buttons.forEach(({ nativeElement: button }, index) => {
|
|
337
|
+
const buttonCentre = button.offsetTop + button.offsetHeight / 2;
|
|
338
|
+
const copies = set > 0 ? this.loopCopiesEachSide.length : 0;
|
|
339
|
+
for (let copy = -copies; copy <= copies; copy++) {
|
|
340
|
+
const offset = copy * set;
|
|
341
|
+
const distance = Math.abs(buttonCentre + offset - centre);
|
|
342
|
+
if (distance < smallestDistance) {
|
|
343
|
+
smallestDistance = distance;
|
|
344
|
+
centred = index;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
const target = this.nearestEnabled(cells, centred);
|
|
349
|
+
if (target < 0 || this.isSelected(column, target)) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
this.pickingByScroll = true;
|
|
353
|
+
this.selectAt(column, target);
|
|
354
|
+
this.pickingByScroll = false;
|
|
355
|
+
}
|
|
356
|
+
nearestEnabled(cells, from) {
|
|
357
|
+
for (let distance = 0; distance <= cells.length / 2; distance++) {
|
|
358
|
+
for (const index of [from + distance, from - distance]) {
|
|
359
|
+
const wrapped = (index + cells.length) % cells.length;
|
|
360
|
+
if (cells[wrapped] && !cells[wrapped].disabled) {
|
|
361
|
+
return wrapped;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return -1;
|
|
366
|
+
}
|
|
367
|
+
isSelected(column, index) {
|
|
368
|
+
return this.cellsFor(column)[index]?.selected ?? false;
|
|
369
|
+
}
|
|
370
|
+
wrapColumn(column, count) {
|
|
371
|
+
const set = this.setHeight(column, count);
|
|
372
|
+
if (set === 0) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
// Whole sets back to the middle of the scroll range in one write, so the scrollend that write raises finds nothing left to wrap.
|
|
376
|
+
const middle = (column.scrollHeight - column.clientHeight) / 2;
|
|
377
|
+
const setsOff = Math.round((column.scrollTop - middle) / set);
|
|
378
|
+
if (setsOff !== 0) {
|
|
379
|
+
column.scrollTop -= setsOff * set;
|
|
380
|
+
// The write cut the wheel animation short; it resumes towards the same row, a whole number of sets nearer.
|
|
381
|
+
const wheel = this.wheelScrolls.get(column);
|
|
382
|
+
if (wheel?.target != null) {
|
|
383
|
+
wheel.target -= setsOff * set;
|
|
384
|
+
this.scrollToWheelTarget(column, wheel.target);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
setHeight(column, count) {
|
|
389
|
+
const [first, second] = column.children;
|
|
390
|
+
if (!column.classList.contains('loops') || !second) {
|
|
391
|
+
return 0;
|
|
392
|
+
}
|
|
393
|
+
return (second.offsetTop - first.offsetTop) * count;
|
|
394
|
+
}
|
|
395
|
+
releaseSmoothScroll(column) {
|
|
396
|
+
window.clearTimeout(this.smoothScrolls.get(column)?.timer);
|
|
397
|
+
this.smoothScrolls.delete(column);
|
|
398
|
+
}
|
|
253
399
|
selectHour(cell) {
|
|
254
400
|
if (cell.disabled) {
|
|
255
401
|
return;
|
|
256
402
|
}
|
|
403
|
+
this.markUserPick();
|
|
257
404
|
const hour24 = this.toH24(cell.value);
|
|
258
405
|
const parsed = this.parsedValue();
|
|
259
406
|
this.emit(hour24, parsed ? parsed.m : this.firstEnabledMinute(hour24), 'hours');
|
|
@@ -262,12 +409,14 @@ class TimeColumnsComponent {
|
|
|
262
409
|
if (cell.disabled) {
|
|
263
410
|
return;
|
|
264
411
|
}
|
|
412
|
+
this.markUserPick();
|
|
265
413
|
this.emit(this.baseHour(), cell.value, 'minutes');
|
|
266
414
|
}
|
|
267
415
|
selectPeriod(cell) {
|
|
268
416
|
if (cell.disabled) {
|
|
269
417
|
return;
|
|
270
418
|
}
|
|
419
|
+
this.markUserPick();
|
|
271
420
|
const parsed = this.parsedValue();
|
|
272
421
|
const hour12 = parsed
|
|
273
422
|
? to12h(parsed.h).h
|
|
@@ -307,7 +456,9 @@ class TimeColumnsComponent {
|
|
|
307
456
|
}
|
|
308
457
|
event.preventDefault();
|
|
309
458
|
this.selectAt(column, target);
|
|
310
|
-
this.buttonsFor(column)()[target]?.nativeElement.focus(
|
|
459
|
+
this.buttonsFor(column)()[target]?.nativeElement.focus({
|
|
460
|
+
preventScroll: true,
|
|
461
|
+
});
|
|
311
462
|
}
|
|
312
463
|
focusSelected() {
|
|
313
464
|
this.hourButtons()[Math.max(this.hourEntry(), 0)]?.nativeElement.focus();
|
|
@@ -342,7 +493,10 @@ class TimeColumnsComponent {
|
|
|
342
493
|
}
|
|
343
494
|
emit(hour24, minute, part) {
|
|
344
495
|
this.timeChange.emit(`${pad2(hour24)}:${pad2(minute)}`);
|
|
345
|
-
|
|
496
|
+
// partPicked closes the single panel once every column is picked; a scroll only browses.
|
|
497
|
+
if (!this.pickingByScroll) {
|
|
498
|
+
this.partPicked.emit(part);
|
|
499
|
+
}
|
|
346
500
|
}
|
|
347
501
|
entryIndex(cells) {
|
|
348
502
|
const selected = cells.findIndex((cell) => cell.selected && !cell.disabled);
|
|
@@ -406,17 +560,58 @@ class TimeColumnsComponent {
|
|
|
406
560
|
: this.periodEntry();
|
|
407
561
|
this.buttonsFor(column)()[Math.max(entry, 0)]?.nativeElement.focus();
|
|
408
562
|
}
|
|
563
|
+
markUserPick() {
|
|
564
|
+
this.userPicked = true;
|
|
565
|
+
window.setTimeout(() => (this.userPicked = false), 500);
|
|
566
|
+
}
|
|
409
567
|
scrollColumn(buttons, index) {
|
|
410
568
|
// The column alone: scrollIntoView would also scroll the page under the overlay.
|
|
411
569
|
const button = buttons[Math.max(index, 0)]?.nativeElement;
|
|
412
570
|
const column = button?.parentElement;
|
|
413
|
-
if (button
|
|
414
|
-
|
|
415
|
-
|
|
571
|
+
if (!button || !column) {
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
// The user is scrolling this column and its value follows the centre; scrolling it back would fight the gesture.
|
|
575
|
+
if (this.userScrolledColumns.has(column)) {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
const top = button.offsetTop - (column.clientHeight - button.offsetHeight) / 2;
|
|
579
|
+
// Any scrollTop write aborts a running smooth scroll, and at a low frame rate the rAF pass lands mid-animation.
|
|
580
|
+
const inFlight = this.smoothScrolls.get(column);
|
|
581
|
+
if (inFlight && Math.abs(inFlight.top - top) <= 1) {
|
|
582
|
+
return;
|
|
416
583
|
}
|
|
584
|
+
if (this.userPicked && !this.prefersReducedMotion()) {
|
|
585
|
+
this.scrollSmoothly(column, top, buttons.length);
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
column.scrollTop = top;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
scrollSmoothly(column, top, count) {
|
|
592
|
+
const set = this.setHeight(column, count);
|
|
593
|
+
if (set > 0) {
|
|
594
|
+
const nearest = [top - set, top, top + set].reduce((best, candidate) => Math.abs(candidate - column.scrollTop) <
|
|
595
|
+
Math.abs(best - column.scrollTop)
|
|
596
|
+
? candidate
|
|
597
|
+
: best);
|
|
598
|
+
if (nearest !== top) {
|
|
599
|
+
column.scrollTop += top - nearest;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
// Assigning scrollTop while this runs would abort the animation, so wrapScroll stands down until scrollend; the timer covers browsers without it.
|
|
603
|
+
this.releaseSmoothScroll(column);
|
|
604
|
+
this.smoothScrolls.set(column, {
|
|
605
|
+
timer: window.setTimeout(() => this.releaseSmoothScroll(column), 2000),
|
|
606
|
+
top,
|
|
607
|
+
});
|
|
608
|
+
column.scrollTo({ top, behavior: 'smooth' });
|
|
609
|
+
}
|
|
610
|
+
prefersReducedMotion() {
|
|
611
|
+
return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
417
612
|
}
|
|
418
613
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: TimeColumnsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
419
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: TimeColumnsComponent, isStandalone: true, selector: "ds-time-columns", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, minuteStep: { classPropertyName: "minuteStep", publicName: "minuteStep", isSignal: true, isRequired: false, transformFunction: null }, minTime: { classPropertyName: "minTime", publicName: "minTime", isSignal: true, isRequired: false, transformFunction: null }, maxTime: { classPropertyName: "maxTime", publicName: "maxTime", isSignal: true, isRequired: false, transformFunction: null }, disabledTime: { classPropertyName: "disabledTime", publicName: "disabledTime", isSignal: true, isRequired: false, transformFunction: null }, loop: { classPropertyName: "loop", publicName: "loop", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { timeChange: "timeChange", partPicked: "partPicked" }, host: { attributes: { "role": "group" }, properties: { "attr.aria-label": "intl().timePicker.time" }, classAttribute: "ds-time-columns" }, viewQueries: [{ propertyName: "hourButtons", predicate: ["hourOpt"], descendants: true, isSignal: true }, { propertyName: "minuteButtons", predicate: ["minOpt"], descendants: true, isSignal: true }, { propertyName: "periodButtons", predicate: ["periodOpt"], descendants: true, isSignal: true }, { propertyName: "hourColumn", first: true, predicate: ["hourCol"], descendants: true, isSignal: true }, { propertyName: "minuteColumn", first: true, predicate: ["minuteCol"], descendants: true, isSignal: true }], ngImport: i0, template: "<!-- A looping column renders its cells
|
|
614
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: TimeColumnsComponent, isStandalone: true, selector: "ds-time-columns", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, minuteStep: { classPropertyName: "minuteStep", publicName: "minuteStep", isSignal: true, isRequired: false, transformFunction: null }, minTime: { classPropertyName: "minTime", publicName: "minTime", isSignal: true, isRequired: false, transformFunction: null }, maxTime: { classPropertyName: "maxTime", publicName: "maxTime", isSignal: true, isRequired: false, transformFunction: null }, disabledTime: { classPropertyName: "disabledTime", publicName: "disabledTime", isSignal: true, isRequired: false, transformFunction: null }, loop: { classPropertyName: "loop", publicName: "loop", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { timeChange: "timeChange", partPicked: "partPicked" }, host: { attributes: { "role": "group" }, properties: { "attr.aria-label": "intl().timePicker.time" }, classAttribute: "ds-time-columns" }, viewQueries: [{ propertyName: "hourButtons", predicate: ["hourOpt"], descendants: true, isSignal: true }, { propertyName: "minuteButtons", predicate: ["minOpt"], descendants: true, isSignal: true }, { propertyName: "periodButtons", predicate: ["periodOpt"], descendants: true, isSignal: true }, { propertyName: "hourColumn", first: true, predicate: ["hourCol"], descendants: true, isSignal: true }, { propertyName: "minuteColumn", first: true, predicate: ["minuteCol"], descendants: true, isSignal: true }], ngImport: i0, template: "<!-- A looping column renders `loopCopiesEachSide` copies of its cells either side of the real ones: they\n are what scrolls into view past either end, and the column moves back by whole sets once a scroll ends.\n Enough copies that a continuous wheel gesture never reaches the edge, where wrapping mid-gesture cuts\n the wheel animation. -->\n<ng-template\n #loopCopy\n let-cells\n let-pick=\"pick\">\n @for (copy of loopCopiesEachSide; track copy) {\n @for (cell of cells; track cell.value) {\n <!-- Not a button: a copy is never focused or announced, the real option is. -->\n <span\n class=\"opt\"\n aria-hidden=\"true\"\n [class.is-selected]=\"cell.selected\"\n [class.is-disabled]=\"cell.disabled\"\n (click)=\"pick(cell)\">\n {{ cell.label }}\n </span>\n }\n }\n</ng-template>\n\n<div\n #hourCol\n class=\"col\"\n role=\"listbox\"\n [class.loops]=\"hoursLoop()\"\n [attr.aria-label]=\"intl().timePicker.hours\"\n (scroll)=\"onScroll($event, 'hours', hourCells().length)\"\n (wheel)=\"onWheel($event)\"\n (touchmove)=\"onUserScroll($event)\"\n (pointerdown)=\"onScrollbarGrab($event)\"\n (scrollend)=\"onScrollEnd($event, 'hours', hourCells().length)\">\n @if (hoursLoop()) {\n <ng-container\n [ngTemplateOutlet]=\"loopCopy\"\n [ngTemplateOutletContext]=\"{ $implicit: hourCells(), pick: pickHour }\" />\n }\n\n @for (cell of hourCells(); track cell.value; let i = $index) {\n <button\n #hourOpt\n type=\"button\"\n role=\"option\"\n class=\"opt\"\n [class.is-selected]=\"cell.selected\"\n [attr.aria-selected]=\"cell.selected\"\n [attr.tabindex]=\"i === hourEntry() ? 0 : -1\"\n [disabled]=\"cell.disabled\"\n (click)=\"selectHour(cell)\"\n (keydown)=\"onKey($event, 'hours', i)\">\n {{ cell.label }}\n </button>\n }\n\n @if (hoursLoop()) {\n <ng-container\n [ngTemplateOutlet]=\"loopCopy\"\n [ngTemplateOutletContext]=\"{ $implicit: hourCells(), pick: pickHour }\" />\n }\n</div>\n\n<div\n #minuteCol\n class=\"col\"\n role=\"listbox\"\n [class.loops]=\"minutesLoop()\"\n [attr.aria-label]=\"intl().timePicker.minutes\"\n (scroll)=\"onScroll($event, 'minutes', minuteCells().length)\"\n (wheel)=\"onWheel($event)\"\n (touchmove)=\"onUserScroll($event)\"\n (pointerdown)=\"onScrollbarGrab($event)\"\n (scrollend)=\"onScrollEnd($event, 'minutes', minuteCells().length)\">\n @if (minutesLoop()) {\n <ng-container\n [ngTemplateOutlet]=\"loopCopy\"\n [ngTemplateOutletContext]=\"{\n $implicit: minuteCells(),\n pick: pickMinute,\n }\" />\n }\n\n @for (cell of minuteCells(); track cell.value; let i = $index) {\n <button\n #minOpt\n type=\"button\"\n role=\"option\"\n class=\"opt\"\n [class.is-selected]=\"cell.selected\"\n [attr.aria-selected]=\"cell.selected\"\n [attr.tabindex]=\"i === minuteEntry() ? 0 : -1\"\n [disabled]=\"cell.disabled\"\n (click)=\"selectMinute(cell)\"\n (keydown)=\"onKey($event, 'minutes', i)\">\n {{ cell.label }}\n </button>\n }\n\n @if (minutesLoop()) {\n <ng-container\n [ngTemplateOutlet]=\"loopCopy\"\n [ngTemplateOutletContext]=\"{\n $implicit: minuteCells(),\n pick: pickMinute,\n }\" />\n }\n</div>\n\n@if (is12h()) {\n <div\n class=\"col\"\n role=\"listbox\"\n [attr.aria-label]=\"intl().timePicker.period\">\n @for (cell of periodCells(); track cell.value; let i = $index) {\n <button\n #periodOpt\n type=\"button\"\n role=\"option\"\n class=\"opt\"\n [class.is-selected]=\"cell.selected\"\n [attr.aria-selected]=\"cell.selected\"\n [attr.tabindex]=\"i === periodEntry() ? 0 : -1\"\n [disabled]=\"cell.disabled\"\n (click)=\"selectPeriod(cell)\"\n (keydown)=\"onKey($event, 'period', i)\">\n {{ cell.label }}\n </button>\n }\n </div>\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_time-picker-option-bg-color-selected: var( --ds-time-picker-option-bg-color-selected, var(--accent) );--_time-picker-option-text-color-selected: var( --ds-time-picker-option-text-color-selected, var(--accent-on) );--_time-picker-option-bg-color-hover: var( --ds-time-picker-option-bg-color-hover, var(--surface-secondary) );display:flex;gap:var(--space-1);align-items:stretch}.col{position:relative;display:flex;flex-direction:column;gap:var(--space-0-5);min-width:var(--ds-time-picker-column-width, 3rem);max-height:var(--ds-time-picker-column-height, 13.5rem);overflow-y:auto;scroll-snap-type:y mandatory;scrollbar-width:thin;padding-inline:var(--space-0-5)}.col.loops{scrollbar-width:none;-webkit-mask-image:linear-gradient(transparent,#000 var(--space-6),#000 calc(100% - var(--space-6)),transparent);mask-image:linear-gradient(transparent,#000 var(--space-6),#000 calc(100% - var(--space-6)),transparent)}.col:not(:last-child){border-right:var(--border-width-default) solid var(--border-subtitle);padding-right:var(--space-1)}.opt{flex:none;scroll-snap-align:center;appearance:none;border:0;cursor:pointer;width:100%;padding:var(--space-1-5) var(--space-3);border-radius:var(--ds-radius-inner);background-color:transparent;color:var(--text-primary);font:inherit;font-variant-numeric:tabular-nums;text-align:center;transition:background-color var(--duration-fast) var(--ease-standard)}.opt:hover:not(:disabled,.is-disabled,.is-selected){background-color:var(--_time-picker-option-bg-color-hover)}.opt:active:not(:disabled,.is-disabled,.is-selected){background-color:var(--surface-muted)}.opt.is-selected{background-color:var(--_time-picker-option-bg-color-selected);color:var(--_time-picker-option-text-color-selected)}.opt:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:calc(-1 * var(--focus-ring-width));animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.opt:disabled,.opt.is-disabled{color:var(--text-disabled);cursor:default}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
420
615
|
}
|
|
421
616
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: TimeColumnsComponent, decorators: [{
|
|
422
617
|
type: Component,
|
|
@@ -424,7 +619,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImpo
|
|
|
424
619
|
class: 'ds-time-columns',
|
|
425
620
|
role: 'group',
|
|
426
621
|
'[attr.aria-label]': 'intl().timePicker.time',
|
|
427
|
-
}, template: "<!-- A looping column renders its cells
|
|
622
|
+
}, template: "<!-- A looping column renders `loopCopiesEachSide` copies of its cells either side of the real ones: they\n are what scrolls into view past either end, and the column moves back by whole sets once a scroll ends.\n Enough copies that a continuous wheel gesture never reaches the edge, where wrapping mid-gesture cuts\n the wheel animation. -->\n<ng-template\n #loopCopy\n let-cells\n let-pick=\"pick\">\n @for (copy of loopCopiesEachSide; track copy) {\n @for (cell of cells; track cell.value) {\n <!-- Not a button: a copy is never focused or announced, the real option is. -->\n <span\n class=\"opt\"\n aria-hidden=\"true\"\n [class.is-selected]=\"cell.selected\"\n [class.is-disabled]=\"cell.disabled\"\n (click)=\"pick(cell)\">\n {{ cell.label }}\n </span>\n }\n }\n</ng-template>\n\n<div\n #hourCol\n class=\"col\"\n role=\"listbox\"\n [class.loops]=\"hoursLoop()\"\n [attr.aria-label]=\"intl().timePicker.hours\"\n (scroll)=\"onScroll($event, 'hours', hourCells().length)\"\n (wheel)=\"onWheel($event)\"\n (touchmove)=\"onUserScroll($event)\"\n (pointerdown)=\"onScrollbarGrab($event)\"\n (scrollend)=\"onScrollEnd($event, 'hours', hourCells().length)\">\n @if (hoursLoop()) {\n <ng-container\n [ngTemplateOutlet]=\"loopCopy\"\n [ngTemplateOutletContext]=\"{ $implicit: hourCells(), pick: pickHour }\" />\n }\n\n @for (cell of hourCells(); track cell.value; let i = $index) {\n <button\n #hourOpt\n type=\"button\"\n role=\"option\"\n class=\"opt\"\n [class.is-selected]=\"cell.selected\"\n [attr.aria-selected]=\"cell.selected\"\n [attr.tabindex]=\"i === hourEntry() ? 0 : -1\"\n [disabled]=\"cell.disabled\"\n (click)=\"selectHour(cell)\"\n (keydown)=\"onKey($event, 'hours', i)\">\n {{ cell.label }}\n </button>\n }\n\n @if (hoursLoop()) {\n <ng-container\n [ngTemplateOutlet]=\"loopCopy\"\n [ngTemplateOutletContext]=\"{ $implicit: hourCells(), pick: pickHour }\" />\n }\n</div>\n\n<div\n #minuteCol\n class=\"col\"\n role=\"listbox\"\n [class.loops]=\"minutesLoop()\"\n [attr.aria-label]=\"intl().timePicker.minutes\"\n (scroll)=\"onScroll($event, 'minutes', minuteCells().length)\"\n (wheel)=\"onWheel($event)\"\n (touchmove)=\"onUserScroll($event)\"\n (pointerdown)=\"onScrollbarGrab($event)\"\n (scrollend)=\"onScrollEnd($event, 'minutes', minuteCells().length)\">\n @if (minutesLoop()) {\n <ng-container\n [ngTemplateOutlet]=\"loopCopy\"\n [ngTemplateOutletContext]=\"{\n $implicit: minuteCells(),\n pick: pickMinute,\n }\" />\n }\n\n @for (cell of minuteCells(); track cell.value; let i = $index) {\n <button\n #minOpt\n type=\"button\"\n role=\"option\"\n class=\"opt\"\n [class.is-selected]=\"cell.selected\"\n [attr.aria-selected]=\"cell.selected\"\n [attr.tabindex]=\"i === minuteEntry() ? 0 : -1\"\n [disabled]=\"cell.disabled\"\n (click)=\"selectMinute(cell)\"\n (keydown)=\"onKey($event, 'minutes', i)\">\n {{ cell.label }}\n </button>\n }\n\n @if (minutesLoop()) {\n <ng-container\n [ngTemplateOutlet]=\"loopCopy\"\n [ngTemplateOutletContext]=\"{\n $implicit: minuteCells(),\n pick: pickMinute,\n }\" />\n }\n</div>\n\n@if (is12h()) {\n <div\n class=\"col\"\n role=\"listbox\"\n [attr.aria-label]=\"intl().timePicker.period\">\n @for (cell of periodCells(); track cell.value; let i = $index) {\n <button\n #periodOpt\n type=\"button\"\n role=\"option\"\n class=\"opt\"\n [class.is-selected]=\"cell.selected\"\n [attr.aria-selected]=\"cell.selected\"\n [attr.tabindex]=\"i === periodEntry() ? 0 : -1\"\n [disabled]=\"cell.disabled\"\n (click)=\"selectPeriod(cell)\"\n (keydown)=\"onKey($event, 'period', i)\">\n {{ cell.label }}\n </button>\n }\n </div>\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_time-picker-option-bg-color-selected: var( --ds-time-picker-option-bg-color-selected, var(--accent) );--_time-picker-option-text-color-selected: var( --ds-time-picker-option-text-color-selected, var(--accent-on) );--_time-picker-option-bg-color-hover: var( --ds-time-picker-option-bg-color-hover, var(--surface-secondary) );display:flex;gap:var(--space-1);align-items:stretch}.col{position:relative;display:flex;flex-direction:column;gap:var(--space-0-5);min-width:var(--ds-time-picker-column-width, 3rem);max-height:var(--ds-time-picker-column-height, 13.5rem);overflow-y:auto;scroll-snap-type:y mandatory;scrollbar-width:thin;padding-inline:var(--space-0-5)}.col.loops{scrollbar-width:none;-webkit-mask-image:linear-gradient(transparent,#000 var(--space-6),#000 calc(100% - var(--space-6)),transparent);mask-image:linear-gradient(transparent,#000 var(--space-6),#000 calc(100% - var(--space-6)),transparent)}.col:not(:last-child){border-right:var(--border-width-default) solid var(--border-subtitle);padding-right:var(--space-1)}.opt{flex:none;scroll-snap-align:center;appearance:none;border:0;cursor:pointer;width:100%;padding:var(--space-1-5) var(--space-3);border-radius:var(--ds-radius-inner);background-color:transparent;color:var(--text-primary);font:inherit;font-variant-numeric:tabular-nums;text-align:center;transition:background-color var(--duration-fast) var(--ease-standard)}.opt:hover:not(:disabled,.is-disabled,.is-selected){background-color:var(--_time-picker-option-bg-color-hover)}.opt:active:not(:disabled,.is-disabled,.is-selected){background-color:var(--surface-muted)}.opt.is-selected{background-color:var(--_time-picker-option-bg-color-selected);color:var(--_time-picker-option-text-color-selected)}.opt:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:calc(-1 * var(--focus-ring-width));animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.opt:disabled,.opt.is-disabled{color:var(--text-disabled);cursor:default}\n"] }]
|
|
428
623
|
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], minuteStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "minuteStep", required: false }] }], minTime: [{ type: i0.Input, args: [{ isSignal: true, alias: "minTime", required: false }] }], maxTime: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxTime", required: false }] }], disabledTime: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledTime", required: false }] }], loop: [{ type: i0.Input, args: [{ isSignal: true, alias: "loop", required: false }] }], timeChange: [{ type: i0.Output, args: ["timeChange"] }], partPicked: [{ type: i0.Output, args: ["partPicked"] }], hourButtons: [{ type: i0.ViewChildren, args: ['hourOpt', { isSignal: true }] }], minuteButtons: [{ type: i0.ViewChildren, args: ['minOpt', { isSignal: true }] }], periodButtons: [{ type: i0.ViewChildren, args: ['periodOpt', { isSignal: true }] }], hourColumn: [{ type: i0.ViewChild, args: ['hourCol', { isSignal: true }] }], minuteColumn: [{ type: i0.ViewChild, args: ['minuteCol', { isSignal: true }] }] } });
|
|
429
624
|
|
|
430
625
|
let nextId = 0;
|
|
@@ -493,7 +688,7 @@ class TimePickerComponent extends DsControlValueAccessor {
|
|
|
493
688
|
uid = `ds-timepicker-${++nextId}`;
|
|
494
689
|
labelId = `${this.uid}-label`;
|
|
495
690
|
openSegment = signal(null, ...(ngDevMode ? [{ debugName: "openSegment" }] : /* istanbul ignore next */ []));
|
|
496
|
-
// Columns visited since this opening; single mode has no Done button and closes once
|
|
691
|
+
// Columns visited since this opening; single mode has no Done button and closes once every column is chosen, AM/PM included on a 12-hour clock. Reset on open.
|
|
497
692
|
pickedParts = signal(new Set(), ...(ngDevMode ? [{ debugName: "pickedParts" }] : /* istanbul ignore next */ []));
|
|
498
693
|
overlayRef = null;
|
|
499
694
|
singleTrigger = viewChild('singleTrigger', ...(ngDevMode ? [{ debugName: "singleTrigger" }] : /* istanbul ignore next */ []));
|
|
@@ -676,7 +871,11 @@ class TimePickerComponent extends DsControlValueAccessor {
|
|
|
676
871
|
onPartPicked(part) {
|
|
677
872
|
const seen = new Set(this.pickedParts()).add(part);
|
|
678
873
|
this.pickedParts.set(seen);
|
|
679
|
-
|
|
874
|
+
const periodChosen = this.resolvedFormat() === '24h' || seen.has('period');
|
|
875
|
+
if (this.mode() === 'single' &&
|
|
876
|
+
seen.has('hours') &&
|
|
877
|
+
seen.has('minutes') &&
|
|
878
|
+
periodChosen) {
|
|
680
879
|
this.close('select');
|
|
681
880
|
}
|
|
682
881
|
}
|