Add expandOnSingleClick
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tp/tp-tree-nav",
|
"name": "@tp/tp-tree-nav",
|
||||||
"version": "1.2.1",
|
"version": "1.3.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "tp-tree-nav.js",
|
"main": "tp-tree-nav.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -255,6 +255,7 @@ export class TpTreeNav extends Position(LitElement) {
|
|||||||
applyStates: { type: Function },
|
applyStates: { type: Function },
|
||||||
emptyMessage: { type: String },
|
emptyMessage: { type: String },
|
||||||
showActions: { type: Boolean },
|
showActions: { type: Boolean },
|
||||||
|
expandOnSingleClick: { type: Boolean },
|
||||||
expandOnDoubleClick: { type: Boolean },
|
expandOnDoubleClick: { type: Boolean },
|
||||||
selectOnRightClick: { type: Boolean },
|
selectOnRightClick: { type: Boolean },
|
||||||
allowDragAndDrop: { type: Boolean },
|
allowDragAndDrop: { type: Boolean },
|
||||||
@@ -299,6 +300,7 @@ export class TpTreeNav extends Position(LitElement) {
|
|||||||
this.applyStates = null;
|
this.applyStates = null;
|
||||||
this.emptyMessage = 'No items';
|
this.emptyMessage = 'No items';
|
||||||
this.showActions = false;
|
this.showActions = false;
|
||||||
|
this.expandOnSingleClick = false;
|
||||||
this.expandOnDoubleClick = false;
|
this.expandOnDoubleClick = false;
|
||||||
this.selectOnRightClick = false;
|
this.selectOnRightClick = false;
|
||||||
this.allowDragAndDrop = false;
|
this.allowDragAndDrop = false;
|
||||||
@@ -362,7 +364,7 @@ export class TpTreeNav extends Position(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_onRowClick(item, originalEvent) {
|
_onRowClick(item, originalEvent) {
|
||||||
const isDouble = this.expandOnDoubleClick && originalEvent?.detail === 2;
|
const isDouble = this.expandOnDoubleClick && !this.expandOnSingleClick && originalEvent?.detail === 2;
|
||||||
|
|
||||||
if (this.manageState) {
|
if (this.manageState) {
|
||||||
const pathStr = item.path.join('/');
|
const pathStr = item.path.join('/');
|
||||||
@@ -394,6 +396,10 @@ export class TpTreeNav extends Position(LitElement) {
|
|||||||
this._toggleExpand(item, 'double-click', originalEvent);
|
this._toggleExpand(item, 'double-click', originalEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.expandOnSingleClick) {
|
||||||
|
this._toggleExpand(item, 'single-click', originalEvent);
|
||||||
|
}
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent('node-click', {
|
this.dispatchEvent(new CustomEvent('node-click', {
|
||||||
detail: { node: item.node, path: item.path, originalEvent },
|
detail: { node: item.node, path: item.path, originalEvent },
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user