{"id":20653475,"url":"https://github.com/t-ski/html-tree-element","last_synced_at":"2026-03-09T12:06:14.770Z","repository":{"id":238203016,"uuid":"787083675","full_name":"t-ski/html-tree-element","owner":"t-ski","description":"Native interface HTML tree element (optionally transformable).","archived":false,"fork":false,"pushed_at":"2024-06-30T11:47:36.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T10:44:34.989Z","etag":null,"topics":["html","tree-element"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/t-ski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-15T21:26:12.000Z","updated_at":"2024-06-30T11:47:39.000Z","dependencies_parsed_at":"2024-11-21T08:45:30.152Z","dependency_job_id":"c29a3d2c-ff42-4f33-82ba-60a42f7d3c69","html_url":"https://github.com/t-ski/html-tree-element","commit_stats":null,"previous_names":["t-ski/html-tree-element"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t-ski%2Fhtml-tree-element","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t-ski%2Fhtml-tree-element/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t-ski%2Fhtml-tree-element/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t-ski%2Fhtml-tree-element/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t-ski","download_url":"https://codeload.github.com/t-ski/html-tree-element/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242757002,"owners_count":20180204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html","tree-element"],"created_at":"2024-11-16T17:44:27.659Z","updated_at":"2026-03-09T12:06:09.740Z","avatar_url":"https://github.com/t-ski.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTMLTreeElement \n\nRich HTML tree element based on pure HTML node templates.\n\n## Integration\n\n``` html\n\u003cscript src=\"https://raw.githubusercontent.com/t-ski/html-tree-element/main/HTMLTreeElement.js\"\u003e\u003c/script\u003e\n```\n\nExisting tree rendering solutions usually rely on fine grained 2D drawing environments like SVG or canvas. The presented tree rendering solution provides a native HTML element interface in favour of simple integration. In fact, displaying a tree merely requires a template for the individual tree nodes, besides the hosting tree instance.\n\n``` html\n\u003cscript\u003e\n  const TREE_OBJECT = { // root\n    genre: \"Manga\",\n    children: [\n      {\n        genre: \"Shonen\"\n      },\n      {\n        genre: \"Shojo\"\n      }\n    ]\n  });\n\u003c/script\u003e\n\n\u003c!-- INDIVIDUAL TREE NODE TEMPLATE --\u003e\n\u003ctemplate id=\"tree-node-template\"\u003e\n  Genre: \u003cem\u003e{{ genre }}\u003c/em\u003e\n\u003c/template\u003e\n\n\u003c!-- HOSTING TREE INSTANCE --\u003e\n\u003ctree-element data=\"TREE_OBJECT\" template=\"#tree-node-template\" /\u003e\n```\n\n## API\n\nEvidently, the tree element reflects data from an existing JavaScript object. The tree element provides a set of chainable methods for simple manipulation. Alternatively, window scope members can be bound via attibutes for an HTML-first approach.\n\n\u003e In general it holds that the attributes resemble the respective method names (see below):  \n\u003e ``` html\n\u003e \u003ctree-element [method-identifier]=\"\u003cwindow-identifier\u003e\" /\u003e\n\u003e ```\n\n### Data Assignment\n\n``` js\ndocument.querySelector(\"tree-element\")\n.data(treeObject);  // TREE_OBJECT\n```\n\n``` html\n\u003ctree-element data=\"treeObject\u003e\" /\u003e\n```\n\n### Template Assignment\n\nA node template can be assigned either through a CSS selector to apply, or directly given an element reference.\n\n``` js\ndocument.querySelector(\"tree-element\")\n.template(templateElementOrSelector);\n```\n\n``` html\n\u003ctree-element template=\"selector\" /\u003e\n```\n\n\u003e The attribute interface accepts only CSS selectors.\n\n### Configuration\n\nA minimal tree requires a node template and the actual tree data. However, several tree characteristics can be optionally adjusted given a configuration object.\n\n``` js\ndocument.querySelector(\"tree-element\")\n.configure(overrideConfiguration);\n```\n\n``` html\n\u003ctree-element configure=\"overrideConfiguration\" /\u003e\n```\n\n| Configuration | Description | Default |\n| :- | :- | -: |\n| `childrenPropertyIdentifier` | Name of the child nodes property to traverse | `\"children\"` |\n| `horizontal` | Whether to expand the tree horizontally | `false` |\n| `linkCap` | Link cap (see [HTML Canvas Line Cap](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap?retiredLocale=de)) | `\"round\"` |\n| `linkColor` | Link color | `\"#000000\"` |\n| `linkMargin` | Link margin to nodes | `0` |\n| `linkSlopeEnd` | Link slope at the inbound node (cubic bezier) | `1.0` |\n| `linkSlopeStart` | Link slope at the outbound node (cubic bezier) | `1.0` |\n| `linkStrength` | Link strength (in px) | `1` |\n| `nodeMargin` | Margin between sibling nodes  | `\"1rem\"` |\n\n### Node Manipulation Callback\n\nTo bind a dynamic rendering or interaction behaviour to each node, a node-wise callback function can be applied. In order to assign multiple node manipulation callbacks successively, the second argument can be set to `true`.\n\n``` js\ndocument.querySelector(\"tree-element\")\n.nodeCallback(nodeCallback, chainToCurrent = false);\n```\n\n``` html\n\u003ctree-element nodecallback=\"callbackFunction\" /\u003e\n```\n\nThe callback function accepts the following arguments in the given order:\n\n| Argument | Description |\n| :- | :- |\n| `nodeData` | Actual data of the current node as given on the input |\n| `nodeShadowRoot` | Shadow DOM root reference of the current node |\n| `isLeafNode` | Whether the current node is a leaf node |\n\nBy default, Mustache-style templates in text nodes are substituted by node data properties (e.g. `{{ name }}`). Also, methods are bound to event attributes (e.g. `onclick=\"sayName()\"`).\n\n### Transformability\n\nSince the tree solution is strongly HTML-based, the default rendering behaviour is in line with the HTML flex concept. However, transformability of the tree – i.e. movability and zoomability – can be optionally enabled. A transform tree maintains a scoped viewport within the tree structure is rendered.\n\n``` js\ndocument.querySelector(\"tree-element\")\n.transform(overrideOptions);\n```\n\n``` html\n\u003ctree-element nodecallback=\"callbackFunction\" /\u003e\n```\n\n| Option | Description | Default |\n| :- | :- | -: |\n| `minZoom` | Minimum zoom factor | `0.5` |\n| `maxZoom` | Maximum zoom factor | `3.0` |\n| `safetyMargin` | Minimum visible space of tree bounding box within the viewport (in px) | `50` |\n| `zoomSpeed` | Zoom speed factor | `1.0` |\n\n## \n\n\u003csub\u003e© Thassilo Martin Schiepanski\u003c/sub\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-ski%2Fhtml-tree-element","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft-ski%2Fhtml-tree-element","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-ski%2Fhtml-tree-element/lists"}