gridpackage.src.vaadin-grid-tree-toggle.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vaadin-webcomponents Show documentation
Show all versions of vaadin-webcomponents Show documentation
Mvnpm composite: Vaadin webcomponents
The newest version!
/**
* @license
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
import { GridTreeToggleMixin } from './vaadin-grid-tree-toggle-mixin.js';
/**
* `` is a helper element for the ``
* that provides toggle and level display functionality for the item tree.
*
* #### Example:
* ```html
*
* ```
* ```js
* const column = document.querySelector('#column');
* column.renderer = (root, column, model) => {
* let treeToggle = root.firstElementChild;
* if (!treeToggle) {
* treeToggle = document.createElement('vaadin-grid-tree-toggle');
* treeToggle.addEventListener('expanded-changed', () => { ... });
* root.appendChild(treeToggle);
* }
* treeToggle.leaf = !model.item.hasChildren;
* treeToggle.level = level;
* treeToggle.expanded = expanded;
* treeToggle.textContent = model.item.name;
* };
* ```
*
* ### Styling
*
* The following shadow DOM parts are available for styling:
*
* Part name | Description
* ---|---
* `toggle` | The tree toggle icon
*
* The following state attributes are available for styling:
*
* Attribute | Description | Part name
* ---|---|---
* `expanded` | When present, the toggle is expanded | :host
* `leaf` | When present, the toggle is not expandable, i. e., the current item is a leaf | :host
*
* The following custom CSS properties are available on
* the `` element:
*
* Custom CSS property | Description | Default
* ---|---|---
* `--vaadin-grid-tree-toggle-level-offset` | Visual offset step for each tree sublevel | `1em`
*
* @fires {CustomEvent} expanded-changed - Fired when the `expanded` property changes.
*
* @customElement
* @extends HTMLElement
* @mixes ThemableMixin
* @mixes DirMixin
* @mixes GridTreeToggleMixin
*/
class GridTreeToggle extends GridTreeToggleMixin(ThemableMixin(DirMixin(PolymerElement))) {
static get is() {
return 'vaadin-grid-tree-toggle';
}
static get template() {
return html`
`;
}
}
defineCustomElement(GridTreeToggle);
export { GridTreeToggle };