@semantic-components/ui 0.11.0 → 0.12.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.
@@ -1,7 +1,7 @@
1
1
  import { clsx } from 'clsx';
2
2
  import { twMerge } from 'tailwind-merge';
3
3
  import * as i0 from '@angular/core';
4
- import { input, computed, Component, ViewEncapsulation, ChangeDetectionStrategy, signal, inject, ElementRef, Directive, HostListener, Injectable, ChangeDetectorRef, viewChild, afterNextRender, forwardRef, ViewContainerRef, contentChildren, model, output, effect, LOCALE_ID, Injector, booleanAttribute, untracked, viewChildren } from '@angular/core';
4
+ import { signal, inject, LOCALE_ID, Injectable, input, computed, Component, ViewEncapsulation, ChangeDetectionStrategy, ElementRef, Directive, HostListener, ChangeDetectorRef, viewChild, afterNextRender, forwardRef, ViewContainerRef, contentChildren, model, output, effect, linkedSignal, Injector, booleanAttribute, untracked, viewChildren } from '@angular/core';
5
5
  import * as i1 from '@angular/forms';
6
6
  import { FormGroup, FormControl, Validators, ReactiveFormsModule, NG_VALUE_ACCESSOR, FormArray, NgForm, FormGroupDirective, NgControl, FormBuilder, FormsModule } from '@angular/forms';
7
7
  import { Editor } from '@tiptap/core';
@@ -10,14 +10,14 @@ import Heading from '@tiptap/extension-heading';
10
10
  import Paragraph from '@tiptap/extension-paragraph';
11
11
  import Text from '@tiptap/extension-text';
12
12
  import { cva } from 'class-variance-authority';
13
- import { SvgQuoteIcon, SvgBoldIcon, SvgListIcon, SvgCodeIcon, SvgPaletteIcon, SvgHighlighterIcon, SvgUndoIcon, SvgRedoIcon, SvgMinusIcon, SvgItalicIcon, SvgListOrderedIcon, SvgStrikethroughIcon, SvgAlignLeftIcon, SvgAlignRightIcon, SvgAlignCenterIcon, SvgUnderlineIcon, SvgCheckIcon, SvgChevronDownIcon, SvgEllipsisIcon, SvgChevronLeftIcon, SvgChevronsLeftIcon, SvgChevronRightIcon, SvgChevronsRightIcon, SvgCalendarIcon, SvgMoonIcon, SvgSunIcon, SvgXIcon, SvgChevronUpIcon, SvgCircleIcon, SvgDotIcon, SvgSearchIcon } from '@semantic-icons/lucide-icons';
13
+ import { SvgQuoteIcon, SvgBoldIcon, SvgListIcon, SvgCodeIcon, SvgPaletteIcon, SvgHighlighterIcon, SvgUndoIcon, SvgRedoIcon, SvgMinusIcon, SvgItalicIcon, SvgListOrderedIcon, SvgStrikethroughIcon, SvgAlignLeftIcon, SvgAlignRightIcon, SvgAlignCenterIcon, SvgUnderlineIcon, SvgCheckIcon, SvgChevronDownIcon, SvgEllipsisIcon, SvgChevronLeftIcon, SvgChevronsLeftIcon, SvgChevronRightIcon, SvgChevronsRightIcon, SvgCalendarIcon, SvgMoonIcon, SvgSunIcon, SvgXIcon, SvgChevronUpIcon, SvgCircleIcon, SvgDotIcon, SvgSearchIcon, SvgClockIcon } from '@semantic-icons/lucide-icons';
14
14
  import { Overlay, OverlayModule, OverlayContainer, OverlayConfig } from '@angular/cdk/overlay';
15
15
  import { ComponentPortal, TemplatePortal } from '@angular/cdk/portal';
16
16
  import * as i1$5 from '@angular/cdk/menu';
17
17
  import { CdkMenuTrigger, CdkMenu, CdkMenuItem, CdkContextMenuTrigger, CdkMenuItemCheckbox, CdkMenuGroup, CdkMenuItemRadio, CdkMenuBar } from '@angular/cdk/menu';
18
18
  import { DialogRef, Dialog, DialogModule } from '@angular/cdk/dialog';
19
19
  import * as i1$1 from '@angular/cdk/a11y';
20
- import { A11yModule, FocusMonitor, ActiveDescendantKeyManager } from '@angular/cdk/a11y';
20
+ import { A11yModule, FocusMonitor, ActiveDescendantKeyManager, _IdGenerator } from '@angular/cdk/a11y';
21
21
  import { Directionality } from '@angular/cdk/bidi';
22
22
  import { TAB, ESCAPE, hasModifierKey, ENTER } from '@angular/cdk/keycodes';
23
23
  import { CdkOption, CdkListbox } from '@angular/cdk/listbox';
@@ -32,13 +32,49 @@ import * as i1$4 from '@angular/cdk/accordion';
32
32
  import { CdkAccordionModule } from '@angular/cdk/accordion';
33
33
  import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
34
34
  import { Subject, debounceTime } from 'rxjs';
35
- import * as i1$6 from '@angular/cdk/layout';
36
- import { LayoutModule } from '@angular/cdk/layout';
35
+ import { BreakpointObserver, LayoutModule } from '@angular/cdk/layout';
37
36
 
38
37
  function cn(...inputs) {
39
38
  return twMerge(clsx(inputs));
40
39
  }
41
40
 
41
+ class ScSettings {
42
+ dateFormatPattern = signal('');
43
+ localeId = inject(LOCALE_ID);
44
+ constructor() {
45
+ this.dateFormatPattern.set(this.getDateFormatPattern(this.localeId));
46
+ }
47
+ getDateFormatPattern(localeId) {
48
+ const getPatternForPart = (part) => {
49
+ switch (part.type) {
50
+ case 'day':
51
+ return 'd'.repeat(part.value.length);
52
+ case 'month':
53
+ return 'M'.repeat(part.value.length);
54
+ case 'year':
55
+ return 'y'.repeat(part.value.length);
56
+ case 'literal':
57
+ return part.value;
58
+ default:
59
+ throw new Error('no default');
60
+ }
61
+ };
62
+ return new Intl.DateTimeFormat(localeId)
63
+ .formatToParts(new Date('2022-01-01'))
64
+ .map(getPatternForPart)
65
+ .join('')
66
+ .toLowerCase();
67
+ }
68
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScSettings, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
69
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScSettings, providedIn: 'root' });
70
+ }
71
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScSettings, decorators: [{
72
+ type: Injectable,
73
+ args: [{
74
+ providedIn: 'root',
75
+ }]
76
+ }], ctorParameters: () => [] });
77
+
42
78
  const scHeadingVariants = cva('', {
43
79
  variants: {
44
80
  level: {
@@ -4971,7 +5007,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
4971
5007
 
4972
5008
  class ScListboxOption {
4973
5009
  class = input('');
4974
- classes = computed(() => cn('relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', this.class()));
5010
+ classes = computed(() => cn('relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50', this.class()));
4975
5011
  isSelected = input.required();
4976
5012
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScListboxOption, deps: [], target: i0.ɵɵFactoryTarget.Component });
4977
5013
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: ScListboxOption, isStandalone: true, selector: "li[sc-listbox-option]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, isSelected: { classPropertyName: "isSelected", publicName: "isSelected", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: `
@@ -5892,11 +5928,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
5892
5928
  }] });
