@rivet-health/design-system 41.1.4 → 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";
@@ -5494,238 +5494,173 @@ i0.ɵɵngDeclareClassMetadata({
5494
5494
  CalendarComponent.defaultMin = timeYear.floor(timeYear.offset(/* @__PURE__ */ new Date(), -7));
5495
5495
  CalendarComponent.defaultMax = timeDay.offset(timeYear.floor(timeYear.offset(/* @__PURE__ */ new Date(), 5)), -1);
5496
5496
  })(CalendarComponent || (CalendarComponent = {}));
5497
- const timeQuarter = timeMonth.every(3);
5498
- var DateRangeComponent = class DateRangeComponent extends InputLabelComponent {
5499
- constructor() {
5500
- super(...arguments);
5501
- this.TODAY = /* @__PURE__ */ new Date();
5502
- this.STORAGE_KEY = "date-range.default";
5503
- this.showPresets$ = new BehaviorSubject(true);
5504
- this.min$ = new BehaviorSubject(CalendarComponent.defaultMin);
5505
- this.max$ = new BehaviorSubject(CalendarComponent.defaultMax);
5506
- this.value$ = new BehaviorSubject(void 0);
5507
- this.distinctValue$ = this.value$.pipe(distinctUntilChanged((previous, current) => previous?.[0].valueOf() === current?.[0].valueOf() && previous?.[1].valueOf() === current?.[1].valueOf()), shareReplay({
5508
- refCount: true,
5509
- bufferSize: 1
5510
- }));
5511
- this.placeholder$ = new BehaviorSubject("Select date range");
5512
- this.disabled$ = new BehaviorSubject(false);
5513
- 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());
5514
5526
  this.open$ = new BehaviorSubject(false);
5515
- this.userSelectedPreset$ = new Subject();
5516
- this.userSelectedDate$ = new Subject();
5517
- this.selectedValue$ = merge(this.distinctValue$, this.userSelectedDate$.pipe(scan((previous, date) => {
5518
- if (previous instanceof Date && date instanceof Date) {
5519
- if (date.valueOf() >= previous.valueOf()) return [previous, date];
5520
- }
5521
- return date;
5522
- })), this.userSelectedPreset$.pipe(filter((preset) => preset !== null), map((preset) => preset.dates))).pipe(shareReplay({
5523
- refCount: true,
5524
- bufferSize: 1
5525
- }));
5526
- this.filteredPresetOptions$ = combineLatest([
5527
- this.min$,
5528
- this.max$,
5529
- this.alternativePresetList$
5530
- ]).pipe(map(([min, max, alternativePresetList]) => {
5531
- const optionsFilteredOnMinMax = DateRangeComponent.Presets.filter((p) => p.dates[0].valueOf() >= min.valueOf() && p.dates[1].valueOf() <= max.valueOf());
5532
- if (alternativePresetList.length == 0) return optionsFilteredOnMinMax;
5533
- else return optionsFilteredOnMinMax.filter((p) => alternativePresetList.includes(p.id));
5534
- }), shareReplay({
5535
- refCount: true,
5536
- bufferSize: 1
5537
- }));
5538
- this.selectedPreset$ = combineLatest([this.selectedValue$, this.userSelectedPreset$.pipe(startWith(null))]).pipe(map(([selectedValue, userSelectedPreset]) => {
5539
- if (selectedValue instanceof Array) {
5540
- const options = DateRangeComponent.Presets.filter((preset) => preset.dates[0].valueOf() === selectedValue[0].valueOf() && preset.dates[1].valueOf() === selectedValue[1].valueOf());
5541
- if (options.length) {
5542
- const mostRecent = options.find((option) => option.id === userSelectedPreset?.id);
5543
- if (mostRecent) return mostRecent;
5544
- return options[0];
5545
- }
5546
- }
5547
- return null;
5548
- }));
5549
- this.favoritePresetIds$ = new LocalStorage(this.STORAGE_KEY, []);
5550
- this.favoritePresets$ = combineLatest([
5551
- this.favoritePresetIds$,
5552
- this.filteredPresetOptions$,
5553
- this.alternativePresetList$
5554
- ]).pipe(map(([ids, presets, alternativePresetList]) => {
5555
- const favoritePresets = ids.map((id) => presets.find((preset) => preset.id === id)).filter((p) => p !== void 0);
5556
- if (alternativePresetList.length == 0) return favoritePresets;
5557
- else return favoritePresets.filter((p) => alternativePresetList.includes(p.id));
5558
- }), shareReplay({
5559
- refCount: true,
5560
- bufferSize: 1
5561
- }));
5562
- this.userLeftActiveYearMonth$ = new Subject();
5563
- this.userRightActiveYearMonth$ = new Subject();
5564
- this.leftMin$ = this.min$.pipe(shareReplay({
5565
- refCount: true,
5566
- bufferSize: 1
5567
- }));
5568
- this.leftMax$ = this.max$.pipe(map((max) => timeDay.offset(timeMonth.floor(max), -1)), shareReplay({
5569
- refCount: true,
5570
- bufferSize: 1
5571
- }));
5572
- this.rightMax$ = this.max$.pipe(shareReplay({
5573
- refCount: true,
5574
- bufferSize: 1
5575
- }));
5576
- 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]) => {
5577
- if (left.valueOf() >= leftMax.valueOf()) return timeMonth.floor(leftMax);
5578
- else return left;
5579
- }), shareReplay({
5580
- refCount: true,
5581
- bufferSize: 1
5582
- }));
5583
- this.rightActiveYearMonth$ = combineLatest([
5584
- this.leftActiveYearMonth$,
5585
- 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])))),
5586
- this.rightMax$
5587
- ]).pipe(map(([left, userRight, rightMax$]) => {
5588
- if (left.valueOf() >= userRight.valueOf()) return timeMonth.floor(timeMonth.offset(left, 1));
5589
- else if (userRight.valueOf() >= rightMax$.valueOf()) return timeMonth.floor(rightMax$);
5590
- else return userRight;
5591
- }), shareReplay({
5592
- refCount: true,
5593
- bufferSize: 1
5594
- }));
5595
- this.rightMin$ = this.leftActiveYearMonth$.pipe(map((left) => timeMonth.floor(timeMonth.offset(left, 1))), shareReplay({
5596
- refCount: true,
5597
- bufferSize: 1
5598
- }));
5599
- this.leftOmitRange$ = this.rightActiveYearMonth$.pipe(map((rightActiveYearMonth) => {
5600
- return [timeMonth.floor(rightActiveYearMonth), timeDay.offset(timeMonth.floor(timeMonth.offset(rightActiveYearMonth, 1)), -1)];
5601
- }), shareReplay({
5602
- refCount: true,
5603
- bufferSize: 1
5604
- }));
5605
- this.userInteracted$ = merge(this.userSelectedDate$, this.userSelectedPreset$);
5606
- 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({
5607
- refCount: true,
5608
- bufferSize: 1
5609
- }));
5610
- this.displayValue$ = this.valueChange.pipe(map((v) => {
5611
- if (v) return v.map((date) => new DatePipe().transform(date)).join(" — ");
5612
- }), shareReplay({
5613
- refCount: true,
5614
- bufferSize: 1
5615
- }));
5527
+ this.calendarId = uniqueId("riv-date-calendar-");
5528
+ this.valueChange = new EventEmitter();
5529
+ this.inputText = "";
5530
+ this.hasFocus = false;
5531
+ this.datePipe = new DatePipe();
5616
5532
  }
