@tolle_/tolle-ui 0.0.29-beta → 0.0.30-beta

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 { Component, Input, forwardRef, ViewChild, Injectable, Optional, HostListener, ContentChildren, EventEmitter, Output, Directive, inject, PLATFORM_ID, Inject, InjectionToken, APP_INITIALIZER, ChangeDetectorRef, ChangeDetectionStrategy, TemplateRef, Injector, HostBinding } from '@angular/core';
4
+ import { Component, Input, forwardRef, ViewChild, Injectable, Optional, HostListener, ContentChildren, EventEmitter, Output, Directive, inject, PLATFORM_ID, Inject, InjectionToken, APP_INITIALIZER, ChangeDetectorRef, ChangeDetectionStrategy, TemplateRef, Injector, HostBinding, ViewChildren } from '@angular/core';
5
5
  import * as i1 from '@angular/common';
6
6
  import { CommonModule, isPlatformBrowser, DOCUMENT, NgIf, NgTemplateOutlet } from '@angular/common';
7
7
  import { cva } from 'class-variance-authority';
@@ -2563,10 +2563,7 @@ class CalendarComponent {
2563
2563
  if (this.minDate && isBefore(date, this.minDate)) {
2564
2564
  return true;
2565
2565
  }
2566
- if (this.maxDate && isBefore(this.maxDate, date)) {
2567
- return true;
2568
- }
2569
- return false;
2566
+ return !!(this.maxDate && isBefore(this.maxDate, date));
2570
2567
  }
2571
2568
  isTodayDisabled() {
2572
2569
  return this.isDateDisabled(new Date());
@@ -6447,6 +6444,192 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
6447
6444
  type: Input
6448
6445
  }] } });
6449
6446
 
