1.3.0 • Published 3 months ago

@robust-ui/tools v1.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

@robust-ui/tools / Exports

Robust

Robust is a system for generating React components with real-time CSS injection. It is programmed in TypeScript, providing type safety and enhanced developer experience.

Project Stats

Alt

Installation

You can install Robust using either npm or pnpm. To do this, run one of the following commands:

Using npm:

npm install @robust-ui/core

Using pnpm:

pnpm install @robust-ui/core

using yarn:

yarn add @robust-ui/core

Alternatively, you can also download Robust from the GitHub repository and manually install the dependencies. The prepare script defined in the package.json file will automatically build all the files within the packages folder.

Usage

To use Robust, you need to make use of the Main component from the @robust-ui/nextjs-components repository. Note that the functionality has only been tested with Next.js and may not work in other React environments.

Here's an example of how to use Robust in a Next.js application:

import { Main, Header, Text, Icon, Flex } from "@robust-ui/nextjs-components";
import { SideMenu } from "@/components/drawer";
import type { AppProps } from "next/app";
import React from "react";

export default function App({ Component, pageProps }: AppProps) {
  const [open, setOpen] = React.useState(false);

  return (
    <Main color="white" fontFamily="Fira Code">
      <Header backgroundColor="gunMetal">
        <Flex>
          <Text fontWeight="700" fontSize="1.5rem">
            Nahuel
          </Text>
        </Flex>
        <Icon type="menu" onClick={() => setOpen(!open)} />
      </Header>
      <SideMenu open={open} setOpen={setOpen} />
      <Component {...pageProps} />
    </Main>
  );
}

In the above example, we import the necessary components from Robust and use them to create a basic application structure. The Main component sets the color and font family for the components. The Header component represents the application header, including a title and a menu icon that toggles the open state. The SideMenu component displays a side drawer with links and language options. Finally, we render the Component with the pageProps.

Please note that this usage example is specific to Next.js, and the functionality may not be tested or supported in other React environments. Make sure to customize the components and their properties based on your specific requirements.

Features

Robust includes the following features:

  • Automatic responsiveness: The components are designed to adapt to different screen sizes and orientations.
  • Quick language switching: Easily switch between different languages using the language options provided.
  • Dark mode: The system supports a dark mode theme that can be enabled or disabled.
  • Global states: Robust provides mechanisms for managing global states and sharing data between components.
  • Real-time CSS injection: The system injects CSS in real time, allowing for dynamic styling and theming.
  • TypeScript support: Robust is programmed in TypeScript, providing type safety and enhanced developer experience.
  • Customizable components: The components can be customized using various properties to suit your specific requirements.
  • Easy to use: Robust is designed to be easy to use and integrate with existing React applications.
  • Extensible: The system can be extended with additional components and functionality as needed.
  • Well-documented: The codebase is well-documented, making it easy to understand and contribute to.
  • Active development: Robust is actively developed and maintained, with regular updates and improvements.

Contributing

Contributions to Robust are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.

License

Robust is released under the MIT License.


Interfaces

@robust-ui/tools / Exports / IOptions

Interface: IOptions

Table of contents

Properties

Properties

digest

digest: BinaryToTextEncoding

Defined in

generate-hash/index.ts:8


hashAlgorithm

hashAlgorithm: string

Defined in

generate-hash/index.ts:4


iterations

iterations: number

Defined in

generate-hash/index.ts:7


pepper

Optional pepper: string

Defined in

generate-hash/index.ts:6


salt

Optional salt: string

Defined in

generate-hash/index.ts:5

@robust-ui/tools / Exports

@robust-ui/tools

Table of contents

Interfaces

Type Aliases

Functions

Type Aliases

PartialRecord

Ƭ PartialRecord\<T, U>: Partial\<Record\<T, U>>

Type parameters

NameType
Textends string
UU

Defined in

attribute-completer/index.ts:1

Functions

attributeCompleter

attributeCompleter(«destructured»): Partial\<Record\<string, unknown>> | undefined

Completes the attributes object by filling in missing values based on the provided input attributes and media breakpoints. Throws an error if the input attributes are invalid.

Parameters

NameType
«destructured»Object
› inputAttributesRecord\<string, unknown>
› mediaBreakpointsRecord\<string, number>

Returns

Partial\<Record\<string, unknown>> | undefined

The completed attributes object or undefined if there are no attributes to complete.

Throws

Error if the input attributes are missing or have an invalid format.

Defined in

attribute-completer/index.ts:13


debounce

debounce\<T>(options): (this: unknown, ...args: Parameters\<T>) => void | undefined

Creates a debounced function that delays invoking the provided function until after a specified delay.

Type parameters

NameTypeDescription
Textends (...args: unknown[]) => voidThe type of the function to debounce.

Parameters

