@ferrlabs/ui-ng 1.39.0 → 1.40.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,6 +1,6 @@
1
1
  import { DOCUMENT, Location, NgTemplateOutlet } from "@angular/common";
2
2
  import * as i0 from "@angular/core";
3
- import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injectable, InjectionToken, LOCALE_ID, ViewContainerRef, ViewEncapsulation, afterRenderEffect, computed, contentChildren, effect, forwardRef, inject, input, makeEnvironmentProviders, model, output, signal, untracked, viewChild } from "@angular/core";
3
+ import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injectable, InjectionToken, LOCALE_ID, ViewContainerRef, ViewEncapsulation, afterNextRender, afterRenderEffect, computed, contentChildren, effect, forwardRef, inject, input, makeEnvironmentProviders, model, output, signal, untracked, viewChild, viewChildren } from "@angular/core";
4
4
  import * as i1$1 from "@angular/forms";
5
5
  import { FormsModule, NG_VALUE_ACCESSOR } from "@angular/forms";
6
6
  import * as i1$2 from "@angular/cdk/a11y";
@@ -13574,6 +13574,17 @@ var SegmentedComponent = class SegmentedComponent {
13574
13574
  ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
13575
13575
  alias: "aria-label"
13576
13576
  });
13577
+ this.group = viewChild.required("group", ...ngDevMode ? [{ debugName: "group" }] : /* istanbul ignore next */ []);
13578
+ this.thumb = viewChild.required("thumb", ...ngDevMode ? [{ debugName: "thumb" }] : /* istanbul ignore next */ []);
13579
+ this.buttons = viewChildren("optionButton", ...ngDevMode ? [{ debugName: "buttons" }] : /* istanbul ignore next */ []);
13580
+ this.selectedIndex = computed(() => this.options().findIndex((o) => o.value === this.value()), ...ngDevMode ? [{ debugName: "selectedIndex" }] : /* istanbul ignore next */ []);
13581
+ afterRenderEffect(() => this.placeThumb(this.selectedIndex()));
13582
+ const destroyRef = inject(DestroyRef);
13583
+ afterNextRender(() => {
13584
+ const observer = new ResizeObserver(() => this.placeThumb(this.selectedIndex()));
13585
+ observer.observe(this.group().nativeElement);
13586
+ destroyRef.onDestroy(() => observer.disconnect());
13587
+ });
13577
13588
  }
