Members
(constant) I18nProvider
I18nProvider Component
Provides internationalization support for the application by managing locale selection and translations.
I18nProvider Component
Provides internationalization support for the application by managing locale selection and translations. Uses React Context API to provide access to the current locale and translation function (t
).
- Source
<I18nProvider defaultLocale="es">
<App />
</I18nProvider>
(constant) I18nProvider
I18nProvider Component
Provides internationalization support for the application by managing locale selection and translations.
I18nProvider Component
Provides internationalization support for the application by managing locale selection and translations. Uses React Context API to provide access to the current locale and translation function (t
).
- Source
<I18nProvider defaultLocale="es">
<App />
</I18nProvider>
(constant) buildQueryString
Build a query string from an object.
Converts an object of key/value pairs into a URL query string.
- Source
const qs = buildQueryString({ foo: "bar", baz: "qux" });
console.log(qs); // "?foo=bar&baz=qux"
(constant) buildQueryString
Build a query string from an object.
Converts an object of key/value pairs into a URL query string.
- Source
const qs = buildQueryString({ foo: "bar", baz: "qux" });
console.log(qs); // "?foo=bar&baz=qux"
(constant) debounce
Debounce function.
Returns a debounced version of the provided function that delays its execution until after a specified delay has elapsed since the last time it was invoked.
- Source
const debouncedLog = debounce(() => console.log('Debounced!'), 300);
window.addEventListener('resize', debouncedLog);
(constant) debounce
Debounce function.
Returns a debounced version of the provided function that delays its execution until after a specified delay has elapsed since the last time it was invoked.
- Source
const debouncedLog = debounce(() => console.log('Debounced!'), 300);
window.addEventListener('resize', debouncedLog);
(constant) deepClone
Deep clone an object.
Creates a deep copy of an object. This implementation uses JSON methods, which is simple but has limitations (e.g., it doesn't copy functions or handle special objects).
- Source
const original = { a: 1, b: { c: 2 } };
const clone = deepClone(original);
console.log(clone); // { a: 1, b: { c: 2 } }
(constant) deepClone
Deep clone an object.
Creates a deep copy of an object. This implementation uses JSON methods, which is simple but has limitations (e.g., it doesn't copy functions or handle special objects).
- Source
const original = { a: 1, b: { c: 2 } };
const clone = deepClone(original);
console.log(clone); // { a: 1, b: { c: 2 } }
(constant) formatDate
Format a date using the browser's locale.
Converts a given date to a localized string format.
- Source
const formattedDate = formatDate(new Date(), 'en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
console.log(formattedDate); // e.g., "Monday, 14 June 2021"
(constant) formatDate
Format a date using the browser's locale.
Converts a given date to a localized string format.
- Source
const formattedDate = formatDate(new Date(), 'en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
console.log(formattedDate); // e.g., "Monday, 14 June 2021"
(constant) generateUUID
Generate a UUID (version 4).
Generates a universally unique identifier. Uses the built-in crypto.randomUUID if available; otherwise, falls back to a manual implementation.
- Source
const id = generateUUID();
console.log(id); // e.g., "3b12f1df-5232-4f5c-9f8a-9c1234567890"
(constant) generateUUID
Generate a UUID (version 4).
Generates a universally unique identifier. Uses the built-in crypto.randomUUID if available; otherwise, falls back to a manual implementation.
- Source
const id = generateUUID();
console.log(id); // e.g., "3b12f1df-5232-4f5c-9f8a-9c1234567890"
(constant) iconCache :Map.<string, React.LazyExoticComponent.<any>>
Cache for dynamically imported icons. Keys are constructed from iconSet and iconName.
- Map.<string, React.LazyExoticComponent.<any>>
- Source
(constant) iconCache :Map.<string, React.LazyExoticComponent.<any>>
Cache for dynamically imported icons. Keys are constructed from iconSet and iconName.
- Map.<string, React.LazyExoticComponent.<any>>
- Source
(constant) mergeObjects
Merge multiple objects deeply.
Merges source objects into a target object recursively. For any key that exists in multiple objects, later sources override earlier ones.
- Source
const defaults = { a: 1, b: { c: 2 } };
const options = { b: { d: 3 } };
const merged = mergeObjects({}, defaults, options);
console.log(merged); // { a: 1, b: { c: 2, d: 3 } }
(constant) mergeObjects
Merge multiple objects deeply.
Merges source objects into a target object recursively. For any key that exists in multiple objects, later sources override earlier ones.
- Source
const defaults = { a: 1, b: { c: 2 } };
const options = { b: { d: 3 } };
const merged = mergeObjects({}, defaults, options);
console.log(merged); // { a: 1, b: { c: 2, d: 3 } }
(constant) parseQueryString
Parse a query string into an object.
Converts a URL query string into an object of key/value pairs.
- Source
const params = parseQueryString('?foo=bar&baz=qux');
console.log(params); // { foo: "bar", baz: "qux" }
(constant) parseQueryString
Parse a query string into an object.
Converts a URL query string into an object of key/value pairs.
- Source
const params = parseQueryString('?foo=bar&baz=qux');
console.log(params); // { foo: "bar", baz: "qux" }
(constant) throttle
Throttle function.
Returns a throttled version of the provided function that ensures it is executed at most once every specified time interval.
- Source
const throttledLog = throttle(() => console.log('Throttled!'), 1000);
window.addEventListener('scroll', throttledLog);
(constant) throttle
Throttle function.
Returns a throttled version of the provided function that ensures it is executed at most once every specified time interval.
- Source
const throttledLog = throttle(() => console.log('Throttled!'), 1000);
window.addEventListener('scroll', throttledLog);
(constant) translations :Object
Object containing all available translations.
- Object
Name | Type | Description |
---|---|---|
en | Object | English translations. |
es | Object | Spanish translations. |
- Source
(constant) translations :Object
Object containing all available translations.
- Object
Name | Type | Description |
---|---|---|
en | Object | English translations. |
es | Object | Spanish translations. |
- Source
(constant) useI18n
Custom hook to access the internationalization (i18n) context.
This hook uses React's useContext to retrieve the current value of I18nContext, providing components with access to localization methods, language settings, and translation utilities.
- Source
import React from 'react';
import { useI18n } from '@/hooks/useI18n';
const MyComponent = () => {
const { translate } = useI18n();
return (
<div>
{translate('welcome_message')}
</div>
);
};
export default MyComponent;
(constant) useI18n
Custom hook to access the internationalization (i18n) context.
This hook uses React's useContext to retrieve the current value of I18nContext, providing components with access to localization methods, language settings, and translation utilities.
- Source
import React from 'react';
import { useI18n } from '@/hooks/useI18n';
const MyComponent = () => {
const { translate } = useI18n();
return (
<div>
{translate('welcome_message')}
</div>
);
};
export default MyComponent;
Methods
Icon(props) → {JSX.Element}
Generic Icon component that dynamically imports icons from react-icons.
Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props | Object | The props for the Icon component. Properties
|
- Source
The rendered icon component.
- Type:
- JSX.
Element
// Renders a FontAwesome beer icon with a size of 32px and orange color.
<Icon iconSet="fa" iconName="FaBeer" size={32} style={{ color: 'orange' }} />
Icon(props) → {JSX.Element}
Generic Icon component that dynamically imports icons from react-icons.
Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props | Object | The props for the Icon component. Properties
|
- Source
The rendered icon component.
- Type:
- JSX.
Element
// Renders a FontAwesome beer icon with a size of 32px and orange color.
<Icon iconSet="fa" iconName="FaBeer" size={32} style={{ color: 'orange' }} />
Spinner() → {JSX.Element}
Spinner Component A generic spinner using inline SVG that serves as a fallback while content is loading.
Spinner Component A generic spinner using inline SVG that serves as a fallback while content is loading.
- Source
The spinner element.
- Type:
- JSX.
Element
Spinner() → {JSX.Element}
Spinner Component A generic spinner using inline SVG that serves as a fallback while content is loading.
Spinner Component A generic spinner using inline SVG that serves as a fallback while content is loading.
- Source
The spinner element.
- Type:
- JSX.
Element
changeLocale(_newLocale)
Placeholder function for changing locale.
Name | Type | Description |
---|---|---|
_newLocale | string | The new locale. |
- Source
changeLocale(_newLocale)
Placeholder function for changing locale.
Name | Type | Description |
---|---|---|
_newLocale | string | The new locale. |
- Source
getCachedIcon(iconSet, iconName) → {React.LazyExoticComponent.<React.ComponentType.<any>>}
Dynamically import and cache the desired icon from react-icons.
Name | Type | Description |
---|---|---|
iconSet | string | The icon set to import from (e.g., "fa", "md", "gi", "si"). |
iconName | string | The name of the icon (e.g., "FaBeer"). |
- Source
The lazy-loaded icon component.
- Type:
- React.LazyExoticComponent.<React.ComponentType.<any>>
getCachedIcon(iconSet, iconName) → {React.LazyExoticComponent.<React.ComponentType.<any>>}
Dynamically import and cache the desired icon from react-icons.
Name | Type | Description |
---|---|---|
iconSet | string | The icon set to import from (e.g., "fa", "md", "gi", "si"). |
iconName | string | The name of the icon (e.g., "FaBeer"). |
- Source
The lazy-loaded icon component.
- Type:
- React.LazyExoticComponent.<React.ComponentType.<any>>
t(key, …_args) → {string}
Default translation function with interpolation.
Name | Type | Attributes | Description |
---|---|---|---|
key | string | Translation key. | |
_args | string | <repeatable> | Interpolation arguments. |
- Source
Translated string.
- Type:
- string
t(key, …_args) → {string}
Default translation function with interpolation.
Name | Type | Attributes | Description |
---|---|---|---|
key | string | Translation key. | |
_args | string | <repeatable> | Interpolation arguments. |
- Source
Translated string.
- Type:
- string
Type Definitions
ErrorHandlerOptions
- Object
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
logger | Logger | <optional> | A Logger instance for logging errors. Defaults to a console logger. | |
sentryEnabled | boolean | <optional> | false | Flag to enable Sentry integration. |
sentryDsn | string | <optional> | The DSN for Sentry initialization. Required if sentryEnabled is true. |
- Source
ErrorHandlerOptions
- Object
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
logger | Logger | <optional> | A Logger instance for logging errors. Defaults to a console logger. | |
sentryEnabled | boolean | <optional> | false | Flag to enable Sentry integration. |
sentryDsn | string | <optional> | The DSN for Sentry initialization. Required if sentryEnabled is true. |
- Source
FetchServiceOptions
- Object
Name | Type | Attributes | Description |
---|---|---|---|
logger | Logger | <optional> | A Logger instance to log API requests and responses. Defaults to a console logger if not provided. |
defaultOptions | Object | <optional> | Default options for fetch requests, which will be merged with each call. |
- Source
FetchServiceOptions
- Object
Name | Type | Attributes | Description |
---|---|---|---|
logger | Logger | <optional> | A Logger instance to log API requests and responses. Defaults to a console logger if not provided. |
defaultOptions | Object | <optional> | Default options for fetch requests, which will be merged with each call. |
- Source
LoggerOptions
- Object
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type | string | <optional> | 'console' | The logging type to use. Options: 'console', 'csv', or 'sqlite'. |
filePath | string | <optional> | For CSV logging, the file path to store log entries. | |
dbPath | string | <optional> | For SQLite logging, the database file path. |
- Source
LoggerOptions
- Object
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type | string | <optional> | 'console' | The logging type to use. Options: 'console', 'csv', or 'sqlite'. |
filePath | string | <optional> | For CSV logging, the file path to store log entries. | |
dbPath | string | <optional> | For SQLite logging, the database file path. |
- Source