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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mapa-mental-widget

v0.1.1

Published

Widget de mapa mental interativo em vanilla JS. Engine de layout de árvore com zoom/pan, collapse/expand, legenda, fullscreen, touch.

Readme

mapa-mental-widget

Widget de mapa mental interativo em vanilla JS. Layout de árvore com zoom/pan, collapse/expand, filtro por cor, fullscreen e suporte touch.

Zero dependências. Qualquer navegador moderno.

Install

npm install mapa-mental-widget
# ou local:
npm install file:../mapa-mental-widget

Uso básico

<link rel="stylesheet" href="./node_modules/mapa-mental-widget/src/mindmap.css">

<div id="mapa" style="height:calc(100vh - 140px)"></div>
<div id="legenda"></div>

<script src="./node_modules/mapa-mental-widget/src/mindmap.js"></script>
<script>
  var treeData = {
    text: 'Produção',
    children: [
      { text: 'Cliente A', children: [
          { text: 'Pedido 123', children: [
              { text: 'Aço 6.35', _cor: '#cbd5e1' }
          ]}
      ]}
    ]
  };

  var mm = new MindMap(document.getElementById('mapa'), treeData);

  // Legenda (opcional)
  mm.renderLegend(document.getElementById('legenda'), [
    { cor: '#cbd5e1', label: 'Pendente' },
    { cor: '#bbf7d0', label: 'Finalizado' }
  ]);
</script>

API

new MindMap(container, treeData, opts?)

Cria instância. Renderiza automaticamente.

| Parâmetro | Tipo | Obrigatório | Descrição | |---|---|---|---| | container | HTMLElement | sim | Elemento que receberá o mapa | | treeData | Object | sim | Árvore com { text, children?, _cor? } (ver formato abaixo) | | opts | Object | não | Configurações (ver abaixo) |

Opções

| Opção | Default | Descrição | |---|---|---| | directions | { 0: 'coluna', 1: 'linha' } | Direção dos filhos por profundidade: 'coluna' ou 'linha' | | nodeColors | { 0: {...}, 1: {...}, 2: {...}, default: {...} } | Cores por profundidade: { bg, color, border } | | config | {} | Override de estilo global (shape, fontSize, shadow, padding, ...) | | fullscreenEl | container | Elemento que recebe .mw-fullscreen ao maximizar |

opts.directions

directions: {
  0: 'coluna',           // profundidade 0 → coluna
  1: 'linha',            // profundidade 1 → linha
  default: 'coluna'      // fallback
}

opts.nodeColors

nodeColors: {
  0: { bg: '#1e293b', color: '#ffffff', border: '#334155' },
  1: { bg: '#f8fafc', color: '#1e293b', border: '#94a3b8' },
  default: { bg: '#fefce8', color: '#1e293b', border: '#eab308' }
}

opts.config

config: {
  shape: 'rounded-rect',   // 'rounded-rect' | 'rect' | 'circle' | 'diamond' | 'cloud'
  fontSize: 14,
  fontWeight: 'normal',
  shadow: false,
  padding: '4px 10px',
  bgColor: '#3a6ea5',
  color: '#ffffff',
  borderColor: '#2a5a8a',
  borderWidth: 2
}

Métodos

| Método | Descrição | |---|---| | .render() | Renderiza/atualiza. Chamado automaticamente no constructor | | .destroy() | Remove eventos e limpa o DOM | | .expandAll() | Expande todos os nós | | .collapseAll() | Colapsa todos os nós | | .centerView() | Centraliza a visualização | | .setFilter(cor) | Filtra nós por cor hex (ou null pra limpar) | | .renderLegend(el, grupos?) | Renderiza legenda interativa. grupos: [{ cor, label }] — se omitido, só mostra cores que aparecem | | .renderControls(el) | Renderiza botões de zoom/controle | | .getState() | Retorna { scale, offsetX, offsetY, collapsed, activeFilter } |

Formato do treeData

{
  text: "Raiz",                        // label do nó (obrigatório)
  _cor: "#cbd5e1",                     // cor opcional — sobrescreve nodeColors
  _direction: 'linha',                 // direção individual (opcional) — > opts.directions
  children: [{
    text: "Filho",
    children: [{
      text: "Folha",
      _cor: "#bbf7d0"                  // cor só na folha
    }]
  }]
}

Nós sem _cor usam nodeColors pela profundidade. Nós sem _direction usam opts.directions[profundidade] → opts.directions.default → herdam do pai → 'coluna'.

Licença MIT

Publicação (npm)

Pacote público e gratuito (MIT). Publicar nova versão:

  1. Bump da versão em package.json — versões são imutáveis no npm, nunca republicar a mesma versão
  2. npm publish (login + 2FA)
  3. Conferir: npm view mapa-mental-widget version

Consumido pelo produto CorteMES via npm update mapa-mental-widget no piloto + build da imagem docker.