13578
13589
  trustedIcon(markup) {
13579
13590
  return markup && isTrustedIconMarkup(markup) ? this.sanitizer.bypassSecurityTrustHtml(markup) : null;
@@ -13581,7 +13592,7 @@ var SegmentedComponent = class SegmentedComponent {
13581
13592
  select(option) {
13582
13593
  this.value.set(option.value);
13583
13594
  }
13584
- handleKeydown(event, index, buttons) {
13595
+ handleKeydown(event, index) {
13585
13596
  const options = this.options();
13586
13597
  const step = {
13587
13598
  ArrowRight: 1,
@@ -13593,7 +13604,22 @@ var SegmentedComponent = class SegmentedComponent {
13593
13604
  event.preventDefault();
13594
13605
  const next = (index + step + options.length) % options.length;
13595
13606
  this.value.set(options[next].value);
13596
- buttons.querySelectorAll("button")[next]?.focus();
13607
+ this.buttons()[next]?.nativeElement.focus();
13608
+ }
13609
+ placeThumb(index) {
13610
+ const thumb = this.thumb().nativeElement;
13611
+ const button = this.buttons()[index]?.nativeElement;
13612
+ if (!button || button.offsetWidth === 0) {
13613
+ thumb.hidden = true;
13614
+ return;
13615
+ }
13616
+ thumb.style.width = `${button.offsetWidth}px`;
13617
+ thumb.style.transform = `translateX(${button.offsetLeft}px)`;
13618
+ if (thumb.hidden) {
13619
+ thumb.hidden = false;
13620
+ return;
13621
+ }
13622
+ thumb.classList.add("flr-seg__thumb--animated");
13597
13623
  }
13598
13624
  static {
13599
13625
  this.ɵfac = i0.ɵɵngDeclareFactory({
@@ -13643,9 +13669,31 @@ var SegmentedComponent = class SegmentedComponent {
13643
13669
  }
13644
13670
  },
13645
13671
  outputs: { value: "valueChange" },
13672
+ viewQueries: [
13673
+ {
13674
+ propertyName: "group",
13675
+ first: true,
13676
+ predicate: ["group"],
13677
+ descendants: true,
13678
+ isSignal: true
13679
+ },
13680
+ {
13681
+ propertyName: "thumb",
13682
+ first: true,
13683
+ predicate: ["thumb"],
13684
+ descendants: true,
13685
+ isSignal: true
13686
+ },
13687
+ {
13688
+ propertyName: "buttons",
13689
+ predicate: ["optionButton"],
13690
+ descendants: true,
13691
+ isSignal: true
13692
+ }
13693
+ ],
13646
13694
  ngImport: i0,
13647
- template: "<div #group class=\"flr-seg\" role=\"radiogroup\" [attr.aria-label]=\"ariaLabel()\">\n @for (option of options(); track option.value; let i = $index) {\n @let selected = option.value === value();\n <button\n type=\"button\"\n role=\"radio\"\n class=\"flr-seg__option\"\n [class.flr-seg__option--selected]=\"selected\"\n [class.flr-seg__option--icon-only]=\"iconOnly() && option.icon\"\n [attr.aria-checked]=\"selected\"\n [attr.aria-label]=\"iconOnly() && option.icon ? option.label : null\"\n [attr.title]=\"iconOnly() && option.icon ? option.label : null\"\n [tabindex]=\"selected ? 0 : -1\"\n (click)=\"select(option)\"\n (keydown)=\"handleKeydown($event, i, group)\"\n >\n @let icon = trustedIcon(option.icon);\n @if (icon) {\n <span class=\"flr-seg__icon\" aria-hidden=\"true\" [innerHTML]=\"icon\"></span>\n }\n @if (!iconOnly() || !icon) {\n <span>{{ option.label }}</span>\n }\n </button>\n }\n</div>\n",
13648
- styles: [":host{display:inline-block}.flr-seg{display:inline-flex;gap:2px;padding:3px;border:1px solid var(--color-rule, rgba(30, 41, 59, .14));border-radius:10px;background:var(--color-app-bg-2, #f4f4f2)}.flr-seg__option{display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 12px;border:0;border-radius:7px;background:transparent;color:var(--color-ink-3, #64748b);font:inherit;font-size:13px;cursor:pointer;transition:color .12s ease,background-color .12s ease}.flr-seg__option:hover{color:var(--color-ink, #1e293b)}.flr-seg__option:focus-visible{outline:2px solid var(--color-accent, currentColor);outline-offset:1px}.flr-seg__option--selected{background:var(--color-card, #ffffff);color:var(--color-ink, #1e293b);box-shadow:0 1px 2px #1e293b1f}.flr-seg__option--icon-only{width:30px;padding:0;justify-content:center}.flr-seg__icon{display:inline-flex}.flr-seg__icon ::ng-deep svg{width:16px;height:16px}\n"],
13695
+ template: "<div #group class=\"flr-seg\" role=\"radiogroup\" [attr.aria-label]=\"ariaLabel()\">\n <span #thumb class=\"flr-seg__thumb\" aria-hidden=\"true\" hidden></span>\n @for (option of options(); track option.value; let i = $index) {\n @let selected = option.value === value();\n <button\n #optionButton\n type=\"button\"\n role=\"radio\"\n class=\"flr-seg__option\"\n [class.flr-seg__option--selected]=\"selected\"\n [class.flr-seg__option--icon-only]=\"iconOnly() && option.icon\"\n [attr.aria-checked]=\"selected\"\n [attr.aria-label]=\"iconOnly() && option.icon ? option.label : null\"\n [attr.title]=\"iconOnly() && option.icon ? option.label : null\"\n [tabindex]=\"selected ? 0 : -1\"\n (click)=\"select(option)\"\n (keydown)=\"handleKeydown($event, i)\"\n >\n @let icon = trustedIcon(option.icon);\n @if (icon) {\n <span class=\"flr-seg__icon\" aria-hidden=\"true\" [innerHTML]=\"icon\"></span>\n }\n @if (!iconOnly() || !icon) {\n <span>{{ option.label }}</span>\n }\n </button>\n }\n</div>\n",
13696
+ styles: [":host{display:inline-block}.flr-seg{position:relative;display:inline-flex;overflow:hidden;gap:2px;padding:3px;border:1px solid var(--color-rule, rgba(30, 41, 59, .14));border-radius:10px;background:var(--color-app-bg-2, #f4f4f2)}.flr-seg__thumb{position:absolute;top:3px;bottom:3px;left:0;border-radius:7px;background:var(--color-card, #ffffff);box-shadow:0 1px 2px #1e293b1f;pointer-events:none}.flr-seg__thumb[hidden]{display:none}.flr-seg__thumb--animated{transition:transform .26s cubic-bezier(.3,0,0,1),width .26s cubic-bezier(.3,0,0,1)}@media(prefers-reduced-motion:reduce){.flr-seg__thumb--animated{transition:none}}.flr-seg__option{position:relative;display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 12px;border:0;border-radius:7px;background:transparent;color:var(--color-ink-3, #64748b);font:inherit;font-size:13px;cursor:pointer;transition:color .12s ease,background-color .12s ease}.flr-seg__option:hover{color:var(--color-ink, #1e293b)}.flr-seg__option:focus-visible{outline:2px solid var(--color-accent, currentColor);outline-offset:-2px}.flr-seg__option--selected{color:var(--color-ink, #1e293b)}.flr-seg__option--icon-only{width:30px;padding:0;justify-content:center}.flr-seg__icon{display:inline-flex}.flr-seg__icon ::ng-deep svg{width:16px;height:16px}\n"],
13649
13697
  changeDetection: i0.ChangeDetectionStrategy.OnPush
13650
13698
  });
13651
13699
  }
@@ -13660,10 +13708,11 @@ i0.ɵɵngDeclareClassMetadata({
13660
13708
  args: [{
13661
13709
  selector: "flr-segmented",
13662
13710
  changeDetection: ChangeDetectionStrategy.OnPush,
13663
- template: "<div #group class=\"flr-seg\" role=\"radiogroup\" [attr.aria-label]=\"ariaLabel()\">\n @for (option of options(); track option.value; let i = $index) {\n @let selected = option.value === value();\n <button\n type=\"button\"\n role=\"radio\"\n class=\"flr-seg__option\"\n [class.flr-seg__option--selected]=\"selected\"\n [class.flr-seg__option--icon-only]=\"iconOnly() && option.icon\"\n [attr.aria-checked]=\"selected\"\n [attr.aria-label]=\"iconOnly() && option.icon ? option.label : null\"\n [attr.title]=\"iconOnly() && option.icon ? option.label : null\"\n [tabindex]=\"selected ? 0 : -1\"\n (click)=\"select(option)\"\n (keydown)=\"handleKeydown($event, i, group)\"\n >\n @let icon = trustedIcon(option.icon);\n @if (icon) {\n <span class=\"flr-seg__icon\" aria-hidden=\"true\" [innerHTML]=\"icon\"></span>\n }\n @if (!iconOnly() || !icon) {\n <span>{{ option.label }}</span>\n }\n </button>\n }\n</div>\n",
13664
- styles: [":host{display:inline-block}.flr-seg{display:inline-flex;gap:2px;padding:3px;border:1px solid var(--color-rule, rgba(30, 41, 59, .14));border-radius:10px;background:var(--color-app-bg-2, #f4f4f2)}.flr-seg__option{display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 12px;border:0;border-radius:7px;background:transparent;color:var(--color-ink-3, #64748b);font:inherit;font-size:13px;cursor:pointer;transition:color .12s ease,background-color .12s ease}.flr-seg__option:hover{color:var(--color-ink, #1e293b)}.flr-seg__option:focus-visible{outline:2px solid var(--color-accent, currentColor);outline-offset:1px}.flr-seg__option--selected{background:var(--color-card, #ffffff);color:var(--color-ink, #1e293b);box-shadow:0 1px 2px #1e293b1f}.flr-seg__option--icon-only{width:30px;padding:0;justify-content:center}.flr-seg__icon{display:inline-flex}.flr-seg__icon ::ng-deep svg{width:16px;height:16px}\n"]
13711
+ template: "<div #group class=\"flr-seg\" role=\"radiogroup\" [attr.aria-label]=\"ariaLabel()\">\n <span #thumb class=\"flr-seg__thumb\" aria-hidden=\"true\" hidden></span>\n @for (option of options(); track option.value; let i = $index) {\n @let selected = option.value === value();\n <button\n #optionButton\n type=\"button\"\n role=\"radio\"\n class=\"flr-seg__option\"\n [class.flr-seg__option--selected]=\"selected\"\n [class.flr-seg__option--icon-only]=\"iconOnly() && option.icon\"\n [attr.aria-checked]=\"selected\"\n [attr.aria-label]=\"iconOnly() && option.icon ? option.label : null\"\n [attr.title]=\"iconOnly() && option.icon ? option.label : null\"\n [tabindex]=\"selected ? 0 : -1\"\n (click)=\"select(option)\"\n (keydown)=\"handleKeydown($event, i)\"\n >\n @let icon = trustedIcon(option.icon);\n @if (icon) {\n <span class=\"flr-seg__icon\" aria-hidden=\"true\" [innerHTML]=\"icon\"></span>\n }\n @if (!iconOnly() || !icon) {\n <span>{{ option.label }}</span>\n }\n </button>\n }\n</div>\n",
13712
+ styles: [":host{display:inline-block}.flr-seg{position:relative;display:inline-flex;overflow:hidden;gap:2px;padding:3px;border:1px solid var(--color-rule, rgba(30, 41, 59, .14));border-radius:10px;background:var(--color-app-bg-2, #f4f4f2)}.flr-seg__thumb{position:absolute;top:3px;bottom:3px;left:0;border-radius:7px;background:var(--color-card, #ffffff);box-shadow:0 1px 2px #1e293b1f;pointer-events:none}.flr-seg__thumb[hidden]{display:none}.flr-seg__thumb--animated{transition:transform .26s cubic-bezier(.3,0,0,1),width .26s cubic-bezier(.3,0,0,1)}@media(prefers-reduced-motion:reduce){.flr-seg__thumb--animated{transition:none}}.flr-seg__option{position:relative;display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 12px;border:0;border-radius:7px;background:transparent;color:var(--color-ink-3, #64748b);font:inherit;font-size:13px;cursor:pointer;transition:color .12s ease,background-color .12s ease}.flr-seg__option:hover{color:var(--color-ink, #1e293b)}.flr-seg__option:focus-visible{outline:2px solid var(--color-accent, currentColor);outline-offset:-2px}.flr-seg__option--selected{color:var(--color-ink, #1e293b)}.flr-seg__option--icon-only{width:30px;padding:0;justify-content:center}.flr-seg__icon{display:inline-flex}.flr-seg__icon ::ng-deep svg{width:16px;height:16px}\n"]
13665
13713
  }]
13666
13714
  }],
13715
+ ctorParameters: () => [],
13667
13716
  propDecorators: {
13668
13717
  options: [{
13669
13718
  type: i0.Input,
@@ -13699,6 +13748,18 @@ i0.ɵɵngDeclareClassMetadata({
13699
13748
  alias: "aria-label",
13700
13749
  required: false
13701
13750
  }]
13751
+ }],
13752
+ group: [{
13753
+ type: i0.ViewChild,
13754
+ args: ["group", { isSignal: true }]
13755
+ }],
13756
+ thumb: [{
13757
+ type: i0.ViewChild,
13758
+ args: ["thumb", { isSignal: true }]
13759
+ }],
13760
+ buttons: [{
13761
+ type: i0.ViewChildren,
13762
+ args: ["optionButton", { isSignal: true }]
13702
13763
  }]
13703
13764
  }
13704
13765
  });