Module

for-angular

Angular integration for the Decaf framework

View Source lib/public-apis.ts, line 8

Classes

CrudFieldComponent

The CrudFieldComponent is a versatile form field component that adapts to different input types and CRUD operations. It extends NgxCrudFormField to inherit form handling capabilities and implements lifecycle hooks to properly initialize, render, and clean up. This component supports various input types (text, number, date, select, etc.), validation rules, and styling options, making it suitable for building dynamic forms for create, read, update, and delete operations.

Members

Object

# static constant DefaultToastOptions

Defines the standard configuration used for toast notifications when specific options are not provided. These defaults ensure a consistent appearance and behavior for toasts throughout the application.

Default configuration options for toast notifications

Properties:
Name Type Description
duration number

Duration in milliseconds the toast should be displayed (3000ms default)

position string

Position on screen where the toast appears ('top' default)

animated boolean

Whether the toast should use animations (true default)

View Source app/utils/NgxToastComponent.ts, line 3

Methods

# static generateLocaleFromString(locale, phrase) → {string}

This utility function creates a properly formatted locale string by combining a locale identifier with a phrase. It handles edge cases such as empty phrases, missing locales, and phrases that already include the locale prefix. This function is useful for ensuring consistent formatting of localized strings throughout the application.

Generates a localized string by combining locale and phrase

Parameters:
Name Type Description
locale string

The locale identifier (e.g., 'en', 'fr')

phrase string | undefined

The phrase to localize

View Source lib/helpers/utils.ts, line 215

The formatted locale string, or empty string if phrase is undefined

string

# static generateRandomValue(lengthopt, onlyNumbersopt) → {string}

This utility function creates a random string of a specified length. It can generate either alphanumeric strings (including uppercase and lowercase letters) or numeric-only strings. This is useful for creating random IDs, temporary passwords, or other random identifiers throughout the application.

Generates a random string or number of specified length

Parameters:
Name Type Attributes Default Description
length number <optional>
8

The length of the random value to generate

onlyNumbers boolean <optional>
false

Whether to generate only numeric characters

View Source lib/helpers/utils.ts, line 252

A randomly generated string of the specified length and character set

string

# static getInjectablesRegistry() → {InjectablesRegistry}

This function implements the singleton pattern for the InjectablesRegistry. It returns the existing registry instance if one exists, or creates a new instance if none exists. The registry is used to store and retrieve injectable dependencies throughout the application.

Retrieves the singleton instance of the injectables registry

View Source lib/helpers/utils.ts, line 7

The singleton injectables registry instance

InjectablesRegistry

# static getLocaleFromClassName(instance, suffixopt) → {string}

This utility function converts a class name or instance into a locale string that can be used for internationalization purposes. It handles different input types (string, function, or object) and applies formatting rules to generate a consistent locale identifier. For short names (less than 3 parts), it reverses the dot-separated string. For longer names, it uses the last part as a prefix and joins the rest with underscores.

Generates a locale string from a class name or instance

Parameters:
Name Type Attributes Description
instance string | FunctionLike | object

The input to generate the locale from (class name, constructor, or instance)

suffix string <optional>

Optional string to append to the instance name before processing

View Source lib/helpers/utils.ts, line 177

A formatted locale string derived from the input

string

# static getLocaleLanguage() → {string}

This utility function gets the current locale language based on the user's browser settings. It provides a consistent way to access the user's language preference throughout the application. The function returns the browser's navigator.language value, defaulting to 'en' if not available.

Retrieves the current locale language

View Source lib/helpers/utils.ts, line 236

The current locale language (e.g., 'en', 'fr')

string

# static getNgxToastComponent(optionsopt) → {NgxToastComponent}

This function implements the singleton pattern for the NgxToastComponent. It returns the existing instance if one exists, or creates a new instance with the provided options if none exists. This ensures that only one toast component is used throughout the application, maintaining consistent behavior and appearance.

Factory function to get the singleton toast component instance

Parameters:
Name Type Attributes Default Description
options ToastOptions <optional>
{}

Optional configuration options for the toast component

View Source app/utils/NgxToastComponent.ts, line 153

