@skyux/core 6.0.0-beta.8 → 6.0.1

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.
@@ -116,6 +116,9 @@ class SkyCoreAdapterService {
116
116
  * @return Returns `true` if a child element with autofocus is found.
117
117
  */
118
118
  applyAutoFocus(elementRef) {
119
+ if (!elementRef) {
120
+ return false;
121
+ }
119
122
  const elementWithAutoFocus = elementRef.nativeElement.querySelector('[autofocus]');
120
123
  // Child was found with the autofocus property. Set focus and return true.
121
124
  if (elementWithAutoFocus) {
@@ -138,11 +141,13 @@ class SkyCoreAdapterService {
138
141
  */
139
142
  getFocusableChildrenAndApplyFocus(elementRef, containerSelector, focusOnContainerIfNoChildrenFound = false) {
140
143
  const containerElement = elementRef.nativeElement.querySelector(containerSelector);
141
- const focusableChildren = this.getFocusableChildren(containerElement);
142
- // Focus first focusable child if available. Otherwise, set focus on container.
143
- if (!this.focusFirstElement(focusableChildren) &&
144
- focusOnContainerIfNoChildrenFound) {
145
- containerElement.focus();
144
+ if (containerElement) {
145
+ const focusableChildren = this.getFocusableChildren(containerElement);
146
+ // Focus first focusable child if available. Otherwise, set focus on container.
147
+ if (!this.focusFirstElement(focusableChildren) &&
148
+ focusOnContainerIfNoChildrenFound) {
149
+ containerElement.focus();
150
+ }
146
151
  }
147
152
  }
148
153
  /**
@@ -152,6 +157,9 @@ class SkyCoreAdapterService {
152
157
  * @param options - Options for getting focusable children.
153
158
  */
154
159
  getFocusableChildren(element, options) {
160
+ if (!element) {
161
+ return [];
162
+ }
155
163
  let elements = Array.prototype.slice.call(element.querySelectorAll(SKY_TABBABLE_SELECTOR));
156
164
  // Unless ignoreTabIndex = true, filter out elements with tabindex = -1.
157
165
  if (!options || !options.ignoreTabIndex) {
@@ -1700,42 +1708,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
1700
1708
 
1701
1709
  /**
1702
1710
  * Provides arguments for the number to format.
1711
+ * @deprecated Use the `SkyNumericOptions` interface instead.
1703
1712
  */
1704
1713
  class NumericOptions {
1705
1714
  constructor() {
1706
- /**
1707
- * Specifies the maximum number of digits after the decimal separator.
1708
- * @default 1
1709
- */
1710
1715
  this.digits = 1;
1711
- /**
1712
- * Specifies how to format the number. Options are `currency` or `number`.
1713
- * @default "number"
1714
- */
1715
1716
  this.format = 'number';
1716
- /**
1717
- * Specifies the format of the currency.
1718
- * @default "standard"
1719
- */
1720
1717
  this.currencySign = 'standard';
1721
- /**
1722
- * Specifies the ISO4217 currency code to use for currency formatting. If you do not specify a
1723
- * currency code, the component uses the browser's culture to determine the currency unless your
1724
- * SPA provides a different culture with `SkyAppLocaleProvider`.
1725
- * @default "USD"
1726
- */
1727
1718
  this.iso = 'USD';
1728
- /**
1729
- * Indicates whether to shorten numbers to rounded numbers and abbreviation characters
1730
- * such as K for thousands, M for millions, B for billions, and T for trillions.
1731
- */
1732
1719
  this.truncate = true;
1733
- /**
1734
- * Specifies the starting point after which numbers are shortened to rounded numbers
1735
- * and abbreviation characters.
1736
- * @default 0
1737
- */
1738
- this.truncateAfter = 0;
1720
+ this.truncateAfter = 1000;
1739
1721
  }
1740
1722
  }
1741
1723
 
@@ -1827,7 +1809,7 @@ class SkyNumericService {
1827
1809
  return this._locale || 'en-US';
1828
1810
  }
1829
1811
  /**
1830
- * Shortens with or without symbol (K/M/B/T) depending on value of number.
1812
+ * Formats a number based on the provided options.
1831
1813
  * @param value The number to format.
1832
1814
  * @param options Format options.
1833
1815
  */
@@ -1992,10 +1974,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
1992
1974
  * M for millions, B for billions, and T for trillions. The pipe also formats for currency.
1993
1975
  * Be sure you have a space after the two curly brackets opening the pipe and
1994
1976
  * a space before the two curly brackets closing the pipe or it will not work.
1995
- * Usage:
1996
- * ```
1997
- * {{ value | skyNumeric(config) }}
1998
- * ```
1999
1977
  */
2000
1978
  class SkyNumericPipe {
2001
1979
  constructor(localeProvider, numericService, changeDetector) {
@@ -2016,6 +1994,9 @@ class SkyNumericPipe {
2016
1994
  this.ngUnsubscribe.next();
2017
1995
  this.ngUnsubscribe.complete();
2018
1996
  }
1997
+ /**
1998
+ * Formats a number based on the provided options.
1999
+ */
2019
2000
  transform(value, config) {
2020
2001
  const newCacheKey = (config ? JSON.stringify(config, Object.keys(config).sort()) : '') +
2021
2002
  `${value}_${config?.locale || this.providerLocale}`;
@@ -2573,7 +2554,7 @@ class SkyResizeObserverMediaQueryService {
2573
2554
  this.resizeObserverService = resizeObserverService;
2574
2555
  this._breakpoints = [
2575
2556
  {
2576
- check: (width) => width <= 767,
2557
+ check: (width) => width > 0 && width <= 767,
2577
2558
  name: SkyMediaBreakpoints.xs,
2578
2559
  },
2579
2560
  {
@@ -2626,11 +2607,7 @@ class SkyResizeObserverMediaQueryService {
2626
2607
  this._stopListening.next();
2627
2608
  }
2628
2609
  this._target = element;
2629
- const width = element.nativeElement.offsetWidth;
2630
- if (width) {
2631
- const breakpoint = this.checkBreakpoint(width);
2632
- this.updateBreakpoint(breakpoint);
2633
- }
2610
+ this.checkWidth(element);
2634
2611
  this.resizeObserverService
2635
2612
  .observe(element)
2636
2613
  .pipe(takeUntil(this._stopListening))
@@ -2655,7 +2632,9 @@ class SkyResizeObserverMediaQueryService {
2655
2632
  subscribe(listener) {
2656
2633
  return this._currentBreakpointObservable
2657
2634
  .pipe(takeUntil(this._stopListening))
2658
- .subscribe(listener);
2635
+ .subscribe((value) => {
2636
+ listener(value);
2637
+ });
2659
2638
  }
2660
2639
  updateBreakpoint(breakpoint) {
2661
2640
  this._currentBreakpoint = breakpoint;
@@ -2665,6 +2644,14 @@ class SkyResizeObserverMediaQueryService {
2665
2644
  return this._breakpoints.find((breakpoint) => breakpoint.check(width))
2666
2645
  ?.name;
2667
2646
  }
2647
+ checkWidth(element) {
2648
+ const width = element.nativeElement.offsetWidth || 0;
2649
+ const breakpoint = this.checkBreakpoint(width);
2650
+ /* istanbul ignore else */
2651
+ if (breakpoint !== this._currentBreakpoint) {
2652
+ this.updateBreakpoint(breakpoint);
2653
+ }
2654
+ }
2668
2655
  }
2669
2656
  SkyResizeObserverMediaQueryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: SkyResizeObserverMediaQueryService, deps: [{ token: SkyResizeObserverService }], target: i0.ɵɵFactoryTarget.Injectable });
2670
2657
  SkyResizeObserverMediaQueryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: SkyResizeObserverMediaQueryService, providedIn: 'any' });