UNPKG

@aws-amplify/ui

Version:

`@aws-amplify/ui` contains low-level logic & styles for stand-alone usage or re-use in framework-specific implementations.

152 lines (151 loc) 5.94 kB
import type { Modifiers } from '../types'; /** * @deprecated - will be removed in a future major version * * Some libraries may not follow Node ES module spec and could be loaded as CommonJS modules, * To ensure the interoperability between ESM and CJS, modules from those libraries have to be loaded via namespace import * And sanitized by the function below because unlike ESM namespace, CJS namespace set `module.exports` object on the `default` key * https://nodejs.org/api/esm.html#interoperability-with-commonjs */ export declare const sanitizeNamespaceImport: <T>(namespaceModule: T) => T; /** * Checks if `value` is an Object (non-primitive, non-array, non-function) * Will return false for Arrays and functions * * * @param {unknown} value The value to check * @returns {boolean} Returns `true` if `value` is an object, `false` otherwise */ export declare function isObject(value: unknown): value is object; /** * Checks if `value` is a string primitive or object * * @param {unknown} value The value to check * @returns {boolean} Returns `true` if `value` is a string, `false` otherwise */ export declare function isString(value: unknown): value is string; /** * Checks if `value` is a Map * * @param {unknown} value The value to check * @returns {boolean} Returns `true` if `value` is a Map, `false` otherwise */ export declare function isMap(value: unknown): value is Map<unknown, unknown>; /** * Checks if `value` is a Set * * @param {unknown} value The value to check * @returns {boolean} Returns `true` if `value` is a Set, `false` otherwise */ export declare function isSet<T>(value: unknown): value is Set<T>; /** * Checks if `value` is undefined * * @param {unknown} value The value to check * @returns {boolean} Returns `true` if `value` is undefined, `false` otherwise */ export declare function isUndefined(value: unknown): value is undefined; /** * Checks if `value` is nullish * * @param {unknown} value The value to check * @returns {boolean} Returns `true` if `value` is nullish, `false` otherwise */ export declare function isNil(value: unknown): value is null | undefined; /** * Checks if `value` is empty * * @param {unknown} value The value to check * @returns {boolean} Returns `true` if `value` is empty, `false` otherwise */ export declare function isEmpty<T>(value: T): boolean; /** * Checks if all members of the `values` param are empty arrays * * @param {unknown} value The values to check * @returns {boolean} Returns `true` if all members of `values` are empty, `false` otherwise */ export declare function areEmptyArrays<T>(...values: T[]): boolean; /** * Checks if `value` is an empty object * * @param {unknown} value The value to check * @returns {boolean} Returns `true` if `value` is empty, `false` otherwise */ export declare function isEmptyObject<T>(value: T): boolean; /** * Checks if all members of the `values` param are empty objects * * @param {unknown} values The values to check * @returns {boolean} Returns `true` if all members of the `values` param are empty, `false` otherwise */ export declare function areEmptyObjects<T>(...values: T[]): boolean; /** * Capitalizes `value` and its return type * * @param {string} value string to capitalize * @returns {string} capitalized string */ export declare function capitalize<T extends string>(value: T): Capitalize<T>; /** * Checks if `key` is a direct property of `value` * * @param {unknown} value `object` potentially containing property * @param {string} key property key * @returns whether `key` param is a property of the `obj` param */ export declare function has(value: unknown, key: string): boolean; /** * Checks if `value` is a function * * @param {unknown} value param to check * @returns {boolean} whether `value` is a function */ export declare function isFunction(value: unknown): value is Function; /** * This helper function creates modifier class names that are used for our flat BEM styling * it takes in a base and modifier and returns the modified class if a modifier was passed in and null otherwise * @param base The base class of the output * @param modifier The modifier to add onto the base * @returns the modified class name or empty string */ export declare const classNameModifier: (base: string, modifier?: Modifiers) => string; /** * This helper function creates modified class names that are used for our flat BEM styling * it takes in a base, modifier, and flag and returns the modified class name if the flag is true and null if the flag is false * @param base * @param modifier * @param flag * @returns the modified class name or empty string */ export declare const classNameModifierByFlag: (base: string, modifier: Modifiers, flag?: boolean) => string; /** * Similar to `Array.join`, with an optional callback/template param * for formatting returned string values * * @param {string[]} values string array * @param {(value: string) => string} template callback format param * @returns formatted string array */ export declare function templateJoin(values: string[], template: (value: string, index: number, values: string[]) => string): string; /** * A function that does nothing * * @param {any[]} _ accepts any parameters * @returns nothing */ export declare function noop(..._: any[]): void; /** * @param {string} groupName name of group * @param events string values related to group */ export declare function groupLog(groupName: string, ...events: any[]): void; /** * Splits an object into 2 objects based on a predicate * * @param {object} obj an object to split into two * @param {function} predicate function to determin where an element should go * @returns */ export declare function splitObject(obj: Record<string, unknown>, predicate: (key: string) => boolean): readonly [Record<string, unknown>, Record<string, unknown>]; export declare const cloneDeep: (obj: unknown) => any;