npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@elementalui/elemental

v0.0.32

Published

A lightweight library for creating and managing DOM elements dynamically

Downloads

6

Readme

Elemental Library Documentation

Overview

The Elemental Library is a lightweight, flexible JavaScript library for creating and managing HTML elements programmatically. It provides a fluent API for building complex user interfaces in a more expressive and less verbose way.

Installation

To use Elemental in your project, you need to include the library in your project files.

Usage

Class: Elemental

The Elemental class is the core of the library, allowing the creation and manipulation of HTML elements.

Properties

  • type: ElementType - The type of the HTML element.
  • parent: Elemental<any> | HTMLElement | null - The parent of the element, which can be another Elemental instance or a regular HTML element.
  • children: ElementalArray<any> - A collection of child Elemental instances.
  • onUnmount: undefined | ((element: Elemental<T>) => void) - A function that is called when the element is unmounted.

Methods

  • constructor(type: ElementType, classes: ClassArray, attributes: AttributeObject): Creates a new Elemental instance with the specified type, classes, and attributes.
  • update(classes: ClassArray, attributes: AttributeObject): Updates the element with new classes and attributes.
  • text(text: string): Sets the text content of the element.
  • innerHTML(html: string): Sets the inner HTML of the element.
  • replaceClasses(remove: ClassArray | string, add: ClassArray | string): Replaces certain classes with new ones.
  • setAttribute(key: string, value: string): Sets an attribute on the element.
  • on(event: string, func: () => void): Adds an event listener to the element.
  • off(event: string, func: () => void): Removes an event listener from the element.
  • init(func: (element: Elemental<T>) => void): Initializes the element with a custom function.
  • getElement(): Returns the underlying HTML element.
  • appendTo(parent: HTMLElement | Elemental<any>): Appends the element to a parent.
  • append(elementOrElements: Elemental<any> | Elemental<any>[]): Appends one or more Elemental instances as children.
  • remove(): Removes the element and its children from the DOM.
  • query(selector: string): Returns a collection of child elements that match the selector.
  • id(elementId: string): Sets the ID of the element.
  • ref(refObject: RefObject<T>): Associates the element with a reference object.
  • addRules(rules: Rule[]): Adds CSS rules to the element.
  • removeRules(rules: Rule[]): Removes CSS rules from the element.
  • getValue(): Gets the value of the element if it's an input or textarea.
  • setValue(value: string): Sets the value of the element if it's an input or textarea.

Examples

Take a look at the TODO app included in the repository for concrete examples!

Contributions

Contributions to the Elemental Library are welcome. Please follow the project's contribution guidelines for submitting issues or pull requests.

License

Please refer to the project's license for usage rights and limitations.