The singleton toast component instance

# static getOnWindow(key) → {unknown|undefined}

This function provides a safe way to access properties on the window object. It uses the getWindow function to get a reference to the window, then accesses the specified property. This is useful for browser environment interactions that need to access window properties or APIs.

Retrieves a property from the window object

Parameters:
Name Type Description
key string

The name of the property to retrieve from the window object

View Source lib/helpers/utils.ts, line 100

The value of the specified property, or undefined if the window or property doesn't exist

unknown | undefined

# static getOnWindowDocument(key) → {any}

This function provides a safe way to access properties on the window's document object. It uses the getWindowDocument function to get a reference to the document, then accesses the specified property. This is useful for browser environment interactions that need to access document properties.

Retrieves a property from the window's document object

Parameters:
Name Type Description
key string

The name of the property to retrieve from the document object

View Source lib/helpers/utils.ts, line 68

The value of the specified property, or undefined if the document or property doesn't exist

any

# static getWindow() → {Window}

This function provides a safe way to access the global window object. It uses globalThis to ensure compatibility across different JavaScript environments. This is the core function used by other window-related utility functions to access the window object.

Retrieves the global window object

View Source lib/helpers/utils.ts, line 133

The global window object

Window

# static getWindowDocument() → {Document|undefined}

This function provides a safe way to access the document object from the window. It uses the getOnWindow function to retrieve the 'document' property from the window object. This is useful for browser environment interactions that need access to the document.

Retrieves the document object from the window

View Source lib/helpers/utils.ts, line 86

The window's document object, or undefined if it doesn't exist

Document | undefined

# static getWindowWidth() → {number|undefined}

This function provides a convenient way to get the current width of the browser window. It uses the getOnWindow function to access the 'innerWidth' property of the window object. This is useful for responsive design implementations and viewport-based calculations.

Retrieves the width of the browser window

View Source lib/helpers/utils.ts, line 148

The current width of the browser window in pixels

number | undefined

# static isDevelopmentMode(contextopt) → {boolean}

This function checks whether the application is currently running in a development environment. It uses Angular's isDevMode() function and also checks the window context and hostname against the provided context parameter. This is useful for enabling development-specific features or logging.

Determines if the application is running in development mode

Parameters:
Name Type Attributes Default Description
context string <optional>
'localhost'

The context string to check against the current environment

View Source lib/helpers/utils.ts, line 24

True if the application is running in development mode, false otherwise

boolean

# static isNotUndefined(prop) → {boolean}

This utility function determines whether a given value is not undefined. It's a simple wrapper that makes code more readable when checking for defined values. The function is particularly useful for checking StringOrBoolean properties that might be undefined.

Checks if a value is not undefined

Parameters:
Name Type Description
prop StringOrBoolean | undefined

The property to check

View Source lib/helpers/utils.ts, line 162

True if the property is not undefined, false otherwise

boolean

# static setOnWindow(key, value) → {void}

This function provides a way to set properties on the window object. It uses the getWindow function to get a reference to the window, then sets the specified property to the provided value. This is useful for storing global data or functions that need to be accessible across the application.

Sets a property on the window object

Parameters:
Name Type Description
key string

The name of the property to set on the window object

value any

The value to assign to the property

View Source lib/helpers/utils.ts, line 116

void

# static windowEventEmitter(name, detail, propsopt) → {void}

This function creates and dispatches a custom event to the browser window. It's useful for cross-component communication or for triggering application-wide events. The function allows specifying the event name, detail data, and additional event properties.

Dispatches a custom event to the document window

Parameters:
Name Type Attributes Description
name string

The name of the custom event to dispatch

detail unknown

The data to include in the event's detail property

props object <optional>

Optional additional properties for the custom event

View Source lib/helpers/utils.ts, line 45

void

Type Definitions

'cancel' | string | undefined

# ToastRole

Defines the possible role values that can be returned when a toast is dismissed. The role indicates how the toast was dismissed (e.g., by clicking a cancel button, timing out, or programmatically).

Type definition for toast dismissal roles

View Source app/utils/NgxToastComponent.ts, line 174