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

mvdom-xp

v0.9.2

Published

MVDOM Experimental Extensions

Downloads

3

Readme

Experimental / Exploration APIs on top of mvdom core.

  • Those APIs might change a lot, and for external teams, it is recommended to copy/paste (i.e. Cherrypick) what is needed.
  • We will try to keep the semver rules when breaking APIs, but no garantee.
  • At this point, minimum documentation and unit testing at this point (beside the private applications we are building wit it)
  • Mostly made to be used with TypeScript, but should work with pure JavaScript.

Note: Some of those APIs might move to mvdom core at some point, and will be deprecated/removed for this module.

Doc

style

Convenient method for applying styling one or more html elements with a set of css properties. Uses

import {style} from 'mvdom-xp';

const el: HTMLElement = ...;
style(el, {
  color: 'red',
  width: '100%'
});

style(els,  {
  color: 'red',
  width: '100%'
}); // works with array

attr

Extract attribute values:

// extract single value
const val: string | null = attr(el, 'name');
// extract array of value for a single el
const [name, label] = attr(el, ['name', 'label']);
// extract single attribute from multiple els
const names: (string | null)[] = attr(els,'name');
// extract and array of (values) for the array of els
const names: [string | null][][] = attr(els, ['name', 'label']);

Set attribute values:

// set singloe value
attr(el, 'name', 'username'); // can use el.setAttribute('name','username') as well
attr(el, {name: 'username', placeholder: 'Enter username'});
// set the same attribute to all of the element
attr(els, {checked: true, readonly: ''}); // true will set empty attribute (i.e. same as '' as value)

css

Set one or more css value based on the key property.

// value == null or === false, the class name key is removed, otherwise it is added. 
css(el, {prime: true, sel: '', 'dark-mode': false, 'mobile-mode': null } );
// <.. class="prime sel" 

dnd (Drag And Drop core API)

Enable a one or more HTMLElements (via on-demand CSS selector bindings) drag and drop logic.

Note: Compared to most if not all Drag and Drop JS Libraries, the css selector is on demand, meaning it is one binding on the container, and it is only when the drag trigger events get initiated that the selector is ran. This gives great flexibility and performance benefits (.e.g, O(1) binding vs O(n))

const containerEl: HTMLElement = ...;

draggable(containerEl, '.item', { // DragController
  onStart: (evt: { source: HTMLElement, handle: HTMLElement }) => void {
    // ...
  },

	onDrag: (evt: DragEventDetail) => void {
    // ...
  }, 

	/** Called when the drag event end (e.g., mouseup), return true to remove the handle and false for custom handle management. */
	onEnd: (evt: DragEventDetail) => boolean | Promise<boolean> {
    // ...
  }
});