@rivet-health/design-system 41.1.3 → 41.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,8 @@ import * as i1 from "@angular/common";
4
4
  import { CommonModule, CurrencyPipe, DatePipe as DatePipe$1, DecimalPipe, PercentPipe } from "@angular/common";
5
5
  import { BehaviorSubject, ReplaySubject, Subject, combineLatest, concatWith, connectable, distinctUntilChanged, filter, from, fromEvent, map, merge, mergeScan, of, scan, share, shareReplay, skip, skipUntil, startWith, switchMap, takeUntil, tap } from "rxjs";
6
6
  import { timeDay, timeDays, timeMonth, timeMonths, timeSunday, timeWeek, timeYear, timeYears, utcDay, utcMonth, utcWeek, utcYear } from "d3-time";
7
- import { timeFormat, utcFormat } from "d3-time-format";
8
7
  import { cloneDeep, debounce, defaultsDeep, difference, flattenDeep, isEqual, isNumber, orderBy, partition, range, sortBy, sum, sumBy, toInteger, union, uniq, uniqueId } from "lodash";
8
+ import { timeFormat, utcFormat } from "d3-time-format";
9
9
  import Fuse from "fuse.js";
10
10
  import { animate, group, query, style, transition, trigger } from "@angular/animations";
11
11
  import { distinctUntilChanged as distinctUntilChanged$1, map as map$1 } from "rxjs/operators";
