Registry / database / flat-tree-builder

flat-tree-builder

JSON →
library1.5.28jsnpmunverified

A package for building tree structures from Postgres ltree data. Version 1.5.28 provides a Classifier class that renders interactive, draggable tree lists in the browser. It requires Bootstrap and is ESM-only. Key differentiators: tight integration with Postgres ltree paths, built-in CRUD operations via configurable URLs, drag-and-drop support, and a modal form for editing. The project appears to be actively maintained with regular releases.

npm install flat-tree-builder
INSTALL
IMPORT
SIG · FLAT-TREE-BUILDER
F
flat-tree-builder
databasejavascriptv1.5.28
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Classifier
import Classifier from 'flat-tree-builder'
import { Classifier } from 'flat-tree-builder'
The package uses a default export for the Classifier class. Named imports will not work.
Classifier
import Classifier from 'flat-tree-builder'
const Classifier = require('flat-tree-builder')
This package is ESM-only and cannot be required with CommonJS. Use import instead.
flat-tree-builder
import Classifier from 'flat-tree-builder'; import 'flat-tree-builder/classifier.css'
import 'flat-tree-builder'
You must also import the CSS file separately using the path 'flat-tree-builder/classifier.css'.

Shows how to import the Classifier, include required CSS, and instantiate it with configuration options.

<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="./node_modules/flat-tree-builder/classifier.css" /> <div id="test"></div> <script type="module"> import Classifier from 'flat-tree-builder'; const classifier = new Classifier('#test', { test: true, search: true, getUrl: '/api/tree', postClassifierUrl: '/api/tree', delUrl: '/api/tree', selectedIds: [], path: 'tree_path', draggable: false, isRootSelectable: true }); </script>
Debug
Known issues
breakingPackage is ESM-only and does not support CommonJS require().
fix
Use ES module imports (import) instead of require(). Ensure your project or script is set up for ESM.
affects: >=1.0.0
gotchaThe Classifier must be instantiated with a valid CSS selector string as the first argument, not a DOM element.
fix
Pass a query selector string like '#test' or '.classifier', not document.getElementById('test').
affects: >=1.0.0
gotchaThe configuration object requires a 'getUrl' property; if missing, requests will fail silently.
fix
Always provide at least the 'getUrl' option when not using test mode.
affects: >=1.0.0
breakingBootstrap CSS is required for styling but not automatically bundled; you must include it separately.
fix
Add a Bootstrap CSS link in your HTML (e.g., from node_modules or CDN).
affects: >=1.0.0
Errors
Common errors & fixes
Uncaught SyntaxError: The requested module 'flat-tree-builder' does not provide an export named 'Classifier'
Using a named import { Classifier } instead of the default import.
fix
Use: import Classifier from 'flat-tree-builder'
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
Trying to use CommonJS require() on an ESM-only package.
fix
Switch to ES module imports: import Classifier from 'flat-tree-builder'
TypeError: Cannot read properties of undefined (reading 'querySelector')
Instantiating Classifier with a DOM element instead of a selector string, or the selector did not match any element.
fix
Pass a valid CSS selector string (e.g., '#myId') and ensure the element exists in the DOM.
Upgrade
Version history
1.5.28latest on npm
Audit
Dependencies
bootstraprequiredCSS dependency for styling (used in example HTML)
Agent activity
7 hits · last 30 days
node
6
Bingbot
1
Resources
flat-tree-builder — npm install flat-tree-builder · libregistry