6447
+ class SegmentedComponent {
6448
+ cdr;
6449
+ items = [];
6450
+ class = '';
6451
+ disabled = false;
6452
+ itemTemplate; // Allow custom content
6453
+ value = null;
6454
+ gliderLeft = 0;
6455
+ gliderWidth = 0;
6456
+ hasValue = false;
6457
+ itemElements;
6458
+ onChange = () => { };
6459
+ onTouched = () => { };
6460
+ constructor(cdr) {
6461
+ this.cdr = cdr;
6462
+ }
6463
+ ngAfterViewInit() {
6464
+ setTimeout(() => this.updateGlider());
6465
+ }
6466
+ ngOnChanges(changes) {
6467
+ // Recalculate if items change or if value changes externally
6468
+ if (changes['items'] && !changes['items'].firstChange) {
6469
+ setTimeout(() => this.updateGlider());
6470
+ }
6471
+ }
6472
+ select(val) {
6473
+ if (this.disabled)
6474
+ return;
6475
+ const item = this.items.find(i => i.value === val);
6476
+ if (item?.disabled)
6477
+ return;
6478
+ this.value = val;
6479
+ this.onChange(val);
6480
+ this.onTouched();
6481
+ this.updateGlider();
6482
+ }
6483
+ updateGlider() {
6484
+ if (!this.itemElements || !this.items.length)
6485
+ return;
6486
+ const index = this.items.findIndex(i => i.value === this.value);
6487
+ if (index === -1) {
6488
+ this.hasValue = false;
6489
+ this.gliderWidth = 0;
6490
+ return;
6491
+ }
6492
+ const activeElement = this.itemElements.get(index)?.nativeElement;
6493
+ if (activeElement) {
6494
+ this.hasValue = true;
6495
+ this.gliderLeft = activeElement.offsetLeft;
6496
+ this.gliderWidth = activeElement.offsetWidth;
6497
+ this.cdr.detectChanges();
6498
+ }
6499
+ }
6500
+ // CVA Implementation
6501
+ writeValue(val) {
6502
+ this.value = val;
6503
+ setTimeout(() => this.updateGlider());
6504
+ }
6505
+ registerOnChange(fn) { this.onChange = fn; }
6506
+ registerOnTouched(fn) { this.onTouched = fn; }
6507
+ setDisabledState(isDisabled) {
6508
+ this.disabled = isDisabled;
6509
+ this.cdr.markForCheck();
6510
+ }
6511
+ cn = cn;
6512
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: SegmentedComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
6513
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: SegmentedComponent, isStandalone: true, selector: "tolle-segment", inputs: { items: "items", class: "class", disabled: "disabled", itemTemplate: "itemTemplate" }, providers: [
6514
+ {
6515
+ provide: NG_VALUE_ACCESSOR,
6516
+ useExisting: forwardRef(() => SegmentedComponent),
6517
+ multi: true
6518
+ }
6519
+ ], viewQueries: [{ propertyName: "itemElements", predicate: ["itemEls"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
6520
+ <div
6521
+ #container
6522
+ [class]="cn(
6523
+ 'relative flex items-center p-1 bg-muted rounded-lg select-none w-full gap-1',
6524
+ class
6525
+ )"
6526
+ role="tablist"
6527
+ >
6528
+ <div
6529
+ class="absolute top-1 bottom-1 bg-background shadow-sm rounded-md transition-all duration-300 ease-[cubic-bezier(0.2,0.0,0.2,1)]"
6530
+ [style.left.px]="gliderLeft"
6531
+ [style.width.px]="gliderWidth"
6532
+ [class.opacity-0]="!hasValue"
6533
+ ></div>
6534
+
6535
+ <button
6536
+ *ngFor="let item of items"
6537
+ #itemEls
6538
+ type="button"
6539
+ role="tab"
6540
+ [disabled]="item.disabled || disabled"
6541
+ [attr.aria-selected]="value === item.value"
6542
+ (click)="select(item.value)"
6543
+ [class]="cn(
6544
+ 'relative z-10 flex-1 px-3 py-1.5 text-sm font-medium transition-colors duration-200 rounded-md text-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
6545
+ 'flex items-center justify-center gap-2',
6546
+ value === item.value
6547
+ ? 'text-foreground'
6548
+ : 'text-muted-foreground hover:text-foreground/70',
6549
+ item.disabled && 'opacity-50 cursor-not-allowed',
6550
+ item.class
6551
+ )"
6552
+ >
6553
+ <ng-container *ngIf="itemTemplate; else defaultContent">
6554
+ <ng-container *ngTemplateOutlet="itemTemplate; context: { $implicit: item, selected: value === item.value }">
6555
+ </ng-container>
6556
+ </ng-container>
6557
+
6558
+ <ng-template #defaultContent>
6559
+ <i *ngIf="item.icon" [class]="item.icon"></i>
6560
+ <span class="truncate">{{ item.label }}</span>
6561
+ </ng-template>
6562
+ </button>
6563
+ </div>
6564
+ `, isInline: true, styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }] });
6565
+ }
6566
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: SegmentedComponent, decorators: [{
6567
+ type: Component,
6568
+ args: [{ selector: 'tolle-segment', standalone: true, imports: [CommonModule, FormsModule], providers: [
6569
+ {
6570
+ provide: NG_VALUE_ACCESSOR,
6571
+ useExisting: forwardRef(() => SegmentedComponent),
6572
+ multi: true
6573
+ }
6574
+ ], template: `
6575
+ <div
6576
+ #container
6577
+ [class]="cn(
6578
+ 'relative flex items-center p-1 bg-muted rounded-lg select-none w-full gap-1',
6579
+ class
6580
+ )"
6581
+ role="tablist"
6582
+ >
6583
+ <div
6584
+ class="absolute top-1 bottom-1 bg-background shadow-sm rounded-md transition-all duration-300 ease-[cubic-bezier(0.2,0.0,0.2,1)]"
6585
+ [style.left.px]="gliderLeft"
6586
+ [style.width.px]="gliderWidth"
6587
+ [class.opacity-0]="!hasValue"
6588
+ ></div>
6589
+
6590
+ <button
6591
+ *ngFor="let item of items"
6592
+ #itemEls
6593
+ type="button"
6594
+ role="tab"
6595
+ [disabled]="item.disabled || disabled"
6596
+ [attr.aria-selected]="value === item.value"
6597
+ (click)="select(item.value)"
6598
+ [class]="cn(
6599
+ 'relative z-10 flex-1 px-3 py-1.5 text-sm font-medium transition-colors duration-200 rounded-md text-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
6600
+ 'flex items-center justify-center gap-2',
6601
+ value === item.value
6602
+ ? 'text-foreground'
6603
+ : 'text-muted-foreground hover:text-foreground/70',
6604
+ item.disabled && 'opacity-50 cursor-not-allowed',
6605
+ item.class
6606
+ )"
6607
+ >
6608
+ <ng-container *ngIf="itemTemplate; else defaultContent">
6609
+ <ng-container *ngTemplateOutlet="itemTemplate; context: { $implicit: item, selected: value === item.value }">
6610
+ </ng-container>
6611
+ </ng-container>
6612
+
6613
+ <ng-template #defaultContent>
6614
+ <i *ngIf="item.icon" [class]="item.icon"></i>
6615
+ <span class="truncate">{{ item.label }}</span>
6616
+ </ng-template>
6617
+ </button>
6618
+ </div>
6619
+ `, styles: [":host{display:block}\n"] }]
6620
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { items: [{
6621
+ type: Input
6622
+ }], class: [{
6623
+ type: Input
6624
+ }], disabled: [{
6625
+ type: Input
6626
+ }], itemTemplate: [{
6627
+ type: Input
6628
+ }], itemElements: [{
6629
+ type: ViewChildren,
6630
+ args: ['itemEls']
6631
+ }] } });
6632
+
6450
6633
  /*
6451
6634
  * Public API Surface of tolle
6452
6635
  */
@@ -6455,5 +6638,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
6455
6638
  * Generated bundle index. Do not edit.
6456
6639
  */
6457
6640
 
6458
- export { AccordionComponent, AccordionItemComponent, AlertComponent, AvatarComponent, AvatarFallbackComponent, BadgeComponent, BreadcrumbComponent, BreadcrumbItemComponent, BreadcrumbLinkComponent, BreadcrumbSeparatorComponent, ButtonComponent, ButtonGroupComponent, CalendarComponent, CardComponent, CardContentComponent, CardFooterComponent, CardHeaderComponent, CardTitleComponent, CheckboxComponent, DataTableComponent, DatePickerComponent, DateRangePickerComponent, DropdownItemComponent, DropdownLabelComponent, DropdownMenuComponent, DropdownSeparatorComponent, DropdownTriggerDirective, EmptyStateComponent, InputComponent, MaskedInputComponent, Modal, ModalComponent, ModalRef, ModalService, ModalStackService, MultiSelectComponent, OtpComponent, OtpGroupComponent, OtpSlotComponent, PaginationComponent, PopoverComponent, PopoverContentComponent, RadioGroupComponent, RadioItemComponent, RangeCalendarComponent, SelectComponent, SelectGroupComponent, SelectItemComponent, SelectSeparatorComponent, SkeletonComponent, SwitchComponent, TOLLE_CONFIG, TextareaComponent, ThemeService, ToastContainerComponent, ToastService, TolleCellDirective, TooltipDirective, cn, provideTolleConfig };
6641
+ export { AccordionComponent, AccordionItemComponent, AlertComponent, AvatarComponent, AvatarFallbackComponent, BadgeComponent, BreadcrumbComponent, BreadcrumbItemComponent, BreadcrumbLinkComponent, BreadcrumbSeparatorComponent, ButtonComponent, ButtonGroupComponent, CalendarComponent, CardComponent, CardContentComponent, CardFooterComponent, CardHeaderComponent, CardTitleComponent, CheckboxComponent, DataTableComponent, DatePickerComponent, DateRangePickerComponent, DropdownItemComponent, DropdownLabelComponent, DropdownMenuComponent, DropdownSeparatorComponent, DropdownTriggerDirective, EmptyStateComponent, InputComponent, MaskedInputComponent, Modal, ModalComponent, ModalRef, ModalService, ModalStackService, MultiSelectComponent, OtpComponent, OtpGroupComponent, OtpSlotComponent, PaginationComponent, PopoverComponent, PopoverContentComponent, RadioGroupComponent, RadioItemComponent, RangeCalendarComponent, SegmentedComponent, SelectComponent, SelectGroupComponent, SelectItemComponent, SelectSeparatorComponent, SkeletonComponent, SwitchComponent, TOLLE_CONFIG, TextareaComponent, ThemeService, ToastContainerComponent, ToastService, TolleCellDirective, TooltipDirective, cn, provideTolleConfig };
6459
6642
  //# sourceMappingURL=tolle-ui.mjs.map