@@ -5234,8 +5234,9 @@ var CalendarComponent = class CalendarComponent {
5234
5234
  const calendarDates = timeDays(timeSunday.floor(activeYearMonth), timeSunday.ceil(timeMonth.offset(activeYearMonth, 1)));
5235
5235
  const minCalendarDate = calendarDates[0];
5236
5236
  const maxCalendarDate = calendarDates[calendarDates.length - 1];
5237
+ const flooredSelectableMin = selectableMin ? timeDay.floor(selectableMin) : void 0;
5237
5238
  const selectedDateCoordinates = /* @__PURE__ */ new Map();
5238
- const visibleDatesInSelectedRange = datesInSelectedRange.filter((selected) => selected.valueOf() >= minCalendarDate.valueOf() && selected.valueOf() <= maxCalendarDate.valueOf() && (selectableMin ? selected.valueOf() >= selectableMin.valueOf() : true) && (selectableMax ? selected.valueOf() <= selectableMax.valueOf() : true) && (omitRange ? selected.valueOf() < omitRange[0].valueOf() || selected.valueOf() > omitRange[1].valueOf() : true));
5239
+ const visibleDatesInSelectedRange = datesInSelectedRange.filter((selected) => selected.valueOf() >= minCalendarDate.valueOf() && selected.valueOf() <= maxCalendarDate.valueOf() && (flooredSelectableMin ? selected.valueOf() >= flooredSelectableMin.valueOf() : true) && (selectableMax ? selected.valueOf() <= selectableMax.valueOf() : true) && (omitRange ? selected.valueOf() < omitRange[0].valueOf() || selected.valueOf() > omitRange[1].valueOf() : true));
5239
5240
  if (visibleDatesInSelectedRange.length > 0) {
5240
5241
  const firstVisibleSelectedDateOffset = getWeekdayNumber(visibleDatesInSelectedRange[0]);
5241
5242
  visibleDatesInSelectedRange.forEach((selected, i) => {
@@ -5275,9 +5276,9 @@ var CalendarComponent = class CalendarComponent {
5275
5276
  return {
5276
5277
  date,
5277
5278
  display: dayFormatter(date),
5278
- fadeIn: inRange && (dateValue === Math.max(minCalendarDate.valueOf(), selectableMin?.valueOf() ?? -Infinity) || dateValue === (omitRange ? timeDay.offset(omitRange[1], 1).valueOf() : -Infinity)),
5279
+ fadeIn: inRange && (dateValue === Math.max(minCalendarDate.valueOf(), flooredSelectableMin?.valueOf() ?? -Infinity) || dateValue === (omitRange ? timeDay.offset(omitRange[1], 1).valueOf() : -Infinity)),
5279
5280
  fadeOut: inRange && (dateValue === Math.min(maxCalendarDate.valueOf(), selectableMax?.valueOf() ?? Infinity) || dateValue === (omitRange ? timeDay.offset(omitRange[0], -1).valueOf() : Infinity)),
5280
- hidden: dateValue < (selectableMin?.valueOf() ?? -Infinity) || dateValue > (selectableMax?.valueOf() ?? Infinity) || (omitRange ? omitRange[0].valueOf() <= dateValue && dateValue <= omitRange[1].valueOf() : false),
5281
+ hidden: dateValue < (flooredSelectableMin?.valueOf() ?? -Infinity) || dateValue > (selectableMax?.valueOf() ?? Infinity) || (omitRange ? omitRange[0].valueOf() <= dateValue && dateValue <= omitRange[1].valueOf() : false),
5281
5282
  inCurrentMonth: dateValue >= activeYearMonth.valueOf() && dateValue < timeMonth.offset(activeYearMonth, 1).valueOf(),
5282
5283
  inRange,
5283
5284
  roundedNe: ne,
@@ -5384,7 +5385,7 @@ var CalendarComponent = class CalendarComponent {
5384
5385
  },
5385
5386
  ngImport: i0,
5386
5387
  template: "<div class=\"controls\">\n <div>\n <riv-simple-select\n [filterabilityOptions]=\"{ enabled: true, placeholder: 'Month' }\"\n [orderBy]=\"'source'\"\n [optionGroups]=\"monthOptions$ | async | rivOptionGroup\"\n [selectedOption]=\"selectedMonthOption$ | async\"\n (selectedOptionChange)=\"emitActiveYearMonth($event?.date ?? null)\"\n >\n <ng-template #trigger let-state=\"state\">\n <span\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n [icon]=\"state.display.open ? 'ChevronUp' : 'ChevronDown'\"\n [iconPosition]=\"'last'\"\n >\n {{ state.display.formattedSelectedOptions || '...' }}\n </span>\n </ng-template>\n </riv-simple-select>\n <riv-simple-select\n [filterabilityOptions]=\"{ enabled: true, placeholder: 'Year' }\"\n [orderBy]=\"'source'\"\n [optionGroups]=\"yearOptions$ | async | rivOptionGroup\"\n [selectedOption]=\"selectedYearOption$ | async\"\n (selectedOptionChange)=\"emitActiveYearMonth($event?.date ?? null)\"\n >\n <ng-template #trigger let-state=\"state\">\n <span\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n [icon]=\"state.display.open ? 'ChevronUp' : 'ChevronDown'\"\n [iconPosition]=\"'last'\"\n >\n {{ state.display.formattedSelectedOptions || '...' }}\n </span>\n </ng-template>\n </riv-simple-select>\n </div>\n <div\n *ngIf=\"{ prev: previousMonth$ | async, next: nextMonth$ | async }; let vm\"\n >\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n [icon]=\"'ArrowLeft'\"\n [disabled]=\"!vm.prev\"\n (click)=\"vm.prev ? activeYearMonthChange.emit(vm.prev) : null\"\n type=\"button\"\n ></button>\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n [icon]=\"'ArrowRight'\"\n [disabled]=\"!vm.next\"\n (click)=\"vm.next ? activeYearMonthChange.emit(vm.next) : null\"\n type=\"button\"\n ></button>\n </div>\n</div>\n<div class=\"calendar\">\n <span class=\"label\">Su</span>\n <span class=\"label\">Mo</span>\n <span class=\"label\">Tu</span>\n <span class=\"label\">We</span>\n <span class=\"label\">Th</span>\n <span class=\"label\">Fr</span>\n <span class=\"label\">Sa</span>\n <button\n *ngFor=\"let day of dates$ | async; trackBy: trackByDate\"\n class=\"day\"\n [disabled]=\"day.hidden\"\n [attr.aria-disabled]=\"day.hidden ? 'true' : null\"\n [class.hidden]=\"day.hidden\"\n [class.bleed]=\"!day.inCurrentMonth && !day.hidden\"\n [class.fade-in]=\"day.fadeIn\"\n [class.fade-out]=\"day.fadeOut\"\n [class.in-range]=\"day.inRange\"\n [class.rounded-ne]=\"day.roundedNe\"\n [class.rounded-nw]=\"day.roundedNw\"\n [class.rounded-se]=\"day.roundedSe\"\n [class.rounded-sw]=\"day.roundedSw\"\n (click)=\"selectDay(day)\"\n type=\"button\"\n >\n <span\n class=\"day-wrapper\"\n [class.selected]=\"day.selected\"\n [class.today]=\"day.today\"\n >\n {{ day.display }}\n </span>\n </button>\n</div>\n",
5387
- styles: [".controls{display:flex;align-items:center;justify-content:space-between}.calendar{display:grid;grid-template-columns:repeat(7,calc(var(--base-grid-size) * 10));grid-auto-rows:calc(var(--base-grid-size) * 6)}.label{display:flex;justify-content:center;align-items:center;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-0);font-weight:var(--font-weight-heavy)}.day{display:flex;align-items:stretch;cursor:pointer}.day.hidden{cursor:default}.day:hover:not(.hidden){background-color:var(--surface-light-1)}.day.in-range{background-color:var(--purp-10)}.day.fade-out{background-image:linear-gradient(to right,var(--purp-10),var(--white-100))}.day.fade-in{background-image:linear-gradient(to right,var(--white-100),var(--purp-10))}.day.bleed{color:var(--type-light-low-contrast)}.day.rounded-ne{border-top-right-radius:var(--border-radius-medium)}.day.rounded-nw{border-top-left-radius:var(--border-radius-medium)}.day.rounded-sw{border-bottom-left-radius:var(--border-radius-medium)}.day.rounded-se{border-bottom-right-radius:var(--border-radius-medium)}.day-wrapper{flex-grow:1;display:flex;justify-content:center;align-items:center;border-radius:var(--border-radius-medium)}.day-wrapper.selected{background-color:var(--purp-60);color:var(--type-dark-high-contrast)}.day-wrapper.today{border-radius:calc(var(--base-grid-size) * 8);border:var(--border-width) solid var(--border-light);font-weight:var(--font-weight-heavy)}\n"],
5388
+ styles: [".controls{display:flex;align-items:center;justify-content:space-between}.calendar{display:grid;grid-template-columns:repeat(7,calc(var(--base-grid-size) * 10));grid-auto-rows:calc(var(--base-grid-size) * 6)}.label{display:flex;justify-content:center;align-items:center;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-0);font-weight:var(--font-weight-heavy)}.day{display:flex;align-items:stretch;cursor:pointer}.day.hidden{cursor:default;color:var(--type-light-disabled)}.day:hover:not(.hidden){background-color:var(--surface-light-1)}.day.in-range{background-color:var(--purp-10)}.day.fade-out{background-image:linear-gradient(to right,var(--purp-10),var(--white-100))}.day.fade-in{background-image:linear-gradient(to right,var(--white-100),var(--purp-10))}.day.bleed{color:var(--type-light-low-contrast)}.day.rounded-ne{border-top-right-radius:var(--border-radius-medium)}.day.rounded-nw{border-top-left-radius:var(--border-radius-medium)}.day.rounded-sw{border-bottom-left-radius:var(--border-radius-medium)}.day.rounded-se{border-bottom-right-radius:var(--border-radius-medium)}.day-wrapper{flex-grow:1;display:flex;justify-content:center;align-items:center;border-radius:var(--border-radius-medium)}.day-wrapper.selected{background-color:var(--purp-60);color:var(--type-dark-high-contrast)}.day-wrapper.today{border-radius:calc(var(--base-grid-size) * 8);border:var(--border-width) solid var(--border-light);font-weight:var(--font-weight-heavy)}\n"],
5388
5389
  dependencies: [
5389
5390
  {
5390
5391
  kind: "directive",
@@ -5474,7 +5475,7 @@ i0.ɵɵngDeclareClassMetadata({
5474
5475
  changeDetection: ChangeDetectionStrategy.OnPush,
5475
5476
  standalone: false,
5476
5477
  template: "<div class=\"controls\">\n <div>\n <riv-simple-select\n [filterabilityOptions]=\"{ enabled: true, placeholder: 'Month' }\"\n [orderBy]=\"'source'\"\n [optionGroups]=\"monthOptions$ | async | rivOptionGroup\"\n [selectedOption]=\"selectedMonthOption$ | async\"\n (selectedOptionChange)=\"emitActiveYearMonth($event?.date ?? null)\"\n >\n <ng-template #trigger let-state=\"state\">\n <span\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n [icon]=\"state.display.open ? 'ChevronUp' : 'ChevronDown'\"\n [iconPosition]=\"'last'\"\n >\n {{ state.display.formattedSelectedOptions || '...' }}\n </span>\n </ng-template>\n </riv-simple-select>\n <riv-simple-select\n [filterabilityOptions]=\"{ enabled: true, placeholder: 'Year' }\"\n [orderBy]=\"'source'\"\n [optionGroups]=\"yearOptions$ | async | rivOptionGroup\"\n [selectedOption]=\"selectedYearOption$ | async\"\n (selectedOptionChange)=\"emitActiveYearMonth($event?.date ?? null)\"\n >\n <ng-template #trigger let-state=\"state\">\n <span\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n [icon]=\"state.display.open ? 'ChevronUp' : 'ChevronDown'\"\n [iconPosition]=\"'last'\"\n >\n {{ state.display.formattedSelectedOptions || '...' }}\n </span>\n </ng-template>\n </riv-simple-select>\n </div>\n <div\n *ngIf=\"{ prev: previousMonth$ | async, next: nextMonth$ | async }; let vm\"\n >\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n [icon]=\"'ArrowLeft'\"\n [disabled]=\"!vm.prev\"\n (click)=\"vm.prev ? activeYearMonthChange.emit(vm.prev) : null\"\n type=\"button\"\n ></button>\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n [icon]=\"'ArrowRight'\"\n [disabled]=\"!vm.next\"\n (click)=\"vm.next ? activeYearMonthChange.emit(vm.next) : null\"\n type=\"button\"\n ></button>\n </div>\n</div>\n<div class=\"calendar\">\n <span class=\"label\">Su</span>\n <span class=\"label\">Mo</span>\n <span class=\"label\">Tu</span>\n <span class=\"label\">We</span>\n <span class=\"label\">Th</span>\n <span class=\"label\">Fr</span>\n <span class=\"label\">Sa</span>\n <button\n *ngFor=\"let day of dates$ | async; trackBy: trackByDate\"\n class=\"day\"\n [disabled]=\"day.hidden\"\n [attr.aria-disabled]=\"day.hidden ? 'true' : null\"\n [class.hidden]=\"day.hidden\"\n [class.bleed]=\"!day.inCurrentMonth && !day.hidden\"\n [class.fade-in]=\"day.fadeIn\"\n [class.fade-out]=\"day.fadeOut\"\n [class.in-range]=\"day.inRange\"\n [class.rounded-ne]=\"day.roundedNe\"\n [class.rounded-nw]=\"day.roundedNw\"\n [class.rounded-se]=\"day.roundedSe\"\n [class.rounded-sw]=\"day.roundedSw\"\n (click)=\"selectDay(day)\"\n type=\"button\"\n >\n <span\n class=\"day-wrapper\"\n [class.selected]=\"day.selected\"\n [class.today]=\"day.today\"\n >\n {{ day.display }}\n </span>\n </button>\n</div>\n",
5477
- styles: [".controls{display:flex;align-items:center;justify-content:space-between}.calendar{display:grid;grid-template-columns:repeat(7,calc(var(--base-grid-size) * 10));grid-auto-rows:calc(var(--base-grid-size) * 6)}.label{display:flex;justify-content:center;align-items:center;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-0);font-weight:var(--font-weight-heavy)}.day{display:flex;align-items:stretch;cursor:pointer}.day.hidden{cursor:default}.day:hover:not(.hidden){background-color:var(--surface-light-1)}.day.in-range{background-color:var(--purp-10)}.day.fade-out{background-image:linear-gradient(to right,var(--purp-10),var(--white-100))}.day.fade-in{background-image:linear-gradient(to right,var(--white-100),var(--purp-10))}.day.bleed{color:var(--type-light-low-contrast)}.day.rounded-ne{border-top-right-radius:var(--border-radius-medium)}.day.rounded-nw{border-top-left-radius:var(--border-radius-medium)}.day.rounded-sw{border-bottom-left-radius:var(--border-radius-medium)}.day.rounded-se{border-bottom-right-radius:var(--border-radius-medium)}.day-wrapper{flex-grow:1;display:flex;justify-content:center;align-items:center;border-radius:var(--border-radius-medium)}.day-wrapper.selected{background-color:var(--purp-60);color:var(--type-dark-high-contrast)}.day-wrapper.today{border-radius:calc(var(--base-grid-size) * 8);border:var(--border-width) solid var(--border-light);font-weight:var(--font-weight-heavy)}\n"]
5478
+ styles: [".controls{display:flex;align-items:center;justify-content:space-between}.calendar{display:grid;grid-template-columns:repeat(7,calc(var(--base-grid-size) * 10));grid-auto-rows:calc(var(--base-grid-size) * 6)}.label{display:flex;justify-content:center;align-items:center;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-0);font-weight:var(--font-weight-heavy)}.day{display:flex;align-items:stretch;cursor:pointer}.day.hidden{cursor:default;color:var(--type-light-disabled)}.day:hover:not(.hidden){background-color:var(--surface-light-1)}.day.in-range{background-color:var(--purp-10)}.day.fade-out{background-image:linear-gradient(to right,var(--purp-10),var(--white-100))}.day.fade-in{background-image:linear-gradient(to right,var(--white-100),var(--purp-10))}.day.bleed{color:var(--type-light-low-contrast)}.day.rounded-ne{border-top-right-radius:var(--border-radius-medium)}.day.rounded-nw{border-top-left-radius:var(--border-radius-medium)}.day.rounded-sw{border-bottom-left-radius:var(--border-radius-medium)}.day.rounded-se{border-bottom-right-radius:var(--border-radius-medium)}.day-wrapper{flex-grow:1;display:flex;justify-content:center;align-items:center;border-radius:var(--border-radius-medium)}.day-wrapper.selected{background-color:var(--purp-60);color:var(--type-dark-high-contrast)}.day-wrapper.today{border-radius:calc(var(--base-grid-size) * 8);border:var(--border-width) solid var(--border-light);font-weight:var(--font-weight-heavy)}\n"]
5478
5479
  }]
5479
5480
  }],
5480
5481
  propDecorators: {
@@ -5493,238 +5494,173 @@ i0.ɵɵngDeclareClassMetadata({
5493
5494
  CalendarComponent.defaultMin = timeYear.floor(timeYear.offset(/* @__PURE__ */ new Date(), -7));
5494
5495
  CalendarComponent.defaultMax = timeDay.offset(timeYear.floor(timeYear.offset(/* @__PURE__ */ new Date(), 5)), -1);
5495
5496
  })(CalendarComponent || (CalendarComponent = {}));
5496
- const timeQuarter = timeMonth.every(3);
5497
- var DateRangeComponent = class DateRangeComponent extends InputLabelComponent {
5498
- constructor() {
5499
- super(...arguments);
5500
- this.TODAY = /* @__PURE__ */ new Date();
5501
- this.STORAGE_KEY = "date-range.default";
5502
- this.showPresets$ = new BehaviorSubject(true);
5503
- this.min$ = new BehaviorSubject(CalendarComponent.defaultMin);
5504
- this.max$ = new BehaviorSubject(CalendarComponent.defaultMax);
5505
- this.value$ = new BehaviorSubject(void 0);
5506
- this.distinctValue$ = this.value$.pipe(distinctUntilChanged((previous, current) => previous?.[0].valueOf() === current?.[0].valueOf() && previous?.[1].valueOf() === current?.[1].valueOf()), shareReplay({
5507
- refCount: true,
5508
- bufferSize: 1
5509
- }));
5510
- this.placeholder$ = new BehaviorSubject("Select date range");
5511
- this.disabled$ = new BehaviorSubject(false);
5512
- this.alternativePresetList$ = new BehaviorSubject([]);
5497
+ var DateComponent = class DateComponent extends InputLabelComponent {
5498
+ set value(v) {
5499
+ if (this._value?.getTime() === v?.getTime()) return;
5500
+ this._value = v;
5501
+ if (!this.hasFocus) this.syncInputText();
5502
+ if (v) this.setActiveMonth(v);
5503
+ this.cdr.markForCheck();
5504
+ }
5505
+ get value() {
5506
+ return this._value;
5507
+ }
5508
+ set open(v) {
5509
+ this.open$.next(v);
5510
+ }
5511
+ get open() {
5512
+ return this.open$.getValue();
5513
+ }
5514
+ constructor(cdr, host) {
5515
+ super();
5516
+ this.cdr = cdr;
5517
+ this.host = host;
5518
+ this.min = CalendarComponent.defaultMin;
5519
+ this.max = CalendarComponent.defaultMax;
5520
+ this.placeholder = "Select date";
5521
+ this.disabled = false;
5522
+ this.size = "medium";
5523
+ this.showClearButton = true;
5524
+ this.showTodayButton = true;
5525
+ this.activeYearMonth = timeMonth.floor(/* @__PURE__ */ new Date());
5513
5526
  this.open$ = new BehaviorSubject(false);
5514
- this.userSelectedPreset$ = new Subject();
5515
- this.userSelectedDate$ = new Subject();
5516
- this.selectedValue$ = merge(this.distinctValue$, this.userSelectedDate$.pipe(scan((previous, date) => {
5517
- if (previous instanceof Date && date instanceof Date) {
5518
- if (date.valueOf() >= previous.valueOf()) return [previous, date];
5519
- }
5520
- return date;
5521
- })), this.userSelectedPreset$.pipe(filter((preset) => preset !== null), map((preset) => preset.dates))).pipe(shareReplay({
5522
- refCount: true,
5523
- bufferSize: 1
5524
- }));
5525
- this.filteredPresetOptions$ = combineLatest([
5526
- this.min$,
5527
- this.max$,
5528
- this.alternativePresetList$
5529
- ]).pipe(map(([min, max, alternativePresetList]) => {
5530
- const optionsFilteredOnMinMax = DateRangeComponent.Presets.filter((p) => p.dates[0].valueOf() >= min.valueOf() && p.dates[1].valueOf() <= max.valueOf());
5531
- if (alternativePresetList.length == 0) return optionsFilteredOnMinMax;
5532
- else return optionsFilteredOnMinMax.filter((p) => alternativePresetList.includes(p.id));
5533
- }), shareReplay({
5534
- refCount: true,
5535
- bufferSize: 1
5536
- }));
5537
- this.selectedPreset$ = combineLatest([this.selectedValue$, this.userSelectedPreset$.pipe(startWith(null))]).pipe(map(([selectedValue, userSelectedPreset]) => {
5538
- if (selectedValue instanceof Array) {
5539
- const options = DateRangeComponent.Presets.filter((preset) => preset.dates[0].valueOf() === selectedValue[0].valueOf() && preset.dates[1].valueOf() === selectedValue[1].valueOf());
5540
- if (options.length) {
5541
- const mostRecent = options.find((option) => option.id === userSelectedPreset?.id);
5542
- if (mostRecent) return mostRecent;
5543
- return options[0];
5544
- }
5545
- }
5546
- return null;
5547
- }));
5548
- this.favoritePresetIds$ = new LocalStorage(this.STORAGE_KEY, []);
5549
- this.favoritePresets$ = combineLatest([
5550
- this.favoritePresetIds$,
5551
- this.filteredPresetOptions$,
5552
- this.alternativePresetList$
5553
- ]).pipe(map(([ids, presets, alternativePresetList]) => {
5554
- const favoritePresets = ids.map((id) => presets.find((preset) => preset.id === id)).filter((p) => p !== void 0);
5555
- if (alternativePresetList.length == 0) return favoritePresets;
5556
- else return favoritePresets.filter((p) => alternativePresetList.includes(p.id));
5557
- }), shareReplay({
5558
- refCount: true,
5559
- bufferSize: 1
5560
- }));
5561
- this.userLeftActiveYearMonth$ = new Subject();
5562
- this.userRightActiveYearMonth$ = new Subject();
5563
- this.leftMin$ = this.min$.pipe(shareReplay({
5564
- refCount: true,
5565
- bufferSize: 1
5566
- }));
5567
- this.leftMax$ = this.max$.pipe(map((max) => timeDay.offset(timeMonth.floor(max), -1)), shareReplay({
5568
- refCount: true,
5569
- bufferSize: 1
5570
- }));
5571
- this.rightMax$ = this.max$.pipe(shareReplay({
5572
- refCount: true,
5573
- bufferSize: 1
5574
- }));
5575
- this.leftActiveYearMonth$ = combineLatest([this.leftMax$, merge(this.userLeftActiveYearMonth$.pipe(startWith(timeMonth.floor(this.TODAY))), this.userSelectedPreset$.pipe(filter((preset) => preset !== null), map((preset) => timeMonth.floor(preset.dates[0]))), this.distinctValue$.pipe(filter((v) => v !== void 0), map((v) => timeMonth.floor(v[0]))))]).pipe(map(([leftMax, left]) => {
5576
- if (left.valueOf() >= leftMax.valueOf()) return timeMonth.floor(leftMax);
5577
- else return left;
5578
- }), shareReplay({
5579
- refCount: true,
5580
- bufferSize: 1
5581
- }));
5582
- this.rightActiveYearMonth$ = combineLatest([
5583
- this.leftActiveYearMonth$,
5584
- merge(this.userRightActiveYearMonth$.pipe(startWith(timeMonth.ceil(this.TODAY))), this.userSelectedPreset$.pipe(filter((preset) => preset !== null), map((preset) => timeMonth.floor(preset.dates[1]))), this.distinctValue$.pipe(filter((v) => v !== void 0), map((v) => timeMonth.floor(v[1])))),
5585
- this.rightMax$
5586
- ]).pipe(map(([left, userRight, rightMax$]) => {
5587
- if (left.valueOf() >= userRight.valueOf()) return timeMonth.floor(timeMonth.offset(left, 1));
5588
- else if (userRight.valueOf() >= rightMax$.valueOf()) return timeMonth.floor(rightMax$);
5589
- else return userRight;
5590
- }), shareReplay({
5591
- refCount: true,
5592
- bufferSize: 1
5593
- }));
5594
- this.rightMin$ = this.leftActiveYearMonth$.pipe(map((left) => timeMonth.floor(timeMonth.offset(left, 1))), shareReplay({
5595
- refCount: true,
5596
- bufferSize: 1
5597
- }));
5598
- this.leftOmitRange$ = this.rightActiveYearMonth$.pipe(map((rightActiveYearMonth) => {
5599
- return [timeMonth.floor(rightActiveYearMonth), timeDay.offset(timeMonth.floor(timeMonth.offset(rightActiveYearMonth, 1)), -1)];
5600
- }), shareReplay({
5601
- refCount: true,
5602
- bufferSize: 1
5603
- }));
5604
- this.userInteracted$ = merge(this.userSelectedDate$, this.userSelectedPreset$);
5605
- this.valueChange = this.selectedValue$.pipe(skipUntil(merge(this.userInteracted$, this.selectedValue$.pipe(filter((v) => v !== void 0)))), filter((v) => !(v instanceof Date)), distinctUntilChanged((previous, current) => previous?.[0].valueOf() === current?.[0].valueOf() && previous?.[1].valueOf() === current?.[1].valueOf()), shareReplay({
5606
- refCount: true,
5607
- bufferSize: 1
5608
- }));
5609
- this.displayValue$ = this.valueChange.pipe(map((v) => {
5610
- if (v) return v.map((date) => new DatePipe().transform(date)).join(" — ");
5611
- }), shareReplay({
5612
- refCount: true,
5613
- bufferSize: 1
5614
- }));
5527
+ this.calendarId = uniqueId("riv-date-calendar-");
5528
+ this.valueChange = new EventEmitter();
5529
+ this.inputText = "";
5530
+ this.hasFocus = false;
5531
+ this.datePipe = new DatePipe();
5615
5532
  }
5616
- set showPresets(v) {
5617
- this.showPresets$.next(v);
5533
+ ngOnChanges(changes) {
5534
+ if (changes["rollingTodayLabel"] && !this.hasFocus) this.syncInputText();
5618
5535
  }
5619
- get showPresets() {
5620
- return this.showPresets$.getValue();
5536
+ onDocumentMouseDown(target) {
5537
+ if (!this.open$.getValue() || !(target instanceof Element)) return;
5538
+ if (this.isInsidePicker(target)) return;
5539
+ this.open$.next(false);
5540
+ this.cdr.markForCheck();
5621
5541
  }
5622
- set min(v) {
5623
- this.min$.next(v);
5542
+ isInsidePicker(target) {
5543
+ const host = this.host.nativeElement;
5544
+ if (host.contains(target)) return true;
5545
+ const layer = target.closest(".callout, .scrim, .overlay-container");
5546
+ return !!layer && !layer.contains(host);
5624
5547
  }
5625
- get min() {
5626
- return this.min$.getValue();
5548
+ clearValue() {
5549
+ this.commit(void 0);
5550
+ this.open$.next(false);
5627
5551
  }
5628
- set max(v) {
5629
- this.max$.next(v);
5552
+ selectToday() {
5553
+ if (!this.isTodaySelectable) return;
5554
+ this.commit(this.isRolling ? void 0 : timeDay.floor(/* @__PURE__ */ new Date()));
5555
+ this.open$.next(false);
5630
5556
  }
5631
- get max() {
5632
- return this.max$.getValue();
5557
+ get isTodaySelectable() {
5558
+ return DateComponent.isValidDate(timeDay.floor(/* @__PURE__ */ new Date()), this.min, this.max);
5633
5559
  }
5634
- set value(v) {
5635
- this.value$.next(v);
5560
+ get selectedCalendarValue() {
5561
+ return this.previewValue ?? this._value ?? (this.isRolling ? timeDay.floor(/* @__PURE__ */ new Date()) : void 0);
5636
5562
  }
5637
- get value() {
5638
- return this.value$.getValue();
5563
+ onInputChange(value) {
5564
+ this.inputText = value;
5565
+ const parsed = this.parseInput(value);
5566
+ this.previewValue = parsed;
5567
+ if (parsed) this.setActiveMonth(parsed);
5568
+ this.cdr.markForCheck();
5639
5569
  }
5640
- set placeholder(v) {
5641
- this.placeholder$.next(v);
5570
+ onInputBlur(event) {
5571
+ this.hasFocus = false;
5572
+ const parsed = this.parseInput(this.inputText);
5573
+ if (parsed) this.commit(parsed);
5574
+ else if (!this.inputText.trim() || this.isRollingText(this.inputText)) this.commit(void 0);
5575
+ else this.syncInputText();
5576
+ this.previewValue = void 0;
5577
+ const nextTarget = event?.relatedTarget;
5578
+ if (!(nextTarget instanceof Element && this.isInsidePicker(nextTarget))) this.open$.next(false);
5579
+ this.cdr.markForCheck();
5642
5580
  }
5643
- get placeholder() {
5644
- return this.placeholder$.getValue();
5581
+ onDateSelect(date) {
5582
+ this.commit(timeDay.floor(date));
5583
+ this.open$.next(false);
5645
5584
  }
5646
- set disabled(v) {
5647
- this.disabled$.next(v);
5585
+ onInputFocus() {
5586
+ this.hasFocus = true;
5587
+ this.open$.next(true);
5648
5588
  }
5649
- get disabled() {
5650
- return this.disabled$.getValue();
5589
+ toggleCalendar() {
5590
+ this.open$.next(!this.open$.getValue());
5651
5591
  }
5652
- getTrigger() {
5653
- return this.customTriggerButton?.nativeElement ?? this.standardTriggerButton?.nativeElement ?? null;
5592
+ get isRolling() {
5593
+ return this.rollingTodayLabel != null;
5654
5594
  }
5655
- set alternativePresetList(v) {
5656
- this.alternativePresetList$.next(v);
5595
+ isRollingText(text) {
5596
+ return this.rollingTodayLabel != null && text.trim().toLowerCase() === this.rollingTodayLabel.toLowerCase();
5657
5597
  }
5658
- get alternativePresetList() {
5659
- return this.alternativePresetList$.getValue();
5598
+ syncInputText() {
5599
+ this.inputText = this._value ? this.formatValue(this._value) : this.rollingTodayLabel ?? "";
5660
5600
  }
5661
- setFavorite(preset, favorite) {
5662
- const ids = new Set(this.favoritePresetIds$.getValue());
5663
- if (favorite) ids.add(preset.id);
5664
- else ids.delete(preset.id);
5665
- this.favoritePresetIds$.next([...ids]);
5601
+ formatValue(date) {
5602
+ return this.datePipe.transform(date);
5666
5603
  }
5667
- static {
5668
- this.ɵfac = i0.ɵɵngDeclareFactory({
5669
- minVersion: "12.0.0",
5670
- version: "22.2.4",
5671
- ngImport: i0,
5672
- type: DateRangeComponent,
5673
- deps: null,
5674
- target: i0.ɵɵFactoryTarget.Component
5675
- });
5604
+ parseInput(text) {
5605
+ const parsed = DateComponent.parseDate(text);
5606
+ return parsed && DateComponent.isValidDate(parsed, this.min, this.max) ? timeDay.floor(parsed) : void 0;
5676
5607
  }
5677
- static {
5678
- this.ɵcmp = i0.ɵɵngDeclareComponent({
5679
- minVersion: "14.0.0",
5680
- version: "22.2.4",
5681
- type: DateRangeComponent,
5608
+ setActiveMonth(date) {
5609
+ const month = timeMonth.floor(date);
5610
+ if (month.getTime() !== this.activeYearMonth.getTime()) this.activeYearMonth = month;
5611
+ }
5612
+ commit(next) {
5613
+ const unchanged = next?.getTime() === this._value?.getTime();
5614
+ this._value = next;
5615
+ this.syncInputText();
5616
+ this.previewValue = void 0;
5617
+ if (next) this.setActiveMonth(next);
5618
+ if (!unchanged) this.valueChange.emit(next);
5619
+ this.cdr.markForCheck();
5620
+ }
5621
+ static {
5622
+ this.ɵfac = i0.ɵɵngDeclareFactory({
5623
+ minVersion: "12.0.0",
5624
+ version: "22.2.4",
5625
+ ngImport: i0,
5626
+ type: DateComponent,
5627
+ deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }],
5628
+ target: i0.ɵɵFactoryTarget.Component
5629
+ });
5630
+ }
5631
+ static {
5632
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
5633
+ minVersion: "14.0.0",
5634
+ version: "22.2.4",
5635
+ type: DateComponent,
5682
5636
  isStandalone: false,
5683
- selector: "riv-date-range",
5637
+ selector: "riv-date",
5684
5638
  inputs: {
5685
- showPresets: "showPresets",
5686
5639
  min: "min",
5687
5640
  max: "max",
5688
5641
  value: "value",
5689
5642
  placeholder: "placeholder",
5690
5643
  disabled: "disabled",
5691
- alternativePresetList: "alternativePresetList"
5644
+ size: "size",
5645
+ showClearButton: "showClearButton",
5646
+ showTodayButton: "showTodayButton",
5647
+ rollingTodayLabel: "rollingTodayLabel",
5648
+ open: "open"
5692
5649
  },
5693
5650
  outputs: { valueChange: "valueChange" },
5651
+ host: { listeners: { "document:mousedown": "onDocumentMouseDown($event.target)" } },
5694
5652
  queries: [{
5695
- propertyName: "triggerTemplate",
5653
+ propertyName: "headerTemplate",
5696
5654
  first: true,
5697
- predicate: ["trigger"],
5655
+ predicate: ["header"],
5698
5656
  descendants: true
5699
5657
  }],
5700
- viewQueries: [{
5701
- propertyName: "customTriggerButton",
5702
- first: true,
5703
- predicate: ["customTriggerButton"],
5704
- descendants: true,
5705
- read: ElementRef
5706
- }, {
5707
- propertyName: "standardTriggerButton",
5708
- first: true,
5709
- predicate: ["standardTriggerButton"],
5710
- descendants: true,
5711
- read: ElementRef
5712
- }],
5713
5658
  usesInheritance: true,
5659
+ usesOnChanges: true,
5714
5660
  ngImport: i0,
5715
- template: "<ng-container *ngIf=\"triggerTemplate; else standardTrigger\">\n <button\n #customTriggerButton\n (click)=\"open$.next(true)\"\n [disabled]=\"disabled$ | async\"\n [attr.aria-disabled]=\"(disabled$ | async) ? 'true' : null\"\n type=\"button\"\n >\n <ng-container\n [ngTemplateOutlet]=\"triggerTemplate\"\n [ngTemplateOutletContext]=\"{ open: open$ | async }\"\n ></ng-container>\n </button>\n</ng-container>\n<ng-template #standardTrigger>\n <riv-input-label\n [label]=\"label\"\n [help]=\"help\"\n [required]=\"required\"\n [state]=\"state\"\n [errorMessage]=\"errorMessage\"\n [labelActionText]=\"labelActionText\"\n (labelAction)=\"labelAction.emit($event)\"\n >\n <button\n #standardTriggerButton\n class=\"trigger\"\n [class.warning]=\"state === 'warning'\"\n [class.error]=\"state === 'error'\"\n (click)=\"open$.next(true)\"\n [disabled]=\"disabled$ | async\"\n [attr.aria-disabled]=\"(disabled$ | async) ? 'true' : null\"\n type=\"button\"\n >\n <ng-container\n *ngIf=\"displayValue$ | async; else placeholderValue; let display\"\n >\n <span class=\"value\">{{ display }}</span>\n </ng-container>\n <ng-template #placeholderValue>\n <span class=\"value placeholder\">{{ placeholder$ | async }}</span>\n </ng-template>\n <span class=\"chevron\">\n <riv-icon [name]=\"'Calendar'\" [size]=\"16\"></riv-icon>\n </span>\n </button>\n </riv-input-label>\n</ng-template>\n\n<ng-template\n #self\n [ngTemplateOutlet]=\"self\"\n let-inputValue\n [ngTemplateOutletContext]=\"{ $implicit: (distinctValue$ | async) }\"\n>\n <ng-container *ngIf=\"open$ | async\">\n <riv-callout\n *riv-overlay\n [anchor]=\"getTrigger()\"\n [showCaret]=\"false\"\n [theme]=\"'light'\"\n [allowedPositions]=\"[\n 'top-left',\n 'top-right',\n 'bottom-right',\n 'bottom-left'\n ]\"\n [preferredPosition]=\"'bottom-right'\"\n (close)=\"open$.next(false); userSelectedDate$.next(inputValue)\"\n >\n <div class=\"content\" [class.include-preset]=\"showPresets\">\n <div *ngIf=\"showPresets\" class=\"presets\">\n <riv-simple-select\n [label]=\"'Date presets'\"\n [filterabilityOptions]=\"{ enabled: true, placeholder: 'Search' }\"\n [orderBy]=\"'source'\"\n [optionGroups]=\"\n (filteredPresetOptions$ | async) ?? [] | rivOptionGroup\n \"\n [selectedOption]=\"selectedPreset$ | async\"\n (selectedOptionChange)=\"userSelectedPreset$.next($event)\"\n >\n <ng-template #option let-node=\"node\">\n <ng-template\n #self\n [ngTemplateOutlet]=\"self\"\n let-isFavorite\n [ngTemplateOutletContext]=\"{\n $implicit: $safeNavigationMigration(\n (favoritePresetIds$ | async)?.includes(node.id)\n )\n }\"\n >\n <div class=\"preset\" [class.favorite]=\"isFavorite\">\n <div class=\"description\">\n <riv-highlight\n class=\"title\"\n [text]=\"node.title\"\n [indices]=\"node.titleHighlightIndices || []\"\n ></riv-highlight>\n <riv-highlight\n class=\"subtitle\"\n [text]=\"node.subtitle\"\n [indices]=\"node.subtitleHighlightIndices || []\"\n ></riv-highlight>\n </div>\n <button\n (click)=\"\n setFavorite(node, !isFavorite); $event.stopPropagation()\n \"\n type=\"button\"\n >\n <riv-icon\n [name]=\"isFavorite ? 'HeartActive' : 'Heart'\"\n [size]=\"16\"\n [rivTooltip]=\"'Mark as favorite'\"\n ></riv-icon>\n </button>\n </div>\n </ng-template>\n </ng-template>\n </riv-simple-select>\n <ng-template\n #self\n [ngTemplateOutlet]=\"self\"\n let-favorites\n [ngTemplateOutletContext]=\"{ $implicit: favoritePresets$ | async }\"\n >\n <riv-input-label *ngIf=\"favorites.length\" [label]=\"'Favorites'\">\n <div class=\"shortcuts\">\n <button\n *ngFor=\"let favorite of favorites\"\n class=\"shortcut\"\n [class.active]=\"(selectedPreset$ | async)?.id === favorite.id\"\n (click)=\"userSelectedPreset$.next(favorite)\"\n type=\"button\"\n >\n <span class=\"title\">{{ favorite.title }}</span>\n <button\n (click)=\"setFavorite(favorite, false)\"\n [rivTooltip]=\"'Remove favorite'\"\n type=\"button\"\n >\n <riv-icon [name]=\"'HeartActive'\" [size]=\"16\"></riv-icon>\n </button>\n </button>\n </div>\n </riv-input-label>\n </ng-template>\n </div>\n\n <div class=\"calendars\">\n <riv-calendar\n class=\"left\"\n [activeYearMonth]=\"(leftActiveYearMonth$ | async) || TODAY\"\n (activeYearMonthChange)=\"userLeftActiveYearMonth$.next($event)\"\n [displayMin]=\"(min$ | async) || TODAY\"\n [displayMax]=\"(max$ | async) || TODAY\"\n [selectableMin]=\"(leftMin$ | async) || TODAY\"\n [selectableMax]=\"(leftMax$ | async) || TODAY\"\n [omitRange]=\"(leftOmitRange$ | async) || [TODAY, TODAY]\"\n [selectedValue]=\"(selectedValue$ | async) || TODAY\"\n (dateSelect)=\"userSelectedDate$.next($event)\"\n ></riv-calendar>\n <riv-calendar\n class=\"right\"\n [activeYearMonth]=\"(rightActiveYearMonth$ | async) || TODAY\"\n (activeYearMonthChange)=\"userRightActiveYearMonth$.next($event)\"\n [displayMin]=\"(min$ | async) || TODAY\"\n [displayMax]=\"(max$ | async) || TODAY\"\n [selectableMin]=\"(rightMin$ | async) || TODAY\"\n [selectableMax]=\"(rightMax$ | async) || TODAY\"\n [selectedValue]=\"(selectedValue$ | async) || TODAY\"\n (dateSelect)=\"userSelectedDate$.next($event)\"\n ></riv-calendar>\n </div>\n\n <footer class=\"buttons\">\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n (click)=\"userSelectedDate$.next(undefined)\"\n type=\"button\"\n >\n Clear\n </button>\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'primary'\"\n (click)=\"open$.next(false)\"\n type=\"button\"\n >\n Done\n </button>\n </footer>\n </div>\n </riv-callout>\n </ng-container>\n</ng-template>\n",
5716
- styles: [".trigger{width:100%;border:var(--border-width) solid var(--border-light);border-radius:var(--border-radius-small);display:flex;gap:var(--size-small);background-color:var(--surface-light-0);cursor:pointer}.trigger:focus{outline:none;border:var(--border-width) solid var(--purp-60)}.trigger:disabled{color:var(--type-light-disabled);background-color:var(--surface-light-1)}.value{font-size:var(--type-2-font-size);line-height:var(--type-2-line-height-0);color:var(--type-light-high-contrast);padding:var(--size-small);flex-grow:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:pre}.value.placeholder{color:var(--type-light-low-contrast)}.chevron{display:flex;justify-content:center;align-items:center;padding:var(--size-xsmall) calc(var(--base-grid-size) * 1.5)}.trigger.warning{border-color:var(--surface-dark-caution)}.trigger.error{border-color:var(--surface-dark-danger);box-shadow:inset 0 0 0 var(--border-width-large) var(--surface-dark-danger)}.content{display:inline-grid;grid-template-rows:1fr auto}.content.include-preset{grid-template-columns:calc(var(--base-grid-size) * 50) 1fr 1fr}.presets{grid-area:1 / 1 / 3 / 2;background-color:var(--surface-light-1);padding:var(--size-xlarge) var(--size-large);border-right:var(--border-width) solid var(--border-light);display:flex;flex-direction:column;gap:var(--size-medium)}.preset{display:flex;transition:background-color var(--short-transition)}.preset:hover{background-color:var(--surface-light-2)}.preset button{color:transparent;transition:color var(--short-transition);padding:var(--size-medium) var(--size-large) var(--size-medium) var(--size-small);cursor:pointer}.preset:hover button{color:var(--type-light-low-contrast)}.preset button:hover{color:var(--type-light-high-contrast)}.preset.favorite button{color:var(--type-light-link)}.preset .description{flex-grow:1;padding:var(--size-medium) var(--size-small) var(--size-medium) var(--size-medium)}.preset .title{display:block;font-size:var(--type-2-font-size);line-height:var(--type-2-line-height-1)}.preset .subtitle{display:block;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-1);color:var(--type-light-low-contrast)}.shortcuts{display:flex;flex-direction:column;gap:var(--size-xsmall);overflow-y:auto}.shortcut{display:flex;align-items:center;padding:var(--size-small) var(--size-small) var(--size-small) var(--size-medium);gap:var(--size-small);border-radius:var(--border-radius-small);transition:background-color var(--short-transition);cursor:pointer}.shortcut:hover{background-color:var(--black-20)}.shortcut.active{background-color:var(--baloo-05)}.shortcut .title{flex-grow:1;text-align:left;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-2)}.shortcut button{color:transparent;transition:color var(--short-transition);cursor:pointer}.shortcut:hover button{color:var(--type-light-link)}.calendars{grid-column:2 / 4;display:grid;grid-template-columns:subgrid;grid-template-rows:subgrid;padding:var(--size-large)}.left{grid-area:1 / 1 / 2 / 2;padding-right:var(--size-large);border-right:var(--border-width) solid var(--border-light)}.right{padding-left:var(--size-large);grid-area:1 / 2 / 2 / 3}.buttons{grid-area:2 / 2 / 3 / 4;padding:var(--size-small);display:flex;justify-content:space-between}\n"],
5661
+ template: "<riv-input-label\n [label]=\"label\"\n [help]=\"help\"\n [required]=\"required\"\n [state]=\"state\"\n [errorMessage]=\"errorMessage\"\n [labelActionText]=\"labelActionText\"\n (labelAction)=\"labelAction.emit($event)\"\n>\n <div\n #trigger\n class=\"trigger\"\n [class.xsmall]=\"size === 'xsmall'\"\n [class.small]=\"size === 'small'\"\n [class.large]=\"size === 'large'\"\n [class.xlarge]=\"size === 'xlarge'\"\n [class.warning]=\"state === 'warning'\"\n [class.error]=\"state === 'error'\"\n [class.disabled]=\"disabled\"\n >\n <input\n #input\n class=\"value\"\n [placeholder]=\"placeholder\"\n [value]=\"inputText\"\n [disabled]=\"disabled\"\n [attr.aria-disabled]=\"disabled ? 'true' : null\"\n [attr.aria-label]=\"label || null\"\n [attr.aria-controls]=\"calendarId\"\n [attr.aria-expanded]=\"open$ | async\"\n role=\"combobox\"\n aria-haspopup=\"dialog\"\n aria-autocomplete=\"none\"\n (input)=\"onInputChange(input.value)\"\n (blur)=\"onInputBlur($event)\"\n (focus)=\"onInputFocus()\"\n (keydown.enter)=\"input.blur(); open$.next(false); $event.preventDefault()\"\n type=\"text\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n <button\n class=\"chevron\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"toggleCalendar()\"\n [disabled]=\"disabled\"\n [attr.aria-disabled]=\"disabled ? 'true' : null\"\n [attr.aria-label]=\"(open$ | async) ? 'Close calendar' : 'Open calendar'\"\n type=\"button\"\n tabindex=\"-1\"\n >\n <riv-icon [name]=\"'Calendar'\" [size]=\"16\"></riv-icon>\n </button>\n </div>\n</riv-input-label>\n<ng-container *ngIf=\"open$ | async\">\n <riv-callout\n *riv-overlay\n [anchor]=\"trigger\"\n [isModal]=\"false\"\n [showCaret]=\"false\"\n [theme]=\"'light'\"\n [allowedPositions]=\"[\n 'top-left',\n 'top-right',\n 'bottom-right',\n 'bottom-left'\n ]\"\n [preferredPosition]=\"'bottom-right'\"\n (close)=\"open$.next(false)\"\n >\n <div [attr.id]=\"calendarId\" (mousedown)=\"$event.preventDefault()\">\n <header *ngIf=\"headerTemplate\">\n <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n </header>\n <div class=\"content\">\n <riv-calendar\n [activeYearMonth]=\"activeYearMonth\"\n (activeYearMonthChange)=\"activeYearMonth = $event\"\n [displayMin]=\"min\"\n [displayMax]=\"max\"\n [selectableMin]=\"min\"\n [selectableMax]=\"max\"\n [selectedValue]=\"selectedCalendarValue\"\n (dateSelect)=\"onDateSelect($event); input.blur()\"\n ></riv-calendar>\n </div>\n <footer *ngIf=\"showClearButton || showTodayButton\" class=\"buttons\">\n <button\n *ngIf=\"showClearButton\"\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n (click)=\"clearValue(); input.blur()\"\n type=\"button\"\n >\n Clear\n </button>\n <button\n *ngIf=\"showTodayButton\"\n class=\"today\"\n rivButton\n [size]=\"'small'\"\n [variant]=\"'basic'\"\n [disabled]=\"!isTodaySelectable\"\n (click)=\"selectToday(); input.blur()\"\n type=\"button\"\n >\n Today\n </button>\n </footer>\n </div>\n </riv-callout>\n</ng-container>\n",
5662
+ styles: [".trigger{width:100%;border:var(--border-width) solid var(--border-light);border-radius:var(--border-radius-small);display:flex;gap:var(--size-small);background-color:var(--surface-light-0);padding-left:var(--size-small);position:relative}.trigger:focus-within{outline:none;border:var(--border-width) solid var(--purp-60)}.trigger.disabled{color:var(--type-light-disabled);background-color:var(--surface-light-1)}.value{font:var(--input-medium);color:var(--type-light-high-contrast);padding:var(--size-small) 0;flex-grow:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:pre;border:none;background:transparent;outline:none;width:100%}.value::placeholder{color:var(--type-light-low-contrast)}.value:disabled{color:var(--type-light-disabled)}.trigger.xsmall .value{font:var(--input-small);padding:var(--size-xsmall) 0}.trigger.small .value{font:var(--input-small)}.trigger.large .value{font:var(--input-large);padding:var(--size-medium) var(--size-xsmall)}.trigger.xlarge .value{font:var(--input-large);padding:var(--size-large) var(--size-small)}.chevron{display:flex;justify-content:center;align-items:center;padding:var(--size-xsmall) calc(var(--base-grid-size) * 1.5);border:none;background:transparent;cursor:pointer;color:var(--type-light-high-contrast)}.chevron:disabled{color:var(--type-light-disabled);cursor:not-allowed}.trigger.warning{border-color:var(--surface-dark-caution)}.trigger.error{border-color:var(--surface-dark-danger);box-shadow:inset 0 0 0 var(--border-width-large) var(--surface-dark-danger)}.content{padding:var(--size-xlarge)}.buttons{padding:0 var(--size-xlarge) var(--size-xlarge);display:flex;justify-content:space-between}.buttons .today{margin-left:auto}\n"],
5717
5663
  dependencies: [
5718
- {
5719
- kind: "directive",
5720
- type: i1.NgForOf,
5721
- selector: "[ngFor][ngForOf]",
5722
- inputs: [
5723
- "ngForOf",
5724
- "ngForTrackBy",
5725
- "ngForTemplate"
5726
- ]
5727
- },
5728
5664
  {
5729
5665
  kind: "directive",
5730
5666
  type: i1.NgIf,
@@ -5791,12 +5727,6 @@ var DateRangeComponent = class DateRangeComponent extends InputLabelComponent {
5791
5727
  ],
5792
5728
  outputs: ["close"]
5793
5729
  },
5794
- {
5795
- kind: "component",
5796
- type: HighlightComponent,
5797
- selector: "riv-highlight",
5798
- inputs: ["text", "indices"]
5799
- },
5800
5730
  {
5801
5731
  kind: "component",
5802
5732
  type: IconComponent,
@@ -5828,55 +5758,10 @@ var DateRangeComponent = class DateRangeComponent extends InputLabelComponent {
5828
5758
  type: OverlayDirective,
5829
5759
  selector: "[riv-overlay]"
5830
5760
  },
5831
- {
5832
- kind: "component",
5833
- type: SimpleSelectComponent,
5834
- selector: "riv-simple-select",
5835
- inputs: [
5836
- "optionGroups",
5837
- "selectedOption",
5838
- "size",
5839
- "disabled",
5840
- "locked",
5841
- "filterabilityOptions",
5842
- "orderBy",
5843
- "placeholder",
5844
- "maxHeight",
5845
- "maxWidth",
5846
- "minHeight",
5847
- "minWidth",
5848
- "dividers",
5849
- "sortSelectedToTop",
5850
- "grow",
5851
- "preferredCalloutPosition",
5852
- "allowedCalloutPositions"
5853
- ],
5854
- outputs: ["selectedOptionChange"]
5855
- },
5856
- {
5857
- kind: "directive",
5858
- type: TooltipDirective,
5859
- selector: "[rivTooltip]",
5860
- inputs: [
5861
- "rivTooltip",
5862
- "rivTooltipTheme",
5863
- "rivTooltipMaxWidth",
5864
- "rivTooltipPreferredPosition",
5865
- "rivTooltipAnchor",
5866
- "rivTooltipCloseDelay",
5867
- "rivTooltipOpenDelay",
5868
- "rivTooltipGracePeriod"
5869
- ]
5870
- },
5871
5761
  {
5872
5762
  kind: "pipe",
5873
5763
  type: i1.AsyncPipe,
5874
5764
  name: "async"
5875
- },
5876
- {
5877
- kind: "pipe",
5878
- type: OptionGroupPipe,
5879
- name: "rivOptionGroup"
5880
5765
  }
5881
5766
  ],
5882
5767
  changeDetection: i0.ChangeDetectionStrategy.OnPush
@@ -5887,361 +5772,334 @@ i0.ɵɵngDeclareClassMetadata({
5887
5772
  minVersion: "12.0.0",
5888
5773
  version: "22.2.4",
5889
5774
  ngImport: i0,
5890
- type: DateRangeComponent,
5775
+ type: DateComponent,
5891
5776
  decorators: [{
5892
5777
  type: Component,
5893
5778
  args: [{
5894
- selector: "riv-date-range",
5779
+ selector: "riv-date",
5895
5780
  changeDetection: ChangeDetectionStrategy.OnPush,
5896
5781
  standalone: false,
5897
- template: "<ng-container *ngIf=\"triggerTemplate; else standardTrigger\">\n <button\n #customTriggerButton\n (click)=\"open$.next(true)\"\n [disabled]=\"disabled$ | async\"\n [attr.aria-disabled]=\"(disabled$ | async) ? 'true' : null\"\n type=\"button\"\n >\n <ng-container\n [ngTemplateOutlet]=\"triggerTemplate\"\n [ngTemplateOutletContext]=\"{ open: open$ | async }\"\n ></ng-container>\n </button>\n</ng-container>\n<ng-template #standardTrigger>\n <riv-input-label\n [label]=\"label\"\n [help]=\"help\"\n [required]=\"required\"\n [state]=\"state\"\n [errorMessage]=\"errorMessage\"\n [labelActionText]=\"labelActionText\"\n (labelAction)=\"labelAction.emit($event)\"\n >\n <button\n #standardTriggerButton\n class=\"trigger\"\n [class.warning]=\"state === 'warning'\"\n [class.error]=\"state === 'error'\"\n (click)=\"open$.next(true)\"\n [disabled]=\"disabled$ | async\"\n [attr.aria-disabled]=\"(disabled$ | async) ? 'true' : null\"\n type=\"button\"\n >\n <ng-container\n *ngIf=\"displayValue$ | async; else placeholderValue; let display\"\n >\n <span class=\"value\">{{ display }}</span>\n </ng-container>\n <ng-template #placeholderValue>\n <span class=\"value placeholder\">{{ placeholder$ | async }}</span>\n </ng-template>\n <span class=\"chevron\">\n <riv-icon [name]=\"'Calendar'\" [size]=\"16\"></riv-icon>\n </span>\n </button>\n </riv-input-label>\n</ng-template>\n\n<ng-template\n #self\n [ngTemplateOutlet]=\"self\"\n let-inputValue\n [ngTemplateOutletContext]=\"{ $implicit: (distinctValue$ | async) }\"\n>\n <ng-container *ngIf=\"open$ | async\">\n <riv-callout\n *riv-overlay\n [anchor]=\"getTrigger()\"\n [showCaret]=\"false\"\n [theme]=\"'light'\"\n [allowedPositions]=\"[\n 'top-left',\n 'top-right',\n 'bottom-right',\n 'bottom-left'\n ]\"\n [preferredPosition]=\"'bottom-right'\"\n (close)=\"open$.next(false); userSelectedDate$.next(inputValue)\"\n >\n <div class=\"content\" [class.include-preset]=\"showPresets\">\n <div *ngIf=\"showPresets\" class=\"presets\">\n <riv-simple-select\n [label]=\"'Date presets'\"\n [filterabilityOptions]=\"{ enabled: true, placeholder: 'Search' }\"\n [orderBy]=\"'source'\"\n [optionGroups]=\"\n (filteredPresetOptions$ | async) ?? [] | rivOptionGroup\n \"\n [selectedOption]=\"selectedPreset$ | async\"\n (selectedOptionChange)=\"userSelectedPreset$.next($event)\"\n >\n <ng-template #option let-node=\"node\">\n <ng-template\n #self\n [ngTemplateOutlet]=\"self\"\n let-isFavorite\n [ngTemplateOutletContext]=\"{\n $implicit: $safeNavigationMigration(\n (favoritePresetIds$ | async)?.includes(node.id)\n )\n }\"\n >\n <div class=\"preset\" [class.favorite]=\"isFavorite\">\n <div class=\"description\">\n <riv-highlight\n class=\"title\"\n [text]=\"node.title\"\n [indices]=\"node.titleHighlightIndices || []\"\n ></riv-highlight>\n <riv-highlight\n class=\"subtitle\"\n [text]=\"node.subtitle\"\n [indices]=\"node.subtitleHighlightIndices || []\"\n ></riv-highlight>\n </div>\n <button\n (click)=\"\n setFavorite(node, !isFavorite); $event.stopPropagation()\n \"\n type=\"button\"\n >\n <riv-icon\n [name]=\"isFavorite ? 'HeartActive' : 'Heart'\"\n [size]=\"16\"\n [rivTooltip]=\"'Mark as favorite'\"\n ></riv-icon>\n </button>\n </div>\n </ng-template>\n </ng-template>\n </riv-simple-select>\n <ng-template\n #self\n [ngTemplateOutlet]=\"self\"\n let-favorites\n [ngTemplateOutletContext]=\"{ $implicit: favoritePresets$ | async }\"\n >\n <riv-input-label *ngIf=\"favorites.length\" [label]=\"'Favorites'\">\n <div class=\"shortcuts\">\n <button\n *ngFor=\"let favorite of favorites\"\n class=\"shortcut\"\n [class.active]=\"(selectedPreset$ | async)?.id === favorite.id\"\n (click)=\"userSelectedPreset$.next(favorite)\"\n type=\"button\"\n >\n <span class=\"title\">{{ favorite.title }}</span>\n <button\n (click)=\"setFavorite(favorite, false)\"\n [rivTooltip]=\"'Remove favorite'\"\n type=\"button\"\n >\n <riv-icon [name]=\"'HeartActive'\" [size]=\"16\"></riv-icon>\n </button>\n </button>\n </div>\n </riv-input-label>\n </ng-template>\n </div>\n\n <div class=\"calendars\">\n <riv-calendar\n class=\"left\"\n [activeYearMonth]=\"(leftActiveYearMonth$ | async) || TODAY\"\n (activeYearMonthChange)=\"userLeftActiveYearMonth$.next($event)\"\n [displayMin]=\"(min$ | async) || TODAY\"\n [displayMax]=\"(max$ | async) || TODAY\"\n [selectableMin]=\"(leftMin$ | async) || TODAY\"\n [selectableMax]=\"(leftMax$ | async) || TODAY\"\n [omitRange]=\"(leftOmitRange$ | async) || [TODAY, TODAY]\"\n [selectedValue]=\"(selectedValue$ | async) || TODAY\"\n (dateSelect)=\"userSelectedDate$.next($event)\"\n ></riv-calendar>\n <riv-calendar\n class=\"right\"\n [activeYearMonth]=\"(rightActiveYearMonth$ | async) || TODAY\"\n (activeYearMonthChange)=\"userRightActiveYearMonth$.next($event)\"\n [displayMin]=\"(min$ | async) || TODAY\"\n [displayMax]=\"(max$ | async) || TODAY\"\n [selectableMin]=\"(rightMin$ | async) || TODAY\"\n [selectableMax]=\"(rightMax$ | async) || TODAY\"\n [selectedValue]=\"(selectedValue$ | async) || TODAY\"\n (dateSelect)=\"userSelectedDate$.next($event)\"\n ></riv-calendar>\n </div>\n\n <footer class=\"buttons\">\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n (click)=\"userSelectedDate$.next(undefined)\"\n type=\"button\"\n >\n Clear\n </button>\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'primary'\"\n (click)=\"open$.next(false)\"\n type=\"button\"\n >\n Done\n </button>\n </footer>\n </div>\n </riv-callout>\n </ng-container>\n</ng-template>\n",
5898
- styles: [".trigger{width:100%;border:var(--border-width) solid var(--border-light);border-radius:var(--border-radius-small);display:flex;gap:var(--size-small);background-color:var(--surface-light-0);cursor:pointer}.trigger:focus{outline:none;border:var(--border-width) solid var(--purp-60)}.trigger:disabled{color:var(--type-light-disabled);background-color:var(--surface-light-1)}.value{font-size:var(--type-2-font-size);line-height:var(--type-2-line-height-0);color:var(--type-light-high-contrast);padding:var(--size-small);flex-grow:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:pre}.value.placeholder{color:var(--type-light-low-contrast)}.chevron{display:flex;justify-content:center;align-items:center;padding:var(--size-xsmall) calc(var(--base-grid-size) * 1.5)}.trigger.warning{border-color:var(--surface-dark-caution)}.trigger.error{border-color:var(--surface-dark-danger);box-shadow:inset 0 0 0 var(--border-width-large) var(--surface-dark-danger)}.content{display:inline-grid;grid-template-rows:1fr auto}.content.include-preset{grid-template-columns:calc(var(--base-grid-size) * 50) 1fr 1fr}.presets{grid-area:1 / 1 / 3 / 2;background-color:var(--surface-light-1);padding:var(--size-xlarge) var(--size-large);border-right:var(--border-width) solid var(--border-light);display:flex;flex-direction:column;gap:var(--size-medium)}.preset{display:flex;transition:background-color var(--short-transition)}.preset:hover{background-color:var(--surface-light-2)}.preset button{color:transparent;transition:color var(--short-transition);padding:var(--size-medium) var(--size-large) var(--size-medium) var(--size-small);cursor:pointer}.preset:hover button{color:var(--type-light-low-contrast)}.preset button:hover{color:var(--type-light-high-contrast)}.preset.favorite button{color:var(--type-light-link)}.preset .description{flex-grow:1;padding:var(--size-medium) var(--size-small) var(--size-medium) var(--size-medium)}.preset .title{display:block;font-size:var(--type-2-font-size);line-height:var(--type-2-line-height-1)}.preset .subtitle{display:block;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-1);color:var(--type-light-low-contrast)}.shortcuts{display:flex;flex-direction:column;gap:var(--size-xsmall);overflow-y:auto}.shortcut{display:flex;align-items:center;padding:var(--size-small) var(--size-small) var(--size-small) var(--size-medium);gap:var(--size-small);border-radius:var(--border-radius-small);transition:background-color var(--short-transition);cursor:pointer}.shortcut:hover{background-color:var(--black-20)}.shortcut.active{background-color:var(--baloo-05)}.shortcut .title{flex-grow:1;text-align:left;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-2)}.shortcut button{color:transparent;transition:color var(--short-transition);cursor:pointer}.shortcut:hover button{color:var(--type-light-link)}.calendars{grid-column:2 / 4;display:grid;grid-template-columns:subgrid;grid-template-rows:subgrid;padding:var(--size-large)}.left{grid-area:1 / 1 / 2 / 2;padding-right:var(--size-large);border-right:var(--border-width) solid var(--border-light)}.right{padding-left:var(--size-large);grid-area:1 / 2 / 2 / 3}.buttons{grid-area:2 / 2 / 3 / 4;padding:var(--size-small);display:flex;justify-content:space-between}\n"]
5782
+ template: "<riv-input-label\n [label]=\"label\"\n [help]=\"help\"\n [required]=\"required\"\n [state]=\"state\"\n [errorMessage]=\"errorMessage\"\n [labelActionText]=\"labelActionText\"\n (labelAction)=\"labelAction.emit($event)\"\n>\n <div\n #trigger\n class=\"trigger\"\n [class.xsmall]=\"size === 'xsmall'\"\n [class.small]=\"size === 'small'\"\n [class.large]=\"size === 'large'\"\n [class.xlarge]=\"size === 'xlarge'\"\n [class.warning]=\"state === 'warning'\"\n [class.error]=\"state === 'error'\"\n [class.disabled]=\"disabled\"\n >\n <input\n #input\n class=\"value\"\n [placeholder]=\"placeholder\"\n [value]=\"inputText\"\n [disabled]=\"disabled\"\n [attr.aria-disabled]=\"disabled ? 'true' : null\"\n [attr.aria-label]=\"label || null\"\n [attr.aria-controls]=\"calendarId\"\n [attr.aria-expanded]=\"open$ | async\"\n role=\"combobox\"\n aria-haspopup=\"dialog\"\n aria-autocomplete=\"none\"\n (input)=\"onInputChange(input.value)\"\n (blur)=\"onInputBlur($event)\"\n (focus)=\"onInputFocus()\"\n (keydown.enter)=\"input.blur(); open$.next(false); $event.preventDefault()\"\n type=\"text\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n <button\n class=\"chevron\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"toggleCalendar()\"\n [disabled]=\"disabled\"\n [attr.aria-disabled]=\"disabled ? 'true' : null\"\n [attr.aria-label]=\"(open$ | async) ? 'Close calendar' : 'Open calendar'\"\n type=\"button\"\n tabindex=\"-1\"\n >\n <riv-icon [name]=\"'Calendar'\" [size]=\"16\"></riv-icon>\n </button>\n </div>\n</riv-input-label>\n<ng-container *ngIf=\"open$ | async\">\n <riv-callout\n *riv-overlay\n [anchor]=\"trigger\"\n [isModal]=\"false\"\n [showCaret]=\"false\"\n [theme]=\"'light'\"\n [allowedPositions]=\"[\n 'top-left',\n 'top-right',\n 'bottom-right',\n 'bottom-left'\n ]\"\n [preferredPosition]=\"'bottom-right'\"\n (close)=\"open$.next(false)\"\n >\n <div [attr.id]=\"calendarId\" (mousedown)=\"$event.preventDefault()\">\n <header *ngIf=\"headerTemplate\">\n <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n </header>\n <div class=\"content\">\n <riv-calendar\n [activeYearMonth]=\"activeYearMonth\"\n (activeYearMonthChange)=\"activeYearMonth = $event\"\n [displayMin]=\"min\"\n [displayMax]=\"max\"\n [selectableMin]=\"min\"\n [selectableMax]=\"max\"\n [selectedValue]=\"selectedCalendarValue\"\n (dateSelect)=\"onDateSelect($event); input.blur()\"\n ></riv-calendar>\n </div>\n <footer *ngIf=\"showClearButton || showTodayButton\" class=\"buttons\">\n <button\n *ngIf=\"showClearButton\"\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n (click)=\"clearValue(); input.blur()\"\n type=\"button\"\n >\n Clear\n </button>\n <button\n *ngIf=\"showTodayButton\"\n class=\"today\"\n rivButton\n [size]=\"'small'\"\n [variant]=\"'basic'\"\n [disabled]=\"!isTodaySelectable\"\n (click)=\"selectToday(); input.blur()\"\n type=\"button\"\n >\n Today\n </button>\n </footer>\n </div>\n </riv-callout>\n</ng-container>\n",
5783
+ styles: [".trigger{width:100%;border:var(--border-width) solid var(--border-light);border-radius:var(--border-radius-small);display:flex;gap:var(--size-small);background-color:var(--surface-light-0);padding-left:var(--size-small);position:relative}.trigger:focus-within{outline:none;border:var(--border-width) solid var(--purp-60)}.trigger.disabled{color:var(--type-light-disabled);background-color:var(--surface-light-1)}.value{font:var(--input-medium);color:var(--type-light-high-contrast);padding:var(--size-small) 0;flex-grow:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:pre;border:none;background:transparent;outline:none;width:100%}.value::placeholder{color:var(--type-light-low-contrast)}.value:disabled{color:var(--type-light-disabled)}.trigger.xsmall .value{font:var(--input-small);padding:var(--size-xsmall) 0}.trigger.small .value{font:var(--input-small)}.trigger.large .value{font:var(--input-large);padding:var(--size-medium) var(--size-xsmall)}.trigger.xlarge .value{font:var(--input-large);padding:var(--size-large) var(--size-small)}.chevron{display:flex;justify-content:center;align-items:center;padding:var(--size-xsmall) calc(var(--base-grid-size) * 1.5);border:none;background:transparent;cursor:pointer;color:var(--type-light-high-contrast)}.chevron:disabled{color:var(--type-light-disabled);cursor:not-allowed}.trigger.warning{border-color:var(--surface-dark-caution)}.trigger.error{border-color:var(--surface-dark-danger);box-shadow:inset 0 0 0 var(--border-width-large) var(--surface-dark-danger)}.content{padding:var(--size-xlarge)}.buttons{padding:0 var(--size-xlarge) var(--size-xlarge);display:flex;justify-content:space-between}.buttons .today{margin-left:auto}\n"]
5899
5784
  }]
5900
5785
  }],
5786
+ ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }],
5901
5787
  propDecorators: {
5902
- showPresets: [{ type: Input }],
5903
5788
  min: [{ type: Input }],
5904
5789
  max: [{ type: Input }],
5905
5790
  value: [{ type: Input }],
5906
5791
  placeholder: [{ type: Input }],
5907
5792
  disabled: [{ type: Input }],
5908
- triggerTemplate: [{
5793
+ size: [{ type: Input }],
5794
+ showClearButton: [{ type: Input }],
5795
+ showTodayButton: [{ type: Input }],
5796
+ rollingTodayLabel: [{ type: Input }],
5797
+ headerTemplate: [{
5909
5798
  type: ContentChild,
5910
- args: ["trigger"]
5911
- }],
5912
- customTriggerButton: [{
5913
- type: ViewChild,
5914
- args: ["customTriggerButton", { read: ElementRef }]
5915
- }],
5916
- standardTriggerButton: [{
5917
- type: ViewChild,
5918
- args: ["standardTriggerButton", { read: ElementRef }]
5799
+ args: ["header"]
5919
5800
  }],
5920
- alternativePresetList: [{ type: Input }],
5921
- valueChange: [{ type: Output }]
5801
+ open: [{ type: Input }],
5802
+ valueChange: [{ type: Output }],
5803
+ onDocumentMouseDown: [{
5804
+ type: HostListener,
5805
+ args: ["document:mousedown", ["$event.target"]]
5806
+ }]
5922
5807
  }
5923
5808
  });
5924
- (function(DateRangeComponent) {
5925
- const today = /* @__PURE__ */ new Date();
5926
- let PresetType;
5927
- (function(PresetType) {
5928
- PresetType["TODAY"] = "today";
5929
- PresetType["YESTERDAY"] = "yesterday";
5930
- PresetType["TOMORROW"] = "tomorrow";
5931
- PresetType["THIS_WEEK"] = "this_week";
5932
- PresetType["THIS_WEEK_SO_FAR"] = "this_week_so_far";
5933
- PresetType["LAST_WEEK"] = "last_week";
5934
- PresetType["NEXT_WEEK"] = "next_week";
5935
- PresetType["THIS_MONTH"] = "this_month";
5936
- PresetType["THIS_MONTH_SO_FAR"] = "this_month_so_far";
5937
- PresetType["LAST_MONTH"] = "last_month";
5938
- PresetType["NEXT_MONTH"] = "next_month";
5939
- PresetType["THIS_QUARTER"] = "this_quarter";
5940
- PresetType["THIS_QUARTER_SO_FAR"] = "this_quarter_so_far";
5941
- PresetType["LAST_QUARTER"] = "last_quarter";
5942
- PresetType["NEXT_QUARTER"] = "next_quarter";
5943
- PresetType["THIS_YEAR"] = "this_year";
5944
- PresetType["THIS_YEAR_SO_FAR"] = "this_year_so_far";
5945
- PresetType["LAST_YEAR"] = "last_year";
5946
- PresetType["NEXT_YEAR"] = "next_year";
5947
- PresetType["LAST_7_DAYS"] = "last_7_days";
5948
- PresetType["LAST_14_DAYS"] = "last_14_days";
5949
- PresetType["LAST_30_DAYS"] = "last_30_days";
5950
- PresetType["LAST_60_DAYS"] = "last_60_days";
5951
- PresetType["LAST_90_DAYS"] = "last_90_days";
5952
- PresetType["LAST_180_DAYS"] = "last_180_days";
5953
- PresetType["LAST_365_DAYS"] = "last_365_days";
5954
- })(PresetType = DateRangeComponent.PresetType || (DateRangeComponent.PresetType = {}));
5955
- DateRangeComponent.Presets = [
5956
- {
5957
- id: PresetType.TODAY,
5958
- title: "Today",
5959
- subtitle: "Today from midnight until the current time",
5960
- dates: [timeDay(), timeDay()]
5961
- },
5962
- {
5963
- id: PresetType.YESTERDAY,
5964
- title: "Yesterday",
5965
- subtitle: "The previous 24 hour day",
5966
- dates: [timeDay.offset(timeDay(), -1), timeDay.offset(timeDay(), -1)]
5967
- },
5968
- {
5969
- id: PresetType.TOMORROW,
5970
- title: "Tomorrow",
5971
- subtitle: "The next 24 hour day",
5972
- dates: [timeDay.offset(timeDay(), 1), timeDay.offset(timeDay(), 1)]
5973
- },
5974
- {
5975
- id: PresetType.THIS_WEEK,
5976
- title: "This week",
5977
- subtitle: "The current calendar week",
5978
- dates: [timeSunday.floor(today), timeDay.offset(timeSunday.ceil(today), -1)]
5979
- },
5980
- {
5981
- id: PresetType.THIS_WEEK_SO_FAR,
5982
- title: "This week so far",
5983
- subtitle: "The current calendar week up to now",
5984
- dates: [timeSunday.floor(today), timeDay.floor(today)]
5985
- },
5986
- {
5987
- id: PresetType.LAST_WEEK,
5988
- title: "Last week",
5989
- subtitle: "The previous calendar week",
5990
- dates: [timeSunday.offset(timeWeek.floor(today), -1), timeDay.offset(timeSunday.offset(timeWeek.ceil(today), -1), -1)]
5991
- },
5992
- {
5993
- id: PresetType.NEXT_WEEK,
5994
- title: "Next week",
5995
- subtitle: "The next calendar week",
5996
- dates: [timeSunday.offset(timeWeek.floor(today), 1), timeDay.offset(timeSunday.offset(timeWeek.ceil(today), 1), -1)]
5997
- },
5998
- {
5999
- id: PresetType.THIS_MONTH,
6000
- title: "This month",
6001
- subtitle: "The current calendar month",
6002
- dates: [timeMonth.floor(today), timeDay.offset(timeMonth.ceil(today), -1)]
6003
- },
6004
- {
6005
- id: PresetType.THIS_MONTH_SO_FAR,
6006
- title: "This month so far",
6007
- subtitle: "The current calendar month up to now",
6008
- dates: [timeMonth.floor(today), timeDay.floor(today)]
6009
- },
6010
- {
6011
- id: PresetType.LAST_MONTH,
6012
- title: "Last month",
6013
- subtitle: "The previous calendar month",
6014
- dates: [timeMonth.offset(timeMonth.floor(today), -1), timeDay.offset(timeMonth.offset(timeMonth.ceil(today), -1), -1)]
6015
- },
6016
- {
6017
- id: PresetType.NEXT_MONTH,
6018
- title: "Next month",
6019
- subtitle: "The next calendar month",
6020
- dates: [timeMonth.offset(timeMonth.floor(today), 1), timeDay.offset(timeMonth.offset(timeMonth.ceil(today), 1), -1)]
6021
- },
6022
- {
6023
- id: PresetType.THIS_QUARTER,
6024
- title: "This quarter",
6025
- subtitle: "The current quarter",
6026
- dates: [timeQuarter.floor(today), timeDay.offset(timeQuarter.ceil(today), -1)]
6027
- },
6028
- {
6029
- id: PresetType.THIS_QUARTER_SO_FAR,
6030
- title: "This quarter so far",
6031
- subtitle: "The current quarter up to now",
6032
- dates: [timeQuarter.floor(today), timeDay.floor(today)]
6033
- },
6034
- {
6035
- id: PresetType.LAST_QUARTER,
6036
- title: "Last quarter",
6037
- subtitle: "The previous full quarter",
6038
- dates: [timeQuarter.offset(timeQuarter.floor(today), -1), timeDay.offset(timeQuarter.offset(timeQuarter.ceil(today), -1), -1)]
6039
- },
6040
- {
6041
- id: PresetType.NEXT_QUARTER,
6042
- title: "Next quarter",
6043
- subtitle: "The next full quarter",
6044
- dates: [timeQuarter.offset(timeQuarter.floor(today), 1), timeDay.offset(timeQuarter.offset(timeQuarter.ceil(today), 1), -1)]
6045
- },
6046
- {
6047
- id: PresetType.THIS_YEAR,
6048
- title: "This year",
6049
- subtitle: "The current calendar year",
6050
- dates: [timeYear.floor(today), timeDay.offset(timeYear.ceil(today), -1)]
6051
- },
6052
- {
6053
- id: PresetType.THIS_YEAR_SO_FAR,
6054
- title: "This year so far",
6055
- subtitle: "The current calendar year up to now",
6056
- dates: [timeYear.floor(today), timeDay.floor(today)]
6057
- },
6058
- {
6059
- id: PresetType.LAST_YEAR,
6060
- title: "Last year",
6061
- subtitle: "The previous calendar year",
6062
- dates: [timeYear.offset(timeYear.floor(today), -1), timeDay.offset(timeYear.offset(timeYear.ceil(today), -1), -1)]
6063
- },
6064
- {
6065
- id: PresetType.NEXT_YEAR,
6066
- title: "Next year",
6067
- subtitle: "The next calendar year",
6068
- dates: [timeYear.offset(timeYear.floor(today), 1), timeDay.offset(timeYear.offset(timeYear.ceil(today), 1), -1)]
6069
- },
6070
- {
6071
- id: PresetType.LAST_7_DAYS,
6072
- title: "Last 7 days",
6073
- subtitle: "The previous 7 days before today",
6074
- dates: [timeDay.floor(timeDay.offset(today, -8)), timeDay.floor(timeDay.offset(today, -1))]
6075
- },
6076
- {
6077
- id: PresetType.LAST_14_DAYS,
6078
- title: "Last 14 days",
6079
- subtitle: "The previous 14 days before today",
6080
- dates: [timeDay.floor(timeDay.offset(today, -15)), timeDay.floor(timeDay.offset(today, -1))]
6081
- },
6082
- {
6083
- id: PresetType.LAST_30_DAYS,
6084
- title: "Last 30 days",
6085
- subtitle: "The previous 30 days before today",
6086
- dates: [timeDay.floor(timeDay.offset(today, -31)), timeDay.floor(timeDay.offset(today, -1))]
6087
- },
6088
- {
6089
- id: PresetType.LAST_60_DAYS,
6090
- title: "Last 60 days",
6091
- subtitle: "The previous 60 days before today",
6092
- dates: [timeDay.floor(timeDay.offset(today, -61)), timeDay.floor(timeDay.offset(today, -1))]
6093
- },
6094
- {
6095
- id: PresetType.LAST_90_DAYS,
6096
- title: "Last 90 days",
6097
- subtitle: "The previous 90 days before today",
6098
- dates: [timeDay.floor(timeDay.offset(today, -91)), timeDay.floor(timeDay.offset(today, -1))]
6099
- },
6100
- {
6101
- id: PresetType.LAST_180_DAYS,
6102
- title: "Last 180 days",
6103
- subtitle: "The previous 180 days before today",
6104
- dates: [timeDay.floor(timeDay.offset(today, -181)), timeDay.floor(timeDay.offset(today, -1))]
6105
- },
6106
- {
6107
- id: PresetType.LAST_365_DAYS,
6108
- title: "Last 365 days",
6109
- subtitle: "The previous 365 days before today",
6110
- dates: [timeDay.floor(timeDay.offset(today, -366)), timeDay.floor(timeDay.offset(today, -1))]
6111
- }
5809
+ (function(DateComponent) {
5810
+ DateComponent.Sizes = [
5811
+ "xsmall",
5812
+ "small",
5813
+ "medium",
5814
+ "large",
5815
+ "xlarge"
6112
5816
  ];
6113
- })(DateRangeComponent || (DateRangeComponent = {}));
6114
- var DateComponent = class DateComponent extends InputLabelComponent {
6115
- set value(v) {
6116
- if (this._value?.getTime() === v?.getTime()) return;
6117
- this._value = v;
6118
- if (!this.hasFocus) this.syncInputText();
6119
- if (v) this.setActiveMonth(v);
6120
- this.cdr.markForCheck();
5817
+ function parseDate(input) {
5818
+ const trimmed = input.trim();
5819
+ if (!trimmed) return void 0;
5820
+ const ymd = /^\d+$/.test(trimmed) ? parseDigits(trimmed) : parseSeparated(trimmed);
5821
+ if (!ymd) return void 0;
5822
+ const [year, month, day] = ymd;
5823
+ const date = new Date(year, month - 1, day);
5824
+ return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day ? date : void 0;
6121
5825
  }
6122
- get value() {
6123
- return this._value;
5826
+ DateComponent.parseDate = parseDate;
5827
+ function expandTwoDigitYear(year) {
5828
+ return year < 100 ? year + (year < 50 ? 2e3 : 1900) : year;
6124
5829
  }
6125
- set open(v) {
6126
- this.open$.next(v);
5830
+ function parseDigits(digits) {
5831
+ if (digits.length !== 8 && digits.length !== 6) return void 0;
5832
+ const year = parseInt(digits.slice(4), 10);
5833
+ return [
5834
+ digits.length === 6 ? expandTwoDigitYear(year) : year,
5835
+ parseInt(digits.slice(0, 2), 10),
5836
+ parseInt(digits.slice(2, 4), 10)
5837
+ ];
6127
5838
  }
6128
- get open() {
6129
- return this.open$.getValue();
5839
+ function parseSeparated(input) {
5840
+ const parts = input.split(/[/.-]/);
5841
+ if (parts.length !== 3) return void 0;
5842
+ const nums = parts.map((p) => parseInt(p, 10));
5843
+ if (nums.some(isNaN)) return void 0;
5844
+ const [year, month, day] = parts[0].length === 4 ? nums : [
5845
+ nums[2],
5846
+ nums[0],
5847
+ nums[1]
5848
+ ];
5849
+ return [
5850
+ parts[0].length === 4 ? year : expandTwoDigitYear(year),
5851
+ month,
5852
+ day
5853
+ ];
6130
5854
  }
6131
- constructor(cdr, host) {
5855
+ function isValidDate(date, min, max) {
5856
+ const time = date.getTime();
5857
+ return time >= timeDay.floor(min).getTime() && time <= max.getTime();
5858
+ }
5859
+ DateComponent.isValidDate = isValidDate;
5860
+ })(DateComponent || (DateComponent = {}));
5861
+ const timeQuarter = timeMonth.every(3);
5862
+ var DateRangeComponent = class DateRangeComponent extends InputLabelComponent {
5863
+ constructor(host) {
6132
5864
  super();
6133
- this.cdr = cdr;
6134
5865
  this.host = host;
6135
- this.min = CalendarComponent.defaultMin;
6136
- this.max = CalendarComponent.defaultMax;
6137
- this.placeholder = "Select date";
6138
- this.disabled = false;
6139
- this.size = "medium";
6140
- this.showClearButton = true;
6141
- this.showTodayButton = true;
6142
- this.activeYearMonth = timeMonth.floor(/* @__PURE__ */ new Date());
5866
+ this.TODAY = /* @__PURE__ */ new Date();
5867
+ this.STORAGE_KEY = "date-range.default";
5868
+ this.calendarId = uniqueId("riv-date-range-calendar-");
5869
+ this.showPresets$ = new BehaviorSubject(true);
5870
+ this.min$ = new BehaviorSubject(CalendarComponent.defaultMin);
5871
+ this.max$ = new BehaviorSubject(CalendarComponent.defaultMax);
5872
+ this.value$ = new BehaviorSubject(void 0);
5873
+ this.distinctValue$ = this.value$.pipe(distinctUntilChanged((previous, current) => previous?.[0].valueOf() === current?.[0].valueOf() && previous?.[1].valueOf() === current?.[1].valueOf()), shareReplay({
5874
+ refCount: true,
5875
+ bufferSize: 1
5876
+ }));
5877
+ this.placeholder$ = new BehaviorSubject("Select date range");
5878
+ this.disabled$ = new BehaviorSubject(false);
5879
+ this.alternativePresetList$ = new BehaviorSubject([]);
6143
5880
  this.open$ = new BehaviorSubject(false);
6144
- this.calendarId = uniqueId("riv-date-calendar-");
6145
- this.valueChange = new EventEmitter();
6146
- this.inputText = "";
6147
- this.hasFocus = false;
6148
- this.datePipe = new DatePipe();
5881
+ this.userSelectedPreset$ = new Subject();
5882
+ this.userSelectedDate$ = new Subject();
5883
+ this.userTypedRange$ = new Subject();
5884
+ this.selectedValue$ = merge(this.distinctValue$, merge(this.userSelectedDate$, this.userTypedRange$).pipe(scan((previous, date) => {
5885
+ if (previous instanceof Date && date instanceof Date) {
5886
+ if (date.valueOf() >= previous.valueOf()) return [previous, date];
5887
+ }
5888
+ return date;
5889
+ })), this.userSelectedPreset$.pipe(filter((preset) => preset !== null), map((preset) => preset.dates))).pipe(shareReplay({
5890
+ refCount: true,
5891
+ bufferSize: 1
5892
+ }));
5893
+ this.filteredPresetOptions$ = combineLatest([
5894
+ this.min$,
5895
+ this.max$,
5896
+ this.alternativePresetList$
5897
+ ]).pipe(map(([min, max, alternativePresetList]) => {
5898
+ const optionsFilteredOnMinMax = DateRangeComponent.Presets.filter((p) => p.dates[0].valueOf() >= min.valueOf() && p.dates[1].valueOf() <= max.valueOf());
5899
+ if (alternativePresetList.length == 0) return optionsFilteredOnMinMax;
5900
+ else return optionsFilteredOnMinMax.filter((p) => alternativePresetList.includes(p.id));
5901
+ }), shareReplay({
5902
+ refCount: true,
5903
+ bufferSize: 1
5904
+ }));
5905
+ this.selectedPreset$ = combineLatest([this.selectedValue$, this.userSelectedPreset$.pipe(startWith(null))]).pipe(map(([selectedValue, userSelectedPreset]) => {
5906
+ if (selectedValue instanceof Array) {
5907
+ const options = DateRangeComponent.Presets.filter((preset) => preset.dates[0].valueOf() === selectedValue[0].valueOf() && preset.dates[1].valueOf() === selectedValue[1].valueOf());
5908
+ if (options.length) {
5909
+ const mostRecent = options.find((option) => option.id === userSelectedPreset?.id);
5910
+ if (mostRecent) return mostRecent;
5911
+ return options[0];
5912
+ }
5913
+ }
5914
+ return null;
5915
+ }));
5916
+ this.favoritePresetIds$ = new LocalStorage(this.STORAGE_KEY, []);
5917
+ this.favoritePresets$ = combineLatest([
5918
+ this.favoritePresetIds$,
5919
+ this.filteredPresetOptions$,
5920
+ this.alternativePresetList$
5921
+ ]).pipe(map(([ids, presets, alternativePresetList]) => {
5922
+ const favoritePresets = ids.map((id) => presets.find((preset) => preset.id === id)).filter((p) => p !== void 0);
5923
+ if (alternativePresetList.length == 0) return favoritePresets;
5924
+ else return favoritePresets.filter((p) => alternativePresetList.includes(p.id));
5925
+ }), shareReplay({
5926
+ refCount: true,
5927
+ bufferSize: 1
5928
+ }));
5929
+ this.userLeftActiveYearMonth$ = new Subject();
5930
+ this.userRightActiveYearMonth$ = new Subject();
5931
+ this.leftMin$ = this.min$.pipe(shareReplay({
5932
+ refCount: true,
5933
+ bufferSize: 1
5934
+ }));
5935
+ this.leftMax$ = this.max$.pipe(map((max) => timeDay.offset(timeMonth.floor(max), -1)), shareReplay({
5936
+ refCount: true,
5937
+ bufferSize: 1
5938
+ }));
5939
+ this.rightMax$ = this.max$.pipe(shareReplay({
5940
+ refCount: true,
5941
+ bufferSize: 1
5942
+ }));
5943
+ this.leftActiveYearMonth$ = combineLatest([this.leftMax$, merge(this.userLeftActiveYearMonth$.pipe(startWith(timeMonth.floor(this.TODAY))), this.userSelectedPreset$.pipe(filter((preset) => preset !== null), map((preset) => timeMonth.floor(preset.dates[0]))), this.userTypedRange$.pipe(map((range) => timeMonth.floor(range[0]))), this.distinctValue$.pipe(filter((v) => v !== void 0), map((v) => timeMonth.floor(v[0]))))]).pipe(map(([leftMax, left]) => {
5944
+ if (left.valueOf() >= leftMax.valueOf()) return timeMonth.floor(leftMax);
5945
+ else return left;
5946
+ }), shareReplay({
5947
+ refCount: true,
5948
+ bufferSize: 1
5949
+ }));
5950
+ this.rightActiveYearMonth$ = combineLatest([
5951
+ this.leftActiveYearMonth$,
5952
+ merge(this.userRightActiveYearMonth$.pipe(startWith(timeMonth.ceil(this.TODAY))), this.userSelectedPreset$.pipe(filter((preset) => preset !== null), map((preset) => timeMonth.floor(preset.dates[1]))), this.userTypedRange$.pipe(map((range) => timeMonth.floor(range[1]))), this.distinctValue$.pipe(filter((v) => v !== void 0), map((v) => timeMonth.floor(v[1])))),
5953
+ this.rightMax$
5954
+ ]).pipe(map(([left, userRight, rightMax$]) => {
5955
+ if (left.valueOf() >= userRight.valueOf()) return timeMonth.floor(timeMonth.offset(left, 1));
5956
+ else if (userRight.valueOf() >= rightMax$.valueOf()) return timeMonth.floor(rightMax$);
5957
+ else return userRight;
5958
+ }), shareReplay({
5959
+ refCount: true,
5960
+ bufferSize: 1
5961
+ }));
5962
+ this.rightMin$ = this.leftActiveYearMonth$.pipe(map((left) => timeMonth.floor(timeMonth.offset(left, 1))), shareReplay({
5963
+ refCount: true,
5964
+ bufferSize: 1
5965
+ }));
5966
+ this.leftOmitRange$ = this.rightActiveYearMonth$.pipe(map((rightActiveYearMonth) => {
5967
+ return [timeMonth.floor(rightActiveYearMonth), timeDay.offset(timeMonth.floor(timeMonth.offset(rightActiveYearMonth, 1)), -1)];
5968
+ }), shareReplay({
5969
+ refCount: true,
5970
+ bufferSize: 1
5971
+ }));
5972
+ this.userInteracted$ = merge(this.userSelectedDate$, this.userSelectedPreset$, this.userTypedRange$);
5973
+ this.valueChange = this.selectedValue$.pipe(skipUntil(merge(this.userInteracted$, this.selectedValue$.pipe(filter((v) => v !== void 0)))), filter((v) => !(v instanceof Date)), distinctUntilChanged((previous, current) => previous?.[0].valueOf() === current?.[0].valueOf() && previous?.[1].valueOf() === current?.[1].valueOf()), shareReplay({
5974
+ refCount: true,
5975
+ bufferSize: 1
5976
+ }));
5977
+ this.displayValue$ = this.valueChange.pipe(map((v) => {
5978
+ if (v) return v.map((date) => new DatePipe().transform(date)).join(" — ");
5979
+ }), shareReplay({
5980
+ refCount: true,
5981
+ bufferSize: 1
5982
+ }));
5983
+ this.typedText$ = new BehaviorSubject(null);
5984
+ this.inputText$ = combineLatest([this.typedText$, this.displayValue$.pipe(startWith(void 0))]).pipe(map(([typed, display]) => typed ?? display ?? ""));
6149
5985
  }
6150
- ngOnChanges(changes) {
6151
- if (changes["rollingTodayLabel"] && !this.hasFocus) this.syncInputText();
5986
+ set showPresets(v) {
5987
+ this.showPresets$.next(v);
6152
5988
  }
6153
- onDocumentMouseDown(target) {
6154
- if (!this.open$.getValue() || !(target instanceof Element)) return;
6155
- if (this.isInsidePicker(target)) return;
6156
- this.open$.next(false);
6157
- this.cdr.markForCheck();
5989
+ get showPresets() {
5990
+ return this.showPresets$.getValue();
6158
5991
  }
6159
- isInsidePicker(target) {
6160
- const host = this.host.nativeElement;
6161
- if (host.contains(target)) return true;
6162
- const layer = target.closest(".callout, .scrim, .overlay-container");
6163
- return !!layer && !layer.contains(host);
5992
+ set min(v) {
5993
+ this.min$.next(v);
6164
5994
  }
6165
- clearValue() {
6166
- this.commit(void 0);
6167
- this.open$.next(false);
5995
+ get min() {
5996
+ return this.min$.getValue();
6168
5997
  }
6169
- selectToday() {
6170
- if (!this.isTodaySelectable) return;
6171
- this.commit(this.isRolling ? void 0 : timeDay.floor(/* @__PURE__ */ new Date()));
6172
- this.open$.next(false);
5998
+ set max(v) {
5999
+ this.max$.next(v);
6173
6000
  }
6174
- get isTodaySelectable() {
6175
- return DateComponent.isValidDate(timeDay.floor(/* @__PURE__ */ new Date()), this.min, this.max);
6001
+ get max() {
6002
+ return this.max$.getValue();
6176
6003
  }
6177
- get selectedCalendarValue() {
6178
- return this.previewValue ?? this._value ?? (this.isRolling ? timeDay.floor(/* @__PURE__ */ new Date()) : void 0);
6004
+ set value(v) {
6005
+ this.value$.next(v);
6179
6006
  }
6180
- onInputChange(value) {
6181
- this.inputText = value;
6182
- const parsed = this.parseInput(value);
6183
- this.previewValue = parsed;
6184
- if (parsed) this.setActiveMonth(parsed);
6185
- this.cdr.markForCheck();
6007
+ get value() {
6008
+ return this.value$.getValue();
6186
6009
  }
6187
- onInputBlur(event) {
6188
- this.hasFocus = false;
6189
- const parsed = this.parseInput(this.inputText);
6190
- if (parsed) this.commit(parsed);
6191
- else if (!this.inputText.trim() || this.isRollingText(this.inputText)) this.commit(void 0);
6192
- else this.syncInputText();
6193
- this.previewValue = void 0;
6194
- const nextTarget = event?.relatedTarget;
6195
- if (!(nextTarget instanceof Element && this.isInsidePicker(nextTarget))) this.open$.next(false);
6196
- this.cdr.markForCheck();
6010
+ set placeholder(v) {
6011
+ this.placeholder$.next(v);
6197
6012
  }
6198
- onDateSelect(date) {
6199
- this.commit(timeDay.floor(date));
6200
- this.open$.next(false);
6013
+ get placeholder() {
6014
+ return this.placeholder$.getValue();
6015
+ }
6016
+ set disabled(v) {
6017
+ this.disabled$.next(v);
6018
+ }
6019
+ get disabled() {
6020
+ return this.disabled$.getValue();
6021
+ }
6022
+ getTrigger() {
6023
+ return this.customTriggerButton?.nativeElement ?? this.standardTriggerButton?.nativeElement ?? null;
6024
+ }
6025
+ set alternativePresetList(v) {
6026
+ this.alternativePresetList$.next(v);
6027
+ }
6028
+ get alternativePresetList() {
6029
+ return this.alternativePresetList$.getValue();
6030
+ }
6031
+ setFavorite(preset, favorite) {
6032
+ const ids = new Set(this.favoritePresetIds$.getValue());
6033
+ if (favorite) ids.add(preset.id);
6034
+ else ids.delete(preset.id);
6035
+ this.favoritePresetIds$.next([...ids]);
6201
6036
  }
6202
6037
  onInputFocus() {
6203
- this.hasFocus = true;
6204
6038
  this.open$.next(true);
6205
6039
  }
6040
+ onInputChange(text) {
6041
+ this.typedText$.next(text);
6042
+ }
6043
+ onInputBlur(event) {
6044
+ this.closeOnFocusLeaving(event);
6045
+ this.commitTypedText();
6046
+ }
6047
+ onInputEnter() {
6048
+ this.closeCalendar();
6049
+ this.commitTypedText();
6050
+ }
6206
6051
  toggleCalendar() {
6207
- this.open$.next(!this.open$.getValue());
6052
+ if (this.open$.getValue()) this.closeCalendar();
6053
+ else this.open$.next(true);
6208
6054
  }
6209
- get isRolling() {
6210
- return this.rollingTodayLabel != null;
6055
+ onEscape(event) {
6056
+ if (!this.open$.getValue() || event.defaultPrevented) return;
6057
+ event.preventDefault();
6058
+ (this.inputElement ?? this.customTriggerButton)?.nativeElement.focus();
6059
+ this.closeCalendar();
6211
6060
  }
6212
- isRollingText(text) {
6213
- return this.rollingTodayLabel != null && text.trim().toLowerCase() === this.rollingTodayLabel.toLowerCase();
6061
+ onInputArrowDown() {
6062
+ this.open$.next(true);
6063
+ setTimeout(() => document.getElementById(this.calendarId)?.querySelector(DateRangeComponent.focusableSelector)?.focus(), 0);
6214
6064
  }
6215
- syncInputText() {
6216
- this.inputText = this._value ? this.formatValue(this._value) : this.rollingTodayLabel ?? "";
6065
+ closeOnFocusLeaving(event) {
6066
+ const next = event?.relatedTarget;
6067
+ if (next instanceof Element && !this.isInsidePicker(next)) this.closeCalendar();
6217
6068
  }
6218
- formatValue(date) {
6219
- return this.datePipe.transform(date);
6069
+ closeCalendar() {
6070
+ this.open$.next(false);
6071
+ if (this.value) this.userTypedRange$.next(this.value);
6072
+ else this.userSelectedDate$.next(void 0);
6220
6073
  }
6221
- parseInput(text) {
6222
- const parsed = DateComponent.parseDate(text);
6223
- return parsed && DateComponent.isValidDate(parsed, this.min, this.max) ? timeDay.floor(parsed) : void 0;
6074
+ onDocumentMouseDown(target) {
6075
+ if (!this.open$.getValue() || !(target instanceof Element)) return;
6076
+ if (this.isInsidePicker(target)) return;
6077
+ this.closeCalendar();
6224
6078
  }
6225
- setActiveMonth(date) {
6226
- const month = timeMonth.floor(date);
6227
- if (month.getTime() !== this.activeYearMonth.getTime()) this.activeYearMonth = month;
6079
+ isInsidePicker(target) {
6080
+ const host = this.host.nativeElement;
6081
+ if (host.contains(target)) return true;
6082
+ const layer = target.closest(".callout, .scrim, .overlay-container");
6083
+ return !!layer && !layer.contains(host);
6228
6084
  }
6229
- commit(next) {
6230
- const unchanged = next?.getTime() === this._value?.getTime();
6231
- this._value = next;
6232
- this.syncInputText();
6233
- this.previewValue = void 0;
6234
- if (next) this.setActiveMonth(next);
6235
- if (!unchanged) this.valueChange.emit(next);
6236
- this.cdr.markForCheck();
6085
+ commitTypedText() {
6086
+ const text = this.typedText$.getValue();
6087
+ if (text === null) return;
6088
+ this.typedText$.next(null);
6089
+ if (!text.trim()) {
6090
+ this.userSelectedDate$.next(void 0);
6091
+ return;
6092
+ }
6093
+ const range = DateRangeComponent.parseDateRange(text, this.min, this.max);
6094
+ if (range) this.userTypedRange$.next(range);
6237
6095
  }
6238
6096
  static {
6239
6097
  this.ɵfac = i0.ɵɵngDeclareFactory({
6240
6098
  minVersion: "12.0.0",
6241
6099
  version: "22.2.4",
6242
6100
  ngImport: i0,
6243
- type: DateComponent,
6244
- deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }],
6101
+ type: DateRangeComponent,
6102
+ deps: [{ token: i0.ElementRef }],
6245
6103
  target: i0.ɵɵFactoryTarget.Component
6246
6104
  });
6247
6105
  }
@@ -6249,35 +6107,64 @@ var DateComponent = class DateComponent extends InputLabelComponent {
6249
6107
  this.ɵcmp = i0.ɵɵngDeclareComponent({
6250
6108
  minVersion: "14.0.0",
6251
6109
  version: "22.2.4",
6252
- type: DateComponent,
6110
+ type: DateRangeComponent,
6253
6111
  isStandalone: false,
6254
- selector: "riv-date",
6112
+ selector: "riv-date-range",
6255
6113
  inputs: {
6114
+ showPresets: "showPresets",
6256
6115
  min: "min",
6257
6116
  max: "max",
6258
6117
  value: "value",
6259
6118
  placeholder: "placeholder",
6260
6119
  disabled: "disabled",
6261
- size: "size",
6262
- showClearButton: "showClearButton",
6263
- showTodayButton: "showTodayButton",
6264
- rollingTodayLabel: "rollingTodayLabel",
6265
- open: "open"
6120
+ alternativePresetList: "alternativePresetList"
6266
6121
  },
6267
6122
  outputs: { valueChange: "valueChange" },
6268
6123
  host: { listeners: { "document:mousedown": "onDocumentMouseDown($event.target)" } },
6269
6124
  queries: [{
6270
- propertyName: "headerTemplate",
6125
+ propertyName: "triggerTemplate",
6271
6126
  first: true,
6272
- predicate: ["header"],
6127
+ predicate: ["trigger"],
6273
6128
  descendants: true
6274
6129
  }],
6130
+ viewQueries: [
6131
+ {
6132
+ propertyName: "customTriggerButton",
6133
+ first: true,
6134
+ predicate: ["customTriggerButton"],
6135
+ descendants: true,
6136
+ read: ElementRef
6137
+ },
6138
+ {
6139
+ propertyName: "standardTriggerButton",
6140
+ first: true,
6141
+ predicate: ["standardTriggerButton"],
6142
+ descendants: true,
6143
+ read: ElementRef
6144
+ },
6145
+ {
6146
+ propertyName: "inputElement",
6147
+ first: true,
6148
+ predicate: ["input"],
6149
+ descendants: true,
6150
+ read: ElementRef
6151
+ }
6152
+ ],
6275
6153
  usesInheritance: true,
6276
- usesOnChanges: true,
6277
6154
  ngImport: i0,
6278
- template: "<riv-input-label\n [label]=\"label\"\n [help]=\"help\"\n [required]=\"required\"\n [state]=\"state\"\n [errorMessage]=\"errorMessage\"\n [labelActionText]=\"labelActionText\"\n (labelAction)=\"labelAction.emit($event)\"\n>\n <div\n #trigger\n class=\"trigger\"\n [class.xsmall]=\"size === 'xsmall'\"\n [class.small]=\"size === 'small'\"\n [class.large]=\"size === 'large'\"\n [class.xlarge]=\"size === 'xlarge'\"\n [class.warning]=\"state === 'warning'\"\n [class.error]=\"state === 'error'\"\n [class.disabled]=\"disabled\"\n >\n <input\n #input\n class=\"value\"\n [placeholder]=\"placeholder\"\n [value]=\"inputText\"\n [disabled]=\"disabled\"\n [attr.aria-disabled]=\"disabled ? 'true' : null\"\n [attr.aria-label]=\"label || null\"\n [attr.aria-controls]=\"calendarId\"\n [attr.aria-expanded]=\"open$ | async\"\n role=\"combobox\"\n aria-haspopup=\"dialog\"\n aria-autocomplete=\"none\"\n (input)=\"onInputChange(input.value)\"\n (blur)=\"onInputBlur($event)\"\n (focus)=\"onInputFocus()\"\n (keydown.enter)=\"input.blur(); open$.next(false); $event.preventDefault()\"\n type=\"text\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n <button\n class=\"chevron\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"toggleCalendar()\"\n [disabled]=\"disabled\"\n [attr.aria-disabled]=\"disabled ? 'true' : null\"\n [attr.aria-label]=\"(open$ | async) ? 'Close calendar' : 'Open calendar'\"\n type=\"button\"\n tabindex=\"-1\"\n >\n <riv-icon [name]=\"'Calendar'\" [size]=\"16\"></riv-icon>\n </button>\n </div>\n</riv-input-label>\n<ng-container *ngIf=\"open$ | async\">\n <riv-callout\n *riv-overlay\n [anchor]=\"trigger\"\n [isModal]=\"false\"\n [showCaret]=\"false\"\n [theme]=\"'light'\"\n [allowedPositions]=\"[\n 'top-left',\n 'top-right',\n 'bottom-right',\n 'bottom-left'\n ]\"\n [preferredPosition]=\"'bottom-right'\"\n (close)=\"open$.next(false)\"\n >\n <div [attr.id]=\"calendarId\" (mousedown)=\"$event.preventDefault()\">\n <header *ngIf=\"headerTemplate\">\n <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n </header>\n <div class=\"content\">\n <riv-calendar\n [activeYearMonth]=\"activeYearMonth\"\n (activeYearMonthChange)=\"activeYearMonth = $event\"\n [displayMin]=\"min\"\n [displayMax]=\"max\"\n [selectableMin]=\"min\"\n [selectableMax]=\"max\"\n [selectedValue]=\"selectedCalendarValue\"\n (dateSelect)=\"onDateSelect($event); input.blur()\"\n ></riv-calendar>\n </div>\n <footer *ngIf=\"showClearButton || showTodayButton\" class=\"buttons\">\n <button\n *ngIf=\"showClearButton\"\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n (click)=\"clearValue(); input.blur()\"\n type=\"button\"\n >\n Clear\n </button>\n <button\n *ngIf=\"showTodayButton\"\n class=\"today\"\n rivButton\n [size]=\"'small'\"\n [variant]=\"'basic'\"\n [disabled]=\"!isTodaySelectable\"\n (click)=\"selectToday(); input.blur()\"\n type=\"button\"\n >\n Today\n </button>\n </footer>\n </div>\n </riv-callout>\n</ng-container>\n",
6279
- styles: [".trigger{width:100%;border:var(--border-width) solid var(--border-light);border-radius:var(--border-radius-small);display:flex;gap:var(--size-small);background-color:var(--surface-light-0);padding-left:var(--size-small);position:relative}.trigger:focus-within{outline:none;border:var(--border-width) solid var(--purp-60)}.trigger.disabled{color:var(--type-light-disabled);background-color:var(--surface-light-1)}.value{font:var(--input-medium);color:var(--type-light-high-contrast);padding:var(--size-small) 0;flex-grow:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:pre;border:none;background:transparent;outline:none;width:100%}.value::placeholder{color:var(--type-light-low-contrast)}.value:disabled{color:var(--type-light-disabled)}.trigger.xsmall .value{font:var(--input-small);padding:var(--size-xsmall) 0}.trigger.small .value{font:var(--input-small)}.trigger.large .value{font:var(--input-large);padding:var(--size-medium) var(--size-xsmall)}.trigger.xlarge .value{font:var(--input-large);padding:var(--size-large) var(--size-small)}.chevron{display:flex;justify-content:center;align-items:center;padding:var(--size-xsmall) calc(var(--base-grid-size) * 1.5);border:none;background:transparent;cursor:pointer;color:var(--type-light-high-contrast)}.chevron:disabled{color:var(--type-light-disabled);cursor:not-allowed}.trigger.warning{border-color:var(--surface-dark-caution)}.trigger.error{border-color:var(--surface-dark-danger);box-shadow:inset 0 0 0 var(--border-width-large) var(--surface-dark-danger)}.content{padding:var(--size-xlarge)}.buttons{padding:0 var(--size-xlarge) var(--size-xlarge);display:flex;justify-content:space-between}.buttons .today{margin-left:auto}\n"],
6155
+ template: "<ng-container *ngIf=\"triggerTemplate; else standardTrigger\">\n <button\n #customTriggerButton\n (click)=\"open$.next(true)\"\n [disabled]=\"disabled$ | async\"\n [attr.aria-disabled]=\"(disabled$ | async) ? 'true' : null\"\n type=\"button\"\n >\n <ng-container\n [ngTemplateOutlet]=\"triggerTemplate\"\n [ngTemplateOutletContext]=\"{ open: open$ | async }\"\n ></ng-container>\n </button>\n</ng-container>\n<ng-template #standardTrigger>\n <riv-input-label\n [label]=\"label\"\n [help]=\"help\"\n [required]=\"required\"\n [state]=\"state\"\n [errorMessage]=\"errorMessage\"\n [labelActionText]=\"labelActionText\"\n (labelAction)=\"labelAction.emit($event)\"\n >\n <div\n #standardTriggerButton\n class=\"trigger\"\n [class.warning]=\"state === 'warning'\"\n [class.error]=\"state === 'error'\"\n [class.disabled]=\"disabled$ | async\"\n >\n <input\n #input\n class=\"value\"\n [placeholder]=\"placeholder$ | async\"\n [value]=\"inputText$ | async\"\n [disabled]=\"disabled$ | async\"\n [attr.aria-disabled]=\"(disabled$ | async) ? 'true' : null\"\n [attr.aria-label]=\"label || null\"\n [attr.aria-controls]=\"calendarId\"\n [attr.aria-expanded]=\"open$ | async\"\n role=\"combobox\"\n aria-haspopup=\"dialog\"\n aria-autocomplete=\"none\"\n (input)=\"onInputChange(input.value)\"\n (blur)=\"onInputBlur($event)\"\n (focus)=\"onInputFocus()\"\n (click)=\"open$.next(true)\"\n (keydown.enter)=\"onInputEnter(); input.blur(); $event.preventDefault()\"\n (keydown.escape)=\"onEscape($event)\"\n (keydown.arrowdown)=\"onInputArrowDown(); $event.preventDefault()\"\n (keydown.alt.arrowdown)=\"onInputArrowDown(); $event.preventDefault()\"\n type=\"text\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n <button\n class=\"chevron\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"toggleCalendar()\"\n [disabled]=\"disabled$ | async\"\n [attr.aria-disabled]=\"(disabled$ | async) ? 'true' : null\"\n [attr.aria-label]=\"(open$ | async) ? 'Close calendar' : 'Open calendar'\"\n type=\"button\"\n tabindex=\"-1\"\n >\n <riv-icon [name]=\"'Calendar'\" [size]=\"16\"></riv-icon>\n </button>\n </div>\n </riv-input-label>\n</ng-template>\n\n<ng-container *ngIf=\"open$ | async\">\n <riv-callout\n *riv-overlay\n [anchor]=\"getTrigger()\"\n [isModal]=\"!!triggerTemplate\"\n [showCaret]=\"false\"\n [theme]=\"'light'\"\n [allowedPositions]=\"[\n 'top-left',\n 'top-right',\n 'bottom-right',\n 'bottom-left'\n ]\"\n [preferredPosition]=\"'bottom-right'\"\n (close)=\"closeCalendar()\"\n >\n <div\n class=\"content\"\n [class.include-preset]=\"showPresets\"\n [attr.id]=\"calendarId\"\n (keydown.escape)=\"onEscape($event)\"\n (focusout)=\"closeOnFocusLeaving($event)\"\n >\n <div *ngIf=\"showPresets\" class=\"presets\">\n <riv-simple-select\n [label]=\"'Date presets'\"\n [filterabilityOptions]=\"{ enabled: true, placeholder: 'Search' }\"\n [orderBy]=\"'source'\"\n [optionGroups]=\"\n (filteredPresetOptions$ | async) ?? [] | rivOptionGroup\n \"\n [selectedOption]=\"selectedPreset$ | async\"\n (selectedOptionChange)=\"userSelectedPreset$.next($event)\"\n >\n <ng-template #option let-node=\"node\">\n <ng-template\n #self\n [ngTemplateOutlet]=\"self\"\n let-isFavorite\n [ngTemplateOutletContext]=\"{\n $implicit: $safeNavigationMigration(\n (favoritePresetIds$ | async)?.includes(node.id)\n )\n }\"\n >\n <div class=\"preset\" [class.favorite]=\"isFavorite\">\n <div class=\"description\">\n <riv-highlight\n class=\"title\"\n [text]=\"node.title\"\n [indices]=\"node.titleHighlightIndices || []\"\n ></riv-highlight>\n <riv-highlight\n class=\"subtitle\"\n [text]=\"node.subtitle\"\n [indices]=\"node.subtitleHighlightIndices || []\"\n ></riv-highlight>\n </div>\n <button\n (click)=\"\n setFavorite(node, !isFavorite); $event.stopPropagation()\n \"\n type=\"button\"\n >\n <riv-icon\n [name]=\"isFavorite ? 'HeartActive' : 'Heart'\"\n [size]=\"16\"\n [rivTooltip]=\"'Mark as favorite'\"\n ></riv-icon>\n </button>\n </div>\n </ng-template>\n </ng-template>\n </riv-simple-select>\n <ng-template\n #self\n [ngTemplateOutlet]=\"self\"\n let-favorites\n [ngTemplateOutletContext]=\"{ $implicit: favoritePresets$ | async }\"\n >\n <riv-input-label *ngIf=\"favorites.length\" [label]=\"'Favorites'\">\n <div class=\"shortcuts\">\n <button\n *ngFor=\"let favorite of favorites\"\n class=\"shortcut\"\n [class.active]=\"(selectedPreset$ | async)?.id === favorite.id\"\n (click)=\"userSelectedPreset$.next(favorite)\"\n type=\"button\"\n >\n <span class=\"title\">{{ favorite.title }}</span>\n <button\n (click)=\"setFavorite(favorite, false)\"\n [rivTooltip]=\"'Remove favorite'\"\n type=\"button\"\n >\n <riv-icon [name]=\"'HeartActive'\" [size]=\"16\"></riv-icon>\n </button>\n </button>\n </div>\n </riv-input-label>\n </ng-template>\n </div>\n\n <div class=\"calendars\">\n <riv-calendar\n class=\"left\"\n [activeYearMonth]=\"(leftActiveYearMonth$ | async) || TODAY\"\n (activeYearMonthChange)=\"userLeftActiveYearMonth$.next($event)\"\n [displayMin]=\"(min$ | async) || TODAY\"\n [displayMax]=\"(max$ | async) || TODAY\"\n [selectableMin]=\"(leftMin$ | async) || TODAY\"\n [selectableMax]=\"(leftMax$ | async) || TODAY\"\n [omitRange]=\"(leftOmitRange$ | async) || [TODAY, TODAY]\"\n [selectedValue]=\"(selectedValue$ | async) || TODAY\"\n (dateSelect)=\"userSelectedDate$.next($event)\"\n ></riv-calendar>\n <riv-calendar\n class=\"right\"\n [activeYearMonth]=\"(rightActiveYearMonth$ | async) || TODAY\"\n (activeYearMonthChange)=\"userRightActiveYearMonth$.next($event)\"\n [displayMin]=\"(min$ | async) || TODAY\"\n [displayMax]=\"(max$ | async) || TODAY\"\n [selectableMin]=\"(rightMin$ | async) || TODAY\"\n [selectableMax]=\"(rightMax$ | async) || TODAY\"\n [selectedValue]=\"(selectedValue$ | async) || TODAY\"\n (dateSelect)=\"userSelectedDate$.next($event)\"\n ></riv-calendar>\n </div>\n\n <footer class=\"buttons\">\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n (click)=\"userSelectedDate$.next(undefined)\"\n type=\"button\"\n >\n Clear\n </button>\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'primary'\"\n (click)=\"closeCalendar()\"\n type=\"button\"\n >\n Done\n </button>\n </footer>\n </div>\n </riv-callout>\n</ng-container>\n",
6156
+ styles: [".trigger{width:100%;border:var(--border-width) solid var(--border-light);border-radius:var(--border-radius-small);display:flex;gap:var(--size-small);background-color:var(--surface-light-0);padding-left:var(--size-small)}.trigger:focus-within{outline:none;border:var(--border-width) solid var(--purp-60)}.trigger.disabled{color:var(--type-light-disabled);background-color:var(--surface-light-1)}.value{font:var(--input-medium);color:var(--type-light-high-contrast);padding:var(--size-small) 0;flex-grow:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:pre;border:none;background:transparent;outline:none;width:100%}.value::placeholder{color:var(--type-light-low-contrast)}.value:disabled{color:var(--type-light-disabled)}.chevron{display:flex;justify-content:center;align-items:center;padding:var(--size-xsmall) calc(var(--base-grid-size) * 1.5);border:none;background:transparent;cursor:pointer;color:var(--type-light-high-contrast)}.chevron:disabled{color:var(--type-light-disabled);cursor:not-allowed}.trigger.warning{border-color:var(--surface-dark-caution)}.trigger.error{border-color:var(--surface-dark-danger);box-shadow:inset 0 0 0 var(--border-width-large) var(--surface-dark-danger)}.content{display:inline-grid;grid-template-rows:1fr auto}.content.include-preset{grid-template-columns:calc(var(--base-grid-size) * 50) 1fr 1fr}.presets{grid-area:1 / 1 / 3 / 2;background-color:var(--surface-light-1);padding:var(--size-xlarge) var(--size-large);border-right:var(--border-width) solid var(--border-light);display:flex;flex-direction:column;gap:var(--size-medium)}.preset{display:flex;transition:background-color var(--short-transition)}.preset:hover{background-color:var(--surface-light-2)}.preset button{color:transparent;transition:color var(--short-transition);padding:var(--size-medium) var(--size-large) var(--size-medium) var(--size-small);cursor:pointer}.preset:hover button{color:var(--type-light-low-contrast)}.preset button:hover{color:var(--type-light-high-contrast)}.preset.favorite button{color:var(--type-light-link)}.preset .description{flex-grow:1;padding:var(--size-medium) var(--size-small) var(--size-medium) var(--size-medium)}.preset .title{display:block;font-size:var(--type-2-font-size);line-height:var(--type-2-line-height-1)}.preset .subtitle{display:block;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-1);color:var(--type-light-low-contrast)}.shortcuts{display:flex;flex-direction:column;gap:var(--size-xsmall);overflow-y:auto}.shortcut{display:flex;align-items:center;padding:var(--size-small) var(--size-small) var(--size-small) var(--size-medium);gap:var(--size-small);border-radius:var(--border-radius-small);transition:background-color var(--short-transition);cursor:pointer}.shortcut:hover{background-color:var(--black-20)}.shortcut.active{background-color:var(--baloo-05)}.shortcut .title{flex-grow:1;text-align:left;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-2)}.shortcut button{color:transparent;transition:color var(--short-transition);cursor:pointer}.shortcut:hover button{color:var(--type-light-link)}.calendars{grid-column:2 / 4;display:grid;grid-template-columns:subgrid;grid-template-rows:subgrid;padding:var(--size-large)}.left{grid-area:1 / 1 / 2 / 2;padding-right:var(--size-large);border-right:var(--border-width) solid var(--border-light)}.right{padding-left:var(--size-large);grid-area:1 / 2 / 2 / 3}.buttons{grid-area:2 / 2 / 3 / 4;padding:var(--size-small);display:flex;justify-content:space-between}\n"],
6280
6157
  dependencies: [
6158
+ {
6159
+ kind: "directive",
6160
+ type: i1.NgForOf,
6161
+ selector: "[ngFor][ngForOf]",
6162
+ inputs: [
6163
+ "ngForOf",
6164
+ "ngForTrackBy",
6165
+ "ngForTemplate"
6166
+ ]
6167
+ },
6281
6168
  {
6282
6169
  kind: "directive",
6283
6170
  type: i1.NgIf,
@@ -6344,6 +6231,12 @@ var DateComponent = class DateComponent extends InputLabelComponent {
6344
6231
  ],
6345
6232
  outputs: ["close"]
6346
6233
  },
6234
+ {
6235
+ kind: "component",
6236
+ type: HighlightComponent,
6237
+ selector: "riv-highlight",
6238
+ inputs: ["text", "indices"]
6239
+ },
6347
6240
  {
6348
6241
  kind: "component",
6349
6242
  type: IconComponent,
@@ -6375,10 +6268,55 @@ var DateComponent = class DateComponent extends InputLabelComponent {
6375
6268
  type: OverlayDirective,
6376
6269
  selector: "[riv-overlay]"
6377
6270
  },
6271
+ {
6272
+ kind: "component",
6273
+ type: SimpleSelectComponent,
6274
+ selector: "riv-simple-select",
6275
+ inputs: [
6276
+ "optionGroups",
6277
+ "selectedOption",
6278
+ "size",
6279
+ "disabled",
6280
+ "locked",
6281
+ "filterabilityOptions",
6282
+ "orderBy",
6283
+ "placeholder",
6284
+ "maxHeight",
6285
+ "maxWidth",
6286
+ "minHeight",
6287
+ "minWidth",
6288
+ "dividers",
6289
+ "sortSelectedToTop",
6290
+ "grow",
6291
+ "preferredCalloutPosition",
6292
+ "allowedCalloutPositions"
6293
+ ],
6294
+ outputs: ["selectedOptionChange"]
6295
+ },
6296
+ {
6297
+ kind: "directive",
6298
+ type: TooltipDirective,
6299
+ selector: "[rivTooltip]",
6300
+ inputs: [
6301
+ "rivTooltip",
6302
+ "rivTooltipTheme",
6303
+ "rivTooltipMaxWidth",
6304
+ "rivTooltipPreferredPosition",
6305
+ "rivTooltipAnchor",
6306
+ "rivTooltipCloseDelay",
6307
+ "rivTooltipOpenDelay",
6308
+ "rivTooltipGracePeriod"
6309
+ ]
6310
+ },
6378
6311
  {
6379
6312
  kind: "pipe",
6380
6313
  type: i1.AsyncPipe,
6381
6314
  name: "async"
6315
+ },
6316
+ {
6317
+ kind: "pipe",
6318
+ type: OptionGroupPipe,
6319
+ name: "rivOptionGroup"
6382
6320
  }
6383
6321
  ],
6384
6322
  changeDetection: i0.ChangeDetectionStrategy.OnPush
@@ -6389,33 +6327,42 @@ i0.ɵɵngDeclareClassMetadata({
6389
6327
  minVersion: "12.0.0",
6390
6328
  version: "22.2.4",
6391
6329
  ngImport: i0,
6392
- type: DateComponent,
6330
+ type: DateRangeComponent,
6393
6331
  decorators: [{
6394
6332
  type: Component,
6395
6333
  args: [{
6396
- selector: "riv-date",
6334
+ selector: "riv-date-range",
6397
6335
  changeDetection: ChangeDetectionStrategy.OnPush,
6398
6336
  standalone: false,
6399
- template: "<riv-input-label\n [label]=\"label\"\n [help]=\"help\"\n [required]=\"required\"\n [state]=\"state\"\n [errorMessage]=\"errorMessage\"\n [labelActionText]=\"labelActionText\"\n (labelAction)=\"labelAction.emit($event)\"\n>\n <div\n #trigger\n class=\"trigger\"\n [class.xsmall]=\"size === 'xsmall'\"\n [class.small]=\"size === 'small'\"\n [class.large]=\"size === 'large'\"\n [class.xlarge]=\"size === 'xlarge'\"\n [class.warning]=\"state === 'warning'\"\n [class.error]=\"state === 'error'\"\n [class.disabled]=\"disabled\"\n >\n <input\n #input\n class=\"value\"\n [placeholder]=\"placeholder\"\n [value]=\"inputText\"\n [disabled]=\"disabled\"\n [attr.aria-disabled]=\"disabled ? 'true' : null\"\n [attr.aria-label]=\"label || null\"\n [attr.aria-controls]=\"calendarId\"\n [attr.aria-expanded]=\"open$ | async\"\n role=\"combobox\"\n aria-haspopup=\"dialog\"\n aria-autocomplete=\"none\"\n (input)=\"onInputChange(input.value)\"\n (blur)=\"onInputBlur($event)\"\n (focus)=\"onInputFocus()\"\n (keydown.enter)=\"input.blur(); open$.next(false); $event.preventDefault()\"\n type=\"text\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n <button\n class=\"chevron\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"toggleCalendar()\"\n [disabled]=\"disabled\"\n [attr.aria-disabled]=\"disabled ? 'true' : null\"\n [attr.aria-label]=\"(open$ | async) ? 'Close calendar' : 'Open calendar'\"\n type=\"button\"\n tabindex=\"-1\"\n >\n <riv-icon [name]=\"'Calendar'\" [size]=\"16\"></riv-icon>\n </button>\n </div>\n</riv-input-label>\n<ng-container *ngIf=\"open$ | async\">\n <riv-callout\n *riv-overlay\n [anchor]=\"trigger\"\n [isModal]=\"false\"\n [showCaret]=\"false\"\n [theme]=\"'light'\"\n [allowedPositions]=\"[\n 'top-left',\n 'top-right',\n 'bottom-right',\n 'bottom-left'\n ]\"\n [preferredPosition]=\"'bottom-right'\"\n (close)=\"open$.next(false)\"\n >\n <div [attr.id]=\"calendarId\" (mousedown)=\"$event.preventDefault()\">\n <header *ngIf=\"headerTemplate\">\n <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n </header>\n <div class=\"content\">\n <riv-calendar\n [activeYearMonth]=\"activeYearMonth\"\n (activeYearMonthChange)=\"activeYearMonth = $event\"\n [displayMin]=\"min\"\n [displayMax]=\"max\"\n [selectableMin]=\"min\"\n [selectableMax]=\"max\"\n [selectedValue]=\"selectedCalendarValue\"\n (dateSelect)=\"onDateSelect($event); input.blur()\"\n ></riv-calendar>\n </div>\n <footer *ngIf=\"showClearButton || showTodayButton\" class=\"buttons\">\n <button\n *ngIf=\"showClearButton\"\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n (click)=\"clearValue(); input.blur()\"\n type=\"button\"\n >\n Clear\n </button>\n <button\n *ngIf=\"showTodayButton\"\n class=\"today\"\n rivButton\n [size]=\"'small'\"\n [variant]=\"'basic'\"\n [disabled]=\"!isTodaySelectable\"\n (click)=\"selectToday(); input.blur()\"\n type=\"button\"\n >\n Today\n </button>\n </footer>\n </div>\n </riv-callout>\n</ng-container>\n",
6400
- styles: [".trigger{width:100%;border:var(--border-width) solid var(--border-light);border-radius:var(--border-radius-small);display:flex;gap:var(--size-small);background-color:var(--surface-light-0);padding-left:var(--size-small);position:relative}.trigger:focus-within{outline:none;border:var(--border-width) solid var(--purp-60)}.trigger.disabled{color:var(--type-light-disabled);background-color:var(--surface-light-1)}.value{font:var(--input-medium);color:var(--type-light-high-contrast);padding:var(--size-small) 0;flex-grow:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:pre;border:none;background:transparent;outline:none;width:100%}.value::placeholder{color:var(--type-light-low-contrast)}.value:disabled{color:var(--type-light-disabled)}.trigger.xsmall .value{font:var(--input-small);padding:var(--size-xsmall) 0}.trigger.small .value{font:var(--input-small)}.trigger.large .value{font:var(--input-large);padding:var(--size-medium) var(--size-xsmall)}.trigger.xlarge .value{font:var(--input-large);padding:var(--size-large) var(--size-small)}.chevron{display:flex;justify-content:center;align-items:center;padding:var(--size-xsmall) calc(var(--base-grid-size) * 1.5);border:none;background:transparent;cursor:pointer;color:var(--type-light-high-contrast)}.chevron:disabled{color:var(--type-light-disabled);cursor:not-allowed}.trigger.warning{border-color:var(--surface-dark-caution)}.trigger.error{border-color:var(--surface-dark-danger);box-shadow:inset 0 0 0 var(--border-width-large) var(--surface-dark-danger)}.content{padding:var(--size-xlarge)}.buttons{padding:0 var(--size-xlarge) var(--size-xlarge);display:flex;justify-content:space-between}.buttons .today{margin-left:auto}\n"]
6337
+ template: "<ng-container *ngIf=\"triggerTemplate; else standardTrigger\">\n <button\n #customTriggerButton\n (click)=\"open$.next(true)\"\n [disabled]=\"disabled$ | async\"\n [attr.aria-disabled]=\"(disabled$ | async) ? 'true' : null\"\n type=\"button\"\n >\n <ng-container\n [ngTemplateOutlet]=\"triggerTemplate\"\n [ngTemplateOutletContext]=\"{ open: open$ | async }\"\n ></ng-container>\n </button>\n</ng-container>\n<ng-template #standardTrigger>\n <riv-input-label\n [label]=\"label\"\n [help]=\"help\"\n [required]=\"required\"\n [state]=\"state\"\n [errorMessage]=\"errorMessage\"\n [labelActionText]=\"labelActionText\"\n (labelAction)=\"labelAction.emit($event)\"\n >\n <div\n #standardTriggerButton\n class=\"trigger\"\n [class.warning]=\"state === 'warning'\"\n [class.error]=\"state === 'error'\"\n [class.disabled]=\"disabled$ | async\"\n >\n <input\n #input\n class=\"value\"\n [placeholder]=\"placeholder$ | async\"\n [value]=\"inputText$ | async\"\n [disabled]=\"disabled$ | async\"\n [attr.aria-disabled]=\"(disabled$ | async) ? 'true' : null\"\n [attr.aria-label]=\"label || null\"\n [attr.aria-controls]=\"calendarId\"\n [attr.aria-expanded]=\"open$ | async\"\n role=\"combobox\"\n aria-haspopup=\"dialog\"\n aria-autocomplete=\"none\"\n (input)=\"onInputChange(input.value)\"\n (blur)=\"onInputBlur($event)\"\n (focus)=\"onInputFocus()\"\n (click)=\"open$.next(true)\"\n (keydown.enter)=\"onInputEnter(); input.blur(); $event.preventDefault()\"\n (keydown.escape)=\"onEscape($event)\"\n (keydown.arrowdown)=\"onInputArrowDown(); $event.preventDefault()\"\n (keydown.alt.arrowdown)=\"onInputArrowDown(); $event.preventDefault()\"\n type=\"text\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n <button\n class=\"chevron\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"toggleCalendar()\"\n [disabled]=\"disabled$ | async\"\n [attr.aria-disabled]=\"(disabled$ | async) ? 'true' : null\"\n [attr.aria-label]=\"(open$ | async) ? 'Close calendar' : 'Open calendar'\"\n type=\"button\"\n tabindex=\"-1\"\n >\n <riv-icon [name]=\"'Calendar'\" [size]=\"16\"></riv-icon>\n </button>\n </div>\n </riv-input-label>\n</ng-template>\n\n<ng-container *ngIf=\"open$ | async\">\n <riv-callout\n *riv-overlay\n [anchor]=\"getTrigger()\"\n [isModal]=\"!!triggerTemplate\"\n [showCaret]=\"false\"\n [theme]=\"'light'\"\n [allowedPositions]=\"[\n 'top-left',\n 'top-right',\n 'bottom-right',\n 'bottom-left'\n ]\"\n [preferredPosition]=\"'bottom-right'\"\n (close)=\"closeCalendar()\"\n >\n <div\n class=\"content\"\n [class.include-preset]=\"showPresets\"\n [attr.id]=\"calendarId\"\n (keydown.escape)=\"onEscape($event)\"\n (focusout)=\"closeOnFocusLeaving($event)\"\n >\n <div *ngIf=\"showPresets\" class=\"presets\">\n <riv-simple-select\n [label]=\"'Date presets'\"\n [filterabilityOptions]=\"{ enabled: true, placeholder: 'Search' }\"\n [orderBy]=\"'source'\"\n [optionGroups]=\"\n (filteredPresetOptions$ | async) ?? [] | rivOptionGroup\n \"\n [selectedOption]=\"selectedPreset$ | async\"\n (selectedOptionChange)=\"userSelectedPreset$.next($event)\"\n >\n <ng-template #option let-node=\"node\">\n <ng-template\n #self\n [ngTemplateOutlet]=\"self\"\n let-isFavorite\n [ngTemplateOutletContext]=\"{\n $implicit: $safeNavigationMigration(\n (favoritePresetIds$ | async)?.includes(node.id)\n )\n }\"\n >\n <div class=\"preset\" [class.favorite]=\"isFavorite\">\n <div class=\"description\">\n <riv-highlight\n class=\"title\"\n [text]=\"node.title\"\n [indices]=\"node.titleHighlightIndices || []\"\n ></riv-highlight>\n <riv-highlight\n class=\"subtitle\"\n [text]=\"node.subtitle\"\n [indices]=\"node.subtitleHighlightIndices || []\"\n ></riv-highlight>\n </div>\n <button\n (click)=\"\n setFavorite(node, !isFavorite); $event.stopPropagation()\n \"\n type=\"button\"\n >\n <riv-icon\n [name]=\"isFavorite ? 'HeartActive' : 'Heart'\"\n [size]=\"16\"\n [rivTooltip]=\"'Mark as favorite'\"\n ></riv-icon>\n </button>\n </div>\n </ng-template>\n </ng-template>\n </riv-simple-select>\n <ng-template\n #self\n [ngTemplateOutlet]=\"self\"\n let-favorites\n [ngTemplateOutletContext]=\"{ $implicit: favoritePresets$ | async }\"\n >\n <riv-input-label *ngIf=\"favorites.length\" [label]=\"'Favorites'\">\n <div class=\"shortcuts\">\n <button\n *ngFor=\"let favorite of favorites\"\n class=\"shortcut\"\n [class.active]=\"(selectedPreset$ | async)?.id === favorite.id\"\n (click)=\"userSelectedPreset$.next(favorite)\"\n type=\"button\"\n >\n <span class=\"title\">{{ favorite.title }}</span>\n <button\n (click)=\"setFavorite(favorite, false)\"\n [rivTooltip]=\"'Remove favorite'\"\n type=\"button\"\n >\n <riv-icon [name]=\"'HeartActive'\" [size]=\"16\"></riv-icon>\n </button>\n </button>\n </div>\n </riv-input-label>\n </ng-template>\n </div>\n\n <div class=\"calendars\">\n <riv-calendar\n class=\"left\"\n [activeYearMonth]=\"(leftActiveYearMonth$ | async) || TODAY\"\n (activeYearMonthChange)=\"userLeftActiveYearMonth$.next($event)\"\n [displayMin]=\"(min$ | async) || TODAY\"\n [displayMax]=\"(max$ | async) || TODAY\"\n [selectableMin]=\"(leftMin$ | async) || TODAY\"\n [selectableMax]=\"(leftMax$ | async) || TODAY\"\n [omitRange]=\"(leftOmitRange$ | async) || [TODAY, TODAY]\"\n [selectedValue]=\"(selectedValue$ | async) || TODAY\"\n (dateSelect)=\"userSelectedDate$.next($event)\"\n ></riv-calendar>\n <riv-calendar\n class=\"right\"\n [activeYearMonth]=\"(rightActiveYearMonth$ | async) || TODAY\"\n (activeYearMonthChange)=\"userRightActiveYearMonth$.next($event)\"\n [displayMin]=\"(min$ | async) || TODAY\"\n [displayMax]=\"(max$ | async) || TODAY\"\n [selectableMin]=\"(rightMin$ | async) || TODAY\"\n [selectableMax]=\"(rightMax$ | async) || TODAY\"\n [selectedValue]=\"(selectedValue$ | async) || TODAY\"\n (dateSelect)=\"userSelectedDate$.next($event)\"\n ></riv-calendar>\n </div>\n\n <footer class=\"buttons\">\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'ghost'\"\n (click)=\"userSelectedDate$.next(undefined)\"\n type=\"button\"\n >\n Clear\n </button>\n <button\n rivButton\n [size]=\"'small'\"\n [variant]=\"'primary'\"\n (click)=\"closeCalendar()\"\n type=\"button\"\n >\n Done\n </button>\n </footer>\n </div>\n </riv-callout>\n</ng-container>\n",
6338
+ styles: [".trigger{width:100%;border:var(--border-width) solid var(--border-light);border-radius:var(--border-radius-small);display:flex;gap:var(--size-small);background-color:var(--surface-light-0);padding-left:var(--size-small)}.trigger:focus-within{outline:none;border:var(--border-width) solid var(--purp-60)}.trigger.disabled{color:var(--type-light-disabled);background-color:var(--surface-light-1)}.value{font:var(--input-medium);color:var(--type-light-high-contrast);padding:var(--size-small) 0;flex-grow:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:pre;border:none;background:transparent;outline:none;width:100%}.value::placeholder{color:var(--type-light-low-contrast)}.value:disabled{color:var(--type-light-disabled)}.chevron{display:flex;justify-content:center;align-items:center;padding:var(--size-xsmall) calc(var(--base-grid-size) * 1.5);border:none;background:transparent;cursor:pointer;color:var(--type-light-high-contrast)}.chevron:disabled{color:var(--type-light-disabled);cursor:not-allowed}.trigger.warning{border-color:var(--surface-dark-caution)}.trigger.error{border-color:var(--surface-dark-danger);box-shadow:inset 0 0 0 var(--border-width-large) var(--surface-dark-danger)}.content{display:inline-grid;grid-template-rows:1fr auto}.content.include-preset{grid-template-columns:calc(var(--base-grid-size) * 50) 1fr 1fr}.presets{grid-area:1 / 1 / 3 / 2;background-color:var(--surface-light-1);padding:var(--size-xlarge) var(--size-large);border-right:var(--border-width) solid var(--border-light);display:flex;flex-direction:column;gap:var(--size-medium)}.preset{display:flex;transition:background-color var(--short-transition)}.preset:hover{background-color:var(--surface-light-2)}.preset button{color:transparent;transition:color var(--short-transition);padding:var(--size-medium) var(--size-large) var(--size-medium) var(--size-small);cursor:pointer}.preset:hover button{color:var(--type-light-low-contrast)}.preset button:hover{color:var(--type-light-high-contrast)}.preset.favorite button{color:var(--type-light-link)}.preset .description{flex-grow:1;padding:var(--size-medium) var(--size-small) var(--size-medium) var(--size-medium)}.preset .title{display:block;font-size:var(--type-2-font-size);line-height:var(--type-2-line-height-1)}.preset .subtitle{display:block;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-1);color:var(--type-light-low-contrast)}.shortcuts{display:flex;flex-direction:column;gap:var(--size-xsmall);overflow-y:auto}.shortcut{display:flex;align-items:center;padding:var(--size-small) var(--size-small) var(--size-small) var(--size-medium);gap:var(--size-small);border-radius:var(--border-radius-small);transition:background-color var(--short-transition);cursor:pointer}.shortcut:hover{background-color:var(--black-20)}.shortcut.active{background-color:var(--baloo-05)}.shortcut .title{flex-grow:1;text-align:left;font-size:var(--type-1-font-size);line-height:var(--type-1-line-height-2)}.shortcut button{color:transparent;transition:color var(--short-transition);cursor:pointer}.shortcut:hover button{color:var(--type-light-link)}.calendars{grid-column:2 / 4;display:grid;grid-template-columns:subgrid;grid-template-rows:subgrid;padding:var(--size-large)}.left{grid-area:1 / 1 / 2 / 2;padding-right:var(--size-large);border-right:var(--border-width) solid var(--border-light)}.right{padding-left:var(--size-large);grid-area:1 / 2 / 2 / 3}.buttons{grid-area:2 / 2 / 3 / 4;padding:var(--size-small);display:flex;justify-content:space-between}\n"]
6401
6339
  }]
6402
6340
  }],
6403
- ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }],
6341
+ ctorParameters: () => [{ type: i0.ElementRef }],
6404
6342
  propDecorators: {
6343
+ showPresets: [{ type: Input }],
6405
6344
  min: [{ type: Input }],
6406
6345
  max: [{ type: Input }],
6407
6346
  value: [{ type: Input }],
6408
6347
  placeholder: [{ type: Input }],
6409
- disabled: [{ type: Input }],
6410
- size: [{ type: Input }],
6411
- showClearButton: [{ type: Input }],
6412
- showTodayButton: [{ type: Input }],
6413
- rollingTodayLabel: [{ type: Input }],
6414
- headerTemplate: [{
6348
+ disabled: [{ type: Input }],
6349
+ triggerTemplate: [{
6415
6350
  type: ContentChild,
6416
- args: ["header"]
6351
+ args: ["trigger"]
6417
6352
  }],
6418
- open: [{ type: Input }],
6353
+ customTriggerButton: [{
6354
+ type: ViewChild,
6355
+ args: ["customTriggerButton", { read: ElementRef }]
6356
+ }],
6357
+ standardTriggerButton: [{
6358
+ type: ViewChild,
6359
+ args: ["standardTriggerButton", { read: ElementRef }]
6360
+ }],
6361
+ inputElement: [{
6362
+ type: ViewChild,
6363
+ args: ["input", { read: ElementRef }]
6364
+ }],
6365
+ alternativePresetList: [{ type: Input }],
6419
6366
  valueChange: [{ type: Output }],
6420
6367
  onDocumentMouseDown: [{
6421
6368
  type: HostListener,
@@ -6423,58 +6370,216 @@ i0.ɵɵngDeclareClassMetadata({
6423
6370
  }]
6424
6371
  }
6425
6372
  });
6426
- (function(DateComponent) {
6427
- DateComponent.Sizes = [
6428
- "xsmall",
6429
- "small",
6430
- "medium",
6431
- "large",
6432
- "xlarge"
6373
+ (function(DateRangeComponent) {
6374
+ const today = /* @__PURE__ */ new Date();
6375
+ DateRangeComponent.focusableSelector = "button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
6376
+ const rangeSeparator = /\s*[—–]\s*|\s+(?:-|to|through)\s+/i;
6377
+ function splitRange(text) {
6378
+ const parts = text.split(rangeSeparator);
6379
+ if (parts.length !== 1) return parts;
6380
+ const splits = [...text.matchAll(/-/g)].map(({ index }) => [text.slice(0, index), text.slice(index + 1)]).filter((halves) => halves.every((half) => DateComponent.parseDate(half)));
6381
+ return splits.length === 1 ? splits[0] : parts;
6382
+ }
6383
+ function parseDateRange(text, min, max) {
6384
+ const parts = splitRange(text.trim());
6385
+ if (parts.length > 2) return void 0;
6386
+ const dates = parts.flatMap((part) => {
6387
+ const date = DateComponent.parseDate(part);
6388
+ return date && DateComponent.isValidDate(date, min, max) ? [timeDay.floor(date)] : [];
6389
+ });
6390
+ if (dates.length !== parts.length) return void 0;
6391
+ const [start, end = start] = sortBy(dates, (date) => date.valueOf());
6392
+ return start ? [start, end] : void 0;
6393
+ }
6394
+ DateRangeComponent.parseDateRange = parseDateRange;
6395
+ let PresetType;
6396
+ (function(PresetType) {
6397
+ PresetType["TODAY"] = "today";
6398
+ PresetType["YESTERDAY"] = "yesterday";
6399
+ PresetType["TOMORROW"] = "tomorrow";
6400
+ PresetType["THIS_WEEK"] = "this_week";
6401
+ PresetType["THIS_WEEK_SO_FAR"] = "this_week_so_far";
6402
+ PresetType["LAST_WEEK"] = "last_week";
6403
+ PresetType["NEXT_WEEK"] = "next_week";
6404
+ PresetType["THIS_MONTH"] = "this_month";
6405
+ PresetType["THIS_MONTH_SO_FAR"] = "this_month_so_far";
6406
+ PresetType["LAST_MONTH"] = "last_month";
6407
+ PresetType["NEXT_MONTH"] = "next_month";
6408
+ PresetType["THIS_QUARTER"] = "this_quarter";
6409
+ PresetType["THIS_QUARTER_SO_FAR"] = "this_quarter_so_far";
6410
+ PresetType["LAST_QUARTER"] = "last_quarter";
6411
+ PresetType["NEXT_QUARTER"] = "next_quarter";
6412
+ PresetType["THIS_YEAR"] = "this_year";
6413
+ PresetType["THIS_YEAR_SO_FAR"] = "this_year_so_far";
6414
+ PresetType["LAST_YEAR"] = "last_year";
6415
+ PresetType["NEXT_YEAR"] = "next_year";
6416
+ PresetType["LAST_7_DAYS"] = "last_7_days";
6417
+ PresetType["LAST_14_DAYS"] = "last_14_days";
6418
+ PresetType["LAST_30_DAYS"] = "last_30_days";
6419
+ PresetType["LAST_60_DAYS"] = "last_60_days";
6420
+ PresetType["LAST_90_DAYS"] = "last_90_days";
6421
+ PresetType["LAST_180_DAYS"] = "last_180_days";
6422
+ PresetType["LAST_365_DAYS"] = "last_365_days";
6423
+ })(PresetType = DateRangeComponent.PresetType || (DateRangeComponent.PresetType = {}));
6424
+ DateRangeComponent.Presets = [
6425
+ {
6426
+ id: PresetType.TODAY,
6427
+ title: "Today",
6428
+ subtitle: "Today from midnight until the current time",
6429
+ dates: [timeDay(), timeDay()]
6430
+ },
6431
+ {
6432
+ id: PresetType.YESTERDAY,
6433
+ title: "Yesterday",
6434
+ subtitle: "The previous 24 hour day",
6435
+ dates: [timeDay.offset(timeDay(), -1), timeDay.offset(timeDay(), -1)]
6436
+ },
6437
+ {
6438
+ id: PresetType.TOMORROW,
6439
+ title: "Tomorrow",
6440
+ subtitle: "The next 24 hour day",
6441
+ dates: [timeDay.offset(timeDay(), 1), timeDay.offset(timeDay(), 1)]
6442
+ },
6443
+ {
6444
+ id: PresetType.THIS_WEEK,
6445
+ title: "This week",
6446
+ subtitle: "The current calendar week",
6447
+ dates: [timeSunday.floor(today), timeDay.offset(timeSunday.ceil(today), -1)]
6448
+ },
6449
+ {
6450
+ id: PresetType.THIS_WEEK_SO_FAR,
6451
+ title: "This week so far",
6452
+ subtitle: "The current calendar week up to now",
6453
+ dates: [timeSunday.floor(today), timeDay.floor(today)]
6454
+ },
6455
+ {
6456
+ id: PresetType.LAST_WEEK,
6457
+ title: "Last week",
6458
+ subtitle: "The previous calendar week",
6459
+ dates: [timeSunday.offset(timeWeek.floor(today), -1), timeDay.offset(timeSunday.offset(timeWeek.ceil(today), -1), -1)]
6460
+ },
6461
+ {
6462
+ id: PresetType.NEXT_WEEK,
6463
+ title: "Next week",
6464
+ subtitle: "The next calendar week",
6465
+ dates: [timeSunday.offset(timeWeek.floor(today), 1), timeDay.offset(timeSunday.offset(timeWeek.ceil(today), 1), -1)]
6466
+ },
6467
+ {
6468
+ id: PresetType.THIS_MONTH,
6469
+ title: "This month",
6470
+ subtitle: "The current calendar month",
6471
+ dates: [timeMonth.floor(today), timeDay.offset(timeMonth.ceil(today), -1)]
6472
+ },
6473
+ {
6474
+ id: PresetType.THIS_MONTH_SO_FAR,
6475
+ title: "This month so far",
6476
+ subtitle: "The current calendar month up to now",
6477
+ dates: [timeMonth.floor(today), timeDay.floor(today)]
6478
+ },
6479
+ {
6480
+ id: PresetType.LAST_MONTH,
6481
+ title: "Last month",
6482
+ subtitle: "The previous calendar month",
6483
+ dates: [timeMonth.offset(timeMonth.floor(today), -1), timeDay.offset(timeMonth.offset(timeMonth.ceil(today), -1), -1)]
6484
+ },
6485
+ {
6486
+ id: PresetType.NEXT_MONTH,
6487
+ title: "Next month",
6488
+ subtitle: "The next calendar month",
6489
+ dates: [timeMonth.offset(timeMonth.floor(today), 1), timeDay.offset(timeMonth.offset(timeMonth.ceil(today), 1), -1)]
6490
+ },
6491
+ {
6492
+ id: PresetType.THIS_QUARTER,
6493
+ title: "This quarter",
6494
+ subtitle: "The current quarter",
6495
+ dates: [timeQuarter.floor(today), timeDay.offset(timeQuarter.ceil(today), -1)]
6496
+ },
6497
+ {
6498
+ id: PresetType.THIS_QUARTER_SO_FAR,
6499
+ title: "This quarter so far",
6500
+ subtitle: "The current quarter up to now",
6501
+ dates: [timeQuarter.floor(today), timeDay.floor(today)]
6502
+ },
6503
+ {
6504
+ id: PresetType.LAST_QUARTER,
6505
+ title: "Last quarter",
6506
+ subtitle: "The previous full quarter",
6507
+ dates: [timeQuarter.offset(timeQuarter.floor(today), -1), timeDay.offset(timeQuarter.offset(timeQuarter.ceil(today), -1), -1)]
6508
+ },
6509
+ {
6510
+ id: PresetType.NEXT_QUARTER,
6511
+ title: "Next quarter",
6512
+ subtitle: "The next full quarter",
6513
+ dates: [timeQuarter.offset(timeQuarter.floor(today), 1), timeDay.offset(timeQuarter.offset(timeQuarter.ceil(today), 1), -1)]
6514
+ },
6515
+ {
6516
+ id: PresetType.THIS_YEAR,
6517
+ title: "This year",
6518
+ subtitle: "The current calendar year",
6519
+ dates: [timeYear.floor(today), timeDay.offset(timeYear.ceil(today), -1)]
6520
+ },
6521
+ {
6522
+ id: PresetType.THIS_YEAR_SO_FAR,
6523
+ title: "This year so far",
6524
+ subtitle: "The current calendar year up to now",
6525
+ dates: [timeYear.floor(today), timeDay.floor(today)]
6526
+ },
6527
+ {
6528
+ id: PresetType.LAST_YEAR,
6529
+ title: "Last year",
6530
+ subtitle: "The previous calendar year",
6531
+ dates: [timeYear.offset(timeYear.floor(today), -1), timeDay.offset(timeYear.offset(timeYear.ceil(today), -1), -1)]
6532
+ },
6533
+ {
6534
+ id: PresetType.NEXT_YEAR,
6535
+ title: "Next year",
6536
+ subtitle: "The next calendar year",
6537
+ dates: [timeYear.offset(timeYear.floor(today), 1), timeDay.offset(timeYear.offset(timeYear.ceil(today), 1), -1)]
6538
+ },
6539
+ {
6540
+ id: PresetType.LAST_7_DAYS,
6541
+ title: "Last 7 days",
6542
+ subtitle: "The previous 7 days before today",
6543
+ dates: [timeDay.floor(timeDay.offset(today, -8)), timeDay.floor(timeDay.offset(today, -1))]
6544
+ },
6545
+ {
6546
+ id: PresetType.LAST_14_DAYS,
6547
+ title: "Last 14 days",
6548
+ subtitle: "The previous 14 days before today",
6549
+ dates: [timeDay.floor(timeDay.offset(today, -15)), timeDay.floor(timeDay.offset(today, -1))]
6550
+ },
6551
+ {
6552
+ id: PresetType.LAST_30_DAYS,
6553
+ title: "Last 30 days",
6554
+ subtitle: "The previous 30 days before today",
6555
+ dates: [timeDay.floor(timeDay.offset(today, -31)), timeDay.floor(timeDay.offset(today, -1))]
6556
+ },
6557
+ {
6558
+ id: PresetType.LAST_60_DAYS,
6559
+ title: "Last 60 days",
6560
+ subtitle: "The previous 60 days before today",
6561
+ dates: [timeDay.floor(timeDay.offset(today, -61)), timeDay.floor(timeDay.offset(today, -1))]
6562
+ },
6563
+ {
6564
+ id: PresetType.LAST_90_DAYS,
6565
+ title: "Last 90 days",
6566
+ subtitle: "The previous 90 days before today",
6567
+ dates: [timeDay.floor(timeDay.offset(today, -91)), timeDay.floor(timeDay.offset(today, -1))]
6568
+ },
6569
+ {
6570
+ id: PresetType.LAST_180_DAYS,
6571
+ title: "Last 180 days",
6572
+ subtitle: "The previous 180 days before today",
6573
+ dates: [timeDay.floor(timeDay.offset(today, -181)), timeDay.floor(timeDay.offset(today, -1))]
6574
+ },
6575
+ {
6576
+ id: PresetType.LAST_365_DAYS,
6577
+ title: "Last 365 days",
6578
+ subtitle: "The previous 365 days before today",
6579
+ dates: [timeDay.floor(timeDay.offset(today, -366)), timeDay.floor(timeDay.offset(today, -1))]
6580
+ }
6433
6581
  ];
6434
- function parseDate(input) {
6435
- const trimmed = input.trim();
6436
- if (!trimmed) return void 0;
6437
- const ymd = /^\d+$/.test(trimmed) ? parseDigits(trimmed) : parseSeparated(trimmed);
6438
- if (!ymd) return void 0;
6439
- const [year, month, day] = ymd;
6440
- const date = new Date(year, month - 1, day);
6441
- return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day ? date : void 0;
6442
- }
6443
- DateComponent.parseDate = parseDate;
6444
- function expandTwoDigitYear(year) {
6445
- return year < 100 ? year + (year < 50 ? 2e3 : 1900) : year;
6446
- }
6447
- function parseDigits(digits) {
6448
- if (digits.length !== 8 && digits.length !== 6) return void 0;
6449
- const year = parseInt(digits.slice(4), 10);
6450
- return [
6451
- digits.length === 6 ? expandTwoDigitYear(year) : year,
6452
- parseInt(digits.slice(0, 2), 10),
6453
- parseInt(digits.slice(2, 4), 10)
6454
- ];
6455
- }
6456
- function parseSeparated(input) {
6457
- const parts = input.split(/[/.-]/);
6458
- if (parts.length !== 3) return void 0;
6459
- const nums = parts.map((p) => parseInt(p, 10));
6460
- if (nums.some(isNaN)) return void 0;
6461
- const [year, month, day] = parts[0].length === 4 ? nums : [
6462
- nums[2],
6463
- nums[0],
6464
- nums[1]
6465
- ];
6466
- return [
6467
- parts[0].length === 4 ? year : expandTwoDigitYear(year),
6468
- month,
6469
- day
6470
- ];
6471
- }
6472
- function isValidDate(date, min, max) {
6473
- const time = date.getTime();
6474
- return time >= min.getTime() && time <= max.getTime();
6475
- }
6476
- DateComponent.isValidDate = isValidDate;
6477
- })(DateComponent || (DateComponent = {}));
6582
+ })(DateRangeComponent || (DateRangeComponent = {}));
6478
6583
  var FilterChipComponent = class FilterChipComponent {
6479
6584
  constructor() {
6480
6585
  this.selected$ = new BehaviorSubject(false);