5617
- set showPresets(v) {
5618
- this.showPresets$.next(v);
5533
+ ngOnChanges(changes) {
5534
+ if (changes["rollingTodayLabel"] && !this.hasFocus) this.syncInputText();
5619
5535
  }
5620
- get showPresets() {
5621
- 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();
5622
5541
  }
5623
- set min(v) {
5624
- 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);
5625
5547
  }
5626
- get min() {
5627
- return this.min$.getValue();
5548
+ clearValue() {
5549
+ this.commit(void 0);
5550
+ this.open$.next(false);
5628
5551
  }
5629
- set max(v) {
5630
- 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);
5631
5556
  }
5632
- get max() {
5633
- return this.max$.getValue();
5557
+ get isTodaySelectable() {
5558
+ return DateComponent.isValidDate(timeDay.floor(/* @__PURE__ */ new Date()), this.min, this.max);
5634
5559
  }
5635
- set value(v) {
5636
- this.value$.next(v);
5560
+ get selectedCalendarValue() {
5561
+ return this.previewValue ?? this._value ?? (this.isRolling ? timeDay.floor(/* @__PURE__ */ new Date()) : void 0);
5637
5562
  }
5638
- get value() {
5639
- 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();
5640
5569
  }
5641
- set placeholder(v) {
5642
- 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();
5643
5580
  }
5644
- get placeholder() {
5645
- return this.placeholder$.getValue();
5581
+ onDateSelect(date) {
5582
+ this.commit(timeDay.floor(date));
5583
+ this.open$.next(false);
5646
5584
  }
5647
- set disabled(v) {
5648
- this.disabled$.next(v);
5585
+ onInputFocus() {
5586
+ this.hasFocus = true;
5587
+ this.open$.next(true);
5649
5588
  }
5650
- get disabled() {
5651
- return this.disabled$.getValue();
5589
+ toggleCalendar() {
5590
+ this.open$.next(!this.open$.getValue());
5652
5591
  }
5653
- getTrigger() {
5654
- return this.customTriggerButton?.nativeElement ?? this.standardTriggerButton?.nativeElement ?? null;
5592
+ get isRolling() {
5593
+ return this.rollingTodayLabel != null;
5655
5594
  }
5656
- set alternativePresetList(v) {
5657
- this.alternativePresetList$.next(v);
5595
+ isRollingText(text) {
5596
+ return this.rollingTodayLabel != null && text.trim().toLowerCase() === this.rollingTodayLabel.toLowerCase();
5658
5597
  }
5659
- get alternativePresetList() {
5660
- return this.alternativePresetList$.getValue();
5598
+ syncInputText() {
5599
+ this.inputText = this._value ? this.formatValue(this._value) : this.rollingTodayLabel ?? "";
5661
5600
  }
5662
- setFavorite(preset, favorite) {
5663
- const ids = new Set(this.favoritePresetIds$.getValue());
5664
- if (favorite) ids.add(preset.id);
5665
- else ids.delete(preset.id);
5666
- this.favoritePresetIds$.next([...ids]);
5601
+ formatValue(date) {
5602
+ return this.datePipe.transform(date);
5667
5603
  }
5668
- static {
5669
- this.ɵfac = i0.ɵɵngDeclareFactory({
5670
- minVersion: "12.0.0",
5671
- version: "22.2.4",
5672
- ngImport: i0,
5673
- type: DateRangeComponent,
5674
- deps: null,
5675
- target: i0.ɵɵFactoryTarget.Component
5676
- });
5604
+ parseInput(text) {
5605
+ const parsed = DateComponent.parseDate(text);
5606
+ return parsed && DateComponent.isValidDate(parsed, this.min, this.max) ? timeDay.floor(parsed) : void 0;
5677
5607
  }
5678
- static {
5679
- this.ɵcmp = i0.ɵɵngDeclareComponent({
5680
- minVersion: "14.0.0",
5681
- version: "22.2.4",
5682
- 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,
5683
5636
  isStandalone: false,
5684
- selector: "riv-date-range",
5637
+ selector: "riv-date",
5685
5638
  inputs: {
5686
- showPresets: "showPresets",
5687
5639
  min: "min",
5688
5640
  max: "max",
5689
5641
  value: "value",
5690
5642
  placeholder: "placeholder",
5691
5643
  disabled: "disabled",
5692
- alternativePresetList: "alternativePresetList"
5644
+ size: "size",
5645
+ showClearButton: "showClearButton",
5646
+ showTodayButton: "showTodayButton",
5647
+ rollingTodayLabel: "rollingTodayLabel",
5648
+ open: "open"
5693
5649
  },
5694
5650
  outputs: { valueChange: "valueChange" },
5651
+ host: { listeners: { "document:mousedown": "onDocumentMouseDown($event.target)" } },
5695
5652
  queries: [{
5696
- propertyName: "triggerTemplate",
5653
+ propertyName: "headerTemplate",
5697
5654
  first: true,
5698
- predicate: ["trigger"],
5655
+ predicate: ["header"],
5699
5656
  descendants: true
5700
5657
  }],
5701
- viewQueries: [{
5702
- propertyName: "customTriggerButton",
5703
- first: true,
5704
- predicate: ["customTriggerButton"],
5705
- descendants: true,
5706
- read: ElementRef
5707
- }, {
5708
- propertyName: "standardTriggerButton",
5709
- first: true,
5710
- predicate: ["standardTriggerButton"],
5711
- descendants: true,
5712
- read: ElementRef
5713
- }],
5714
5658
  usesInheritance: true,
5659
+ usesOnChanges: true,
5715
5660
  ngImport: i0,
5716
- 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",
5717
- 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"],
5718
5663
  dependencies: [
5719
- {
5720
- kind: "directive",
5721
- type: i1.NgForOf,
5722
- selector: "[ngFor][ngForOf]",
5723
- inputs: [
5724
- "ngForOf",
5725
- "ngForTrackBy",
5726
- "ngForTemplate"
5727
- ]
5728
- },
5729
5664
  {
5730
5665
  kind: "directive",
5731
5666
  type: i1.NgIf,
@@ -5792,12 +5727,6 @@ var DateRangeComponent = class DateRangeComponent extends InputLabelComponent {
5792
5727
  ],
5793
5728
  outputs: ["close"]
5794
5729
  },
5795
- {
5796
- kind: "component",
5797
- type: HighlightComponent,
5798
- selector: "riv-highlight",
5799
- inputs: ["text", "indices"]
5800
- },
5801
5730
  {
5802
5731
  kind: "component",
5803
5732
  type: IconComponent,
@@ -5829,55 +5758,10 @@ var DateRangeComponent = class DateRangeComponent extends InputLabelComponent {
5829
5758
  type: OverlayDirective,
5830
5759
  selector: "[riv-overlay]"
5831
5760
  },
5832
- {
5833
- kind: "component",
5834
- type: SimpleSelectComponent,
5835
- selector: "riv-simple-select",
5836
- inputs: [
5837
- "optionGroups",
5838
- "selectedOption",
5839
- "size",
5840
- "disabled",
5841
- "locked",
5842
- "filterabilityOptions",
5843
- "orderBy",
5844
- "placeholder",
5845
- "maxHeight",
5846
- "maxWidth",
5847
- "minHeight",
5848
- "minWidth",
5849
- "dividers",
5850
- "sortSelectedToTop",
5851
- "grow",
5852
- "preferredCalloutPosition",
5853
- "allowedCalloutPositions"
5854
- ],
5855
- outputs: ["selectedOptionChange"]
5856
- },
5857
- {
5858
- kind: "directive",
5859
- type: TooltipDirective,
5860
- selector: "[rivTooltip]",
5861
- inputs: [
5862
- "rivTooltip",
5863
- "rivTooltipTheme",
5864
- "rivTooltipMaxWidth",
5865
- "rivTooltipPreferredPosition",
5866
- "rivTooltipAnchor",
5867
- "rivTooltipCloseDelay",
5868
- "rivTooltipOpenDelay",
5869
- "rivTooltipGracePeriod"
5870
- ]
5871
- },
5872
5761
  {
5873
5762
  kind: "pipe",
5874
5763
  type: i1.AsyncPipe,
5875
5764
  name: "async"
5876
- },
5877
- {
5878
- kind: "pipe",
5879
- type: OptionGroupPipe,
5880
- name: "rivOptionGroup"
5881
5765
  }
5882
5766
  ],
5883
5767
  changeDetection: i0.ChangeDetectionStrategy.OnPush
@@ -5888,361 +5772,334 @@ i0.ɵɵngDeclareClassMetadata({
5888
5772
  minVersion: "12.0.0",
5889
5773
  version: "22.2.4",
5890
5774
  ngImport: i0,
5891
- type: DateRangeComponent,
5775
+ type: DateComponent,
5892
5776
  decorators: [{
5893
5777
  type: Component,
5894
5778
  args: [{
5895
- selector: "riv-date-range",
5779
+ selector: "riv-date",
5896
5780
  changeDetection: ChangeDetectionStrategy.OnPush,
5897
5781
  standalone: false,
5898
- 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",
5899
- 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"]
5900
5784
  }]
5901
5785
  }],
5786
+ ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }],
5902
5787
  propDecorators: {
5903
- showPresets: [{ type: Input }],
5904
5788
  min: [{ type: Input }],
5905
5789
  max: [{ type: Input }],
5906
5790
  value: [{ type: Input }],
5907
5791
  placeholder: [{ type: Input }],
5908
5792
  disabled: [{ type: Input }],
5909
- triggerTemplate: [{
5793
+ size: [{ type: Input }],
5794
+ showClearButton: [{ type: Input }],
5795
+ showTodayButton: [{ type: Input }],
5796
+ rollingTodayLabel: [{ type: Input }],
5797
+ headerTemplate: [{
5910
5798
  type: ContentChild,
5911
- args: ["trigger"]
5912
- }],
5913
- customTriggerButton: [{
5914
- type: ViewChild,
5915
- args: ["customTriggerButton", { read: ElementRef }]
5916
- }],
5917
- standardTriggerButton: [{
5918
- type: ViewChild,
5919
- args: ["standardTriggerButton", { read: ElementRef }]
5799
+ args: ["header"]
5920
5800
  }],
5921
- alternativePresetList: [{ type: Input }],
5922
- valueChange: [{ type: Output }]
5801
+ open: [{ type: Input }],
5802
+ valueChange: [{ type: Output }],
5803
+ onDocumentMouseDown: [{
5804
+ type: HostListener,
5805
+ args: ["document:mousedown", ["$event.target"]]
5806
+ }]
5923
5807
  }
5924
5808
  });
5925
- (function(DateRangeComponent) {
5926
- const today = /* @__PURE__ */ new Date();
5927
- let PresetType;
5928
- (function(PresetType) {
5929
- PresetType["TODAY"] = "today";
5930
- PresetType["YESTERDAY"] = "yesterday";
5931
- PresetType["TOMORROW"] = "tomorrow";
5932
- PresetType["THIS_WEEK"] = "this_week";
5933
- PresetType["THIS_WEEK_SO_FAR"] = "this_week_so_far";
5934
- PresetType["LAST_WEEK"] = "last_week";
5935
- PresetType["NEXT_WEEK"] = "next_week";
5936
- PresetType["THIS_MONTH"] = "this_month";
5937
- PresetType["THIS_MONTH_SO_FAR"] = "this_month_so_far";
5938
- PresetType["LAST_MONTH"] = "last_month";
5939
- PresetType["NEXT_MONTH"] = "next_month";
5940
- PresetType["THIS_QUARTER"] = "this_quarter";
5941
- PresetType["THIS_QUARTER_SO_FAR"] = "this_quarter_so_far";
5942
- PresetType["LAST_QUARTER"] = "last_quarter";
5943
- PresetType["NEXT_QUARTER"] = "next_quarter";
5944
- PresetType["THIS_YEAR"] = "this_year";
5945
- PresetType["THIS_YEAR_SO_FAR"] = "this_year_so_far";
5946
- PresetType["LAST_YEAR"] = "last_year";
5947
- PresetType["NEXT_YEAR"] = "next_year";
5948
- PresetType["LAST_7_DAYS"] = "last_7_days";
5949
- PresetType["LAST_14_DAYS"] = "last_14_days";
5950
- PresetType["LAST_30_DAYS"] = "last_30_days";
5951
- PresetType["LAST_60_DAYS"] = "last_60_days";
5952
- PresetType["LAST_90_DAYS"] = "last_90_days";
5953
- PresetType["LAST_180_DAYS"] = "last_180_days";
5954
- PresetType["LAST_365_DAYS"] = "last_365_days";
5955
- })(PresetType = DateRangeComponent.PresetType || (DateRangeComponent.PresetType = {}));
5956
- DateRangeComponent.Presets = [
5957
- {
5958
- id: PresetType.TODAY,
5959
- title: "Today",
5960
- subtitle: "Today from midnight until the current time",
5961
- dates: [timeDay(), timeDay()]
5962
- },
5963
- {
5964
- id: PresetType.YESTERDAY,
5965
- title: "Yesterday",
5966
- subtitle: "The previous 24 hour day",
5967
- dates: [timeDay.offset(timeDay(), -1), timeDay.offset(timeDay(), -1)]
5968
- },
5969
- {
5970
- id: PresetType.TOMORROW,
5971
- title: "Tomorrow",
5972
- subtitle: "The next 24 hour day",
5973
- dates: [timeDay.offset(timeDay(), 1), timeDay.offset(timeDay(), 1)]
5974
- },
5975
- {
5976
- id: PresetType.THIS_WEEK,
5977
- title: "This week",
5978
- subtitle: "The current calendar week",
5979
- dates: [timeSunday.floor(today), timeDay.offset(timeSunday.ceil(today), -1)]
5980
- },
5981
- {
5982
- id: PresetType.THIS_WEEK_SO_FAR,
5983
- title: "This week so far",
5984
- subtitle: "The current calendar week up to now",
5985
- dates: [timeSunday.floor(today), timeDay.floor(today)]
5986
- },
5987
- {
5988
- id: PresetType.LAST_WEEK,
5989
- title: "Last week",
5990
- subtitle: "The previous calendar week",
5991
- dates: [timeSunday.offset(timeWeek.floor(today), -1), timeDay.offset(timeSunday.offset(timeWeek.ceil(today), -1), -1)]
5992
- },
5993
- {
5994
- id: PresetType.NEXT_WEEK,
5995
- title: "Next week",
5996
- subtitle: "The next calendar week",
5997
- dates: [timeSunday.offset(timeWeek.floor(today), 1), timeDay.offset(timeSunday.offset(timeWeek.ceil(today), 1), -1)]
5998
- },
5999
- {
6000
- id: PresetType.THIS_MONTH,
6001
- title: "This month",
6002
- subtitle: "The current calendar month",
6003
- dates: [timeMonth.floor(today), timeDay.offset(timeMonth.ceil(today), -1)]
6004
- },
6005
- {
6006
- id: PresetType.THIS_MONTH_SO_FAR,
6007
- title: "This month so far",
6008
- subtitle: "The current calendar month up to now",
6009
- dates: [timeMonth.floor(today), timeDay.floor(today)]
6010
- },
6011
- {
6012
- id: PresetType.LAST_MONTH,
6013
- title: "Last month",
6014
- subtitle: "The previous calendar month",
6015
- dates: [timeMonth.offset(timeMonth.floor(today), -1), timeDay.offset(timeMonth.offset(timeMonth.ceil(today), -1), -1)]
6016
- },
6017
- {
6018
- id: PresetType.NEXT_MONTH,
6019
- title: "Next month",
6020
- subtitle: "The next calendar month",
6021
- dates: [timeMonth.offset(timeMonth.floor(today), 1), timeDay.offset(timeMonth.offset(timeMonth.ceil(today), 1), -1)]
6022
- },
6023
- {
6024
- id: PresetType.THIS_QUARTER,
6025
- title: "This quarter",
6026
- subtitle: "The current quarter",
6027
- dates: [timeQuarter.floor(today), timeDay.offset(timeQuarter.ceil(today), -1)]
6028
- },
6029
- {
6030
- id: PresetType.THIS_QUARTER_SO_FAR,
6031
- title: "This quarter so far",
6032
- subtitle: "The current quarter up to now",
6033
- dates: [timeQuarter.floor(today), timeDay.floor(today)]
6034
- },
6035
- {
6036
- id: PresetType.LAST_QUARTER,
6037
- title: "Last quarter",
6038
- subtitle: "The previous full quarter",
6039
- dates: [timeQuarter.offset(timeQuarter.floor(today), -1), timeDay.offset(timeQuarter.offset(timeQuarter.ceil(today), -1), -1)]
6040
- },
6041
- {
6042
- id: PresetType.NEXT_QUARTER,
6043
- title: "Next quarter",
6044
- subtitle: "The next full quarter",
6045
- dates: [timeQuarter.offset(timeQuarter.floor(today), 1), timeDay.offset(timeQuarter.offset(timeQuarter.ceil(today), 1), -1)]
6046
- },
6047
- {
6048
- id: PresetType.THIS_YEAR,
6049
- title: "This year",
6050
- subtitle: "The current calendar year",
6051
- dates: [timeYear.floor(today), timeDay.offset(timeYear.ceil(today), -1)]
6052
- },
6053
- {
6054
- id: PresetType.THIS_YEAR_SO_FAR,
6055
- title: "This year so far",
6056
- subtitle: "The current calendar year up to now",
6057
- dates: [timeYear.floor(today), timeDay.floor(today)]
6058
- },
6059
- {
6060
- id: PresetType.LAST_YEAR,
6061
- title: "Last year",
6062
- subtitle: "The previous calendar year",
6063
- dates: [timeYear.offset(timeYear.floor(today), -1), timeDay.offset(timeYear.offset(timeYear.ceil(today), -1), -1)]
6064
- },
6065
- {
6066
- id: PresetType.NEXT_YEAR,
6067
- title: "Next year",
6068
- subtitle: "The next calendar year",
6069
- dates: [timeYear.offset(timeYear.floor(today), 1), timeDay.offset(timeYear.offset(timeYear.ceil(today), 1), -1)]
6070
- },
6071
- {
6072
- id: PresetType.LAST_7_DAYS,
6073
- title: "Last 7 days",
6074
- subtitle: "The previous 7 days before today",
6075
- dates: [timeDay.floor(timeDay.offset(today, -8)), timeDay.floor(timeDay.offset(today, -1))]
6076
- },
6077
- {
6078
- id: PresetType.LAST_14_DAYS,
6079
- title: "Last 14 days",
6080
- subtitle: "The previous 14 days before today",
6081
- dates: [timeDay.floor(timeDay.offset(today, -15)), timeDay.floor(timeDay.offset(today, -1))]
6082
- },
6083
- {
6084
- id: PresetType.LAST_30_DAYS,
6085
- title: "Last 30 days",
6086
- subtitle: "The previous 30 days before today",
6087
- dates: [timeDay.floor(timeDay.offset(today, -31)), timeDay.floor(timeDay.offset(today, -1))]
6088
- },
6089
- {
6090
- id: PresetType.LAST_60_DAYS,
6091
- title: "Last 60 days",
6092
- subtitle: "The previous 60 days before today",
6093
- dates: [timeDay.floor(timeDay.offset(today, -61)), timeDay.floor(timeDay.offset(today, -1))]
6094
- },
6095
- {
6096
- id: PresetType.LAST_90_DAYS,
6097
- title: "Last 90 days",
6098
- subtitle: "The previous 90 days before today",
6099
- dates: [timeDay.floor(timeDay.offset(today, -91)), timeDay.floor(timeDay.offset(today, -1))]
6100
- },
6101
- {
6102
- id: PresetType.LAST_180_DAYS,
6103
- title: "Last 180 days",
6104
- subtitle: "The previous 180 days before today",
6105
- dates: [timeDay.floor(timeDay.offset(today, -181)), timeDay.floor(timeDay.offset(today, -1))]
6106
- },
6107
- {
6108
- id: PresetType.LAST_365_DAYS,
6109
- title: "Last 365 days",
6110
- subtitle: "The previous 365 days before today",
6111
- dates: [timeDay.floor(timeDay.offset(today, -366)), timeDay.floor(timeDay.offset(today, -1))]
6112
- }
5809
+ (function(DateComponent) {
5810
+ DateComponent.Sizes = [
5811
+ "xsmall",
5812
+ "small",
5813
+ "medium",
5814
+ "large",
5815
+ "xlarge"
6113
5816
  ];
6114
- })(DateRangeComponent || (DateRangeComponent = {}));
6115
- var DateComponent = class DateComponent extends InputLabelComponent {
6116
- set value(v) {
6117
- if (this._value?.getTime() === v?.getTime()) return;
6118
- this._value = v;
6119
- if (!this.hasFocus) this.syncInputText();
6120
- if (v) this.setActiveMonth(v);
6121
- 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;
6122
5825
  }
6123
- get value() {
6124
- return this._value;
5826
+ DateComponent.parseDate = parseDate;
5827
+ function expandTwoDigitYear(year) {
5828
+ return year < 100 ? year + (year < 50 ? 2e3 : 1900) : year;
6125
5829
  }
6126
- set open(v) {
6127
- 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
+ ];
6128
5838
  }
6129
- get open() {
6130
- 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
+ ];
6131
5854
  }
6132
- 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) {
6133
5864
  super();
6134
- this.cdr = cdr;
6135
5865
  this.host = host;
6136
- this.min = CalendarComponent.defaultMin;
6137
- this.max = CalendarComponent.defaultMax;
6138
- this.placeholder = "Select date";
6139
- this.disabled = false;
6140
- this.size = "medium";
6141
- this.showClearButton = true;
6142
- this.showTodayButton = true;
6143
- 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([]);
6144
5880
  this.open$ = new BehaviorSubject(false);
6145
- this.calendarId = uniqueId("riv-date-calendar-");
6146
- this.valueChange = new EventEmitter();
6147
- this.inputText = "";
6148
- this.hasFocus = false;
6149
- 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 ?? ""));
6150
5985
  }
6151
- ngOnChanges(changes) {
6152
- if (changes["rollingTodayLabel"] && !this.hasFocus) this.syncInputText();
5986
+ set showPresets(v) {
5987
+ this.showPresets$.next(v);
6153
5988
  }
6154
- onDocumentMouseDown(target) {
6155
- if (!this.open$.getValue() || !(target instanceof Element)) return;
6156
- if (this.isInsidePicker(target)) return;
6157
- this.open$.next(false);
6158
- this.cdr.markForCheck();
5989
+ get showPresets() {
5990
+ return this.showPresets$.getValue();
6159
5991
  }
6160
- isInsidePicker(target) {
6161
- const host = this.host.nativeElement;
6162
- if (host.contains(target)) return true;
6163
- const layer = target.closest(".callout, .scrim, .overlay-container");
6164
- return !!layer && !layer.contains(host);
5992
+ set min(v) {
5993
+ this.min$.next(v);
6165
5994
  }
6166
- clearValue() {
6167
- this.commit(void 0);
6168
- this.open$.next(false);
5995
+ get min() {
5996
+ return this.min$.getValue();
6169
5997
  }
6170
- selectToday() {
6171
- if (!this.isTodaySelectable) return;
6172
- this.commit(this.isRolling ? void 0 : timeDay.floor(/* @__PURE__ */ new Date()));
6173
- this.open$.next(false);
5998
+ set max(v) {
5999
+ this.max$.next(v);
6174
6000
  }
6175
- get isTodaySelectable() {
6176
- return DateComponent.isValidDate(timeDay.floor(/* @__PURE__ */ new Date()), this.min, this.max);
6001
+ get max() {
6002
+ return this.max$.getValue();
6177
6003
  }
6178
- get selectedCalendarValue() {
6179
- return this.previewValue ?? this._value ?? (this.isRolling ? timeDay.floor(/* @__PURE__ */ new Date()) : void 0);
6004
+ set value(v) {
6005
+ this.value$.next(v);
6180
6006
  }
6181
- onInputChange(value) {
6182
- this.inputText = value;
6183
- const parsed = this.parseInput(value);
6184
- this.previewValue = parsed;
6185
- if (parsed) this.setActiveMonth(parsed);
6186
- this.cdr.markForCheck();
6007
+ get value() {
6008
+ return this.value$.getValue();
6187
6009
  }
6188
- onInputBlur(event) {
6189
- this.hasFocus = false;
6190
- const parsed = this.parseInput(this.inputText);
6191
- if (parsed) this.commit(parsed);
6192
- else if (!this.inputText.trim() || this.isRollingText(this.inputText)) this.commit(void 0);
6193
- else this.syncInputText();
6194
- this.previewValue = void 0;
6195
- const nextTarget = event?.relatedTarget;
6196
- if (!(nextTarget instanceof Element && this.isInsidePicker(nextTarget))) this.open$.next(false);
6197
- this.cdr.markForCheck();
6010
+ set placeholder(v) {
6011
+ this.placeholder$.next(v);
6198
6012
  }
6199
- onDateSelect(date) {
6200
- this.commit(timeDay.floor(date));
6201
- 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]);
6202
6036
  }
6203
6037
  onInputFocus() {
6204
- this.hasFocus = true;
6205
6038
  this.open$.next(true);
6206
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
+ }
6207
6051
  toggleCalendar() {
6208
- this.open$.next(!this.open$.getValue());
6052
+ if (this.open$.getValue()) this.closeCalendar();
6053
+ else this.open$.next(true);
6209
6054
  }
6210
- get isRolling() {
6211
- 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();
6212
6060
  }
6213
- isRollingText(text) {
6214
- 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);
6215
6064
  }
6216
- syncInputText() {
6217
- 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();
6218
6068
  }
6219
- formatValue(date) {
6220
- 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);
6221
6073
  }
6222
- parseInput(text) {
6223
- const parsed = DateComponent.parseDate(text);
6224
- 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();
6225
6078
  }
6226
- setActiveMonth(date) {
6227
- const month = timeMonth.floor(date);
6228
- 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);
6229
6084
  }
6230
- commit(next) {
6231
- const unchanged = next?.getTime() === this._value?.getTime();
6232
- this._value = next;
6233
- this.syncInputText();
6234
- this.previewValue = void 0;
6235
- if (next) this.setActiveMonth(next);
6236
- if (!unchanged) this.valueChange.emit(next);
6237
- 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);
6238
6095
  }
6239
6096
  static {
6240
6097
  this.ɵfac = i0.ɵɵngDeclareFactory({
6241
6098
  minVersion: "12.0.0",
6242
6099
  version: "22.2.4",
6243
6100
  ngImport: i0,
6244
- type: DateComponent,
6245
- deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }],
6101
+ type: DateRangeComponent,
6102
+ deps: [{ token: i0.ElementRef }],
6246
6103
  target: i0.ɵɵFactoryTarget.Component
6247
6104
  });
6248
6105
  }
@@ -6250,35 +6107,64 @@ var DateComponent = class DateComponent extends InputLabelComponent {
6250
6107
  this.ɵcmp = i0.ɵɵngDeclareComponent({
6251
6108
  minVersion: "14.0.0",
6252
6109
  version: "22.2.4",
6253
- type: DateComponent,
6110
+ type: DateRangeComponent,
6254
6111
  isStandalone: false,
6255
- selector: "riv-date",
6112
+ selector: "riv-date-range",
6256
6113
  inputs: {
6114
+ showPresets: "showPresets",
6257
6115
  min: "min",
6258
6116
  max: "max",
6259
6117
  value: "value",
6260
6118
  placeholder: "placeholder",
6261
6119
  disabled: "disabled",
6262
- size: "size",
6263
- showClearButton: "showClearButton",
6264
- showTodayButton: "showTodayButton",
6265
- rollingTodayLabel: "rollingTodayLabel",
6266
- open: "open"
6120
+ alternativePresetList: "alternativePresetList"
6267
6121
  },
6268
6122
  outputs: { valueChange: "valueChange" },
6269
6123
  host: { listeners: { "document:mousedown": "onDocumentMouseDown($event.target)" } },
6270
6124
  queries: [{
6271
- propertyName: "headerTemplate",
6125
+ propertyName: "triggerTemplate",
6272
6126
  first: true,
6273
- predicate: ["header"],
6127
+ predicate: ["trigger"],
6274
6128
  descendants: true
6275
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
+ ],
6276
6153
  usesInheritance: true,
6277
- usesOnChanges: true,
6278
6154
  ngImport: i0,
6279
- 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",
6280
- 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"],
6281
6157
  dependencies: [
6158
+ {
6159
+ kind: "directive",
6160
+ type: i1.NgForOf,
6161
+ selector: "[ngFor][ngForOf]",
6162
+ inputs: [
6163
+ "ngForOf",
6164
+ "ngForTrackBy",
6165
+ "ngForTemplate"
6166
+ ]
6167
+ },
6282
6168
  {
6283
6169
  kind: "directive",
6284
6170
  type: i1.NgIf,
@@ -6345,6 +6231,12 @@ var DateComponent = class DateComponent extends InputLabelComponent {
6345
6231
  ],
6346
6232
  outputs: ["close"]
6347
6233
  },
6234
+ {
6235
+ kind: "component",
6236
+ type: HighlightComponent,
6237
+ selector: "riv-highlight",
6238
+ inputs: ["text", "indices"]
6239
+ },
6348
6240
  {
6349
6241
  kind: "component",
6350
6242
  type: IconComponent,
@@ -6376,10 +6268,55 @@ var DateComponent = class DateComponent extends InputLabelComponent {
6376
6268
  type: OverlayDirective,
6377
6269
  selector: "[riv-overlay]"
6378
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
+ },
6379
6311
  {
6380
6312
  kind: "pipe",
6381
6313
  type: i1.AsyncPipe,
6382
6314
  name: "async"
6315
+ },
6316
+ {
6317
+ kind: "pipe",
6318
+ type: OptionGroupPipe,
6319
+ name: "rivOptionGroup"
6383
6320
  }
6384
6321
  ],
6385
6322
  changeDetection: i0.ChangeDetectionStrategy.OnPush
@@ -6390,33 +6327,42 @@ i0.ɵɵngDeclareClassMetadata({
6390
6327
  minVersion: "12.0.0",
6391
6328
  version: "22.2.4",
6392
6329
  ngImport: i0,
6393
- type: DateComponent,
6330
+ type: DateRangeComponent,
6394
6331
  decorators: [{
6395
6332
  type: Component,
6396
6333
  args: [{
6397
- selector: "riv-date",
6334
+ selector: "riv-date-range",
6398
6335
  changeDetection: ChangeDetectionStrategy.OnPush,
6399
6336
  standalone: false,
6400
- 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",
6401
- 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"]
6402
6339
  }]
6403
6340
  }],
6404
- ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }],
6341
+ ctorParameters: () => [{ type: i0.ElementRef }],
6405
6342
  propDecorators: {
6343
+ showPresets: [{ type: Input }],
6406
6344
  min: [{ type: Input }],
6407
6345
  max: [{ type: Input }],
6408
6346
  value: [{ type: Input }],
6409
6347
  placeholder: [{ type: Input }],
6410
6348
  disabled: [{ type: Input }],
6411
- size: [{ type: Input }],
6412
- showClearButton: [{ type: Input }],
6413
- showTodayButton: [{ type: Input }],
6414
- rollingTodayLabel: [{ type: Input }],
6415
- headerTemplate: [{
6349
+ triggerTemplate: [{
6416
6350
  type: ContentChild,
6417
- args: ["header"]
6351
+ args: ["trigger"]
6418
6352
  }],
6419
- 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 }],
6420
6366
  valueChange: [{ type: Output }],
6421
6367
  onDocumentMouseDown: [{
6422
6368
  type: HostListener,
@@ -6424,58 +6370,216 @@ i0.ɵɵngDeclareClassMetadata({
6424
6370
  }]
6425
6371
  }
6426
6372
  });
6427
- (function(DateComponent) {
6428
- DateComponent.Sizes = [
6429
- "xsmall",
6430
- "small",
6431
- "medium",
6432
- "large",
6433
- "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
+ }
6434
6581
  ];
6435
- function parseDate(input) {
6436
- const trimmed = input.trim();
6437
- if (!trimmed) return void 0;
6438
- const ymd = /^\d+$/.test(trimmed) ? parseDigits(trimmed) : parseSeparated(trimmed);
6439
- if (!ymd) return void 0;
6440
- const [year, month, day] = ymd;
6441
- const date = new Date(year, month - 1, day);
6442
- return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day ? date : void 0;
6443
- }
6444
- DateComponent.parseDate = parseDate;
6445
- function expandTwoDigitYear(year) {
6446
- return year < 100 ? year + (year < 50 ? 2e3 : 1900) : year;
6447
- }
6448
- function parseDigits(digits) {
6449
- if (digits.length !== 8 && digits.length !== 6) return void 0;
6450
- const year = parseInt(digits.slice(4), 10);
6451
- return [
6452
- digits.length === 6 ? expandTwoDigitYear(year) : year,
6453
- parseInt(digits.slice(0, 2), 10),
6454
- parseInt(digits.slice(2, 4), 10)
6455
- ];
6456
- }
6457
- function parseSeparated(input) {
6458
- const parts = input.split(/[/.-]/);
6459
- if (parts.length !== 3) return void 0;
6460
- const nums = parts.map((p) => parseInt(p, 10));
6461
- if (nums.some(isNaN)) return void 0;
6462
- const [year, month, day] = parts[0].length === 4 ? nums : [
6463
- nums[2],
6464
- nums[0],
6465
- nums[1]
6466
- ];
6467
- return [
6468
- parts[0].length === 4 ? year : expandTwoDigitYear(year),
6469
- month,
6470
- day
6471
- ];
6472
- }
6473
- function isValidDate(date, min, max) {
6474
- const time = date.getTime();
6475
- return time >= timeDay.floor(min).getTime() && time <= max.getTime();
6476
- }
6477
- DateComponent.isValidDate = isValidDate;
6478
- })(DateComponent || (DateComponent = {}));
6582
+ })(DateRangeComponent || (DateRangeComponent = {}));
6479
6583
  var FilterChipComponent = class FilterChipComponent {
6480
6584
  constructor() {
6481
6585
  this.selected$ = new BehaviorSubject(false);