5893
5929
 
5894
5930
  class ScCalendar {
5931
+ _cdr = inject(ChangeDetectorRef);
5895
5932
  class = input('');
5896
5933
  classes = computed(() => cn('', this.class()));
5897
5934
  localeId = inject(LOCALE_ID);
5898
- year = signal(0);
5899
- month = signal(0);
5935
+ date = computed(() => {
5936
+ if (this.value()) {
5937
+ return new Date(this.value());
5938
+ }
5939
+ return new Date();
5940
+ });
5941
+ year = linkedSignal(() => this.date().getFullYear());
5942
+ month = linkedSignal(() => this.date().getMonth());
5900
5943
  weekDaysNames = signal([]);
5901
5944
  monthYear = computed(() => {
5902
5945
  const options = {
@@ -5928,18 +5971,31 @@ class ScCalendar {
5928
5971
  .map((e) => e.long)
5929
5972
  .indexOf(dayName);
5930
5973
  });
5931
- selectedDay = signal('');
5932
- ngOnInit() {
5933
- this.init();
5934
- this.setLocaleDayNames();
5974
+ value = model('');
5975
+ setSelectedDay(day) {
5976
+ this.value.set(day);
5977
+ this._onChange(day);
5978
+ this._cdr.markForCheck();
5935
5979
  }
5936
- init() {
5937
- const today = new Date();
5938
- this.year.set(today.getFullYear());
5939
- this.month.set(today.getMonth());
5980
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
5981
+ _onChange = () => { };
5982
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
5983
+ _onTouched = () => { };
5984
+ writeValue(value) {
5985
+ this.value.set(value);
5940
5986
  }
5941
- setSelectedDay(day) {
5942
- this.selectedDay.set(day);
5987
+ registerOnChange(fn) {
5988
+ this._onChange = fn;
5989
+ }
5990
+ registerOnTouched(fn) {
5991
+ this._onTouched = fn;
5992
+ }
5993
+ _disabledByCva = signal(false);
5994
+ setDisabledState(isDisabled) {
5995
+ this._disabledByCva.set(isDisabled);
5996
+ }
5997
+ ngOnInit() {
5998
+ this.setLocaleDayNames();
5943
5999
  }
5944
6000
  //https://github.com/angular/angular/issues/57193
5945
6001
  setLocaleDayNames() {
@@ -5999,7 +6055,13 @@ class ScCalendar {
5999
6055
  });
6000
6056
  }
6001
6057
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScCalendar, deps: [], target: i0.ɵɵFactoryTarget.Component });
6002
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.5", type: ScCalendar, isStandalone: true, selector: "sc-calendar", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: `
6058
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.5", type: ScCalendar, isStandalone: true, selector: "sc-calendar", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { properties: { "class": "classes()" } }, providers: [
6059
+ {
6060
+ provide: NG_VALUE_ACCESSOR,
6061
+ useExisting: forwardRef(() => ScCalendar),
6062
+ multi: true,
6063
+ },
6064
+ ], ngImport: i0, template: `
6003
6065
  <div sc-card>
6004
6066
  <div sc-card-header>
6005
6067
  <sc-month-year-header [monthYear]="monthYear()" (monthYearChange)="setMonthYear($event)" />
@@ -6010,7 +6072,7 @@ class ScCalendar {
6010
6072
  [weekDaysNames]="weekDaysNames()"
6011
6073
  [days]="monthDays()"
6012
6074
  [firstDayMonth]="firstDayMonth()"
6013
- [selectedDay]="selectedDay()"
6075
+ [selectedDay]="value()"
6014
6076
  (selectedDayChange)="setSelectedDay($event)"
6015
6077
  />
6016
6078
  </div>
@@ -6043,7 +6105,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
6043
6105
  [weekDaysNames]="weekDaysNames()"
6044
6106
  [days]="monthDays()"
6045
6107
  [firstDayMonth]="firstDayMonth()"
6046
- [selectedDay]="selectedDay()"
6108
+ [selectedDay]="value()"
6047
6109
  (selectedDayChange)="setSelectedDay($event)"
6048
6110
  />
6049
6111
  </div>
@@ -6055,7 +6117,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
6055
6117
  </div>
6056
6118
  `, host: {
6057
6119
  '[class]': 'classes()',
6058
- }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush }]
6120
+ }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
6121
+ {
6122
+ provide: NG_VALUE_ACCESSOR,
6123
+ useExisting: forwardRef(() => ScCalendar),
6124
+ multi: true,
6125
+ },
6126
+ ] }]
6059
6127
  }] });
6060
6128
 
6061
6129
  class ScFullCalendar {
@@ -6075,9 +6143,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
6075
6143
  }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush }]
6076
6144
  }] });
6077
6145
 
