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

neweb-components

v0.13.23

Published

NewebComponents - framework, which has 2 goals:

Downloads

29

Readme

NewebComponents

NewebComponents - framework, which has 2 goals:

  1. The real separating of the design and logic for user-interface.
  2. Reactive web-components without virtual dom, only with HTML5 DOM specification.

NewebComponents use pure HTML for templating, without data-binding, conditions, cycles and event-handlers.

NewebComponents use RxJs as engine for reactivity.

NPM version Build Status Dependency Status Coverage percentage experimental

Install

npm install neweb-components --save

or

yarn add neweb-components

Usage

Simple example :: counter

import { interval } from "rxjs";
import { t } from "rx-template-strings";
import { HtmlComponent, render } from "neweb-components";
// Create new component
const view = new HtmlComponent({
    innerHTML:  t`Counter: ${interval()}`,
});
// Render into container #root
render(view, document.getElementById("root") as HTMLElement);

Complex example

// index.ts

import { interval } from "rxjs";
import { Component, Document, render } from "neweb-components";
import View from "./view";
// Bind components to real window-object by special class `Document`, for example, window can be from JSDOM
Component.setDocument(new Document({
    window,
}));
// Instance of view
const view = new View({
    counter: interval(),
});
// Render into container #root
render(view, document.getElementById("root") as HTMLElement);

// template.html

<div>
    <div>Counter: <template name="lblCounter"></template></div>
    <form name="frmMain">
        <div>
            <input autocomplete="off" name="txtEmail" type="text" placeholder="Type email" />
            <small name="tipsEmail"></small>
        </div>
        <div>
            <input type="submit" value="Save" />
        </div>
    </form>
    <ul name="listEmails">
        <li></li>
    </ul>
</div>

// view.ts

import { BehaviorSubject } from "rxjs/BehaviorSubject";
import { Subject } from "rxjs/Subject";
import { Component, ElementComponent, InputComponent, List } from "neweb-components";
import template = require("./template.html");

enum EmailErrorType {
    None = "",
    Required = "Required",
    ShouldContainsDog = "Email should contains @",
}

class View extends Component<{
    counter: Observable<number>;
}> {
    email = new BehaviorSubject("");
    emailError = new BehaviorSubject(EmailErrorType.Required);
    emails = new BehaviorSubject<string[]>([]);
    submit = new Subject<void>();
    beforeMount() {
        this.subscribe(this.email, (value) => {
            if (!value) {
                this.emailError.next(EmailErrorType.Required);
            } else if (value.indexOf("@") === -1) {
                this.emailError.next(EmailErrorType.ShouldContainsDog);
            } else {
                this.emailError.next(EmailErrorType.None);
            }
        });
        this.addElement("lblCounter", new Text({
            value: this.props.counter.pipe(map((v) => v.toString())),
        }));
        this.addElement("txtEmail", new InputComponent({
            value: this.email,
        }));
        this.addElement("tipsEmail", new ElementComponent({
            innerHTML: this.emailError,
        }));
        this.addElement("frmMain", new ElementComponent({
            events: {
                submit: (e) => {
                    e.preventDefault();
                    if (!this.emailError.getValue()) {
                        const items = this.emails.getValue();
                        items.push(this.email.getValue());
                        this.emails.next(items);
                        this.email.next("");
                    }
                },
            },
        }));
        this.addElement("listEmails", new List({
            items: this.emails,
        }));
    }
    getTemplate() {
        return template;
    }
}
export default View;

API

Test

npm install
npm test