NameTypeDefault valueDescription
optionsObjectundefinedThe options for the debounced function.
options.delay?number0The delay in milliseconds before invoking the debounced function.
options.fnTundefinedThe function to debounce.
options.immediate?booleanfalseSpecifies whether the debounced function should be invoked immediately on the leading edge.

Returns

(this: unknown, ...args: Parameters\<T>) => void | undefined

  • The debounced function.

Defined in

debounce/index.ts:11


generateHash

generateHash(«destructured»): string

Generates a hash for the given input string using the specified options.

Parameters

NameType
«destructured»Object
› inputStringstring
› options?IOptions

Returns

string

The generated hash as a string.

Throws

Error if an invalid hash algorithm or digest format is provided.

Defined in

generate-hash/index.ts:19


generateUniqueId

generateUniqueId(«destructured»): string

Generates a unique ID based on the provided object, prefix, and options. If the object is a string, it will be used directly. Otherwise, it will be converted to a JSON string. The generated ID is a hash of the input string using the specified hash algorithm and digest. If a prefix is provided, it will be prepended to the generated ID.

Parameters

NameType
«destructured»Object
› objectunknown
› options?IOptions
› prefix?string

Returns

string

The generated unique ID.

Throws

Error if unable to generate an ID from the input.

Defined in

generate-unique-id/index.ts:16


isEmptyArray

isEmptyArray(arr): boolean

Checks if an array is empty.

Parameters

NameTypeDescription
arrunknown[]The array to check.

Returns

boolean

True if the array is empty, false otherwise.

Defined in

validation-input/index.ts:25


isEmptyObject

isEmptyObject(obj): boolean

Checks if an object is empty.

Parameters

NameTypeDescription
objobjectThe object to check.

Returns

boolean

True if the object is empty, false otherwise.

Defined in

validation-input/index.ts:16


isNullOrUndefined

isNullOrUndefined(value): boolean

Checks if a value is null or undefined.

Parameters

NameTypeDescription
valueunknownThe value to check.

Returns

boolean

True if the value is null or undefined, false otherwise.

Defined in

validation-input/index.ts:7


normalizeInputKey

normalizeInputKey(«destructured»): Object

Normalizes the input key by removing the specified keyword and converting it to the desired output format. Throws an error if the input key is invalid or no valid prop name is found.

Parameters

NameTypeDefault value
«destructured»Objectundefined
› inputKeystringundefined
› keyword?string"raw"
› outputKey?"camelCase" | "snakeCase" | "kebabCase""camelCase"

Returns

Object

An object containing the information about whether the keyword is present in the input key and the normalized output key.

NameType
isKeywordPresentboolean
outputstring

Throws

Error if the input key is invalid or no valid prop name is found.

Defined in

normalize-input-key/index.ts:11


propagation

propagation(«destructured»): ReactNode[] | null | undefined

Propagates HTML attributes to all valid React elements in the children tree.

Parameters

NameType
«destructured»Object
› childrenReactNode
› propsHTMLAttributes\<HTMLElement>

Returns

ReactNode[] | null | undefined

The updated ReactNode with the propagated attributes.

Defined in

propagation/index.ts:17


propsSplitter

propsSplitter(«destructured»): Object

Splits the props into HTML props and style props based on the provided commands.

Parameters

NameType
«destructured»IpropsSplitterProps

Returns

Object

An object containing the HTML props and style props.

NameType
htmlPropsRecord\<string, unknown>
stylePropsRecord\<string, unknown>

Defined in

props-splitter/index.ts:15


safeJSON

safeJSON(«destructured»): string | undefined

Safely converts an object to a JSON string representation.

Parameters

NameType
«destructured»Object
› indentation?string | number
› objectunknown
› replacerFunction?(key: string, value: unknown) => unknown

Returns

string | undefined

The JSON string representation of the object, or undefined if an error occurs.

Throws

Error if unable to stringify the object.

Defined in

safe-json/index.ts:10


stopPropagation

stopPropagation(children): undefined | null | (string | number | ReactElement\<any, string | JSXElementConstructor\<any>> | Iterable\<ReactNode>)[]

Stops the propagation of click events on the provided React children elements.

Parameters

NameTypeDescription
childrenObjectThe React children elements.
children.childrenReactNode-

Returns

undefined | null | (string | number | ReactElement\<any, string | JSXElementConstructor\<any>> | Iterable\<ReactNode>)[]

The modified React children elements with click event propagation stopped.

Defined in

stop-propagation/index.ts:16


valueRecoverer

valueRecoverer(«destructured»): unknown | undefined

Recovers the value based on the provided input properties and values.

Parameters

NameType
«destructured»Object
› breakPointsObject
› breakPoints.contextRecord\<string, unknown>
› breakPoints.currentstring
› currentGlobalLanguage?string
› darkModeboolean
› inputPropstring
› inputValueunknown
› isRaw?boolean
› themeRecord\<string, { [key: string | number]: unknown; }>

Returns

unknown | undefined

The recovered value.

Defined in

value-recoverer/index.ts:15