6146
+ const scInputStyles = signal('flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm');
6078
6147
  class ScInput {
6079
6148
  class = input('');
6080
- classes = computed(() => cn('flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', this.class()));
6149
+ classes = computed(() => cn(scInputStyles(), this.class()));
6081
6150
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
6082
6151
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.5", type: ScInput, isStandalone: true, selector: "input[sc-input]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: `
6083
6152
  <ng-content />
@@ -6092,35 +6161,74 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
6092
6161
  }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush }]
6093
6162
  }] });
6094
6163
 
6164
+ class ScDateInput {
6165
+ el = inject(ElementRef);
6166
+ dateFormatRegExp = (current) => {
6167
+ switch (current.length) {
6168
+ case 0: {
6169
+ return new RegExp(/^\d$/g);
6170
+ }
6171
+ case 1: {
6172
+ return new RegExp(/^\d{1,2}\/?$/g);
6173
+ }
6174
+ case 2: {
6175
+ return new RegExp(/^\d{1,2}\/\d?$/g);
6176
+ }
6177
+ case 3: {
6178
+ return new RegExp(/^\d{1,2}\/\d{1,2}\/?$/g);
6179
+ }
6180
+ case 4: {
6181
+ return new RegExp(/^\d{1,2}\/\d{1,2}\/?\d?$/g);
6182
+ }
6183
+ case 5: {
6184
+ return new RegExp(/^\d{1,2}\/\d{1,2}\/\d{0,2}$/g);
6185
+ }
6186
+ case 6: {
6187
+ return new RegExp(/^\d{1,2}\/\d{1,2}\/\d{0,3}$/g);
6188
+ }
6189
+ default: {
6190
+ return new RegExp(/^\d{1,2}\/\d{1,2}\/\d{1,4}$/g);
6191
+ }
6192
+ }
6193
+ };
6194
+ previousKey = '';
6195
+ onKeyDown(event) {
6196
+ if (event.key === 'Backspace' ||
6197
+ event.key === 'Delete' ||
6198
+ event.key === 'ArrowLeft' ||
6199
+ event.key === 'ArrowRight' ||
6200
+ (this.previousKey === 'Control' && event.key === 'c') ||
6201
+ (this.previousKey === 'Control' && event.key === 'v') ||
6202
+ (this.previousKey === 'Control' && event.key === 'x')) {
6203
+ this.previousKey = event.key;
6204
+ return;
6205
+ }
6206
+ this.previousKey = event.key;
6207
+ const current = this.el.nativeElement.value;
6208
+ const start = this.el.nativeElement.selectionStart;
6209
+ const end = this.el.nativeElement.selectionEnd;
6210
+ const next = current.slice(0, start) + event.key + current.slice(end);
6211
+ if (this.dateFormatRegExp(current).exec(next) === null) {
6212
+ event.preventDefault();
6213
+ }
6214
+ }
6215
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScDateInput, deps: [], target: i0.ɵɵFactoryTarget.Directive });
6216
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.5", type: ScDateInput, isStandalone: true, selector: "[scDateInput]", host: { listeners: { "keydown": "onKeyDown($event)" } }, ngImport: i0 });
6217
+ }
6218
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScDateInput, decorators: [{
6219
+ type: Directive,
6220
+ args: [{
6221
+ selector: '[scDateInput]',
6222
+ host: {
6223
+ '(keydown)': 'onKeyDown($event)',
6224
+ },
6225
+ }]
6226
+ }] });
6227
+
6095
6228
  class ScDatePicker {
6096
6229
  class = input('');
6097
6230
  classes = computed(() => cn('flex relative', this.class()));
6098
6231
  host = inject(ElementRef);
6099
- localeId = inject(LOCALE_ID);
6100
- dateFormatPattern = signal('');
6101
- ngOnInit() {
6102
- this.dateFormatPattern.set(this.getDateFormatPattern(this.localeId));
6103
- }
6104
- getDateFormatPattern(localeId) {
6105
- const getPatternForPart = (part) => {
6106
- switch (part.type) {
6107
- case 'day':
6108
- return 'd'.repeat(part.value.length);
6109
- case 'month':
6110
- return 'M'.repeat(part.value.length);
6111
- case 'year':
6112
- return 'y'.repeat(part.value.length);
6113
- case 'literal':
6114
- return part.value;
6115
- default:
6116
- throw new Error('no default');
6117
- }
6118
- };
6119
- return new Intl.DateTimeFormat(localeId)
6120
- .formatToParts(new Date('2022-01-01'))
6121
- .map(getPatternForPart)
6122
- .join('');
6123
- }
6124
6232
  _injector = inject(Injector);
6125
6233
  _dir = inject(Directionality, { optional: true });
6126
6234
  _overlay = inject(Overlay);
@@ -6223,16 +6331,16 @@ class ScDatePicker {
6223
6331
  <button class="absolute inset-y-0 end-0 pe-4" (click)="open()" sc-button variant="ghost">
6224
6332
  <svg-calendar-icon />
6225
6333
  </button>
6226
- <input #input sc-input type="text" placeholder="Select date" />
6227
- `, isInline: true, styles: [""], dependencies: [{ kind: "component", type: ScInput, selector: "input[sc-input]", inputs: ["class"] }, { kind: "component", type: SvgCalendarIcon, selector: "svg-calendar-icon", inputs: ["class", "svgClass"] }, { kind: "component", type: ScButton, selector: "button[sc-button], a[sc-button]", inputs: ["variant", "size", "class"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
6334
+ <input #input sc-input scDateInput type="text" placeholder="Select date" />
6335
+ `, isInline: true, styles: [""], dependencies: [{ kind: "component", type: ScInput, selector: "input[sc-input]", inputs: ["class"] }, { kind: "component", type: SvgCalendarIcon, selector: "svg-calendar-icon", inputs: ["class", "svgClass"] }, { kind: "component", type: ScButton, selector: "button[sc-button], a[sc-button]", inputs: ["variant", "size", "class"] }, { kind: "directive", type: ScDateInput, selector: "[scDateInput]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
6228
6336
  }
6229
6337
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScDatePicker, decorators: [{
6230
6338
  type: Component,
6231
- args: [{ selector: 'sc-date-picker', imports: [ScInput, SvgCalendarIcon, ScButton], template: `
6339
+ args: [{ selector: 'sc-date-picker', imports: [ScInput, SvgCalendarIcon, ScButton, ScDateInput], template: `
6232
6340
  <button class="absolute inset-y-0 end-0 pe-4" (click)="open()" sc-button variant="ghost">
6233
6341
  <svg-calendar-icon />
6234
6342
  </button>
6235
- <input #input sc-input type="text" placeholder="Select date" />
6343
+ <input #input sc-input scDateInput type="text" placeholder="Select date" />
6236
6344
  `, host: {
6237
6345
  '[class]': 'classes()',
6238
6346
  }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush }]
@@ -8972,13 +9080,13 @@ class ScHoverCardTriggerFor {
8972
9080
  viewContainer = inject(ViewContainerRef);
8973
9081
  scHoverCardTriggerFor = input.required();
8974
9082
  overlayRef = null;
8975
- showTooltip() {
9083
+ showCard() {
8976
9084
  if (this.overlayRef?.hasAttached() === true) {
8977
9085
  return;
8978
9086
  }
8979
9087
  this.attachTooltip();
8980
9088
  }
8981
- hideTooltip() {
9089
+ hideCard() {
8982
9090
  if (this.overlayRef?.hasAttached() === true) {
8983
9091
  this.overlayRef?.detach();
8984
9092
  }
@@ -8991,14 +9099,6 @@ class ScHoverCardTriggerFor {
8991
9099
  const positionStrategy = this.getPositionStrategy();
8992
9100
  this.overlayRef = this.overlay.create({ positionStrategy });
8993
9101
  }
8994
- // const injector = Injector.create({
8995
- // providers: [
8996
- // {
8997
- // provide: TOOLTIP_DATA,
8998
- // useValue: this.appTooltip,
8999
- // },
9000
- // ],
9001
- // });
9002
9102
  const componentPortal = new ComponentPortal(ScHoverCard, this.viewContainer);
9003
9103
  // Attach tooltip portal to overlay
9004
9104
  const componentRef = this.overlayRef.attach(componentPortal);
@@ -9026,26 +9126,20 @@ class ScHoverCardTriggerFor {
9026
9126
  ]);
9027
9127
  }
9028
9128
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScHoverCardTriggerFor, deps: [], target: i0.ɵɵFactoryTarget.Directive });
9029
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.5", type: ScHoverCardTriggerFor, isStandalone: true, selector: "[scHoverCardTriggerFor]", inputs: { scHoverCardTriggerFor: { classPropertyName: "scHoverCardTriggerFor", publicName: "scHoverCardTriggerFor", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "mouseover": "showTooltip()", "focus": "showTooltip()", "mouseleave": "hideTooltip()", "blur": "hideTooltip()" } }, ngImport: i0 });
9129
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.5", type: ScHoverCardTriggerFor, isStandalone: true, selector: "[scHoverCardTriggerFor]", inputs: { scHoverCardTriggerFor: { classPropertyName: "scHoverCardTriggerFor", publicName: "scHoverCardTriggerFor", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "mouseover": "showCard()", "focus": "showCard()", "mouseleave": "hideCard()", "blur": "hideCard()" } }, ngImport: i0 });
9030
9130
  }
9031
9131
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScHoverCardTriggerFor, decorators: [{
9032
9132
  type: Directive,
9033
9133
  args: [{
9034
9134
  selector: '[scHoverCardTriggerFor]',
9135
+ host: {
9136
+ '(mouseover)': 'showCard()',
9137
+ '(focus)': 'showCard()',
9138
+ '(mouseleave)': 'hideCard()',
9139
+ '(blur)': 'hideCard()',
9140
+ },
9035
9141
  }]
9036
- }], propDecorators: { showTooltip: [{
9037
- type: HostListener,
9038
- args: ['mouseover']
9039
- }, {
9040
- type: HostListener,
9041
- args: ['focus']
9042
- }], hideTooltip: [{
9043
- type: HostListener,
9044
- args: ['mouseleave']
9045
- }, {
9046
- type: HostListener,
9047
- args: ['blur']
9048
- }] } });
9142
+ }] });
9049
9143
 
