index.d.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { ElementRef } from '@angular/core';
  2. /**
  3. * Type describing the allowed values for a boolean input.
  4. * @docs-private
  5. */
  6. export declare type BooleanInput = string | boolean | null | undefined;
  7. /** Wraps the provided value in an array, unless the provided value is an array. */
  8. export declare function coerceArray<T>(value: T | T[]): T[];
  9. export declare function coerceArray<T>(value: T | readonly T[]): readonly T[];
  10. /** Coerces a data-bound value (typically a string) to a boolean. */
  11. export declare function coerceBooleanProperty(value: any): boolean;
  12. /** Coerces a value to a CSS pixel value. */
  13. export declare function coerceCssPixelValue(value: any): string;
  14. /**
  15. * Coerces an ElementRef or an Element into an element.
  16. * Useful for APIs that can accept either a ref or the native element itself.
  17. */
  18. export declare function coerceElement<T>(elementOrRef: ElementRef<T> | T): T;
  19. /** Coerces a data-bound value (typically a string) to a number. */
  20. export declare function coerceNumberProperty(value: any): number;
  21. export declare function coerceNumberProperty<D>(value: any, fallback: D): number | D;
  22. /**
  23. * Coerces a value to an array of trimmed non-empty strings.
  24. * Any input that is not an array, `null` or `undefined` will be turned into a string
  25. * via `toString()` and subsequently split with the given separator.
  26. * `null` and `undefined` will result in an empty array.
  27. * This results in the following outcomes:
  28. * - `null` -&gt; `[]`
  29. * - `[null]` -&gt; `["null"]`
  30. * - `["a", "b ", " "]` -&gt; `["a", "b"]`
  31. * - `[1, [2, 3]]` -&gt; `["1", "2,3"]`
  32. * - `[{ a: 0 }]` -&gt; `["[object Object]"]`
  33. * - `{ a: 0 }` -&gt; `["[object", "Object]"]`
  34. *
  35. * Useful for defining CSS classes or table columns.
  36. * @param value the value to coerce into an array of strings
  37. * @param separator split-separator if value isn't an array
  38. */
  39. export declare function coerceStringArray(value: any, separator?: string | RegExp): string[];
  40. /**
  41. * Whether the provided value is considered a number.
  42. * @docs-private
  43. */
  44. export declare function _isNumberValue(value: any): boolean;
  45. /**
  46. * Type describing the allowed values for a number input
  47. * @docs-private
  48. */
  49. export declare type NumberInput = string | number | null | undefined;
  50. export { }