@flusys/ng-ui 9.1.2 → 9.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.
@@ -724,6 +724,9 @@ const PRESET_NAMES = [
724
724
  function setVar(name, value, root) {
725
725
  root.style.setProperty(name, value);
726
726
  }
727
+ function ownEntry(record, key) {
728
+ return key != null && Object.hasOwn(record, key) ? record[key] : void 0;
729
+ }
727
730
  function applyPrimaryPalette(palette, isDark = false, root = document.documentElement) {
728
731
  for (const shade of [
729
732
  "50",
@@ -898,12 +901,12 @@ function getAppliedTheme() {
898
901
  function applyTheme(options, root = document.documentElement) {
899
902
  appliedTheme = { ...options };
900
903
  const presetName = options.preset ?? "Aura";
901
- const preset = PRESETS[presetName] ?? PRESETS["Aura"];
904
+ const preset = ownEntry(PRESETS, presetName) ?? PRESETS["Aura"];
902
905
  const primaryName = options.primary ?? "violet";
903
906
  const surfaceName = options.surface;
904
907
  const isDark = options.darkTheme ?? false;
905
- const primaryPalette = primaryName === "noir" ? NOIR_PRIMARY : PRIMARY_PALETTES[primaryName] ?? PRIMARY_PALETTES["violet"];
906
- const surfacePalette = SURFACE_PALETTES[surfaceName ?? (isDark ? "zinc" : "slate")] ?? SURFACE_PALETTES["slate"];
908
+ const primaryPalette = primaryName === "noir" ? NOIR_PRIMARY : ownEntry(PRIMARY_PALETTES, primaryName) ?? PRIMARY_PALETTES["violet"];
909
+ const surfacePalette = ownEntry(SURFACE_PALETTES, surfaceName ?? (isDark ? "zinc" : "slate")) ?? SURFACE_PALETTES["slate"];
907
910
  applyPreset(preset, root);
908
911
  applySurfacePalette(surfacePalette, root);
909
912
  applyPrimaryPalette(primaryPalette, isDark, root);
@@ -950,30 +953,33 @@ function buildBootstrapPreset(envConfig) {
950
953
  };
951
954
  }
952
955
  function initializeNgUITheme(options, platformId) {
953
- if (!isPlatformBrowser(platformId)) return;
956
+ if (!isPlatformBrowser(platformId)) return null;
954
957
  let themeOptions = {};
955
958
  const themePreset = options?.theme?.preset;
956
959
  if (themePreset && typeof themePreset === "object" && "preset" in themePreset && "options" in themePreset) themeOptions = themePreset.preset;
957
960
  else if (themePreset) themeOptions = themePreset;
958
961
  const darkModeSelector = options?.theme?.options?.darkModeSelector ?? ".app-dark";
959
- const isDark = document.documentElement.classList.contains(darkModeSelector.replace(".", "")) || document.documentElement.getAttribute("class")?.includes("app-dark") === true;
962
+ const isDarkNow = () => document.documentElement.classList.contains(darkModeSelector.replace(".", "")) || document.documentElement.getAttribute("class")?.includes("app-dark") === true;
963
+ const isDark = isDarkNow();
960
964
  applyTheme({
961
965
  ...themeOptions,
962
966
  darkTheme: isDark
963
967
  });
964
968
  let wasDark = isDark;
965
- new MutationObserver(() => {
966
- const nowDark = document.documentElement.classList.contains("app-dark");
969
+ const observer = new MutationObserver(() => {
970
+ const nowDark = isDarkNow();
967
971
  if (nowDark === wasDark) return;
968
972
  wasDark = nowDark;
969
973
  applyTheme({
970
974
  ...getAppliedTheme(),
971
975
  darkTheme: nowDark
972
976
  });
973
- }).observe(document.documentElement, {
977
+ });
978
+ observer.observe(document.documentElement, {
974
979
  attributes: true,
975
980
  attributeFilter: ["class"]
976
981
  });
982
+ return observer;
977
983
  }
978
984
  function provideNgUI(options) {
979
985
  const configOptions = {
@@ -988,8 +994,8 @@ function provideNgUI(options) {
988
994
  return config;
989
995
  }
990
996
  }, provideAppInitializer(() => {
991
- const platformId = inject(PLATFORM_ID);
992
- initializeNgUITheme(options ?? {}, platformId);
997
+ const observer = initializeNgUITheme(options ?? {}, inject(PLATFORM_ID));
998
+ if (observer) inject(DestroyRef).onDestroy(() => observer.disconnect());
993
999
  })]);
994
1000
  }
995
1001
  const BASE_Z_INDEX = 1e3;
@@ -21021,7 +21027,7 @@ var AccordionComponent = class AccordionComponent {
21021
21027
  this.value.set(wasOpen ? cur.filter((x) => x !== v) : [...cur, v]);
21022
21028
  this.emitToggle(v, wasOpen);
21023
21029
  } else {
21024
- const wasOpen = current === v;
21030
+ const wasOpen = Array.isArray(current) ? current.includes(v) : current === v;
21025
21031
  this.value.set(wasOpen ? null : v);
21026
21032
  this.emitToggle(v, wasOpen);
21027
21033
  }
@@ -21040,9 +21046,10 @@ var AccordionComponent = class AccordionComponent {
21040
21046
  if (!headers.length) return;
21041
21047
  const currentEl = document.activeElement;
21042
21048
  const currentIndex = headers.findIndex((h) => h.buttonEl() === currentEl);
21049
+ if (currentIndex < 0) return;
21043
21050
  let nextIndex = null;
21044
- if (event.key === "ArrowDown") nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % headers.length;
21045
- else if (event.key === "ArrowUp") nextIndex = currentIndex < 0 ? 0 : (currentIndex - 1 + headers.length) % headers.length;
21051
+ if (event.key === "ArrowDown") nextIndex = (currentIndex + 1) % headers.length;
21052
+ else if (event.key === "ArrowUp") nextIndex = (currentIndex - 1 + headers.length) % headers.length;
21046
21053
  else if (event.key === "Home") nextIndex = 0;
21047
21054
  else if (event.key === "End") nextIndex = headers.length - 1;
21048
21055
  if (nextIndex === null) return;
@@ -27486,6 +27493,10 @@ var AutoCompleteComponent = class AutoCompleteComponent {
27486
27493
  isDisabled = computed(() => this.disabled() || this._formDisabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
27487
27494
  constructor() {
27488
27495
  blockClicksWhileDisabled(this.isDisabled);
27496
+ inject(DestroyRef).onDestroy(() => {
27497
+ clearTimeout(this._debounce);
27498
+ clearTimeout(this._blurTimer);
27499
+ });
27489
27500
  }
27490
27501
  dropdown = input(false, {
27491
27502
  ...ngDevMode ? { debugName: "dropdown" } : /* istanbul ignore next */ {},
@@ -27578,6 +27589,7 @@ var AutoCompleteComponent = class AutoCompleteComponent {
27578
27589
  _onChange = () => {};
27579
27590
  _onTouched = () => {};
27580
27591
  _debounce;
27592
+ _blurTimer;
27581
27593
  itemRef = contentChild("item", ...ngDevMode ? [{ debugName: "itemRef" }] : /* istanbul ignore next */ []);
27582
27594
  groupRef = contentChild("group", ...ngDevMode ? [{ debugName: "groupRef" }] : /* istanbul ignore next */ []);
27583
27595
  headerRef = contentChild("header", ...ngDevMode ? [{ debugName: "headerRef" }] : /* istanbul ignore next */ []);
@@ -27660,7 +27672,7 @@ var AutoCompleteComponent = class AutoCompleteComponent {
27660
27672
  return this.open() ? "border-primary" : "border-(--f-form-field-border-color) hover:border-(--f-form-field-hover-border-color)";
27661
27673
  }, ...ngDevMode ? [{ debugName: "wrapperClass" }] : /* istanbul ignore next */ []);
27662
27674
  getLabel(item) {
27663
- if (!item) return "";
27675
+ if (item == null || item === "") return "";
27664
27676
  if (typeof item !== "object") return String(item);
27665
27677
  return String(item[this.field()] ?? item);
27666
27678
  }
@@ -27699,7 +27711,8 @@ var AutoCompleteComponent = class AutoCompleteComponent {
27699
27711
  }
27700
27712
  _handleBlur() {
27701
27713
  this.blurEvent.emit();
27702
- setTimeout(() => {
27714
+ clearTimeout(this._blurTimer);
27715
+ this._blurTimer = setTimeout(() => {
27703
27716
  if (this.forceSelection() && this.flatSuggestions().length === 0) this.query = "";
27704
27717
  this._open.set(false);
27705
27718
  this._onTouched();
@@ -27716,7 +27729,7 @@ var AutoCompleteComponent = class AutoCompleteComponent {
27716
27729
  } else if (e.key === "Enter") {
27717
27730
  e.preventDefault();
27718
27731
  const idx = this.activeIndex();
27719
- if (idx >= 0) this.selectItem(e, this.flatSuggestions()[idx]);
27732
+ if (idx >= 0 && idx < len) this.selectItem(e, this.flatSuggestions()[idx]);
27720
27733
  } else if (e.key === "Escape") this._open.set(false);
27721
27734
  else if (e.key === "Backspace" && this.multiple() && this.query === "" && this.selectedItems().length) this.removeChip(this.selectedItems().length - 1, e);
27722
27735
  }
@@ -27780,7 +27793,7 @@ var AutoCompleteComponent = class AutoCompleteComponent {
27780
27793
  if (this.multiple()) this._selectedItems.set(Array.isArray(val) ? val : []);
27781
27794
  else {
27782
27795
  this._value.set(val);
27783
- this.query = val ? this.getLabel(val) : "";
27796
+ this.query = this.getLabel(val);
27784
27797
  }
27785
27798
  }
27786
27799
  registerOnChange(fn) {
@@ -28157,6 +28170,8 @@ var AutoCompleteComponent = class AutoCompleteComponent {
28157
28170
  class="flex-1 min-w-[6rem] text-sm bg-transparent focus:outline-none text-(--f-form-field-color) placeholder:text-(--f-form-field-placeholder-color)"
28158
28171
  [placeholder]="selectedItems().length === 0 ? placeholder() : ''"
28159
28172
  [attr.aria-label]="ariaLabel() || null"
28173
+ [attr.disabled]="isDisabled() ? '' : null"
28174
+ [disabled]="isDisabled()"
28160
28175
  [(ngModel)]="query"
28161
28176
  (ngModelChange)="onQueryChange($event)"
28162
28177
  (keydown)="onKeyDown($event)"
@@ -28199,6 +28214,8 @@ var AutoCompleteComponent = class AutoCompleteComponent {
28199
28214
  [class.pr-12!]="dropdown() && showClear() && !!query"
28200
28215
  [placeholder]="placeholder()"
28201
28216
  [attr.aria-label]="ariaLabel() || null"
28217
+ [attr.disabled]="isDisabled() ? '' : null"
28218
+ [disabled]="isDisabled()"
28202
28219
  [(ngModel)]="query"
28203
28220
  (ngModelChange)="onQueryChange($event)"
28204
28221
  (keydown)="onKeyDown($event)"
@@ -28522,6 +28539,8 @@ i0.ɵɵngDeclareClassMetadata({
28522
28539
  class="flex-1 min-w-[6rem] text-sm bg-transparent focus:outline-none text-(--f-form-field-color) placeholder:text-(--f-form-field-placeholder-color)"
28523
28540
  [placeholder]="selectedItems().length === 0 ? placeholder() : ''"
28524
28541
  [attr.aria-label]="ariaLabel() || null"
28542
+ [attr.disabled]="isDisabled() ? '' : null"
28543
+ [disabled]="isDisabled()"
28525
28544
  [(ngModel)]="query"
28526
28545
  (ngModelChange)="onQueryChange($event)"
28527
28546
  (keydown)="onKeyDown($event)"
@@ -28564,6 +28583,8 @@ i0.ɵɵngDeclareClassMetadata({
28564
28583
  [class.pr-12!]="dropdown() && showClear() && !!query"
28565
28584
  [placeholder]="placeholder()"
28566
28585
  [attr.aria-label]="ariaLabel() || null"
28586
+ [attr.disabled]="isDisabled() ? '' : null"
28587
+ [disabled]="isDisabled()"
28567
28588
  [(ngModel)]="query"
28568
28589
  (ngModelChange)="onQueryChange($event)"
28569
28590
  (keydown)="onKeyDown($event)"