9050
9144
  class ScAvatarFallback {
9051
9145
  class = input('');
@@ -9584,7 +9678,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
9584
9678
  class ScMenuCheckboxItem {
9585
9679
  _cdkMenuItemCheckbox = inject(CdkMenuItemCheckbox, { host: true });
9586
9680
  class = input('');
9587
- classes = computed(() => cn('relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', this.class()));
9681
+ classes = computed(() => cn('relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50', this.class()));
9588
9682
  disabled = input(false, {
9589
9683
  transform: booleanAttribute,
9590
9684
  });
@@ -9646,7 +9740,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
9646
9740
 
9647
9741
  class ScMenuRadioItem {
9648
9742
  class = input('');
9649
- classes = computed(() => cn('relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', this.class()));
9743
+ classes = computed(() => cn('relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50', this.class()));
9650
9744
  value = input('');
9651
9745
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScMenuRadioItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
9652
9746
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.5", type: ScMenuRadioItem, isStandalone: true, selector: "button[sc-menu-radio-item]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, hostDirectives: [{ directive: i1$5.CdkMenuItemRadio }], ngImport: i0, template: `
@@ -10172,7 +10266,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
10172
10266
  }] });
10173
10267
 
10174
10268
  class ScSidebar {
10175
- observer;
10269
+ observer = inject(BreakpointObserver);
10176
10270
  sidebarState = inject(ScSidebarState);
10177
10271
  class = input('');
10178
10272
  classes = computed(() => cn('block relative', this.class()));
@@ -10194,8 +10288,7 @@ class ScSidebar {
10194
10288
  this.variant() === 'floating' || this.variant() === 'inset'
10195
10289
  ? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]'
10196
10290
  : 'group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l'));
10197
- constructor(observer) {
10198
- this.observer = observer;
10291
+ constructor() {
10199
10292
  this.observer.observe('(max-width: 768px)').subscribe((result) => {
10200
10293
  this.sidebarState.isMobile.set(result.matches);
10201
10294
  if (!result.matches && this.openMobile()) {
@@ -10203,7 +10296,7 @@ class ScSidebar {
10203
10296
  }
10204
10297
  });
10205
10298
  }
10206
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScSidebar, deps: [{ token: i1$6.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Component });
10299
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScSidebar, deps: [], target: i0.ɵɵFactoryTarget.Component });
10207
10300
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: ScSidebar, isStandalone: true, selector: "sc-sidebar", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, collapsible: { classPropertyName: "collapsible", publicName: "collapsible", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: `
10208
10301
  <ng-template #sc_sidebar_content>
10209
10302
  <ng-content />
@@ -10277,7 +10370,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
10277
10370
  `, host: {
10278
10371
  '[class]': 'classes()',
10279
10372
  }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush }]
10280
- }], ctorParameters: () => [{ type: i1$6.BreakpointObserver }] });
10373
+ }], ctorParameters: () => [] });
10281
10374
 
10282
10375
  class ScSidebarProvider {
10283
10376
  sidebarState = inject(ScSidebarState);
@@ -10470,9 +10563,453 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
10470
10563
  }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush }]
10471
10564
  }] });
10472
10565
 
10566
+ class ScTimeOption {
10567
+ /** The unique ID of the option. */
10568
+ id = signal(inject(_IdGenerator).getId('sc-time-option-'));
10569
+ class = input('');
10570
+ _class = computed(() => cn('relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50', this._active() && 'bg-accent text-accent-foreground', this.class()));
10571
+ _active = signal(false);
10572
+ _selected = signal(false);
10573
+ _disabledByInput = input(false, {
10574
+ alias: 'disabled',
10575
+ transform: booleanAttribute,
10576
+ });
10577
+ _disabled = computed(() => this._disabledByInput() || booleanAttribute(this.disabled));
10578
+ value = input();
10579
+ setActiveStyles() {
10580
+ this._active.set(true);
10581
+ }
10582
+ setInactiveStyles() {
10583
+ this._active.set(false);
10584
+ }
10585
+ disabled;
10586
+ getLabel() {
10587
+ return this.value() ?? '';
10588
+ }
10589
+ _element = inject(ElementRef);
10590
+ /** Gets the host DOM element. */
10591
+ _getHostElement() {
10592
+ return this._element.nativeElement;
10593
+ }
10594
+ /** Selects the option. */
10595
+ select() {
10596
+ if (!this._selected()) {
10597
+ this._selected.set(true);
10598
+ }
10599
+ }
10600
+ /** Deselects the option. */
10601
+ deselect() {
10602
+ if (this._selected()) {
10603
+ this._selected.set(false);
10604
+ }
10605
+ }
10606
+ onClick() {
10607
+ if (this._selected()) {
10608
+ this._selected.set(false);
10609
+ }
10610
+ else {
10611
+ this.selected.emit(this.value());
10612
+ this._selected.set(true);
10613
+ }
10614
+ }
10615
+ selected = output();
10616
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScTimeOption, deps: [], target: i0.ɵɵFactoryTarget.Component });
10617
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: ScTimeOption, isStandalone: true, selector: "sc-time-option", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, _disabledByInput: { classPropertyName: "_disabledByInput", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "selected" }, host: { listeners: { "mouseover": "setActiveStyles()", "mouseleave": "setInactiveStyles()", "click": "onClick()" }, properties: { "id": "id()", "class": "_class()", "attr.data-disabled": "_disabled()" } }, ngImport: i0, template: `
10618
+ @if (_selected()) {
10619
+ <svg-check-icon class="absolute left-2 flex size-4 items-center justify-center" />
10620
+ }
10621
+
10622
+ <ng-content />
10623
+ `, isInline: true, styles: [""], dependencies: [{ kind: "component", type: SvgCheckIcon, selector: "svg-check-icon", inputs: ["class", "svgClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
10624
+ }
10625
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScTimeOption, decorators: [{
10626
+ type: Component,
10627
+ args: [{ selector: 'sc-time-option', imports: [SvgCheckIcon], template: `
10628
+ @if (_selected()) {
10629
+ <svg-check-icon class="absolute left-2 flex size-4 items-center justify-center" />
10630
+ }
10631
+
10632
+ <ng-content />
10633
+ `, host: {
10634
+ '[id]': 'id()',
10635
+ '[class]': '_class()',
10636
+ '[attr.data-disabled]': '_disabled()',
10637
+ '(mouseover)': 'setActiveStyles()',
10638
+ '(mouseleave)': 'setInactiveStyles()',
10639
+ '(click)': 'onClick()',
10640
+ }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush }]
10641
+ }] });
10642
+
10643
+ class ScTimePickerInput {
10644
+ class = input('');
10645
+ classes = computed(() => cn(scInputStyles(), this.class()));
10646
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScTimePickerInput, deps: [], target: i0.ɵɵFactoryTarget.Directive });
10647
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.5", type: ScTimePickerInput, isStandalone: true, selector: "[scTimePickerInput]", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, ngImport: i0 });
10648
+ }
10649
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScTimePickerInput, decorators: [{
10650
+ type: Directive,
10651
+ args: [{
10652
+ selector: '[scTimePickerInput]',
10653
+ host: {
10654
+ '[class]': 'classes()',
10655
+ },
10656
+ }]
10657
+ }] });
10658
+
10659
+ class ScTimePicker {
10660
+ class = input('');
10661
+ classes = computed(() => cn('flex relative', this.class()));
10662
+ _overlay = inject(Overlay);
10663
+ _dir = inject(Directionality, { optional: true });
10664
+ _viewContainerRef = inject(ViewContainerRef);
10665
+ _injector = inject(Injector);
10666
+ // private _defaultConfig = inject(MAT_TIMEPICKER_CONFIG, { optional: true });
10667
+ // private _dateAdapter = inject<DateAdapter<D>>(DateAdapter, { optional: true })!;
10668
+ // private _dateFormats = inject(MAT_DATE_FORMATS, { optional: true })!;
10669
+ _isOpen = signal(false);
10670
+ _activeDescendant = signal(null);
10671
+ _input = viewChild.required('input');
10672
+ _overlayRef = null;
10673
+ _portal = null;
10674
+ _optionsCacheKey = null;
10675
+ _localeChanges;
10676
+ _onOpenRender = null;
10677
+ _panelTemplate = viewChild.required('panelTemplate');
10678
+ _timeOptions = [];
10679
+ _options = viewChildren(ScTimeOption);
10680
+ _keyManager = new ActiveDescendantKeyManager(this._options, this._injector)
10681
+ .withHomeAndEnd(true)
10682
+ .withPageUpDown(true)
10683
+ .withVerticalOrientation(true);
10684
+ /**
10685
+ * Interval between each option in the timepicker. The value can either be an amount of
10686
+ * seconds (e.g. 90) or a number with a unit (e.g. 45m). Supported units are `s` for seconds,
10687
+ * `m` for minutes or `h` for hours.
10688
+ */
10689
+ // readonly interval: InputSignalWithTransform<number | null, number | string | null> = input(
10690
+ // parseInterval(this._defaultConfig?.interval || null),
10691
+ // { transform: parseInterval },
10692
+ // );
10693
+ /**
10694
+ * Array of pre-defined options that the user can select from, as an alternative to using the
10695
+ * `interval` input. An error will be thrown if both `options` and `interval` are specified.
10696
+ */
10697
+ options = input(null);
10698
+ /** Whether the timepicker is open. */
10699
+ isOpen = this._isOpen.asReadonly();
10700
+ /** Emits when the user selects a time. */
10701
+ selected = output();
10702
+ /** Emits when the timepicker is opened. */
10703
+ opened = output();
10704
+ /** Emits when the timepicker is closed. */
10705
+ closed = output();
10706
+ /** ID of the active descendant option. */
10707
+ activeDescendant = this._activeDescendant.asReadonly();
10708
+ /** Unique ID of the timepicker's panel */
10709
+ panelId = inject(_IdGenerator).getId('sc-time-picker-panel-');
10710
+ /** Whether ripples within the timepicker should be disabled. */
10711
+ // readonly disableRipple: InputSignalWithTransform<boolean, unknown> = input(
10712
+ // this._defaultConfig?.disableRipple ?? false,
10713
+ // {
10714
+ // transform: booleanAttribute,
10715
+ // },
10716
+ // );
10717
+ /** ARIA label for the timepicker panel. */
10718
+ ariaLabel = input(null, {
10719
+ alias: 'aria-label',
10720
+ });
10721
+ /** ID of the label element for the timepicker panel. */
10722
+ ariaLabelledby = input(null, {
10723
+ alias: 'aria-labelledby',
10724
+ });
10725
+ /** Whether the timepicker is currently disabled. */
10726
+ disabled = computed(() => !!this._input().nativeElement?.disabled);
10727
+ constructor() {
10728
+ // if (typeof ngDevMode === 'undefined' || ngDevMode) {
10729
+ // validateAdapter(this._dateAdapter, this._dateFormats);
10730
+ effect(() => {
10731
+ const options = this.options();
10732
+ // const interval = this.interval();
10733
+ // if (options !== null && interval !== null) {
10734
+ // throw new Error(
10735
+ // 'Cannot specify both the `options` and `interval` inputs at the same time',
10736
+ // );
10737
+ // } else if (options?.length === 0) {
10738
+ // throw new Error('Value of `options` input cannot be an empty array');
10739
+ // }
10740
+ });
10741
+ // }
10742
+ // Since the panel ID is static, we can set it once without having to maintain a host binding.
10743
+ const element = inject(ElementRef);
10744
+ element.nativeElement.setAttribute('sc-time-picker-panel-id', this.panelId);
10745
+ this._handleLocaleChanges();
10746
+ this._handleInputStateChanges();
10747
+ this._keyManager.change.subscribe(() => this._activeDescendant.set(this._keyManager.activeItem?.id() || null));
10748
+ }
10749
+ /** Opens the timepicker. */
10750
+ open() {
10751
+ const input = this._input();
10752
+ if (!input) {
10753
+ return;
10754
+ }
10755
+ // Focus should already be on the input, but this call is in case the timepicker is opened
10756
+ // programmatically. We need to call this even if the timepicker is already open, because
10757
+ // the user might be clicking the toggle.
10758
+ input.nativeElement.focus();
10759
+ if (this._isOpen()) {
10760
+ return;
10761
+ }
10762
+ this._isOpen.set(true);
10763
+ this._generateOptions();
10764
+ const overlayRef = this._getOverlayRef();
10765
+ overlayRef.updateSize({ width: input.nativeElement.offsetWidth });
10766
+ this._portal ??= new TemplatePortal(this._panelTemplate(), this._viewContainerRef);
10767
+ overlayRef.attach(this._portal);
10768
+ this._onOpenRender?.destroy();
10769
+ this._onOpenRender = afterNextRender(() => {
10770
+ const options = this._options();
10771
+ this._syncSelectedState(input.nativeElement?.value, options, options[0]);
10772
+ this._onOpenRender = null;
10773
+ }, { injector: this._injector });
10774
+ this.opened.emit();
10775
+ }
10776
+ /** Closes the timepicker. */
10777
+ close() {
10778
+ if (this._isOpen()) {
10779
+ this._isOpen.set(false);
10780
+ this._overlayRef?.detach();
10781
+ this.closed.emit();
10782
+ }
10783
+ }
10784
+ /** Registers an input with the timepicker. */
10785
+ // registerInput(input: MatTimepickerInput<D>): void {
10786
+ // const currentInput = this._input();
10787
+ // if (currentInput && input !== currentInput && (typeof ngDevMode === 'undefined' || ngDevMode)) {
10788
+ // throw new Error('MatTimepicker can only be registered with one input at a time');
10789
+ // }
10790
+ // this._input.set(input);
10791
+ // }
10792
+ ngOnDestroy() {
10793
+ this._keyManager.destroy();
10794
+ this._localeChanges.unsubscribe();
10795
+ this._onOpenRender?.destroy();
10796
+ this._overlayRef?.dispose();
10797
+ }
10798
+ /** Selects a specific time value. */
10799
+ _selectValue(value) {
10800
+ //TODO
10801
+ this._input().nativeElement.value = value;
10802
+ this.close();
10803
+ this.selected.emit({ value });
10804
+ this._input().nativeElement?.focus();
10805
+ }
10806
+ /** Gets the value of the `aria-labelledby` attribute. */
10807
+ _getAriaLabelledby() {
10808
+ if (this.ariaLabel()) {
10809
+ return null;
10810
+ }
10811
+ return this.ariaLabelledby() || null;
10812
+ }
10813
+ /** Creates an overlay reference for the timepicker panel. */
10814
+ _getOverlayRef() {
10815
+ if (this._overlayRef) {
10816
+ return this._overlayRef;
10817
+ }
10818
+ const positionStrategy = this._overlay
10819
+ .position()
10820
+ .flexibleConnectedTo(this._input())
10821
+ .withFlexibleDimensions(false)
10822
+ .withPush(false)
10823
+ // .withTransformOriginOn('.mat-timepicker-panel')
10824
+ .withPositions([
10825
+ {
10826
+ originX: 'start',
10827
+ originY: 'bottom',
10828
+ overlayX: 'start',
10829
+ overlayY: 'top',
10830
+ },
10831
+ {
10832
+ originX: 'start',
10833
+ originY: 'top',
10834
+ overlayX: 'start',
10835
+ overlayY: 'bottom',
10836
+ // panelClass: 'mat-timepicker-above',
10837
+ },
10838
+ ]);
10839
+ this._overlayRef = this._overlay.create({
10840
+ positionStrategy,
10841
+ scrollStrategy: this._overlay.scrollStrategies.reposition(),
10842
+ direction: this._dir || 'ltr',
10843
+ hasBackdrop: false,
10844
+ });
10845
+ this._overlayRef.keydownEvents().subscribe((event) => {
10846
+ this._handleKeydown(event);
10847
+ });
10848
+ this._overlayRef.outsidePointerEvents().subscribe((event) => {
10849
+ const target = _getEventTarget(event);
10850
+ const origin = this._input().nativeElement;
10851
+ if (target && origin && target !== origin && !origin.contains(target)) {
10852
+ this.close();
10853
+ }
10854
+ });
10855
+ return this._overlayRef;
10856
+ }
10857
+ /** Generates the list of options from which the user can select.. */
10858
+ _generateOptions() {
10859
+ // Default the interval to 30 minutes.
10860
+ this._timeOptions = [
10861
+ { value: '1', label: '1' },
10862
+ { value: '2', label: '2' },
10863
+ { value: '3', label: '3' },
10864
+ { value: '4', label: '4' },
10865
+ { value: '5', label: '5' },
10866
+ { value: '6', label: '6' },
10867
+ ];
10868
+ }
10869
+ /**
10870
+ * Synchronizes the internal state of the component based on a specific selected date.
10871
+ * @param value Currently selected date.
10872
+ * @param options Options rendered out in the timepicker.
10873
+ * @param fallback Option to set as active if no option is selected.
10874
+ */
10875
+ _syncSelectedState(value, options, fallback) {
10876
+ let hasSelected = false;
10877
+ for (const option of options) {
10878
+ if (value && option.value() === value) {
10879
+ option.select();
10880
+ scrollOptionIntoView(option, 'center');
10881
+ untracked(() => this._keyManager.setActiveItem(option));
10882
+ hasSelected = true;
10883
+ }
10884
+ else {
10885
+ option.deselect();
10886
+ }
10887
+ }
10888
+ // If no option was selected, we need to reset the key manager since
10889
+ // it might be holding onto an option that no longer exists.
10890
+ if (!hasSelected) {
10891
+ if (fallback) {
10892
+ untracked(() => this._keyManager.setActiveItem(fallback));
10893
+ scrollOptionIntoView(fallback, 'center');
10894
+ }
10895
+ else {
10896
+ untracked(() => this._keyManager.setActiveItem(-1));
10897
+ }
10898
+ }
10899
+ }
10900
+ /** Handles keyboard events while the overlay is open. */
10901
+ _handleKeydown(event) {
10902
+ const keyCode = event.keyCode;
10903
+ if (keyCode === TAB) {
10904
+ this.close();
10905
+ }
10906
+ else if (keyCode === ESCAPE && !hasModifierKey(event)) {
10907
+ event.preventDefault();
10908
+ this.close();
10909
+ }
10910
+ else if (keyCode === ENTER) {
10911
+ event.preventDefault();
10912
+ if (this._keyManager.activeItem) {
10913
+ this._selectValue(this._keyManager.activeItem.value() ?? '');
10914
+ }
10915
+ else {
10916
+ this.close();
10917
+ }
10918
+ }
10919
+ else {
10920
+ const previousActive = this._keyManager.activeItem;
10921
+ this._keyManager.onKeydown(event);
10922
+ const currentActive = this._keyManager.activeItem;
10923
+ if (currentActive && currentActive !== previousActive) {
10924
+ scrollOptionIntoView(currentActive, 'nearest');
10925
+ }
10926
+ }
10927
+ }
10928
+ /** Sets up the logic that updates the timepicker when the locale changes. */
10929
+ _handleLocaleChanges() {
10930
+ // Re-generate the options list if the locale changes.
10931
+ // this._localeChanges = this._dateAdapter.localeChanges.subscribe(() => {
10932
+ // this._optionsCacheKey = null;
10933
+ // if (this.isOpen()) {
10934
+ // this._generateOptions();
10935
+ // }
10936
+ // });
10937
+ }
10938
+ /**
10939
+ * Sets up the logic that updates the timepicker when the state of the connected input changes.
10940
+ */
10941
+ _handleInputStateChanges() {
10942
+ effect(() => {
10943
+ const input = this._input();
10944
+ const options = this._options();
10945
+ if (this._isOpen() && input) {
10946
+ this._syncSelectedState(input.nativeElement.value, options, null);
10947
+ }
10948
+ });
10949
+ }
10950
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScTimePicker, deps: [], target: i0.ɵɵFactoryTarget.Component });
10951
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: ScTimePicker, isStandalone: true, selector: "sc-time-picker", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "selected", opened: "opened", closed: "closed" }, host: { properties: { "class": "classes()" } }, viewQueries: [{ propertyName: "_input", first: true, predicate: ["input"], descendants: true, isSignal: true }, { propertyName: "_panelTemplate", first: true, predicate: ["panelTemplate"], descendants: true, isSignal: true }, { propertyName: "_options", predicate: ScTimeOption, descendants: true, isSignal: true }], ngImport: i0, template: `
10952
+ <button class="absolute inset-y-0 end-0 pe-4" (click)="open()" sc-button variant="ghost">
10953
+ <svg-clock-icon />
10954
+ </button>
10955
+ <input #input scTimePickerInput type="text" placeholder="Select time" />
10956
+
10957
+ <ng-template #panelTemplate>
10958
+ <div
10959
+ class="relative z-50 max-h-96 w-full min-w-32 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
10960
+ [attr.aria-label]="ariaLabel() || null"
10961
+ [attr.aria-labelledby]="_getAriaLabelledby()"
10962
+ [id]="panelId"
10963
+ role="listbox"
10964
+ >
10965
+ @for (option of _timeOptions; track option.value) {
10966
+ <sc-time-option [value]="option.value" (selected)="_selectValue(option.value)">
10967
+ {{ option.label }}
10968
+ </sc-time-option>
10969
+ }
10970
+ </div>
10971
+ </ng-template>
10972
+ `, isInline: true, styles: [""], dependencies: [{ kind: "component", type: SvgClockIcon, selector: "svg-clock-icon", inputs: ["class", "svgClass"] }, { kind: "component", type: ScButton, selector: "button[sc-button], a[sc-button]", inputs: ["variant", "size", "class"] }, { kind: "component", type: ScTimeOption, selector: "sc-time-option", inputs: ["class", "disabled", "value"], outputs: ["selected"] }, { kind: "directive", type: ScTimePickerInput, selector: "[scTimePickerInput]", inputs: ["class"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
10973
+ }
10974
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: ScTimePicker, decorators: [{
10975
+ type: Component,
10976
+ args: [{ selector: 'sc-time-picker', imports: [SvgClockIcon, ScButton, ScTimeOption, ScTimePickerInput], template: `
10977
+ <button class="absolute inset-y-0 end-0 pe-4" (click)="open()" sc-button variant="ghost">
10978
+ <svg-clock-icon />
10979
+ </button>
10980
+ <input #input scTimePickerInput type="text" placeholder="Select time" />
10981
+
10982
+ <ng-template #panelTemplate>
10983
+ <div
10984
+ class="relative z-50 max-h-96 w-full min-w-32 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
10985
+ [attr.aria-label]="ariaLabel() || null"
10986
+ [attr.aria-labelledby]="_getAriaLabelledby()"
10987
+ [id]="panelId"
10988
+ role="listbox"
10989
+ >
10990
+ @for (option of _timeOptions; track option.value) {
10991
+ <sc-time-option [value]="option.value" (selected)="_selectValue(option.value)">
10992
+ {{ option.label }}
10993
+ </sc-time-option>
10994
+ }
10995
+ </div>
10996
+ </ng-template>
10997
+ `, host: {
10998
+ '[class]': 'classes()',
10999
+ }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush }]
11000
+ }], ctorParameters: () => [] });
11001
+ /**
11002
+ * Scrolls an option into view.
11003
+ * @param option Option to be scrolled into view.
11004
+ * @param position Position to which to align the option relative to the scrollable container.
11005
+ */
11006
+ function scrollOptionIntoView(option, position) {
11007
+ option._getHostElement().scrollIntoView({ block: position, inline: position });
11008
+ }
11009
+
10473
11010
  /**
10474
11011
  * Generated bundle index. Do not edit.
10475
11012
  */
10476
11013
 
10477
- export { FormFieldCustomControlComponent, ScAccordion, ScAccordionContent, ScAccordionHeader, ScAccordionItem, ScAccordionItemDescription, ScAccordionTrigger, ScAlert, ScAlertDescription, ScAlertDialog, ScAlertTitle, ScAspectRatio, ScAutocomplete, ScAvatar, ScBadge, ScBreadcrumb, ScBreadcrumbEllipsis, ScBreadcrumbItem, ScBreadcrumbLink, ScBreadcrumbList, ScBreadcrumbPage, ScBreadcrumbSeparator, ScButton, ScCalendar, ScCard, ScCardContent, ScCardDescription, ScCardFooter, ScCardHeader, ScCardTitle, ScCarousel, ScCarouselContainer, ScCarouselItem, ScCarouselItems, ScCarouselNext, ScCarouselPrevious, ScCheckbox, ScCollapsible, ScCollapsibleContent, ScCollapsibleTrigger, ScCommand, ScCommandDialog, ScCommandEmpty, ScCommandError, ScCommandGroup, ScCommandInput, ScCommandItem, ScCommandList, ScCommandLoading, ScCommandSeparator, ScCommandShortcut, ScContextMenuTriggerFor, ScDataTable, ScDatePicker, ScDialog, ScDialogClose, ScDialogContent, ScDialogDescription, ScDialogFooter, ScDialogHeader, ScDialogTitle, ScEditor, ScFullCalendar, ScHoverCard, ScHoverCardTriggerFor, ScInput, ScInputOTPGroup, ScInputOTPSeparator, ScInputOTPSlot, ScInputOtp, ScLabel, ScMenu, ScMenuBar, ScMenuBarItem, ScMenuCheckboxGroup, ScMenuCheckboxItem, ScMenuGroup, ScMenuItem, ScMenuLabel, ScMenuRadioGroup, ScMenuRadioItem, ScMenuSeparator, ScMenuShortcut, ScMenuTriggerFor, ScNav, ScNavItem, ScNavItemDropdown, ScNavLink, ScNavList, ScOption, ScPaginator, ScPopoverTriggerFor, ScProgress, ScRadioGroup, ScRadioItem, ScScrollArea, ScSelect, ScSheet, ScSheetClose, ScSheetConfig, ScSheetTrigger, ScSidebar, ScSidebarProvider, ScSidebarState, ScSidebarToggler, ScSkeleton, ScSlider, ScSwitch, ScTab, ScTabContent, ScTabLabel, ScTable, ScTableBody, ScTableCaption, ScTableCell, ScTableContainer, ScTableFooter, ScTableHead, ScTableHeader, ScTableRow, ScTabs, ScTextarea, ScThemeToggler, ScToast, ScToastExample, ScToggle, ScTooltip, TelInputComponent, TelModel, Toaster, buttonVariants, cn, scThemeProvider };
11014
+ export { FormFieldCustomControlComponent, ScAccordion, ScAccordionContent, ScAccordionHeader, ScAccordionItem, ScAccordionItemDescription, ScAccordionTrigger, ScAlert, ScAlertDescription, ScAlertDialog, ScAlertTitle, ScAspectRatio, ScAutocomplete, ScAvatar, ScBadge, ScBreadcrumb, ScBreadcrumbEllipsis, ScBreadcrumbItem, ScBreadcrumbLink, ScBreadcrumbList, ScBreadcrumbPage, ScBreadcrumbSeparator, ScButton, ScCalendar, ScCard, ScCardContent, ScCardDescription, ScCardFooter, ScCardHeader, ScCardTitle, ScCarousel, ScCarouselContainer, ScCarouselItem, ScCarouselItems, ScCarouselNext, ScCarouselPrevious, ScCheckbox, ScCollapsible, ScCollapsibleContent, ScCollapsibleTrigger, ScCommand, ScCommandDialog, ScCommandEmpty, ScCommandError, ScCommandGroup, ScCommandInput, ScCommandItem, ScCommandList, ScCommandLoading, ScCommandSeparator, ScCommandShortcut, ScContextMenuTriggerFor, ScDataTable, ScDatePicker, ScDialog, ScDialogClose, ScDialogContent, ScDialogDescription, ScDialogFooter, ScDialogHeader, ScDialogTitle, ScEditor, ScFullCalendar, ScHoverCard, ScHoverCardTriggerFor, ScInput, ScInputOTPGroup, ScInputOTPSeparator, ScInputOTPSlot, ScInputOtp, ScLabel, ScMenu, ScMenuBar, ScMenuBarItem, ScMenuCheckboxGroup, ScMenuCheckboxItem, ScMenuGroup, ScMenuItem, ScMenuLabel, ScMenuRadioGroup, ScMenuRadioItem, ScMenuSeparator, ScMenuShortcut, ScMenuTriggerFor, ScNav, ScNavItem, ScNavItemDropdown, ScNavLink, ScNavList, ScOption, ScPaginator, ScPopoverTriggerFor, ScProgress, ScRadioGroup, ScRadioItem, ScScrollArea, ScSelect, ScSettings, ScSheet, ScSheetClose, ScSheetConfig, ScSheetTrigger, ScSidebar, ScSidebarProvider, ScSidebarState, ScSidebarToggler, ScSkeleton, ScSlider, ScSwitch, ScTab, ScTabContent, ScTabLabel, ScTable, ScTableBody, ScTableCaption, ScTableCell, ScTableContainer, ScTableFooter, ScTableHead, ScTableHeader, ScTableRow, ScTabs, ScTextarea, ScThemeToggler, ScTimePicker, ScToast, ScToastExample, ScToggle, ScTooltip, TelInputComponent, TelModel, Toaster, buttonVariants, cn, scInputStyles, scThemeProvider };
10478
11015
  //# sourceMappingURL=semantic-components-ui.mjs.map