forked from mbraak/jqTree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree.jquery.js.map
1 lines (1 loc) · 208 KB
/
tree.jquery.js.map
1
{"version":3,"file":"tree.jquery.js","sources":["src/position.ts","src/dragAndDropHandler/dragElement.ts","src/util.ts","src/dragAndDropHandler/generateHitAreas.ts","src/dragAndDropHandler/iterateVisibleNodes.ts","src/dragAndDropHandler/index.ts","src/elementsRenderer.ts","src/dataLoader.ts","src/keyHandler.ts","src/mouseUtils.ts","src/mouseHandler.ts","src/saveStateHandler.ts","src/scrollHandler/containerScrollParent.ts","src/scrollHandler/documentScrollParent.ts","src/scrollHandler/createScrollParent.ts","src/scrollHandler.ts","src/selectNodeHandler.ts","src/simple.widget.ts","src/nodeUtils.ts","src/node.ts","src/nodeElement/borderDropHint.ts","src/nodeElement/ghostDropHint.ts","src/nodeElement/index.ts","src/nodeElement/folderElement.ts","src/tree.jquery.ts","src/version.ts"],"sourcesContent":["export enum Position {\n Before = 1,\n After,\n Inside,\n None,\n}\n\nconst positionNames: Record<string, Position> = {\n before: Position.Before,\n after: Position.After,\n inside: Position.Inside,\n none: Position.None,\n};\n\nexport const getPositionName = (position: Position): string => {\n for (const name in positionNames) {\n if (Object.prototype.hasOwnProperty.call(positionNames, name)) {\n if (positionNames[name] === position) {\n return name;\n }\n }\n }\n\n return \"\";\n};\n\nexport const getPosition = (name: string): Position | undefined =>\n positionNames[name];\n","interface DragElementParams {\n autoEscape: boolean;\n nodeName: string;\n offsetX: number;\n offsetY: number;\n treeElement: HTMLElement;\n}\n\nclass DragElement {\n private offsetX: number;\n private offsetY: number;\n private element: HTMLElement;\n\n constructor({\n autoEscape,\n nodeName,\n offsetX,\n offsetY,\n treeElement,\n }: DragElementParams) {\n this.offsetX = offsetX;\n this.offsetY = offsetY;\n\n this.element = this.createElement(nodeName, autoEscape);\n\n treeElement.appendChild(this.element);\n }\n\n public move(pageX: number, pageY: number): void {\n this.element.style.left = `${pageX - this.offsetX}px`;\n this.element.style.top = `${pageY - this.offsetY}px`;\n }\n\n public remove(): void {\n this.element.remove();\n }\n\n private createElement(nodeName: string, autoEscape: boolean) {\n const element = document.createElement(\"span\");\n element.classList.add(\"jqtree-title\", \"jqtree-dragging\");\n\n if (autoEscape) {\n element.textContent = nodeName;\n } else {\n element.innerHTML = nodeName;\n }\n\n element.style.position = \"absolute\";\n\n return element;\n }\n}\n\nexport default DragElement;\n","export const isInt = (n: unknown): boolean =>\n typeof n === \"number\" && n % 1 === 0;\n\nexport const isFunction = (v: unknown): boolean => typeof v === \"function\";\n\nexport const getBoolString = (value: unknown): string =>\n value ? \"true\" : \"false\";\n\nexport const getOffsetTop = (element: HTMLElement) =>\n getElementPosition(element).top;\n\nexport const getElementPosition = (element: HTMLElement) => {\n const rect = element.getBoundingClientRect();\n\n return {\n left: rect.x + window.scrollX,\n top: rect.y + window.scrollY,\n };\n};\n","import { HitArea } from \"./types\";\nimport { Node } from \"../node\";\nimport { Position } from \"../position\";\nimport { getOffsetTop } from \"../util\";\nimport iterateVisibleNodes from \"./iterateVisibleNodes\";\n\ninterface HitPosition {\n top: number;\n node: Node;\n position: Position;\n}\n\nexport const generateHitPositions = (\n tree: Node,\n currentNode: Node,\n): HitPosition[] => {\n const hitPositions: HitPosition[] = [];\n let lastTop = 0;\n\n const addHitPosition = (node: Node, position: number, top: number) => {\n hitPositions.push({\n top,\n node,\n position,\n });\n lastTop = top;\n };\n\n const handleAfterOpenFolder = (node: Node, nextNode: Node | null) => {\n if (node === currentNode || nextNode === currentNode) {\n // Cannot move before or after current item\n addHitPosition(node, Position.None, lastTop);\n } else {\n addHitPosition(node, Position.After, lastTop);\n }\n };\n\n const handleClosedFolder = (\n node: Node,\n nextNode: Node | null,\n element: HTMLElement,\n ) => {\n const top = getOffsetTop(element);\n\n if (node === currentNode) {\n // Cannot move after current item\n addHitPosition(node, Position.None, top);\n } else {\n addHitPosition(node, Position.Inside, top);\n\n // Cannot move before current item\n if (nextNode !== currentNode) {\n addHitPosition(node, Position.After, top);\n }\n }\n };\n\n const handleFirstNode = (node: Node) => {\n if (node !== currentNode) {\n addHitPosition(node, Position.Before, getOffsetTop(node.element));\n }\n };\n\n const handleNode = (\n node: Node,\n nextNode: Node | null,\n element: HTMLElement,\n ) => {\n const top = getOffsetTop(element);\n\n if (node === currentNode) {\n // Cannot move inside current item\n addHitPosition(node, Position.None, top);\n } else {\n addHitPosition(node, Position.Inside, top);\n }\n\n if (nextNode === currentNode || node === currentNode) {\n // Cannot move before or after current item\n addHitPosition(node, Position.None, top);\n } else {\n addHitPosition(node, Position.After, top);\n }\n };\n\n const handleOpenFolder = (node: Node, element: HTMLElement) => {\n if (node === currentNode) {\n // Cannot move inside current item\n\n // Dnd over the current element is not possible: add a position with type None for the top and the bottom.\n const top = getOffsetTop(element);\n const height = element.clientHeight;\n addHitPosition(node, Position.None, top);\n\n if (height > 5) {\n // Subtract 5 pixels to allow more space for the next element.\n addHitPosition(node, Position.None, top + height - 5);\n }\n\n // Stop iterating\n return false;\n }\n\n // Cannot move before current item\n if (node.children[0] !== currentNode) {\n addHitPosition(node, Position.Inside, getOffsetTop(element));\n }\n\n // Continue iterating\n return true;\n };\n\n iterateVisibleNodes(tree, {\n handleAfterOpenFolder,\n handleClosedFolder,\n handleFirstNode,\n handleNode,\n handleOpenFolder,\n });\n\n return hitPositions;\n};\n\nexport const generateHitAreasForGroup = (\n hitAreas: HitArea[],\n positionsInGroup: HitPosition[],\n top: number,\n bottom: number,\n) => {\n // limit positions in group\n const positionCount = Math.min(positionsInGroup.length, 4);\n\n const areaHeight = Math.round((bottom - top) / positionCount);\n let areaTop = top;\n\n for (let i = 0; i < positionCount; i++) {\n const position = positionsInGroup[i] as HitPosition;\n\n if (position.position !== Position.None) {\n hitAreas.push({\n top: areaTop,\n bottom: areaTop + areaHeight,\n node: position.node,\n position: position.position,\n });\n }\n\n areaTop += areaHeight;\n }\n};\n\nexport const generateHitAreasFromPositions = (\n hitPositions: HitPosition[],\n treeBottom: number,\n): HitArea[] => {\n if (!hitPositions.length) {\n return [];\n }\n\n let previousTop = (hitPositions[0] as HitPosition).top;\n let group: HitPosition[] = [];\n const hitAreas: HitArea[] = [];\n\n for (const position of hitPositions) {\n if (position.top !== previousTop && group.length) {\n generateHitAreasForGroup(\n hitAreas,\n group,\n previousTop,\n position.top,\n );\n\n previousTop = position.top;\n group = [];\n }\n\n group.push(position);\n }\n\n generateHitAreasForGroup(hitAreas, group, previousTop, treeBottom);\n\n return hitAreas;\n};\n\nconst generateHitAreas = (tree: Node, currentNode: Node, treeBottom: number) =>\n generateHitAreasFromPositions(\n generateHitPositions(tree, currentNode),\n treeBottom,\n );\n\nexport default generateHitAreas;\n","import { Node } from \"../node\";\n\ninterface Options {\n handleAfterOpenFolder: (node: Node, nextNode: Node | null) => void;\n handleClosedFolder: (\n node: Node,\n nextNode: Node | null,\n element: HTMLElement,\n ) => void;\n handleFirstNode: (node: Node) => void;\n handleNode: (\n node: Node,\n nextNode: Node | null,\n element: HTMLElement,\n ) => void;\n\n /*\n override\n return\n - true: continue iterating\n - false: stop iterating\n */\n handleOpenFolder: (node: Node, element: HTMLElement) => boolean;\n}\n\nconst iterateVisibleNodes = (\n tree: Node,\n {\n handleAfterOpenFolder,\n handleClosedFolder,\n handleFirstNode,\n handleNode,\n handleOpenFolder,\n }: Options,\n) => {\n let isFirstNode = true;\n\n const iterate = (node: Node, nextNode: Node | null): void => {\n let mustIterateInside =\n (node.is_open || !node.element) && node.hasChildren();\n\n let element: HTMLElement | null = null;\n\n // Is the element visible?\n if (node.element?.offsetParent) {\n element = node.element;\n\n if (isFirstNode) {\n handleFirstNode(node);\n isFirstNode = false;\n }\n\n if (!node.hasChildren()) {\n handleNode(node, nextNode, node.element);\n } else if (node.is_open) {\n if (!handleOpenFolder(node, node.element)) {\n mustIterateInside = false;\n }\n } else {\n handleClosedFolder(node, nextNode, element);\n }\n }\n\n if (mustIterateInside) {\n const childrenLength = node.children.length;\n node.children.forEach((_, i) => {\n const child = node.children[i];\n\n if (child) {\n if (i === childrenLength - 1) {\n iterate(child, null);\n } else {\n const nextChild = node.children[i + 1];\n\n if (nextChild) {\n iterate(child, nextChild);\n }\n }\n }\n });\n\n if (node.is_open && element) {\n handleAfterOpenFolder(node, nextNode);\n }\n }\n };\n\n iterate(tree, null);\n};\n\nexport default iterateVisibleNodes;\n","import { Node } from \"../node\";\nimport { getPositionName, Position } from \"../position\";\nimport { DropHint, HitArea } from \"./types\";\nimport { PositionInfo } from \"../mouseUtils\";\nimport NodeElement from \"../nodeElement\";\nimport DragElement from \"./dragElement\";\nimport generateHitAreas from \"./generateHitAreas\";\nimport { getElementPosition } from \"../util\";\nimport {\n OnCanMove,\n OnCanMoveTo,\n OnIsMoveHandle,\n DragMethod,\n} from \"../jqtreeOptions\";\nimport {\n GetScrollLeft,\n GetTree,\n OpenNode,\n RefreshElements,\n TriggerEvent,\n} from \"../jqtreeMethodTypes\";\n\ninterface Dimensions {\n left: number;\n top: number;\n right: number;\n bottom: number;\n}\n\ntype GetNodeElement = (element: HTMLElement) => NodeElement | null;\ntype GetNodeElementForNode = (node: Node) => NodeElement;\n\ninterface DragAndDropHandlerParams {\n autoEscape?: boolean;\n getNodeElement: GetNodeElement;\n getNodeElementForNode: GetNodeElementForNode;\n getScrollLeft: GetScrollLeft;\n getTree: GetTree;\n onCanMove?: OnCanMove;\n onCanMoveTo?: OnCanMoveTo;\n onDragMove?: DragMethod;\n onDragStop?: DragMethod;\n onIsMoveHandle?: OnIsMoveHandle;\n openFolderDelay: number | false;\n openNode: OpenNode;\n refreshElements: RefreshElements;\n slide: boolean;\n treeElement: HTMLElement;\n triggerEvent: TriggerEvent;\n}\n\nexport class DragAndDropHandler {\n public hitAreas: HitArea[];\n public isDragging: boolean;\n public currentItem: NodeElement | null;\n public hoveredArea: HitArea | null;\n\n private autoEscape?: boolean;\n private dragElement: DragElement | null;\n private getNodeElement: GetNodeElement;\n private getNodeElementForNode: GetNodeElementForNode;\n private getScrollLeft: GetScrollLeft;\n private getTree: GetTree;\n private onCanMove?: OnCanMove;\n private onCanMoveTo?: OnCanMoveTo;\n private onDragMove?: DragMethod;\n private onDragStop?: DragMethod;\n private onIsMoveHandle?: OnIsMoveHandle;\n private openFolderDelay: number | false;\n private openFolderTimer: number | null;\n private openNode: OpenNode;\n private previousGhost: DropHint | null;\n private refreshElements: RefreshElements;\n private slide: boolean;\n private treeElement: HTMLElement;\n private triggerEvent: TriggerEvent;\n\n constructor({\n autoEscape,\n getNodeElement,\n getNodeElementForNode,\n getScrollLeft,\n getTree,\n onCanMove,\n onCanMoveTo,\n onDragMove,\n onDragStop,\n onIsMoveHandle,\n openNode,\n refreshElements,\n slide,\n treeElement,\n triggerEvent,\n }: DragAndDropHandlerParams) {\n this.autoEscape = autoEscape;\n this.getNodeElement = getNodeElement;\n this.getNodeElementForNode = getNodeElementForNode;\n this.getScrollLeft = getScrollLeft;\n this.getTree = getTree;\n this.onCanMove = onCanMove;\n this.onCanMoveTo = onCanMoveTo;\n this.onDragMove = onDragMove;\n this.onDragStop = onDragStop;\n this.onIsMoveHandle = onIsMoveHandle;\n this.openNode = openNode;\n this.refreshElements = refreshElements;\n this.slide = slide;\n this.treeElement = treeElement;\n this.triggerEvent = triggerEvent;\n\n this.hoveredArea = null;\n this.hitAreas = [];\n this.isDragging = false;\n this.currentItem = null;\n }\n\n public mouseCapture(positionInfo: PositionInfo): boolean | null {\n const element = positionInfo.target;\n\n if (!this.mustCaptureElement(element)) {\n return null;\n }\n\n if (this.onIsMoveHandle && !this.onIsMoveHandle(jQuery(element))) {\n return null;\n }\n\n let nodeElement = this.getNodeElement(element);\n\n if (nodeElement && this.onCanMove) {\n if (!this.onCanMove(nodeElement.node)) {\n nodeElement = null;\n }\n }\n\n this.currentItem = nodeElement;\n return this.currentItem != null;\n }\n\n public mouseStart(positionInfo: PositionInfo): boolean {\n if (!this.currentItem) {\n return false;\n }\n\n this.refresh();\n\n const { left, top } = getElementPosition(positionInfo.target);\n\n const node = this.currentItem.node;\n\n this.dragElement = new DragElement({\n autoEscape: this.autoEscape ?? true,\n nodeName: node.name,\n offsetX: positionInfo.pageX - left,\n offsetY: positionInfo.pageY - top,\n treeElement: this.treeElement,\n });\n\n this.isDragging = true;\n this.currentItem.element.classList.add(\"jqtree-moving\");\n\n return true;\n }\n\n public mouseDrag(positionInfo: PositionInfo): boolean {\n if (!this.currentItem || !this.dragElement) {\n return false;\n }\n\n this.dragElement.move(positionInfo.pageX, positionInfo.pageY);\n\n const area = this.findHoveredArea(\n positionInfo.pageX,\n positionInfo.pageY,\n );\n\n if (area && this.canMoveToArea(area)) {\n if (!area.node.isFolder()) {\n this.stopOpenFolderTimer();\n }\n\n if (this.hoveredArea !== area) {\n this.hoveredArea = area;\n\n // If this is a closed folder, start timer to open it\n if (this.mustOpenFolderTimer(area)) {\n this.startOpenFolderTimer(area.node);\n } else {\n this.stopOpenFolderTimer();\n }\n\n this.updateDropHint();\n }\n } else {\n this.removeDropHint();\n this.stopOpenFolderTimer();\n this.hoveredArea = area;\n }\n\n if (!area) {\n if (this.onDragMove) {\n this.onDragMove(\n this.currentItem.node,\n positionInfo.originalEvent,\n );\n }\n }\n\n return true;\n }\n\n public mouseStop(positionInfo: PositionInfo): boolean {\n this.moveItem(positionInfo);\n this.clear();\n this.removeHover();\n this.removeDropHint();\n this.removeHitAreas();\n\n const currentItem = this.currentItem;\n\n if (this.currentItem) {\n this.currentItem.element.classList.remove(\"jqtree-moving\");\n this.currentItem = null;\n }\n\n this.isDragging = false;\n\n if (!this.hoveredArea && currentItem) {\n if (this.onDragStop) {\n this.onDragStop(currentItem.node, positionInfo.originalEvent);\n }\n }\n\n return false;\n }\n\n public refresh(): void {\n this.removeHitAreas();\n\n if (this.currentItem) {\n this.generateHitAreas();\n\n this.currentItem = this.getNodeElementForNode(\n this.currentItem.node,\n );\n\n if (this.isDragging) {\n this.currentItem.element.classList.add(\"jqtree-moving\");\n }\n }\n }\n\n private generateHitAreas(): void {\n const tree = this.getTree();\n\n if (!this.currentItem || !tree) {\n this.hitAreas = [];\n } else {\n this.hitAreas = generateHitAreas(\n tree,\n this.currentItem.node,\n this.getTreeDimensions().bottom,\n );\n }\n }\n\n private mustCaptureElement(element: HTMLElement): boolean {\n const nodeName = element.nodeName;\n\n return (\n nodeName !== \"INPUT\" &&\n nodeName !== \"SELECT\" &&\n nodeName !== \"TEXTAREA\"\n );\n }\n\n private canMoveToArea(area: HitArea): boolean {\n if (!this.onCanMoveTo) {\n return true;\n }\n\n if (!this.currentItem) {\n return false;\n }\n\n const positionName = getPositionName(area.position);\n\n return this.onCanMoveTo(this.currentItem.node, area.node, positionName);\n }\n\n private removeHitAreas(): void {\n this.hitAreas = [];\n }\n\n private clear(): void {\n if (this.dragElement) {\n this.dragElement.remove();\n this.dragElement = null;\n }\n }\n\n private removeDropHint(): void {\n if (this.previousGhost) {\n this.previousGhost.remove();\n }\n }\n\n private removeHover(): void {\n this.hoveredArea = null;\n }\n\n private findHoveredArea(x: number, y: number): HitArea | null {\n const dimensions = this.getTreeDimensions();\n\n if (\n x < dimensions.left ||\n y < dimensions.top ||\n x > dimensions.right ||\n y > dimensions.bottom\n ) {\n return null;\n }\n\n let low = 0;\n let high = this.hitAreas.length;\n while (low < high) {\n const mid = (low + high) >> 1;\n const area = this.hitAreas[mid];\n\n if (!area) {\n return null;\n }\n\n if (y < area.top) {\n high = mid;\n } else if (y > area.bottom) {\n low = mid + 1;\n } else {\n return area;\n }\n }\n\n return null;\n }\n\n private mustOpenFolderTimer(area: HitArea): boolean {\n const node = area.node;\n\n return (\n node.isFolder() &&\n !node.is_open &&\n area.position === Position.Inside\n );\n }\n\n private updateDropHint(): void {\n if (!this.hoveredArea) {\n return;\n }\n\n // remove previous drop hint\n this.removeDropHint();\n\n // add new drop hint\n const nodeElement = this.getNodeElementForNode(this.hoveredArea.node);\n this.previousGhost = nodeElement.addDropHint(this.hoveredArea.position);\n }\n\n private startOpenFolderTimer(folder: Node): void {\n const openFolder = (): void => {\n this.openNode(folder, this.slide, () => {\n this.refresh();\n this.updateDropHint();\n });\n };\n\n this.stopOpenFolderTimer();\n\n const openFolderDelay = this.openFolderDelay;\n\n if (openFolderDelay !== false) {\n this.openFolderTimer = window.setTimeout(\n openFolder,\n openFolderDelay,\n );\n }\n }\n\n private stopOpenFolderTimer(): void {\n if (this.openFolderTimer) {\n clearTimeout(this.openFolderTimer);\n this.openFolderTimer = null;\n }\n }\n\n private moveItem(positionInfo: PositionInfo): void {\n if (\n this.currentItem &&\n this.hoveredArea &&\n this.hoveredArea.position !== Position.None &&\n this.canMoveToArea(this.hoveredArea)\n ) {\n const movedNode = this.currentItem.node;\n const targetNode = this.hoveredArea.node;\n const position = this.hoveredArea.position;\n const previousParent = movedNode.parent;\n\n if (position === Position.Inside) {\n this.hoveredArea.node.is_open = true;\n }\n\n const doMove = (): void => {\n const tree = this.getTree();\n\n if (tree) {\n tree.moveNode(movedNode, targetNode, position);\n\n this.treeElement.textContent = \"\";\n this.refreshElements(null);\n }\n };\n\n const event = this.triggerEvent(\"tree.move\", {\n move_info: {\n moved_node: movedNode,\n target_node: targetNode,\n position: getPositionName(position),\n previous_parent: previousParent,\n do_move: doMove,\n original_event: positionInfo.originalEvent,\n },\n });\n\n if (!event.isDefaultPrevented()) {\n doMove();\n }\n }\n }\n\n private getTreeDimensions(): Dimensions {\n // Return the dimensions of the tree. Add a margin to the bottom to allow\n // to drag-and-drop after the last element.\n const treePosition = getElementPosition(this.treeElement);\n const left = treePosition.left + this.getScrollLeft();\n const top = treePosition.top;\n\n return {\n left,\n top,\n right: left + this.treeElement.clientWidth,\n bottom: top + this.treeElement.clientHeight + 16,\n };\n }\n}\n","import { getBoolString } from \"./util\";\nimport { Node } from \"./node\";\nimport { IconElement, OnCreateLi } from \"./jqtreeOptions\";\nimport { GetTree, IsNodeSelected } from \"./jqtreeMethodTypes\";\n\ninterface ElementsRendererParams {\n autoEscape: boolean;\n buttonLeft: boolean;\n closedIcon?: IconElement;\n dragAndDrop: boolean;\n $element: JQuery<HTMLElement>;\n getTree: GetTree;\n isNodeSelected: IsNodeSelected;\n onCreateLi?: OnCreateLi;\n openedIcon?: IconElement;\n rtl?: boolean;\n showEmptyFolder: boolean;\n tabIndex?: number;\n}\n\nexport default class ElementsRenderer {\n public openedIconElement?: HTMLElement | Text;\n public closedIconElement?: HTMLElement | Text;\n private autoEscape: boolean;\n private buttonLeft: boolean;\n private dragAndDrop: boolean;\n private $element: JQuery<HTMLElement>;\n private getTree: GetTree;\n private isNodeSelected: IsNodeSelected;\n private onCreateLi?: OnCreateLi;\n private rtl?: boolean;\n private showEmptyFolder: boolean;\n private tabIndex?: number;\n\n constructor({\n autoEscape,\n buttonLeft,\n closedIcon,\n onCreateLi,\n dragAndDrop,\n $element,\n getTree,\n isNodeSelected,\n openedIcon,\n rtl,\n showEmptyFolder,\n tabIndex,\n }: ElementsRendererParams) {\n this.autoEscape = autoEscape;\n this.buttonLeft = buttonLeft;\n this.dragAndDrop = dragAndDrop;\n this.$element = $element;\n this.getTree = getTree;\n this.isNodeSelected = isNodeSelected;\n this.onCreateLi = onCreateLi;\n this.rtl = rtl;\n this.showEmptyFolder = showEmptyFolder;\n this.tabIndex = tabIndex;\n this.openedIconElement = this.createButtonElement(openedIcon || \"+\");\n this.closedIconElement = this.createButtonElement(closedIcon || \"-\");\n }\n\n public render(fromNode: Node | null): void {\n if (fromNode && fromNode.parent) {\n this.renderFromNode(fromNode);\n } else {\n this.renderFromRoot();\n }\n }\n\n public renderFromRoot(): void {\n this.$element.empty();\n\n const tree = this.getTree();\n\n if (this.$element[0] && tree) {\n this.createDomElements(this.$element[0], tree.children, true, 1);\n }\n }\n\n public renderFromNode(node: Node): void {\n // remember current li\n const $previousLi = jQuery(node.element);\n\n // create element\n const li = this.createLi(node, node.getLevel());\n this.attachNodeData(node, li);\n\n // add element to dom\n $previousLi.after(li);\n\n // remove previous li\n $previousLi.remove();\n\n // create children\n if (node.children) {\n this.createDomElements(\n li,\n node.children,\n false,\n node.getLevel() + 1,\n );\n }\n }\n\n private createDomElements(\n element: Element,\n children: Node[],\n isRootNode: boolean,\n level: number,\n ): void {\n const ul = this.createUl(isRootNode);\n element.appendChild(ul);\n\n for (const child of children) {\n const li = this.createLi(child, level);\n ul.appendChild(li);\n\n this.attachNodeData(child, li);\n\n if (child.hasChildren()) {\n this.createDomElements(li, child.children, false, level + 1);\n }\n }\n }\n\n private attachNodeData(node: Node, li: HTMLElement): void {\n node.element = li;\n jQuery(li).data(\"node\", node);\n }\n\n private createUl(isRootNode: boolean): HTMLUListElement {\n let classString;\n let role;\n\n if (!isRootNode) {\n classString = \"\";\n role = \"group\";\n } else {\n classString = \"jqtree-tree\";\n role = \"tree\";\n\n if (this.rtl) {\n classString += \" jqtree-rtl\";\n }\n }\n\n if (this.dragAndDrop) {\n classString += \" jqtree-dnd\";\n }\n\n const ul = document.createElement(\"ul\");\n ul.className = `jqtree_common ${classString}`;\n\n ul.setAttribute(\"role\", role);\n\n return ul;\n }\n\n private createLi(node: Node, level: number): HTMLLIElement {\n const isSelected = Boolean(this.isNodeSelected(node));\n\n const mustShowFolder =\n node.isFolder() || (node.isEmptyFolder && this.showEmptyFolder);\n\n const li = mustShowFolder\n ? this.createFolderLi(node, level, isSelected)\n : this.createNodeLi(node, level, isSelected);\n\n if (this.onCreateLi) {\n this.onCreateLi(node, jQuery(li), isSelected);\n }\n\n return li;\n }\n\n private setTreeItemAriaAttributes(\n element: HTMLElement,\n name: string,\n level: number,\n isSelected: boolean,\n ) {\n element.setAttribute(\"aria-label\", name);\n element.setAttribute(\"aria-level\", `${level}`);\n element.setAttribute(\"aria-selected\", getBoolString(isSelected));\n element.setAttribute(\"role\", \"treeitem\");\n }\n\n private createFolderLi(\n node: Node,\n level: number,\n isSelected: boolean,\n ): HTMLLIElement {\n const buttonClasses = this.getButtonClasses(node);\n const folderClasses = this.getFolderClasses(node, isSelected);\n\n const iconElement = node.is_open\n ? this.openedIconElement\n : this.closedIconElement;\n\n // li\n const li = document.createElement(\"li\");\n li.className = `jqtree_common ${folderClasses}`;\n li.setAttribute(\"role\", \"none\");\n\n // div\n const div = document.createElement(\"div\");\n div.className = \"jqtree-element jqtree_common\";\n div.setAttribute(\"role\", \"none\");\n\n li.appendChild(div);\n\n // button link\n const buttonLink = document.createElement(\"a\");\n buttonLink.className = buttonClasses;\n\n if (iconElement) {\n buttonLink.appendChild(iconElement.cloneNode(true));\n }\n\n if (this.buttonLeft) {\n div.appendChild(buttonLink);\n }\n\n // title span\n const titleSpan = this.createTitleSpan(\n node.name,\n isSelected,\n true,\n level,\n );\n titleSpan.setAttribute(\"aria-expanded\", getBoolString(node.is_open));\n div.appendChild(titleSpan);\n\n if (!this.buttonLeft) {\n div.appendChild(buttonLink);\n }\n\n return li;\n }\n\n private createNodeLi(\n node: Node,\n level: number,\n isSelected: boolean,\n ): HTMLLIElement {\n const liClasses = [\"jqtree_common\"];\n\n if (isSelected) {\n liClasses.push(\"jqtree-selected\");\n }\n\n const classString = liClasses.join(\" \");\n\n // li\n const li = document.createElement(\"li\");\n li.className = classString;\n li.setAttribute(\"role\", \"none\");\n\n // div\n const div = document.createElement(\"div\");\n div.className = \"jqtree-element jqtree_common\";\n div.setAttribute(\"role\", \"none\");\n\n li.appendChild(div);\n\n // title span\n const titleSpan = this.createTitleSpan(\n node.name,\n isSelected,\n false,\n level,\n );\n div.appendChild(titleSpan);\n\n return li;\n }\n\n private createTitleSpan(\n nodeName: string,\n isSelected: boolean,\n isFolder: boolean,\n level: number,\n ): HTMLSpanElement {\n const titleSpan = document.createElement(\"span\");\n\n let classes = \"jqtree-title jqtree_common\";\n\n if (isFolder) {\n classes += \" jqtree-title-folder\";\n }\n\n classes += ` jqtree-title-button-${this.buttonLeft ? \"left\" : \"right\"}`;\n\n titleSpan.className = classes;\n\n if (isSelected) {\n const tabIndex = this.tabIndex;\n\n if (tabIndex !== undefined) {\n titleSpan.setAttribute(\"tabindex\", `${tabIndex}`);\n }\n }\n\n this.setTreeItemAriaAttributes(titleSpan, nodeName, level, isSelected);\n\n if (this.autoEscape) {\n titleSpan.textContent = nodeName;\n } else {\n titleSpan.innerHTML = nodeName;\n }\n\n return titleSpan;\n }\n\n private getButtonClasses(node: Node): string {\n const classes = [\"jqtree-toggler\", \"jqtree_common\"];\n\n if (!node.is_open) {\n classes.push(\"jqtree-closed\");\n }\n\n if (this.buttonLeft) {\n classes.push(\"jqtree-toggler-left\");\n } else {\n classes.push(\"jqtree-toggler-right\");\n }\n\n return classes.join(\" \");\n }\n\n private getFolderClasses(node: Node, isSelected: boolean): string {\n const classes = [\"jqtree-folder\"];\n\n if (!node.is_open) {\n classes.push(\"jqtree-closed\");\n }\n\n if (isSelected) {\n classes.push(\"jqtree-selected\");\n }\n\n if (node.is_loading) {\n classes.push(\"jqtree-loading\");\n }\n\n return classes.join(\" \");\n }\n\n private createButtonElement(\n value: IconElement,\n ): HTMLElement | Text | undefined {\n if (typeof value === \"string\") {\n // convert value to html\n const div = document.createElement(\"div\");\n div.innerHTML = value;\n\n return document.createTextNode(div.innerHTML);\n } else if (value == null) {\n return undefined;\n } else if ((value as HTMLElement).nodeType) {\n return value as HTMLElement;\n } else {\n return jQuery(value)[0];\n }\n }\n}\n","import { Node } from \"./node\";\nimport { DataFilter, OnLoadFailed, OnLoading } from \"./jqtreeOptions\";\nimport { LoadData, TriggerEvent } from \"./jqtreeMethodTypes\";\n\nexport type HandleFinishedLoading = () => void;\n\ninterface DataLoaderParams {\n dataFilter?: DataFilter;\n loadData: LoadData;\n onLoadFailed?: OnLoadFailed;\n onLoading?: OnLoading;\n treeElement: HTMLElement;\n triggerEvent: TriggerEvent;\n}\n\nexport default class DataLoader {\n private dataFilter?: DataFilter;\n private loadData: LoadData;\n private onLoadFailed?: OnLoadFailed;\n private onLoading?: OnLoading;\n private treeElement: HTMLElement;\n private triggerEvent: TriggerEvent;\n\n constructor({\n dataFilter,\n loadData,\n onLoadFailed,\n onLoading,\n treeElement,\n triggerEvent,\n }: DataLoaderParams) {\n this.dataFilter = dataFilter;\n this.loadData = loadData;\n this.onLoadFailed = onLoadFailed;\n this.onLoading = onLoading;\n this.treeElement = treeElement;\n this.triggerEvent = triggerEvent;\n }\n\n public loadFromUrl(\n urlInfo: string | JQuery.AjaxSettings | null,\n parentNode: Node | null,\n onFinished: HandleFinishedLoading | null,\n ): void {\n if (!urlInfo) {\n return;\n }\n\n const element = this.getDomElement(parentNode);\n this.addLoadingClass(element);\n this.notifyLoading(true, parentNode, element);\n\n const stopLoading = (): void => {\n this.removeLoadingClass(element);\n this.notifyLoading(false, parentNode, element);\n };\n\n const handleSuccess = (data: string | NodeData[]): void => {\n stopLoading();\n this.loadData(this.parseData(data), parentNode);\n\n if (onFinished && typeof onFinished === \"function\") {\n onFinished();\n }\n };\n\n const handleError = (jqXHR: JQuery.jqXHR): void => {\n stopLoading();\n\n if (this.onLoadFailed) {\n this.onLoadFailed(jqXHR);\n }\n };\n\n this.submitRequest(urlInfo, handleSuccess, handleError);\n }\n\n private addLoadingClass(element: HTMLElement): void {\n element.classList.add(\"jqtree-loading\");\n }\n\n private removeLoadingClass(element: HTMLElement): void {\n element.classList.remove(\"jqtree-loading\");\n }\n\n private getDomElement(parentNode: Node | null): HTMLElement {\n if (parentNode) {\n return parentNode.element;\n } else {\n return this.treeElement;\n }\n }\n\n private notifyLoading(\n isLoading: boolean,\n node: Node | null,\n element: HTMLElement,\n ): void {\n const $el = jQuery(element);\n\n if (this.onLoading) {\n this.onLoading(isLoading, node, $el);\n }\n\n this.triggerEvent(\"tree.loading_data\", {\n isLoading,\n node,\n $el,\n });\n }\n\n private submitRequest(\n urlInfoInput: string | JQuery.AjaxSettings,\n handleSuccess: JQuery.Ajax.SuccessCallback<any>,\n handleError: JQuery.Ajax.ErrorCallback<any>,\n ): void {\n const urlInfo =\n typeof urlInfoInput === \"string\"\n ? { url: urlInfoInput }\n : urlInfoInput;\n\n const ajaxSettings: JQuery.AjaxSettings = {\n method: \"GET\",\n cache: false,\n dataType: \"json\",\n success: handleSuccess,\n error: handleError,\n ...urlInfo,\n };\n\n ajaxSettings.method = ajaxSettings.method?.toUpperCase() || \"GET\";\n\n void jQuery.ajax(ajaxSettings);\n }\n\n private parseData(data: string | NodeData[]): NodeData[] {\n const getParsedData = () => {\n if (typeof data === \"string\") {\n return JSON.parse(data) as NodeData[];\n } else {\n return data;\n }\n };\n\n const parsedData = getParsedData();\n\n if (this.dataFilter) {\n return this.dataFilter(parsedData);\n } else {\n return parsedData;\n }\n }\n}\n","import { Node } from \"./node\";\nimport {\n CloseNode,\n GetSelectedNode,\n IsFocusOnTree,\n OpenNode,\n SelectNode,\n} from \"./jqtreeMethodTypes\";\n\ntype KeyboardEventHandler = (event: KeyboardEvent) => boolean;\n\ninterface KeyHandlerParams {\n closeNode: CloseNode;\n getSelectedNode: GetSelectedNode;\n isFocusOnTree: IsFocusOnTree;\n keyboardSupport: boolean;\n openNode: OpenNode;\n selectNode: SelectNode;\n}\n\nexport default class KeyHandler {\n private closeNode: CloseNode;\n private getSelectedNode: GetSelectedNode;\n private handleKeyDownHandler?: KeyboardEventHandler;\n private isFocusOnTree: IsFocusOnTree;\n private keyboardSupport: boolean;\n private openNode: OpenNode;\n private originalSelectNode: SelectNode;\n\n constructor({\n closeNode,\n getSelectedNode,\n isFocusOnTree,\n keyboardSupport,\n openNode,\n selectNode,\n }: KeyHandlerParams) {\n this.closeNode = closeNode;\n this.getSelectedNode = getSelectedNode;\n this.isFocusOnTree = isFocusOnTree;\n this.keyboardSupport = keyboardSupport;\n this.openNode = openNode;\n this.originalSelectNode = selectNode;\n\n if (keyboardSupport) {\n this.handleKeyDownHandler = this.handleKeyDown.bind(this);\n\n document.addEventListener(\"keydown\", this.handleKeyDownHandler);\n }\n }\n\n public deinit(): void {\n if (this.handleKeyDownHandler) {\n document.removeEventListener(\"keydown\", this.handleKeyDownHandler);\n }\n }\n\n public moveDown(selectedNode: Node): boolean {\n return this.selectNode(selectedNode.getNextVisibleNode());\n }\n\n public moveUp(selectedNode: Node): boolean {\n return this.selectNode(selectedNode.getPreviousVisibleNode());\n }\n\n public moveRight(selectedNode: Node): boolean {\n if (!selectedNode.isFolder()) {\n return true;\n } else {\n // folder node\n if (selectedNode.is_open) {\n // Right moves to the first child of an open node\n return this.selectNode(selectedNode.getNextVisibleNode());\n } else {\n // Right expands a closed node\n this.openNode(selectedNode);\n return false;\n }\n }\n }\n\n public moveLeft(selectedNode: Node): boolean {\n if (selectedNode.isFolder() && selectedNode.is_open) {\n // Left on an open node closes the node\n this.closeNode(selectedNode);\n return false;\n } else {\n // Left on a closed or end node moves focus to the node's parent\n return this.selectNode(selectedNode.getParent());\n }\n }\n\n public selectNode(node: Node | null): boolean {\n if (!node) {\n return true;\n } else {\n this.originalSelectNode(node);\n\n return false;\n }\n }\n\n private handleKeyDown = (e: KeyboardEvent): boolean => {\n if (!this.canHandleKeyboard()) {\n return true;\n }\n\n const selectedNode = this.getSelectedNode();\n if (!selectedNode) {\n return true;\n }\n\n switch (e.key) {\n case \"ArrowDown\":\n return this.moveDown(selectedNode);\n\n case \"ArrowUp\":\n return this.moveUp(selectedNode);\n\n case \"ArrowRight\":\n return this.moveRight(selectedNode);\n\n case \"ArrowLeft\":\n return this.moveLeft(selectedNode);\n\n default:\n return true;\n }\n };\n\n private canHandleKeyboard(): boolean {\n return this.keyboardSupport && this.isFocusOnTree();\n }\n}\n","export interface PositionInfo {\n originalEvent: Event;\n pageX: number;\n pageY: number;\n target: HTMLElement;\n}\n\nexport const getPositionInfoFromMouseEvent = (e: MouseEvent): PositionInfo => ({\n originalEvent: e,\n pageX: e.pageX,\n pageY: e.pageY,\n target: e.target as HTMLElement,\n});\n\nexport const getPositionInfoFromTouch = (\n touch: Touch,\n e: TouchEvent,\n): PositionInfo => ({\n originalEvent: e,\n pageX: touch.pageX,\n pageY: touch.pageY,\n target: touch.target as HTMLElement,\n});\n","import {\n getPositionInfoFromMouseEvent,\n getPositionInfoFromTouch,\n PositionInfo,\n} from \"./mouseUtils\";\nimport { Node } from \"./node\";\nimport { TriggerEvent } from \"./jqtreeMethodTypes\";\n\ninterface ClickTarget {\n node: Node;\n type: \"button\" | \"label\";\n}\n\ntype GetNode = (element: HTMLElement) => null | Node;\n\ninterface MouseHandlerParams {\n element: HTMLElement;\n getMouseDelay: () => number;\n getNode: GetNode;\n onClickButton: (node: Node) => void;\n onClickTitle: (node: Node) => void;\n onMouseCapture: (positionInfo: PositionInfo) => boolean | null;\n onMouseDrag: (positionInfo: PositionInfo) => void;\n onMouseStart: (positionInfo: PositionInfo) => boolean;\n onMouseStop: (positionInfo: PositionInfo) => void;\n triggerEvent: TriggerEvent;\n useContextMenu: boolean;\n}\n\nclass MouseHandler {\n private element: HTMLElement;\n private getMouseDelay: () => number;\n private getNode: GetNode;\n private isMouseDelayMet: boolean;\n private isMouseStarted: boolean;\n private mouseDelayTimer: number | null;\n private mouseDownInfo: PositionInfo | null;\n private onClickButton: (node: Node) => void;\n private onClickTitle: (node: Node) => void;\n private onMouseCapture: (positionInfo: PositionInfo) => boolean | null;\n private onMouseDrag: (positionInfo: PositionInfo) => void;\n private onMouseStart: (positionInfo: PositionInfo) => boolean;\n private onMouseStop: (positionInfo: PositionInfo) => void;\n private triggerEvent: TriggerEvent;\n private useContextMenu: boolean;\n\n constructor({\n element,\n getMouseDelay,\n getNode,\n onClickButton,\n onClickTitle,\n onMouseCapture,\n onMouseDrag,\n onMouseStart,\n onMouseStop,\n triggerEvent,\n useContextMenu,\n }: MouseHandlerParams) {\n this.element = element;\n this.getMouseDelay = getMouseDelay;\n this.getNode = getNode;\n this.onClickButton = onClickButton;\n this.onClickTitle = onClickTitle;\n this.onMouseCapture = onMouseCapture;\n this.onMouseDrag = onMouseDrag;\n this.onMouseStart = onMouseStart;\n this.onMouseStop = onMouseStop;\n this.triggerEvent = triggerEvent;\n this.useContextMenu = useContextMenu;\n\n element.addEventListener(\"click\", this.handleClick);\n element.addEventListener(\"dblclick\", this.handleDblclick);\n element.addEventListener(\"mousedown\", this.mouseDown, {\n passive: false,\n });\n element.addEventListener(\"touchstart\", this.touchStart, {\n passive: false,\n });\n\n if (useContextMenu) {\n element.addEventListener(\"contextmenu\", this.handleContextmenu);\n }\n\n this.isMouseStarted = false;\n this.mouseDelayTimer = null;\n this.isMouseDelayMet = false;\n this.mouseDownInfo = null;\n }\n\n public deinit(): void {\n this.element.removeEventListener(\"click\", this.handleClick);\n this.element.removeEventListener(\"dblclick\", this.handleDblclick);\n\n if (this.useContextMenu) {\n this.element.removeEventListener(\n \"contextmenu\",\n this.handleContextmenu,\n );\n }\n\n this.element.removeEventListener(\"mousedown\", this.mouseDown);\n this.element.removeEventListener(\"touchstart\", this.touchStart);\n this.removeMouseMoveEventListeners();\n }\n\n private mouseDown = (e: MouseEvent): void => {\n // Left mouse button?\n if (e.button !== 0) {\n return;\n }\n\n const result = this.handleMouseDown(getPositionInfoFromMouseEvent(e));\n\n if (result && e.cancelable) {\n e.preventDefault();\n }\n };\n\n private handleMouseDown(positionInfo: PositionInfo): boolean {\n // We may have missed mouseup (out of window)\n if (this.isMouseStarted) {\n this.handleMouseUp(positionInfo);\n }\n\n this.mouseDownInfo = positionInfo;\n\n if (!this.onMouseCapture(positionInfo)) {\n return false;\n }\n\n this.handleStartMouse();\n\n return true;\n }\n\n private handleStartMouse(): void {\n document.addEventListener(\"mousemove\", this.mouseMove, {\n passive: false,\n });\n document.addEventListener(\"touchmove\", this.touchMove, {\n passive: false,\n });\n document.addEventListener(\"mouseup\", this.mouseUp, { passive: false });\n document.addEventListener(\"touchend\", this.touchEnd, {\n passive: false,\n });\n\n const mouseDelay = this.getMouseDelay();\n\n if (mouseDelay) {\n this.startMouseDelayTimer(mouseDelay);\n } else {\n this.isMouseDelayMet = true;\n }\n }\n\n private startMouseDelayTimer(mouseDelay: number): void {\n if (this.mouseDelayTimer) {\n clearTimeout(this.mouseDelayTimer);\n }\n\n this.mouseDelayTimer = window.setTimeout(() => {\n if (this.mouseDownInfo) {\n this.isMouseDelayMet = true;\n }\n }, mouseDelay);\n\n this.isMouseDelayMet = false;\n }\n\n private mouseMove = (e: MouseEvent): void => {\n this.handleMouseMove(e, getPositionInfoFromMouseEvent(e));\n };\n\n private handleMouseMove(\n e: MouseEvent | TouchEvent,\n positionInfo: PositionInfo,\n ): void {\n if (this.isMouseStarted) {\n this.onMouseDrag(positionInfo);\n\n if (e.cancelable) {\n e.preventDefault();\n }\n return;\n }\n\n if (!this.isMouseDelayMet) {\n return;\n }\n\n if (this.mouseDownInfo) {\n this.isMouseStarted =\n this.onMouseStart(this.mouseDownInfo) !== false;\n }\n\n if (this.isMouseStarted) {\n this.onMouseDrag(positionInfo);\n\n if (e.cancelable) {\n e.preventDefault();\n }\n } else {\n this.handleMouseUp(positionInfo);\n }\n }\n\n private mouseUp = (e: MouseEvent): void => {\n this.handleMouseUp(getPositionInfoFromMouseEvent(e));\n };\n\n private handleMouseUp(positionInfo: PositionInfo): void {\n this.removeMouseMoveEventListeners();\n this.isMouseDelayMet = false;\n this.mouseDownInfo = null;\n\n if (this.isMouseStarted) {\n this.isMouseStarted = false;\n this.onMouseStop(positionInfo);\n }\n }\n\n private removeMouseMoveEventListeners() {\n document.removeEventListener(\"mousemove\", this.mouseMove);\n document.removeEventListener(\"touchmove\", this.touchMove);\n document.removeEventListener(\"mouseup\", this.mouseUp);\n document.removeEventListener(\"touchend\", this.touchEnd);\n }\n\n private touchStart = (e: TouchEvent): void => {\n if (!e) {\n return;\n }\n\n if (e.touches.length > 1) {\n return;\n }\n\n const touch = e.touches[0];\n\n if (!touch) {\n return;\n }\n\n this.handleMouseDown(getPositionInfoFromTouch(touch, e));\n };\n\n private touchMove = (e: TouchEvent): void => {\n if (!e) {\n return;\n }\n\n if (e.touches.length > 1) {\n return;\n }\n\n const touch = e.touches[0];\n\n if (!touch) {\n return;\n }\n\n this.handleMouseMove(e, getPositionInfoFromTouch(touch, e));\n };\n\n private touchEnd = (e: TouchEvent): void => {\n if (!e) {\n return;\n }\n\n if (e.touches.length > 1) {\n return;\n }\n\n const touch = e.touches[0];\n\n if (!touch) {\n return;\n }\n\n this.handleMouseUp(getPositionInfoFromTouch(touch, e));\n };\n\n private handleClick = (e: MouseEvent): void => {\n if (!e.target) {\n return;\n }\n\n const clickTarget = this.getClickTarget(e.target as HTMLElement);\n\n if (!clickTarget) {\n return;\n }\n\n if (clickTarget.type === \"button\") {\n this.onClickButton(clickTarget.node);\n\n e.preventDefault();\n e.stopPropagation();\n } else if (clickTarget.type === \"label\") {\n const event = this.triggerEvent(\"tree.click\", {\n node: clickTarget.node,\n click_event: e,\n });\n\n if (!event.isDefaultPrevented()) {\n this.onClickTitle(clickTarget.node);\n }\n }\n };\n\n private handleDblclick = (e: MouseEvent): void => {\n if (!e.target) {\n return;\n }\n\n const clickTarget = this.getClickTarget(e.target as HTMLElement);\n\n if (clickTarget?.type === \"label\") {\n this.triggerEvent(\"tree.dblclick\", {\n node: clickTarget.node,\n click_event: e,\n });\n }\n };\n\n private handleContextmenu = (e: MouseEvent) => {\n if (!e.target) {\n return;\n }\n\n const div = (e.target as HTMLElement).closest<HTMLElement>(\n \"ul.jqtree-tree .jqtree-element\",\n );\n\n if (div) {\n const node = this.getNode(div);\n if (node) {\n e.preventDefault();\n e.stopPropagation();\n\n this.triggerEvent(\"tree.contextmenu\", {\n node,\n click_event: e,\n });\n return false;\n }\n }\n\n return null;\n };\n\n private getClickTarget(element: HTMLElement): ClickTarget | null {\n const button = element.closest<HTMLElement>(\".jqtree-toggler\");\n\n if (button) {\n const node = this.getNode(button);\n\n if (node) {\n return {\n type: \"button\",\n node,\n };\n }\n } else {\n const jqTreeElement =\n element.closest<HTMLElement>(\".jqtree-element\");\n\n if (jqTreeElement) {\n const node = this.getNode(jqTreeElement);\n if (node) {\n return {\n type: \"label\",\n node,\n };\n }\n }\n }\n\n return null;\n }\n}\n\nexport default MouseHandler;\n","import { isInt } from \"./util\";\nimport { Node } from \"./node\";\nimport { OnGetStateFromStorage, OnSetStateFromStorage } from \"./jqtreeOptions\";\nimport {\n AddToSelection,\n GetNodeById,\n GetSelectedNodes,\n GetTree,\n OpenNode,\n RefreshElements,\n RemoveFromSelection,\n} from \"./jqtreeMethodTypes\";\n\nexport interface SavedState {\n open_nodes: NodeId[];\n selected_node: NodeId[];\n}\n\ninterface SaveStateHandlerParams {\n addToSelection: AddToSelection;\n getNodeById: GetNodeById;\n getSelectedNodes: GetSelectedNodes;\n getTree: GetTree;\n onGetStateFromStorage?: OnGetStateFromStorage;\n onSetStateFromStorage?: OnSetStateFromStorage;\n openNode: OpenNode;\n refreshElements: RefreshElements;\n removeFromSelection: RemoveFromSelection;\n saveState: boolean | string;\n}\n\nexport default class SaveStateHandler {\n private addToSelection: AddToSelection;\n private getNodeById: GetNodeById;\n private getSelectedNodes: GetSelectedNodes;\n private getTree: GetTree;\n private onGetStateFromStorage?: OnGetStateFromStorage;\n private onSetStateFromStorage?: OnSetStateFromStorage;\n private openNode: OpenNode;\n private refreshElements: RefreshElements;\n private removeFromSelection: RemoveFromSelection;\n private saveStateOption: boolean | string;\n private _supportsLocalStorage: boolean | null;\n\n constructor({\n addToSelection,\n getNodeById,\n getSelectedNodes,\n getTree,\n onGetStateFromStorage,\n onSetStateFromStorage,\n openNode,\n refreshElements,\n removeFromSelection,\n saveState,\n }: SaveStateHandlerParams) {\n this.addToSelection = addToSelection;\n this.getNodeById = getNodeById;\n this.getSelectedNodes = getSelectedNodes;\n this.getTree = getTree;\n this.onGetStateFromStorage = onGetStateFromStorage;\n this.onSetStateFromStorage = onSetStateFromStorage;\n this.openNode = openNode;\n this.refreshElements = refreshElements;\n this.removeFromSelection = removeFromSelection;\n this.saveStateOption = saveState;\n }\n\n public saveState(): void {\n const state = JSON.stringify(this.getState());\n\n if (this.onSetStateFromStorage) {\n this.onSetStateFromStorage(state);\n } else if (this.supportsLocalStorage()) {\n localStorage.setItem(this.getKeyName(), state);\n }\n }\n\n public getStateFromStorage(): SavedState | null {\n const jsonData = this.loadFromStorage();\n\n if (jsonData) {\n return this.parseState(jsonData) as unknown as SavedState;\n } else {\n return null;\n }\n }\n\n public getState(): SavedState {\n const getOpenNodeIds = (): NodeId[] => {\n const openNodes: NodeId[] = [];\n\n this.getTree()?.iterate((node: Node) => {\n if (node.is_open && node.id && node.hasChildren()) {\n openNodes.push(node.id);\n }\n return true;\n });\n\n return openNodes;\n };\n\n const getSelectedNodeIds = (): NodeId[] => {\n const selectedNodeIds: NodeId[] = [];\n\n this.getSelectedNodes().forEach((node) => {\n if (node.id != null) {\n selectedNodeIds.push(node.id);\n }\n });\n\n return selectedNodeIds;\n };\n\n return {\n open_nodes: getOpenNodeIds(),\n selected_node: getSelectedNodeIds(),\n };\n }\n\n /*\n Set initial state\n Don't handle nodes that are loaded on demand\n\n result: must load on demand\n */\n public setInitialState(state: SavedState): boolean {\n if (!state) {\n return false;\n } else {\n let mustLoadOnDemand = false;\n\n if (state.open_nodes) {\n mustLoadOnDemand = this.openInitialNodes(state.open_nodes);\n }\n\n if (state.selected_node) {\n this.resetSelection();\n this.selectInitialNodes(state.selected_node);\n }\n\n return mustLoadOnDemand;\n }\n }\n\n public setInitialStateOnDemand(\n state: SavedState,\n cbFinished: () => void,\n ): void {\n let loadingCount = 0;\n let nodeIds = state.open_nodes;\n\n const openNodes = (): void => {\n const newNodesIds = [];\n\n for (const nodeId of nodeIds) {\n const node = this.getNodeById(nodeId);\n\n if (!node) {\n newNodesIds.push(nodeId);\n } else {\n if (!node.is_loading) {\n if (node.load_on_demand) {\n loadAndOpenNode(node);\n } else {\n this.openNode(node, false);\n }\n }\n }\n }\n\n nodeIds = newNodesIds;\n\n if (this.selectInitialNodes(state.selected_node)) {\n this.refreshElements(null);\n }\n\n if (loadingCount === 0) {\n cbFinished();\n }\n };\n\n const loadAndOpenNode = (node: Node): void => {\n loadingCount += 1;\n this.openNode(node, false, () => {\n loadingCount -= 1;\n openNodes();\n });\n };\n\n openNodes();\n }\n\n public getNodeIdToBeSelected(): NodeId | null {\n const state = this.getStateFromStorage();\n\n if (state?.selected_node) {\n return state.selected_node[0] || null;\n } else {\n return null;\n }\n }\n\n private parseState(jsonData: string): SavedState {\n const state = JSON.parse(jsonData) as Record<string, unknown>;\n\n // Check if selected_node is an int (instead of an array)\n if (state && state.selected_node && isInt(state.selected_node)) {\n // Convert to array\n state.selected_node = [state.selected_node];\n }\n\n return state as unknown as SavedState;\n }\n\n private loadFromStorage(): string | null {\n if (this.onGetStateFromStorage) {\n return this.onGetStateFromStorage();\n } else if (this.supportsLocalStorage()) {\n return localStorage.getItem(this.getKeyName());\n } else {\n return null;\n }\n }\n\n private openInitialNodes(nodeIds: NodeId[]): boolean {\n let mustLoadOnDemand = false;\n\n for (const nodeId of nodeIds) {\n const node = this.getNodeById(nodeId);\n\n if (node) {\n if (!node.load_on_demand) {\n node.is_open = true;\n } else {\n mustLoadOnDemand = true;\n }\n }\n }\n\n return mustLoadOnDemand;\n }\n\n private selectInitialNodes(nodeIds: NodeId[]): boolean {\n let selectCount = 0;\n\n for (const nodeId of nodeIds) {\n const node = this.getNodeById(nodeId);\n\n if (node) {\n selectCount += 1;\n\n this.addToSelection(node);\n }\n }\n\n return selectCount !== 0;\n }\n\n private resetSelection(): void {\n const selectedNodes = this.getSelectedNodes();\n\n selectedNodes.forEach((node) => {\n this.removeFromSelection(node);\n });\n }\n\n private getKeyName(): string {\n if (typeof this.saveStateOption === \"string\") {\n return this.saveStateOption;\n } else {\n return \"tree\";\n }\n }\n\n private supportsLocalStorage(): boolean {\n const testSupport = (): boolean => {\n // Is local storage supported?\n if (localStorage == null) {\n return false;\n } else {\n // Check if it's possible to store an item. Safari does not allow this in private browsing mode.\n try {\n const key = \"_storage_test\";\n sessionStorage.setItem(key, \"value\");\n sessionStorage.removeItem(key);\n } catch (error) {\n return false;\n }\n\n return true;\n }\n };\n\n if (this._supportsLocalStorage == null) {\n this._supportsLocalStorage = testSupport();\n }\n\n return this._supportsLocalStorage;\n }\n}\n","import type { ScrollParent } from \"./types\";\nimport { getElementPosition, getOffsetTop } from '../util'\n\ntype HorizontalScrollDirection = \"left\" | \"right\";\ntype VerticalScrollDirection = \"bottom\" | \"top\";\n\ninterface Params {\n container: HTMLElement;\n refreshHitAreas: () => void;\n}\n\nexport default class ContainerScrollParent implements ScrollParent {\n private container: HTMLElement;\n private horizontalScrollDirection?: HorizontalScrollDirection;\n private horizontalScrollTimeout?: number;\n private refreshHitAreas: () => void;\n private scrollParentBottom?: number;\n private scrollParentTop?: number;\n private verticalScrollTimeout?: number;\n private verticalScrollDirection?: VerticalScrollDirection;\n\n constructor({ container, refreshHitAreas }: Params) {\n this.container = container;\n this.refreshHitAreas = refreshHitAreas;\n }\n\n public checkHorizontalScrolling(pageX: number): void {\n const newHorizontalScrollDirection =\n this.getNewHorizontalScrollDirection(pageX);\n\n if (this.horizontalScrollDirection !== newHorizontalScrollDirection) {\n this.horizontalScrollDirection = newHorizontalScrollDirection;\n\n if (this.horizontalScrollTimeout != null) {\n window.clearTimeout(this.verticalScrollTimeout);\n }\n\n if (newHorizontalScrollDirection) {\n this.horizontalScrollTimeout = window.setTimeout(\n this.scrollHorizontally.bind(this),\n 40,\n );\n }\n }\n }\n\n public checkVerticalScrolling(pageY: number) {\n const newVerticalScrollDirection =\n this.getNewVerticalScrollDirection(pageY);\n\n if (this.verticalScrollDirection !== newVerticalScrollDirection) {\n this.verticalScrollDirection = newVerticalScrollDirection;\n\n if (this.verticalScrollTimeout != null) {\n window.clearTimeout(this.verticalScrollTimeout);\n this.verticalScrollTimeout = undefined;\n }\n\n if (newVerticalScrollDirection) {\n this.verticalScrollTimeout = window.setTimeout(\n this.scrollVertically.bind(this),\n 40,\n );\n }\n }\n }\n\n public getScrollLeft(): number {\n return this.container.scrollLeft;\n }\n\n public scrollToY(top: number): void {\n this.container.scrollTop = top;\n }\n\n public stopScrolling() {\n this.horizontalScrollDirection = undefined;\n this.verticalScrollDirection = undefined;\n this.scrollParentTop = undefined;\n this.scrollParentBottom = undefined;\n }\n\n private getNewHorizontalScrollDirection(\n pageX: number,\n ): HorizontalScrollDirection | undefined {\n const scrollParentOffset = getElementPosition(this.container);\n\n const rightEdge = scrollParentOffset.left + this.container.clientWidth;\n const leftEdge = scrollParentOffset.left;\n const isNearRightEdge = pageX > rightEdge - 20;\n const isNearLeftEdge = pageX < leftEdge + 20;\n\n if (isNearRightEdge) {\n return \"right\";\n } else if (isNearLeftEdge) {\n return \"left\";\n }\n\n return undefined;\n }\n\n private getNewVerticalScrollDirection(\n pageY: number,\n ): VerticalScrollDirection | undefined {\n if (pageY < this.getScrollParentTop()) {\n return \"top\";\n }\n\n if (pageY > this.getScrollParentBottom()) {\n return \"bottom\";\n }\n\n return undefined;\n }\n\n private scrollHorizontally() {\n if (!this.horizontalScrollDirection) {\n return;\n }\n\n const distance = this.horizontalScrollDirection === \"left\" ? -20 : 20;\n\n this.container.scrollBy({\n left: distance,\n top: 0,\n behavior: \"instant\",\n });\n\n this.refreshHitAreas();\n\n setTimeout(this.scrollHorizontally.bind(this), 40);\n }\n\n private scrollVertically() {\n if (!this.verticalScrollDirection) {\n return;\n }\n\n const distance = this.verticalScrollDirection === \"top\" ? -20 : 20;\n\n this.container.scrollBy({\n left: 0,\n top: distance,\n behavior: \"instant\",\n });\n\n this.refreshHitAreas();\n\n setTimeout(this.scrollVertically.bind(this), 40);\n }\n\n private getScrollParentTop() {\n if (this.scrollParentTop == null) {\n this.scrollParentTop = getOffsetTop(this.container)\n }\n\n return this.scrollParentTop;\n }\n\n private getScrollParentBottom() {\n if (this.scrollParentBottom == null) {\n this.scrollParentBottom = this.getScrollParentTop() + this.container.clientHeight;\n }\n\n return this.scrollParentBottom;\n }\n}\n","import type { ScrollParent } from \"./types\";\nimport { getOffsetTop } from '../util'\n\ntype HorizontalScrollDirection = \"left\" | \"right\";\ntype VerticalScrollDirection = \"bottom\" | \"top\";\n\ninterface Params {\n refreshHitAreas: () => void;\n treeElement: HTMLElement;\n}\n\nexport default class DocumentScrollParent implements ScrollParent {\n private documentScrollHeight?: number;\n private documentScrollWidth?: number;\n private horizontalScrollDirection?: HorizontalScrollDirection;\n private horizontalScrollTimeout?: number;\n private refreshHitAreas: () => void;\n private treeElement: HTMLElement;\n private verticalScrollDirection?: VerticalScrollDirection;\n private verticalScrollTimeout?: number;\n\n constructor({ refreshHitAreas, treeElement }: Params) {\n this.refreshHitAreas = refreshHitAreas;\n this.treeElement = treeElement;\n }\n\n public checkHorizontalScrolling(pageX: number): void {\n const newHorizontalScrollDirection =\n this.getNewHorizontalScrollDirection(pageX);\n\n if (this.horizontalScrollDirection !== newHorizontalScrollDirection) {\n this.horizontalScrollDirection = newHorizontalScrollDirection;\n\n if (this.horizontalScrollTimeout != null) {\n window.clearTimeout(this.horizontalScrollTimeout);\n }\n\n if (newHorizontalScrollDirection) {\n this.horizontalScrollTimeout = window.setTimeout(\n this.scrollHorizontally.bind(this),\n 40,\n );\n }\n }\n }\n\n public checkVerticalScrolling(pageY: number) {\n const newVerticalScrollDirection =\n this.getNewVerticalScrollDirection(pageY);\n\n if (this.verticalScrollDirection !== newVerticalScrollDirection) {\n this.verticalScrollDirection = newVerticalScrollDirection;\n\n if (this.verticalScrollTimeout != null) {\n window.clearTimeout(this.verticalScrollTimeout);\n this.verticalScrollTimeout = undefined;\n }\n\n if (newVerticalScrollDirection) {\n this.verticalScrollTimeout = window.setTimeout(\n this.scrollVertically.bind(this),\n 40,\n );\n }\n }\n }\n\n public getScrollLeft(): number {\n return document.documentElement.scrollLeft;\n }\n\n public scrollToY(top: number): void {\n const treeTop = getOffsetTop(this.treeElement);\n\n document.documentElement.scrollTop = top + treeTop;\n }\n\n public stopScrolling() {\n this.horizontalScrollDirection = undefined;\n this.verticalScrollDirection = undefined;\n this.documentScrollHeight = undefined;\n this.documentScrollWidth = undefined;\n }\n\n private getNewHorizontalScrollDirection(\n pageX: number,\n ): HorizontalScrollDirection | undefined {\n const scrollLeft = document.documentElement.scrollLeft;\n const windowWidth = window.innerWidth;\n\n const isNearRightEdge = pageX > windowWidth - 20;\n const isNearLeftEdge = pageX - scrollLeft < 20;\n\n if (isNearRightEdge && this.canScrollRight()) {\n return \"right\";\n }\n\n if (isNearLeftEdge) {\n return \"left\";\n }\n\n return undefined;\n }\n\n private canScrollRight() {\n const documentElement = document.documentElement;\n\n return (\n documentElement.scrollLeft + documentElement.clientWidth <\n this.getDocumentScrollWidth()\n );\n }\n\n private canScrollDown() {\n const documentElement = document.documentElement;\n\n return (\n documentElement.scrollTop + documentElement.clientHeight <\n this.getDocumentScrollHeight()\n );\n }\n\n private getDocumentScrollHeight() {\n // Store the original scroll height because the scroll height can increase when the drag element is moved beyond the scroll height.\n if (this.documentScrollHeight == null) {\n this.documentScrollHeight = document.documentElement.scrollHeight;\n }\n\n return this.documentScrollHeight;\n }\n\n private getDocumentScrollWidth() {\n // Store the original scroll width because the scroll width can increase when the drag element is moved beyond the scroll width.\n if (this.documentScrollWidth == null) {\n this.documentScrollWidth = document.documentElement.scrollWidth;\n }\n\n return this.documentScrollWidth;\n }\n\n private getNewVerticalScrollDirection(\n pageY: number,\n ): VerticalScrollDirection | undefined {\n const scrollTop = jQuery(document).scrollTop() || 0;\n const distanceTop = pageY - scrollTop;\n\n if (distanceTop < 20) {\n return \"top\";\n }\n\n const windowHeight = window.innerHeight;\n\n if (windowHeight - (pageY - scrollTop) < 20 && this.canScrollDown()) {\n return \"bottom\";\n }\n\n return undefined;\n }\n\n private scrollHorizontally() {\n if (!this.horizontalScrollDirection) {\n return;\n }\n\n const distance = this.horizontalScrollDirection === \"left\" ? -20 : 20;\n window.scrollBy({ left: distance, top: 0, behavior: \"instant\" });\n\n this.refreshHitAreas();\n\n setTimeout(this.scrollHorizontally.bind(this), 40);\n }\n\n private scrollVertically() {\n if (!this.verticalScrollDirection) {\n return;\n }\n\n const distance = this.verticalScrollDirection === \"top\" ? -20 : 20;\n window.scrollBy({ left: 0, top: distance, behavior: \"instant\" });\n\n this.refreshHitAreas();\n\n setTimeout(this.scrollVertically.bind(this), 40);\n }\n}\n","import type { ScrollParent } from \"./types\";\nimport ContainerScrollParent from \"./containerScrollParent\";\nimport DocumentScrollParent from \"./documentScrollParent\";\n\nconst isOverflow = (overflowValue: string) =>\n overflowValue === \"auto\" || overflowValue === \"scroll\";\n\nconst hasOverFlow = (element: HTMLElement): boolean => {\n const style = getComputedStyle(element);\n\n return isOverflow(style.overflowX) || isOverflow(style.overflowY);\n};\n\nconst getParentWithOverflow = (\n treeElement: HTMLElement,\n): HTMLElement | null => {\n if (hasOverFlow(treeElement)) {\n return treeElement;\n }\n\n let parent = treeElement.parentElement;\n\n while (parent) {\n if (hasOverFlow(parent)) {\n return parent;\n }\n\n parent = parent.parentElement;\n }\n\n return null;\n};\n\nconst createScrollParent = (\n treeElement: HTMLElement,\n refreshHitAreas: () => void,\n): ScrollParent => {\n const container = getParentWithOverflow(treeElement);\n\n if (container && container.tagName !== \"HTML\") {\n return new ContainerScrollParent({\n container,\n refreshHitAreas,\n });\n } else {\n return new DocumentScrollParent({ refreshHitAreas, treeElement });\n }\n};\n\nexport default createScrollParent;\n","import { PositionInfo } from \"./mouseUtils\";\nimport { ScrollParent } from \"./scrollHandler/types\";\nimport createScrollParent from \"./scrollHandler/createScrollParent\";\n\ninterface ScrollHandlerParams {\n refreshHitAreas: () => void;\n treeElement: HTMLElement;\n}\n\nexport default class ScrollHandler {\n private refreshHitAreas: () => void;\n private scrollParent?: ScrollParent;\n private treeElement: HTMLElement;\n\n constructor({ refreshHitAreas, treeElement }: ScrollHandlerParams) {\n this.refreshHitAreas = refreshHitAreas;\n this.scrollParent = undefined;\n this.treeElement = treeElement;\n }\n\n public checkScrolling(positionInfo: PositionInfo): void {\n this.checkVerticalScrolling(positionInfo);\n this.checkHorizontalScrolling(positionInfo);\n }\n\n public stopScrolling() {\n this.getScrollParent().stopScrolling();\n }\n\n public scrollToY(top: number): void {\n this.getScrollParent().scrollToY(top);\n }\n\n public getScrollLeft(): number {\n return this.getScrollParent().getScrollLeft();\n }\n\n private checkVerticalScrolling(positionInfo: PositionInfo): void {\n this.getScrollParent().checkVerticalScrolling(positionInfo.pageY);\n }\n\n private checkHorizontalScrolling(positionInfo: PositionInfo): void {\n this.getScrollParent().checkHorizontalScrolling(positionInfo.pageX);\n }\n\n private getScrollParent(): ScrollParent {\n if (!this.scrollParent) {\n this.scrollParent = createScrollParent(\n this.treeElement,\n this.refreshHitAreas,\n );\n }\n\n return this.scrollParent;\n }\n}\n","import { Node } from \"./node\";\nimport { GetNodeById } from \"./jqtreeMethodTypes\";\n\ninterface SelectNodeHandlerParameters {\n getNodeById: GetNodeById;\n}\n\nexport default class SelectNodeHandler {\n private getNodeById: GetNodeById;\n private selectedNodes: Set<NodeId>;\n private selectedSingleNode: Node | null;\n\n constructor({ getNodeById }: SelectNodeHandlerParameters) {\n this.getNodeById = getNodeById;\n this.selectedNodes = new Set<NodeId>();\n this.clear();\n }\n\n public getSelectedNode(): Node | false {\n const selectedNodes = this.getSelectedNodes();\n\n if (selectedNodes.length) {\n return selectedNodes[0] || false;\n } else {\n return false;\n }\n }\n\n public getSelectedNodes(): Node[] {\n if (this.selectedSingleNode) {\n return [this.selectedSingleNode];\n } else {\n const selectedNodes: Node[] = [];\n\n this.selectedNodes.forEach((id) => {\n const node = this.getNodeById(id);\n if (node) {\n selectedNodes.push(node);\n }\n });\n\n return selectedNodes;\n }\n }\n\n public getSelectedNodesUnder(parent: Node): Node[] {\n if (this.selectedSingleNode) {\n if (parent.isParentOf(this.selectedSingleNode)) {\n return [this.selectedSingleNode];\n } else {\n return [];\n }\n } else {\n const selectedNodes = [];\n\n for (const id in this.selectedNodes) {\n if (\n Object.prototype.hasOwnProperty.call(this.selectedNodes, id)\n ) {\n const node = this.getNodeById(id);\n if (node && parent.isParentOf(node)) {\n selectedNodes.push(node);\n }\n }\n }\n\n return selectedNodes;\n }\n }\n\n public isNodeSelected(node: Node): boolean {\n if (node.id != null) {\n return this.selectedNodes.has(node.id);\n } else if (this.selectedSingleNode) {\n return this.selectedSingleNode.element === node.element;\n } else {\n return false;\n }\n }\n\n public clear(): void {\n this.selectedNodes.clear();\n this.selectedSingleNode = null;\n }\n\n public removeFromSelection(node: Node, includeChildren = false): void {\n if (node.id == null) {\n if (\n this.selectedSingleNode &&\n node.element === this.selectedSingleNode.element\n ) {\n this.selectedSingleNode = null;\n }\n } else {\n this.selectedNodes.delete(node.id);\n\n if (includeChildren) {\n node.iterate(() => {\n if (node.id != null) {\n this.selectedNodes.delete(node.id);\n }\n return true;\n });\n }\n }\n }\n\n public addToSelection(node: Node): void {\n if (node.id != null) {\n this.selectedNodes.add(node.id);\n } else {\n this.selectedSingleNode = node;\n }\n }\n}\n","const register = (widgetClass: unknown, widgetName: string): void => {\n const getDataKey = (): string => `simple_widget_${widgetName}`;\n\n const getWidgetData = (\n el: HTMLElement,\n dataKey: string\n ): SimpleWidget<unknown> | null => {\n const widget = jQuery.data(el, dataKey) as unknown;\n\n if (widget && widget instanceof SimpleWidget) {\n return widget;\n } else {\n return null;\n }\n };\n\n const createWidget = ($el: JQuery, options: unknown): JQuery => {\n const dataKey = getDataKey();\n\n for (const el of $el.get()) {\n const existingWidget = getWidgetData(el, dataKey);\n\n if (!existingWidget) {\n const simpleWidgetClass = widgetClass as typeof SimpleWidget;\n const widget = new simpleWidgetClass(el, options);\n\n if (!jQuery.data(el, dataKey)) {\n jQuery.data(el, dataKey, widget);\n }\n\n // Call init after setting data, so we can call methods\n widget.init();\n }\n }\n\n return $el;\n };\n\n const destroyWidget = ($el: JQuery): void => {\n const dataKey = getDataKey();\n\n for (const el of $el.get()) {\n const widget = getWidgetData(el, dataKey);\n\n if (widget) {\n widget.destroy();\n }\n\n jQuery.removeData(el, dataKey);\n }\n };\n\n const callFunction = (\n $el: JQuery,\n functionName: string,\n args: unknown[]\n ): unknown => {\n let result = null;\n\n for (const el of $el.get()) {\n const widget = jQuery.data(el, getDataKey()) as unknown;\n\n if (widget && widget instanceof SimpleWidget) {\n const simpleWidget = widget as SimpleWidget<unknown>;\n const widgetFunction = simpleWidget[functionName];\n\n if (widgetFunction && typeof widgetFunction === \"function\") {\n result = widgetFunction.apply(widget, args) as unknown;\n }\n }\n }\n\n return result;\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n (jQuery.fn as any)[widgetName] = function (\n this: JQuery,\n argument1: unknown,\n ...args: unknown[]\n ) {\n if (!argument1) {\n return createWidget(this, null);\n } else if (typeof argument1 === \"object\") {\n const options = argument1 as unknown;\n return createWidget(this, options);\n } else if (typeof argument1 === \"string\" && argument1[0] !== \"_\") {\n const functionName = argument1;\n\n if (functionName === \"destroy\") {\n return destroyWidget(this);\n } else if (functionName === \"get_widget_class\") {\n return widgetClass;\n } else {\n return callFunction(this, functionName, args);\n }\n } else {\n return undefined;\n }\n };\n};\n\nexport default class SimpleWidget<WidgetOptions> {\n public static register(widgetClass: unknown, widgetName: string): void {\n register(widgetClass, widgetName);\n }\n\n [key: string]: unknown;\n\n protected static defaults: unknown = {};\n\n public options: WidgetOptions;\n\n public $el: JQuery<HTMLElement>;\n\n constructor(el: HTMLElement, options: WidgetOptions) {\n this.$el = jQuery(el);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const defaults = (this.constructor as any)[\"defaults\"] as WidgetOptions;\n this.options = { ...defaults, ...options };\n }\n\n public destroy(): void {\n this.deinit();\n }\n\n public init(): void {\n //\n }\n\n public deinit(): void {\n //\n }\n}\n","interface NodeRecordWithChildren extends NodeRecord {\n children: NodeData[];\n}\n\nexport const isNodeRecordWithChildren = (\n data: NodeData,\n): data is NodeRecordWithChildren =>\n typeof data === \"object\" &&\n \"children\" in data &&\n data[\"children\"] instanceof Array;\n","import { isNodeRecordWithChildren } from \"./nodeUtils\";\nimport { Position } from \"./position\";\n\ntype IterateCallback = (node: Node, level: number) => boolean;\n\nexport class Node implements INode {\n public id?: NodeId;\n public name: string;\n public children: Node[];\n public parent: Node | null;\n public idMapping: Map<NodeId, Node>;\n public tree?: Node;\n public nodeClass?: typeof Node;\n public load_on_demand: boolean;\n public is_open: boolean;\n public element: HTMLElement;\n public is_loading: boolean;\n public isEmptyFolder: boolean;\n\n [key: string]: unknown;\n\n constructor(\n nodeData: NodeData | null = null,\n isRoot = false,\n nodeClass = Node,\n ) {\n this.name = \"\";\n this.load_on_demand = false;\n\n this.isEmptyFolder =\n nodeData != null &&\n isNodeRecordWithChildren(nodeData) &&\n nodeData.children.length === 0;\n\n this.setData(nodeData);\n\n this.children = [];\n this.parent = null;\n\n if (isRoot) {\n this.idMapping = new Map<NodeId, Node>();\n this.tree = this;\n this.nodeClass = nodeClass;\n }\n }\n\n /*\n Set the data of this node.\n\n setData(string): set the name of the node\n setData(object): set attributes of the node\n\n Examples:\n setData('node1')\n\n setData({ name: 'node1', id: 1});\n\n setData({ name: 'node2', id: 2, color: 'green'});\n\n * This is an internal function; it is not in the docs\n * Does not remove existing node values\n */\n public setData(o: NodeData | null): void {\n if (!o) {\n return;\n } else if (typeof o === \"string\") {\n this.name = o;\n } else if (typeof o === \"object\") {\n for (const key in o) {\n if (Object.prototype.hasOwnProperty.call(o, key)) {\n const value = o[key];\n\n if (key === \"label\" || key === \"name\") {\n // You can use the 'label' key instead of 'name'; this is a legacy feature\n if (typeof value === \"string\") {\n this.name = value;\n }\n } else if (key !== \"children\" && key !== \"parent\") {\n // You can't update the children or the parent using this function\n this[key] = value;\n }\n }\n }\n }\n }\n\n /*\n Create tree from data.\n\n Structure of data is:\n [\n {\n name: 'node1',\n children: [\n { name: 'child1' },\n { name: 'child2' }\n ]\n },\n {\n name: 'node2'\n }\n ]\n */\n public loadFromData(data: NodeData[]): Node {\n this.removeChildren();\n\n for (const childData of data) {\n const node = this.createNode(childData);\n this.addChild(node);\n\n if (isNodeRecordWithChildren(childData)) {\n node.loadFromData(childData.children);\n }\n }\n\n return this;\n }\n\n /*\n Add child.\n\n tree.addChild(\n new Node('child1')\n );\n */\n public addChild(node: Node): void {\n this.children.push(node);\n node.setParent(this);\n }\n\n /*\n Add child at position. Index starts at 0.\n\n tree.addChildAtPosition(\n new Node('abc'),\n 1\n );\n */\n public addChildAtPosition(node: Node, index: number): void {\n this.children.splice(index, 0, node);\n node.setParent(this);\n }\n\n /*\n Remove child. This also removes the children of the node.\n\n tree.removeChild(tree.children[0]);\n */\n public removeChild(node: Node): void {\n // remove children from the index\n node.removeChildren();\n\n this.doRemoveChild(node);\n }\n\n /*\n Get child index.\n\n var index = getChildIndex(node);\n */\n public getChildIndex(node: Node): number {\n return this.children.indexOf(node);\n }\n\n /*\n Does the tree have children?\n\n if (tree.hasChildren()) {\n //\n }\n */\n public hasChildren(): boolean {\n return this.children.length !== 0;\n }\n\n public isFolder(): boolean {\n return this.hasChildren() || this.load_on_demand;\n }\n\n /*\n Iterate over all the nodes in the tree.\n\n Calls callback with (node, level).\n\n The callback must return true to continue the iteration on current node.\n\n tree.iterate(\n function(node, level) {\n console.log(node.name);\n\n // stop iteration after level 2\n return (level <= 2);\n }\n );\n\n */\n public iterate(callback: IterateCallback): void {\n const _iterate = (node: Node, level: number): void => {\n if (node.children) {\n for (const child of node.children) {\n const result = callback(child, level);\n\n if (result && child.hasChildren()) {\n _iterate(child, level + 1);\n }\n }\n }\n };\n\n _iterate(this, 0);\n }\n\n /*\n Move node relative to another node.\n\n Argument position: Position.BEFORE, Position.AFTER or Position.Inside\n\n // move node1 after node2\n tree.moveNode(node1, node2, Position.AFTER);\n */\n public moveNode(\n movedNode: Node,\n targetNode: Node,\n position: Position,\n ): boolean {\n if (!movedNode.parent || movedNode.isParentOf(targetNode)) {\n // - Node is parent of target node\n // - Or, parent is empty\n return false;\n } else {\n movedNode.parent.doRemoveChild(movedNode);\n\n switch (position) {\n case Position.After: {\n if (targetNode.parent) {\n targetNode.parent.addChildAtPosition(\n movedNode,\n targetNode.parent.getChildIndex(targetNode) + 1,\n );\n return true;\n }\n return false;\n }\n\n case Position.Before: {\n if (targetNode.parent) {\n targetNode.parent.addChildAtPosition(\n movedNode,\n targetNode.parent.getChildIndex(targetNode),\n );\n return true;\n }\n return false;\n }\n\n case Position.Inside: {\n // move inside as first child\n targetNode.addChildAtPosition(movedNode, 0);\n return true;\n }\n\n default:\n return false;\n }\n }\n }\n\n /*\n Get the tree as data.\n */\n public getData(includeParent = false): NodeRecord[] {\n const getDataFromNodes = (nodes: Node[]): Record<string, unknown>[] => {\n return nodes.map((node) => {\n const tmpNode: Record<string, unknown> = {};\n\n for (const k in node) {\n if (\n [\n \"parent\",\n \"children\",\n \"element\",\n \"idMapping\",\n \"load_on_demand\",\n \"nodeClass\",\n \"tree\",\n \"isEmptyFolder\",\n ].indexOf(k) === -1 &&\n Object.prototype.hasOwnProperty.call(node, k)\n ) {\n const v = node[k];\n tmpNode[k] = v;\n }\n }\n\n if (node.hasChildren()) {\n tmpNode[\"children\"] = getDataFromNodes(node.children);\n }\n\n return tmpNode;\n });\n };\n\n if (includeParent) {\n return getDataFromNodes([this]);\n } else {\n return getDataFromNodes(this.children);\n }\n }\n\n public getNodeByName(name: string): Node | null {\n return this.getNodeByCallback((node: Node) => node.name === name);\n }\n\n public getNodeByNameMustExist(name: string): Node {\n const node = this.getNodeByCallback((n: Node) => n.name === name);\n\n if (!node) {\n throw `Node with name ${name} not found`;\n }\n\n return node;\n }\n\n public getNodeByCallback(callback: (node: Node) => boolean): Node | null {\n let result: Node | null = null;\n\n this.iterate((node: Node) => {\n if (result) {\n return false;\n } else if (callback(node)) {\n result = node;\n return false;\n } else {\n return true;\n }\n });\n\n return result;\n }\n\n public addAfter(nodeInfo: NodeData): Node | null {\n if (!this.parent) {\n return null;\n } else {\n const node = this.createNode(nodeInfo);\n\n const childIndex = this.parent.getChildIndex(this);\n this.parent.addChildAtPosition(node, childIndex + 1);\n\n node.loadChildrenFromData(nodeInfo);\n return node;\n }\n }\n\n public addBefore(nodeInfo: NodeData): Node | null {\n if (!this.parent) {\n return null;\n } else {\n const node = this.createNode(nodeInfo);\n\n const childIndex = this.parent.getChildIndex(this);\n this.parent.addChildAtPosition(node, childIndex);\n\n node.loadChildrenFromData(nodeInfo);\n return node;\n }\n }\n\n public addParent(nodeInfo: NodeData): Node | null {\n if (!this.parent) {\n return null;\n } else {\n const newParent = this.createNode(nodeInfo);\n\n if (this.tree) {\n newParent.setParent(this.tree);\n }\n const originalParent = this.parent;\n\n for (const child of originalParent.children) {\n newParent.addChild(child);\n }\n\n originalParent.children = [];\n originalParent.addChild(newParent);\n return newParent;\n }\n }\n\n public remove(): void {\n if (this.parent) {\n this.parent.removeChild(this);\n this.parent = null;\n }\n }\n\n public append(nodeInfo: NodeData): Node {\n const node = this.createNode(nodeInfo);\n this.addChild(node);\n\n node.loadChildrenFromData(nodeInfo);\n return node;\n }\n\n public prepend(nodeInfo: NodeData): Node {\n const node = this.createNode(nodeInfo);\n this.addChildAtPosition(node, 0);\n\n node.loadChildrenFromData(nodeInfo);\n return node;\n }\n\n public isParentOf(node: Node): boolean {\n let parent = node.parent;\n\n while (parent) {\n if (parent === this) {\n return true;\n }\n\n parent = parent.parent;\n }\n\n return false;\n }\n\n public getLevel(): number {\n let level = 0;\n let node: Node = this; // eslint-disable-line @typescript-eslint/no-this-alias\n\n while (node.parent) {\n level += 1;\n node = node.parent;\n }\n\n return level;\n }\n\n public getNodeById(nodeId: NodeId): Node | null {\n return this.idMapping.get(nodeId) || null;\n }\n\n public addNodeToIndex(node: Node): void {\n if (node.id != null) {\n this.idMapping.set(node.id, node);\n }\n }\n\n public removeNodeFromIndex(node: Node): void {\n if (node.id != null) {\n this.idMapping.delete(node.id);\n }\n }\n\n public removeChildren(): void {\n this.iterate((child: Node) => {\n this.tree?.removeNodeFromIndex(child);\n return true;\n });\n\n this.children = [];\n }\n\n public getPreviousSibling(): Node | null {\n if (!this.parent) {\n return null;\n } else {\n const previousIndex = this.parent.getChildIndex(this) - 1;\n if (previousIndex >= 0) {\n return this.parent.children[previousIndex] || null;\n } else {\n return null;\n }\n }\n }\n\n public getNextSibling(): Node | null {\n if (!this.parent) {\n return null;\n } else {\n const nextIndex = this.parent.getChildIndex(this) + 1;\n if (nextIndex < this.parent.children.length) {\n return this.parent.children[nextIndex] || null;\n } else {\n return null;\n }\n }\n }\n\n public getNodesByProperty(key: string, value: unknown): Node[] {\n return this.filter((node: Node) => node[key] === value);\n }\n\n public filter(f: (node: Node) => boolean): Node[] {\n const result: Node[] = [];\n\n this.iterate((node: Node) => {\n if (f(node)) {\n result.push(node);\n }\n\n return true;\n });\n\n return result;\n }\n\n public getNextNode(includeChildren = true): Node | null {\n if (includeChildren && this.hasChildren()) {\n return this.children[0] || null;\n } else if (!this.parent) {\n return null;\n } else {\n const nextSibling = this.getNextSibling();\n\n if (nextSibling) {\n return nextSibling;\n } else {\n return this.parent.getNextNode(false);\n }\n }\n }\n\n public getNextVisibleNode(): Node | null {\n if (this.hasChildren() && this.is_open) {\n // First child\n return this.children[0] || null;\n } else {\n if (!this.parent) {\n return null;\n } else {\n const nextSibling = this.getNextSibling();\n if (nextSibling) {\n // Next sibling\n return nextSibling;\n } else {\n // Next node of parent\n return this.parent.getNextNode(false);\n }\n }\n }\n }\n\n public getPreviousNode(): Node | null {\n if (!this.parent) {\n return null;\n } else {\n const previousSibling = this.getPreviousSibling();\n\n if (!previousSibling) {\n return this.getParent();\n } else if (previousSibling.hasChildren()) {\n return previousSibling.getLastChild();\n } else {\n return previousSibling;\n }\n }\n }\n\n public getPreviousVisibleNode(): Node | null {\n if (!this.parent) {\n return null;\n } else {\n const previousSibling = this.getPreviousSibling();\n\n if (!previousSibling) {\n return this.getParent();\n } else if (\n !previousSibling.hasChildren() ||\n !previousSibling.is_open\n ) {\n // Previous sibling\n return previousSibling;\n } else {\n // Last child of previous sibling\n return previousSibling.getLastChild();\n }\n }\n }\n\n public getParent(): Node | null {\n // Return parent except if it is the root node\n if (!this.parent) {\n return null;\n } else if (!this.parent.parent) {\n // Root node -> null\n return null;\n } else {\n return this.parent;\n }\n }\n\n public getLastChild(): Node | null {\n if (!this.hasChildren()) {\n return null;\n } else {\n const lastChild = this.children[this.children.length - 1];\n\n if (!lastChild) {\n return null;\n }\n\n if (!(lastChild.hasChildren() && lastChild.is_open)) {\n return lastChild;\n } else {\n return lastChild?.getLastChild();\n }\n }\n }\n\n // Init Node from data without making it the root of the tree\n public initFromData(data: NodeData): void {\n const addNode = (nodeData: NodeData): void => {\n this.setData(nodeData);\n\n if (\n isNodeRecordWithChildren(nodeData) &&\n nodeData.children.length\n ) {\n addChildren(nodeData.children);\n }\n };\n\n const addChildren = (childrenData: NodeData[]): void => {\n for (const child of childrenData) {\n const node = this.createNode();\n node.initFromData(child);\n this.addChild(node);\n }\n };\n\n addNode(data);\n }\n\n private setParent(parent: Node): void {\n this.parent = parent;\n this.tree = parent.tree;\n this.tree?.addNodeToIndex(this);\n }\n\n private doRemoveChild(node: Node): void {\n this.children.splice(this.getChildIndex(node), 1);\n this.tree?.removeNodeFromIndex(node);\n }\n\n private getNodeClass(): typeof Node {\n return this.nodeClass || this?.tree?.nodeClass || Node;\n }\n\n private createNode(nodeData?: NodeData): Node {\n const nodeClass = this.getNodeClass();\n return new nodeClass(nodeData);\n }\n\n // Load children data from nodeInfo if it has children\n private loadChildrenFromData(nodeInfo: NodeData) {\n if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {\n this.loadFromData(nodeInfo.children);\n }\n }\n}\n","import { DropHint } from \"../dragAndDropHandler/types\";\n\nclass BorderDropHint implements DropHint {\n private hint?: HTMLElement;\n\n constructor(element: HTMLElement, scrollLeft: number) {\n const div = element.querySelector(\":scope > .jqtree-element\");\n\n if (!div) {\n this.hint = undefined;\n return;\n }\n\n const width = Math.max(element.offsetWidth + scrollLeft - 4, 0);\n const height = Math.max(element.clientHeight - 4, 0);\n\n const hint = document.createElement(\"span\");\n hint.className = \"jqtree-border\";\n hint.style.width = `${width}px`;\n hint.style.height = `${height}px`;\n\n this.hint = hint;\n\n div.append(this.hint);\n }\n\n public remove(): void {\n this.hint?.remove();\n }\n}\n\nexport default BorderDropHint;\n","import { DropHint } from \"../dragAndDropHandler/types\";\n\nclass GhostDropHint implements DropHint {\n private element: HTMLElement;\n private ghost: HTMLElement;\n\n constructor(element: HTMLElement) {\n this.element = element;\n this.ghost = this.createGhostElement();\n\n this.element.after(this.ghost);\n this.ghost.classList.add(\"jqtree-inside\");\n }\n\n public remove(): void {\n this.ghost.remove();\n }\n\n private createGhostElement() {\n const ghost = document.createElement(\"li\");\n ghost.className = \"jqtree_common jqtree-ghost\";\n\n const circleSpan = document.createElement(\"span\");\n circleSpan.className = \"jqtree_common jqtree-circle\";\n ghost.append(circleSpan);\n\n const lineSpan = document.createElement(\"span\");\n lineSpan.className = \"jqtree_common jqtree-line\";\n ghost.append(lineSpan);\n\n return ghost;\n }\n}\n\nexport default GhostDropHint;\n","import { Node } from \"../node\";\nimport { Position } from \"../position\";\nimport { DropHint } from \"../dragAndDropHandler/types\";\nimport BorderDropHint from \"./borderDropHint\";\nimport GhostDropHint from \"./ghostDropHint\";\nimport { GetScrollLeft } from \"../jqtreeMethodTypes\";\n\nexport interface NodeElementParams {\n getScrollLeft: GetScrollLeft;\n node: Node;\n tabIndex?: number;\n $treeElement: JQuery<HTMLElement>;\n}\n\nclass NodeElement {\n public node: Node;\n public element: HTMLElement;\n private getScrollLeft: GetScrollLeft;\n private tabIndex?: number;\n private $treeElement: JQuery<HTMLElement>;\n\n constructor({\n getScrollLeft,\n node,\n tabIndex,\n $treeElement,\n }: NodeElementParams) {\n this.getScrollLeft = getScrollLeft;\n this.tabIndex = tabIndex;\n this.$treeElement = $treeElement;\n\n this.init(node);\n }\n\n public init(node: Node): void {\n this.node = node;\n\n if (!node.element) {\n const element = this.$treeElement.get(0);\n\n if (element) {\n node.element = element;\n }\n }\n\n if (node.element) {\n this.element = node.element;\n }\n }\n\n public addDropHint(position: number): DropHint {\n if (this.mustShowBorderDropHint(position)) {\n return new BorderDropHint(this.element, this.getScrollLeft());\n } else {\n return new GhostDropHint(this.element);\n }\n }\n\n public select(mustSetFocus: boolean): void {\n this.element.classList.add(\"jqtree-selected\");\n\n const titleSpan = this.getTitleSpan();\n const tabIndex = this.tabIndex;\n\n // Check for null or undefined\n if (tabIndex != null) {\n titleSpan.setAttribute(\"tabindex\", tabIndex.toString());\n }\n\n titleSpan.setAttribute(\"aria-selected\", \"true\");\n\n if (mustSetFocus) {\n titleSpan.focus();\n }\n }\n\n public deselect(): void {\n this.element.classList.remove(\"jqtree-selected\");\n\n const titleSpan = this.getTitleSpan();\n titleSpan.removeAttribute(\"tabindex\");\n titleSpan.setAttribute(\"aria-selected\", \"false\");\n\n titleSpan.blur();\n }\n\n protected getUl(): HTMLUListElement {\n return this.element.querySelector(\":scope > ul\") as HTMLUListElement;\n }\n\n protected getTitleSpan(): HTMLSpanElement {\n return this.element.querySelector(\n \":scope > .jqtree-element > span.jqtree-title\",\n ) as HTMLSpanElement;\n }\n\n protected mustShowBorderDropHint(position: Position): boolean {\n return position === Position.Inside;\n }\n}\n\nexport default NodeElement;\n","import { Position } from \"../position\";\nimport NodeElement, { NodeElementParams } from \"./index\";\nimport { OnFinishOpenNode, TriggerEvent } from \"../jqtreeMethodTypes\";\n\ninterface FolderElementParams extends NodeElementParams {\n closedIconElement?: HTMLElement | Text;\n openedIconElement?: HTMLElement | Text;\n triggerEvent: TriggerEvent;\n}\n\nclass FolderElement extends NodeElement {\n private closedIconElement?: HTMLElement | Text;\n private openedIconElement?: HTMLElement | Text;\n private triggerEvent: TriggerEvent;\n\n constructor({\n closedIconElement,\n getScrollLeft,\n node,\n openedIconElement,\n tabIndex,\n $treeElement,\n triggerEvent,\n }: FolderElementParams) {\n super({\n getScrollLeft,\n node,\n tabIndex,\n $treeElement,\n });\n\n this.closedIconElement = closedIconElement;\n this.openedIconElement = openedIconElement;\n this.triggerEvent = triggerEvent;\n }\n\n public open(\n onFinished: OnFinishOpenNode | undefined,\n slide = true,\n animationSpeed: JQuery.Duration = \"fast\",\n ): void {\n if (this.node.is_open) {\n return;\n }\n\n this.node.is_open = true;\n\n const button = this.getButton();\n button.classList.remove(\"jqtree-closed\");\n button.innerHTML = \"\";\n\n const openedIconElement = this.openedIconElement;\n\n if (openedIconElement) {\n const icon = openedIconElement.cloneNode(true);\n button.appendChild(icon);\n }\n\n const doOpen = (): void => {\n this.element.classList.remove(\"jqtree-closed\");\n\n const titleSpan = this.getTitleSpan();\n titleSpan.setAttribute(\"aria-expanded\", \"true\");\n\n if (onFinished) {\n onFinished(this.node);\n }\n\n this.triggerEvent(\"tree.open\", {\n node: this.node,\n });\n };\n\n if (slide) {\n jQuery(this.getUl()).slideDown(animationSpeed, doOpen);\n } else {\n jQuery(this.getUl()).show();\n doOpen();\n }\n }\n\n public close(\n slide = true,\n animationSpeed: JQuery.Duration | undefined = \"fast\",\n ): void {\n if (!this.node.is_open) {\n return;\n }\n\n this.node.is_open = false;\n\n const button = this.getButton();\n button.classList.add(\"jqtree-closed\");\n button.innerHTML = \"\";\n\n const closedIconElement = this.closedIconElement;\n\n if (closedIconElement) {\n const icon = closedIconElement.cloneNode(true);\n button.appendChild(icon);\n }\n\n const doClose = (): void => {\n this.element.classList.add(\"jqtree-closed\");\n\n const titleSpan = this.getTitleSpan();\n titleSpan.setAttribute(\"aria-expanded\", \"false\");\n\n this.triggerEvent(\"tree.close\", {\n node: this.node,\n });\n };\n\n if (slide) {\n jQuery(this.getUl()).slideUp(animationSpeed, doClose);\n } else {\n jQuery(this.getUl()).hide();\n doClose();\n }\n }\n\n protected mustShowBorderDropHint(position: Position): boolean {\n return !this.node.is_open && position === Position.Inside;\n }\n\n private getButton(): HTMLLinkElement {\n return this.element.querySelector(\n \":scope > .jqtree-element > a.jqtree-toggler\",\n ) as HTMLLinkElement;\n }\n}\n\nexport default FolderElement;\n","import __version__ from \"./version\";\nimport { DragAndDropHandler } from \"./dragAndDropHandler\";\nimport ElementsRenderer from \"./elementsRenderer\";\nimport DataLoader, { HandleFinishedLoading } from \"./dataLoader\";\nimport KeyHandler from \"./keyHandler\";\nimport MouseHandler from \"./mouseHandler\";\nimport { PositionInfo } from \"./mouseUtils\";\nimport SaveStateHandler, { SavedState } from \"./saveStateHandler\";\nimport ScrollHandler from \"./scrollHandler\";\nimport SelectNodeHandler from \"./selectNodeHandler\";\nimport SimpleWidget from \"./simple.widget\";\nimport { getOffsetTop, isFunction } from \"./util\";\nimport { Node } from \"./node\";\nimport { getPosition } from \"./position\";\nimport NodeElement from \"./nodeElement\";\nimport FolderElement from \"./nodeElement/folderElement\";\nimport { OnFinishOpenNode } from \"./jqtreeMethodTypes\";\nimport { JQTreeOptions } from \"./jqtreeOptions\";\n\ninterface SelectNodeOptions {\n mustToggle?: boolean;\n mustSetFocus?: boolean;\n}\n\nconst NODE_PARAM_IS_EMPTY = \"Node parameter is empty\";\nconst PARAM_IS_EMPTY = \"Parameter is empty: \";\n\nexport class JqTreeWidget extends SimpleWidget<JQTreeOptions> {\n protected static defaults: JQTreeOptions = {\n animationSpeed: \"fast\",\n autoEscape: true,\n autoOpen: false, // true / false / int (open n levels starting at 0)\n buttonLeft: true,\n // The symbol to use for a closed node - ► BLACK RIGHT-POINTING POINTER\n // http://www.fileformat.info/info/unicode/char/25ba/index.htm\n closedIcon: undefined,\n data: undefined,\n dataFilter: undefined,\n dataUrl: undefined,\n dragAndDrop: false,\n keyboardSupport: true,\n nodeClass: Node,\n onCanMove: undefined, // Can this node be moved?\n onCanMoveTo: undefined, // Can this node be moved to this position? function(moved_node, target_node, position)\n onCanSelectNode: undefined,\n onCreateLi: undefined,\n onDragMove: undefined,\n onDragStop: undefined,\n onGetStateFromStorage: undefined,\n onIsMoveHandle: undefined,\n onLoadFailed: undefined,\n onLoading: undefined,\n onSetStateFromStorage: undefined,\n openedIcon: \"▼\",\n openFolderDelay: 500, // The delay for opening a folder during drag and drop; the value is in milliseconds\n // The symbol to use for an open node - ▼ BLACK DOWN-POINTING TRIANGLE\n // http://www.fileformat.info/info/unicode/char/25bc/index.htm\n rtl: undefined, // right-to-left support; true / false (default)\n saveState: false, // true / false / string (cookie name)\n selectable: true,\n showEmptyFolder: false,\n slide: true, // must display slide animation?\n startDndDelay: 300, // The delay for starting dnd (in milliseconds)\n tabIndex: 0,\n useContextMenu: true,\n };\n\n private element: JQuery;\n private isInitialized: boolean;\n private tree: Node;\n\n private dataLoader: DataLoader;\n private dndHandler: DragAndDropHandler;\n private keyHandler: KeyHandler;\n private mouseHandler: MouseHandler;\n private renderer: ElementsRenderer;\n private saveStateHandler: SaveStateHandler;\n private scrollHandler: ScrollHandler;\n private selectNodeHandler: SelectNodeHandler;\n\n public toggle(node: Node, slideParam: null | boolean = null): JQuery {\n if (!node) {\n throw Error(NODE_PARAM_IS_EMPTY);\n }\n\n const slide = slideParam ?? this.options.slide;\n\n if (node.is_open) {\n this.closeNode(node, slide);\n } else {\n this.openNode(node, slide);\n }\n\n return this.element;\n }\n\n public getTree(): Node {\n return this.tree;\n }\n\n public selectNode(\n node: Node | null,\n optionsParam?: SelectNodeOptions,\n ): JQuery {\n this.doSelectNode(node, optionsParam);\n return this.element;\n }\n\n public getSelectedNode(): Node | false {\n return this.selectNodeHandler.getSelectedNode();\n }\n\n public toJson(): string {\n return JSON.stringify(this.tree.getData());\n }\n\n public loadData(data: NodeData[], parentNode: Node | null): JQuery {\n this.doLoadData(data, parentNode);\n return this.element;\n }\n\n /*\n signatures:\n - loadDataFromUrl(url, parent_node=null, on_finished=null)\n loadDataFromUrl('/my_data');\n loadDataFromUrl('/my_data', node1);\n loadDataFromUrl('/my_data', node1, function() { console.log('finished'); });\n loadDataFromUrl('/my_data', null, function() { console.log('finished'); });\n\n - loadDataFromUrl(parent_node=null, on_finished=null)\n loadDataFromUrl();\n loadDataFromUrl(node1);\n loadDataFromUrl(null, function() { console.log('finished'); });\n loadDataFromUrl(node1, function() { console.log('finished'); });\n */\n public loadDataFromUrl(\n param1: string | null | Node,\n param2?: Node | null | HandleFinishedLoading,\n param3?: HandleFinishedLoading,\n ): JQuery {\n if (typeof param1 === \"string\") {\n // first parameter is url\n this.doLoadDataFromUrl(\n param1,\n param2 as Node | null,\n param3 ?? null,\n );\n } else {\n // first parameter is not url\n this.doLoadDataFromUrl(\n null,\n param1,\n param2 as HandleFinishedLoading | null,\n );\n }\n\n return this.element;\n }\n\n public reload(onFinished: HandleFinishedLoading | null): JQuery {\n this.doLoadDataFromUrl(null, null, onFinished);\n return this.element;\n }\n\n public refresh(): JQuery {\n this.refreshElements(null);\n return this.element;\n }\n\n public getNodeById(nodeId: NodeId): Node | null {\n return this.tree.getNodeById(nodeId);\n }\n\n public getNodeByName(name: string): Node | null {\n return this.tree.getNodeByName(name);\n }\n\n public getNodeByNameMustExist(name: string): Node {\n return this.tree.getNodeByNameMustExist(name);\n }\n\n public getNodesByProperty(key: string, value: unknown): Node[] {\n return this.tree.getNodesByProperty(key, value);\n }\n\n public getNodeByHtmlElement(\n inputElement: HTMLElement | JQuery<HTMLElement>,\n ): Node | null {\n const element =\n inputElement instanceof HTMLElement\n ? inputElement\n : inputElement[0];\n\n if (!element) {\n return null;\n }\n\n return this.getNode(element);\n }\n\n public getNodeByCallback(callback: (node: Node) => boolean): Node | null {\n return this.tree.getNodeByCallback(callback);\n }\n\n public openNode(\n node: Node,\n param1?: boolean | OnFinishOpenNode,\n param2?: OnFinishOpenNode,\n ): JQuery {\n if (!node) {\n throw Error(NODE_PARAM_IS_EMPTY);\n }\n\n const parseParams = (): [boolean, OnFinishOpenNode | undefined] => {\n let onFinished: OnFinishOpenNode | null;\n let slide: boolean | null;\n\n if (isFunction(param1)) {\n onFinished = param1 as OnFinishOpenNode;\n slide = null;\n } else {\n slide = param1 as boolean;\n onFinished = param2 as OnFinishOpenNode;\n }\n\n if (slide == null) {\n slide = this.options.slide ?? false;\n }\n\n return [slide, onFinished];\n };\n\n const [slide, onFinished] = parseParams();\n\n this.openNodeInternal(node, slide, onFinished);\n return this.element;\n }\n\n public closeNode(node: Node, slideParam?: null | boolean): JQuery {\n if (!node) {\n throw Error(NODE_PARAM_IS_EMPTY);\n }\n\n const slide = slideParam ?? this.options.slide;\n\n if (node.isFolder() || node.isEmptyFolder) {\n this.createFolderElement(node).close(\n slide,\n this.options.animationSpeed,\n );\n\n this.saveState();\n }\n\n return this.element;\n }\n\n public isDragging(): boolean {\n return this.dndHandler.isDragging;\n }\n\n public refreshHitAreas(): JQuery {\n this.dndHandler.refresh();\n return this.element;\n }\n\n public addNodeAfter(\n newNodeInfo: NodeData,\n existingNode: Node,\n ): Node | null {\n const newNode = existingNode.addAfter(newNodeInfo);\n\n if (newNode) {\n this.refreshElements(existingNode.parent);\n }\n\n return newNode;\n }\n\n public addNodeBefore(\n newNodeInfo: NodeData,\n existingNode: Node,\n ): Node | null {\n if (!existingNode) {\n throw Error(PARAM_IS_EMPTY + \"existingNode\");\n }\n\n const newNode = existingNode.addBefore(newNodeInfo);\n\n if (newNode) {\n this.refreshElements(existingNode.parent);\n }\n\n return newNode;\n }\n\n public addParentNode(\n newNodeInfo: NodeData,\n existingNode: Node,\n ): Node | null {\n if (!existingNode) {\n throw Error(PARAM_IS_EMPTY + \"existingNode\");\n }\n\n const newNode = existingNode.addParent(newNodeInfo);\n\n if (newNode) {\n this.refreshElements(newNode.parent);\n }\n\n return newNode;\n }\n\n public removeNode(node: Node): JQuery {\n if (!node) {\n throw Error(NODE_PARAM_IS_EMPTY);\n }\n\n if (!node.parent) {\n throw Error(\"Node has no parent\");\n }\n\n this.selectNodeHandler.removeFromSelection(node, true); // including children\n\n const parent = node.parent;\n node.remove();\n this.refreshElements(parent);\n\n return this.element;\n }\n\n public appendNode(newNodeInfo: NodeData, parentNodeParam?: Node): Node {\n const parentNode = parentNodeParam || this.tree;\n\n const node = parentNode.append(newNodeInfo);\n\n this.refreshElements(parentNode);\n\n return node;\n }\n\n public prependNode(newNodeInfo: NodeData, parentNodeParam?: Node): Node {\n const parentNode = parentNodeParam ?? this.tree;\n\n const node = parentNode.prepend(newNodeInfo);\n\n this.refreshElements(parentNode);\n\n return node;\n }\n\n public updateNode(node: Node, data: NodeData): JQuery {\n if (!node) {\n throw Error(NODE_PARAM_IS_EMPTY);\n }\n\n const idIsChanged =\n typeof data === \"object\" && data.id && data.id !== node.id;\n\n if (idIsChanged) {\n this.tree.removeNodeFromIndex(node);\n }\n\n node.setData(data);\n\n if (idIsChanged) {\n this.tree.addNodeToIndex(node);\n }\n\n if (\n typeof data === \"object\" &&\n data[\"children\"] &&\n data[\"children\"] instanceof Array\n ) {\n node.removeChildren();\n\n if (data.children.length) {\n node.loadFromData(data.children as Node[]);\n }\n }\n\n this.refreshElements(node);\n\n return this.element;\n }\n\n private isSelectedNodeInSubtree(subtree: Node): boolean {\n const selectedNode = this.getSelectedNode();\n\n if (!selectedNode) {\n return false;\n } else {\n return subtree === selectedNode || subtree.isParentOf(selectedNode);\n }\n }\n\n public moveNode(node: Node, targetNode: Node, position: string): JQuery {\n if (!node) {\n throw Error(NODE_PARAM_IS_EMPTY);\n }\n\n if (!targetNode) {\n throw Error(PARAM_IS_EMPTY + \"targetNode\");\n }\n\n const positionIndex = getPosition(position);\n\n if (positionIndex !== undefined) {\n this.tree.moveNode(node, targetNode, positionIndex);\n this.refreshElements(null);\n }\n\n return this.element;\n }\n\n public getStateFromStorage(): SavedState | null {\n return this.saveStateHandler.getStateFromStorage();\n }\n\n public addToSelection(node: Node, mustSetFocus?: boolean): JQuery {\n if (!node) {\n throw Error(NODE_PARAM_IS_EMPTY);\n }\n\n this.selectNodeHandler.addToSelection(node);\n this.openParents(node);\n\n this.getNodeElementForNode(node).select(\n mustSetFocus === undefined ? true : mustSetFocus,\n );\n\n this.saveState();\n\n return this.element;\n }\n\n public getSelectedNodes(): Node[] {\n return this.selectNodeHandler.getSelectedNodes();\n }\n\n public isNodeSelected(node: Node): boolean {\n if (!node) {\n throw Error(NODE_PARAM_IS_EMPTY);\n }\n\n return this.selectNodeHandler.isNodeSelected(node);\n }\n\n public removeFromSelection(node: Node): JQuery {\n if (!node) {\n throw Error(NODE_PARAM_IS_EMPTY);\n }\n\n this.selectNodeHandler.removeFromSelection(node);\n\n this.getNodeElementForNode(node).deselect();\n this.saveState();\n\n return this.element;\n }\n\n public scrollToNode(node: Node): JQuery {\n if (!node) {\n throw Error(NODE_PARAM_IS_EMPTY);\n }\n\n const top =\n getOffsetTop(node.element) -\n getOffsetTop(this.$el.get(0) as HTMLElement);\n\n this.scrollHandler.scrollToY(top);\n\n return this.element;\n }\n\n public getState(): SavedState | null {\n return this.saveStateHandler.getState();\n }\n\n public setState(state: SavedState): JQuery {\n this.saveStateHandler.setInitialState(state);\n this.refreshElements(null);\n\n return this.element;\n }\n\n public setOption(option: string, value: unknown): JQuery {\n (this.options as unknown as Record<string, unknown>)[option] = value;\n return this.element;\n }\n\n public moveDown(): JQuery {\n const selectedNode = this.getSelectedNode();\n if (selectedNode) {\n this.keyHandler.moveDown(selectedNode);\n }\n\n return this.element;\n }\n\n public moveUp(): JQuery {\n const selectedNode = this.getSelectedNode();\n if (selectedNode) {\n this.keyHandler.moveUp(selectedNode);\n }\n\n return this.element;\n }\n\n public getVersion(): string {\n return __version__;\n }\n\n private openNodeInternal(\n node: Node,\n slide = true,\n onFinished?: OnFinishOpenNode,\n ): void {\n const doOpenNode = (\n _node: Node,\n _slide: boolean,\n _onFinished?: OnFinishOpenNode,\n ): void => {\n const folderElement = this.createFolderElement(_node);\n folderElement.open(\n _onFinished,\n _slide,\n this.options.animationSpeed,\n );\n };\n\n if (node.isFolder() || node.isEmptyFolder) {\n if (node.load_on_demand) {\n this.loadFolderOnDemand(node, slide, onFinished);\n } else {\n let parent = node.parent;\n\n while (parent) {\n // nb: do not open root element\n if (parent.parent) {\n doOpenNode(parent, false);\n }\n parent = parent.parent;\n }\n\n doOpenNode(node, slide, onFinished);\n this.saveState();\n }\n }\n }\n\n /*\n Redraw the tree or part of the tree.\n from_node: redraw this subtree\n */\n private refreshElements(fromNode: Node | null): void {\n const mustSetFocus = this.isFocusOnTree();\n const mustSelect = fromNode\n ? this.isSelectedNodeInSubtree(fromNode)\n : false;\n\n this.renderer.render(fromNode);\n\n if (mustSelect) {\n this.selectCurrentNode(mustSetFocus);\n }\n\n this.triggerEvent(\"tree.refresh\");\n }\n\n private getNodeElementForNode(node: Node): NodeElement {\n if (node.isFolder()) {\n return this.createFolderElement(node);\n } else {\n return this.createNodeElement(node);\n }\n }\n\n private getNodeElement(element: HTMLElement): NodeElement | null {\n const node = this.getNode(element);\n if (node) {\n return this.getNodeElementForNode(node);\n } else {\n return null;\n }\n }\n\n public init(): void {\n super.init();\n\n this.element = this.$el;\n this.isInitialized = false;\n\n this.options.rtl = this.getRtlOption();\n\n if (this.options.closedIcon == null) {\n this.options.closedIcon = this.getDefaultClosedIcon();\n }\n\n this.connectHandlers();\n\n this.initData();\n }\n\n public deinit(): void {\n this.element.empty();\n this.element.off();\n\n this.keyHandler.deinit();\n this.mouseHandler.deinit();\n\n this.tree = new Node({}, true);\n\n super.deinit();\n }\n\n private triggerEvent(\n eventName: string,\n values?: Record<string, unknown>,\n ): JQuery.Event {\n const event = jQuery.Event(eventName, values);\n this.element.trigger(event);\n return event;\n }\n\n private mouseCapture(positionInfo: PositionInfo): boolean | null {\n if (this.options.dragAndDrop) {\n return this.dndHandler.mouseCapture(positionInfo);\n } else {\n return false;\n }\n }\n\n private mouseStart(positionInfo: PositionInfo): boolean {\n if (this.options.dragAndDrop) {\n return this.dndHandler.mouseStart(positionInfo);\n } else {\n return false;\n }\n }\n\n private mouseDrag(positionInfo: PositionInfo): boolean {\n if (this.options.dragAndDrop) {\n const result = this.dndHandler.mouseDrag(positionInfo);\n\n this.scrollHandler.checkScrolling(positionInfo);\n return result;\n } else {\n return false;\n }\n }\n\n private mouseStop(positionInfo: PositionInfo): boolean {\n if (this.options.dragAndDrop) {\n this.scrollHandler.stopScrolling();\n return this.dndHandler.mouseStop(positionInfo);\n } else {\n return false;\n }\n }\n\n private initData(): void {\n if (this.options.data) {\n this.doLoadData(this.options.data, null);\n } else {\n const dataUrl = this.getDataUrlInfo(null);\n\n if (dataUrl) {\n this.doLoadDataFromUrl(null, null, null);\n } else {\n this.doLoadData([], null);\n }\n }\n }\n\n private getDataUrlInfo(node: Node | null): JQuery.AjaxSettings | null {\n const dataUrl =\n this.options.dataUrl || (this.element.data(\"url\") as string | null);\n\n const getUrlFromString = (url: string): JQuery.AjaxSettings => {\n const urlInfo: JQuery.AjaxSettings = { url };\n\n setUrlInfoData(urlInfo);\n\n return urlInfo;\n };\n\n const setUrlInfoData = (urlInfo: JQuery.AjaxSettings): void => {\n if (node?.id) {\n // Load on demand of a subtree; add node parameter\n const data = { node: node.id };\n urlInfo[\"data\"] = data;\n } else {\n // Add selected_node parameter\n const selectedNodeId = this.getNodeIdToBeSelected();\n if (selectedNodeId) {\n const data = { selected_node: selectedNodeId };\n urlInfo[\"data\"] = data;\n }\n }\n };\n\n if (typeof dataUrl === \"function\") {\n return dataUrl(node);\n } else if (typeof dataUrl === \"string\") {\n return getUrlFromString(dataUrl);\n } else if (dataUrl && typeof dataUrl === \"object\") {\n setUrlInfoData(dataUrl);\n return dataUrl;\n } else {\n return null;\n }\n }\n\n private getNodeIdToBeSelected(): NodeId | null {\n if (this.options.saveState) {\n return this.saveStateHandler.getNodeIdToBeSelected();\n } else {\n return null;\n }\n }\n\n private initTree(data: NodeData[]): void {\n const doInit = (): void => {\n if (!this.isInitialized) {\n this.isInitialized = true;\n this.triggerEvent(\"tree.init\");\n }\n };\n\n if (!this.options.nodeClass) {\n return;\n }\n\n this.tree = new this.options.nodeClass(\n null,\n true,\n this.options.nodeClass,\n );\n\n this.selectNodeHandler.clear();\n\n this.tree.loadFromData(data);\n\n const mustLoadOnDemand = this.setInitialState();\n\n this.refreshElements(null);\n\n if (!mustLoadOnDemand) {\n doInit();\n } else {\n // Load data on demand and then init the tree\n this.setInitialStateOnDemand(doInit);\n }\n }\n\n // Set initial state, either by restoring the state or auto-opening nodes\n // result: must load nodes on demand?\n private setInitialState(): boolean {\n const restoreState = (): [boolean, boolean] => {\n // result: is state restored, must load on demand?\n if (!this.options.saveState) {\n return [false, false];\n } else {\n const state = this.saveStateHandler.getStateFromStorage();\n\n if (!state) {\n return [false, false];\n } else {\n const mustLoadOnDemand =\n this.saveStateHandler.setInitialState(state);\n\n // return true: the state is restored\n return [true, mustLoadOnDemand];\n }\n }\n };\n\n const autoOpenNodes = (): boolean => {\n // result: must load on demand?\n if (this.options.autoOpen === false) {\n return false;\n }\n\n const maxLevel = this.getAutoOpenMaxLevel();\n let mustLoadOnDemand = false;\n\n this.tree.iterate((node: Node, level: number) => {\n if (node.load_on_demand) {\n mustLoadOnDemand = true;\n return false;\n } else if (!node.hasChildren()) {\n return false;\n } else {\n node.is_open = true;\n return level !== maxLevel;\n }\n });\n\n return mustLoadOnDemand;\n };\n\n let [isRestored, mustLoadOnDemand] = restoreState(); // eslint-disable-line prefer-const\n\n if (!isRestored) {\n mustLoadOnDemand = autoOpenNodes();\n }\n\n return mustLoadOnDemand;\n }\n\n // Set the initial state for nodes that are loaded on demand\n // Call cb_finished when done\n private setInitialStateOnDemand(cbFinished: () => void): void {\n const restoreState = (): boolean => {\n if (!this.options.saveState) {\n return false;\n } else {\n const state = this.saveStateHandler.getStateFromStorage();\n\n if (!state) {\n return false;\n } else {\n this.saveStateHandler.setInitialStateOnDemand(\n state,\n cbFinished,\n );\n\n return true;\n }\n }\n };\n\n const autoOpenNodes = (): void => {\n const maxLevel = this.getAutoOpenMaxLevel();\n let loadingCount = 0;\n\n const loadAndOpenNode = (node: Node): void => {\n loadingCount += 1;\n this.openNodeInternal(node, false, () => {\n loadingCount -= 1;\n openNodes();\n });\n };\n\n const openNodes = (): void => {\n this.tree.iterate((node: Node, level: number) => {\n if (node.load_on_demand) {\n if (!node.is_loading) {\n loadAndOpenNode(node);\n }\n\n return false;\n } else {\n this.openNodeInternal(node, false);\n\n return level !== maxLevel;\n }\n });\n\n if (loadingCount === 0) {\n cbFinished();\n }\n };\n\n openNodes();\n };\n\n if (!restoreState()) {\n autoOpenNodes();\n }\n }\n\n private getAutoOpenMaxLevel(): number {\n if (this.options.autoOpen === true) {\n return -1;\n } else if (typeof this.options.autoOpen === \"number\") {\n return this.options.autoOpen;\n } else if (typeof this.options.autoOpen === \"string\") {\n return parseInt(this.options.autoOpen, 10);\n } else {\n return 0;\n }\n }\n\n private getNode(element: HTMLElement): null | Node {\n const liElement = element.closest(\"li.jqtree_common\");\n\n if (liElement) {\n return jQuery(liElement).data(\"node\") as Node;\n } else {\n return null;\n }\n }\n\n private saveState(): void {\n if (this.options.saveState) {\n this.saveStateHandler.saveState();\n }\n }\n\n private selectCurrentNode(mustSetFocus: boolean): void {\n const node = this.getSelectedNode();\n if (node) {\n const nodeElement = this.getNodeElementForNode(node);\n if (nodeElement) {\n nodeElement.select(mustSetFocus);\n }\n }\n }\n\n private deselectCurrentNode(): void {\n const node = this.getSelectedNode();\n if (node) {\n this.removeFromSelection(node);\n }\n }\n\n private getDefaultClosedIcon(): string {\n if (this.options.rtl) {\n // triangle to the left\n return \"◀\";\n } else {\n // triangle to the right\n return \"►\";\n }\n }\n\n private getRtlOption(): boolean {\n if (this.options.rtl != null) {\n return this.options.rtl;\n } else {\n const dataRtl = this.element.data(\"rtl\") as unknown;\n\n if (\n dataRtl !== null &&\n dataRtl !== false &&\n dataRtl !== undefined\n ) {\n return true;\n } else {\n return false;\n }\n }\n }\n\n private doSelectNode(\n node: Node | null,\n optionsParam?: SelectNodeOptions,\n ): void {\n const saveState = (): void => {\n if (this.options.saveState) {\n this.saveStateHandler.saveState();\n }\n };\n\n if (!node) {\n // Called with empty node -> deselect current node\n this.deselectCurrentNode();\n saveState();\n return;\n }\n const defaultOptions = { mustSetFocus: true, mustToggle: true };\n const selectOptions = { ...defaultOptions, ...(optionsParam || {}) };\n\n const canSelect = (): boolean => {\n if (this.options.onCanSelectNode) {\n return (\n this.options.selectable === true &&\n this.options.onCanSelectNode(node)\n );\n } else {\n return this.options.selectable === true;\n }\n };\n\n if (!canSelect()) {\n return;\n }\n\n if (this.selectNodeHandler.isNodeSelected(node)) {\n if (selectOptions.mustToggle) {\n this.deselectCurrentNode();\n this.triggerEvent(\"tree.select\", {\n node: null,\n previous_node: node,\n });\n }\n } else {\n const deselectedNode = this.getSelectedNode() || null;\n this.deselectCurrentNode();\n this.addToSelection(node, selectOptions.mustSetFocus);\n\n this.triggerEvent(\"tree.select\", {\n node,\n deselected_node: deselectedNode,\n });\n this.openParents(node);\n }\n\n saveState();\n }\n\n private doLoadData(data: NodeData[] | null, parentNode: Node | null): void {\n if (data) {\n if (parentNode) {\n this.deselectNodes(parentNode);\n this.loadSubtree(data, parentNode);\n } else {\n this.initTree(data);\n }\n\n if (this.isDragging()) {\n this.dndHandler.refresh();\n }\n }\n\n this.triggerEvent(\"tree.load_data\", {\n tree_data: data,\n parent_node: parentNode,\n });\n }\n\n private deselectNodes(parentNode: Node): void {\n const selectedNodesUnderParent =\n this.selectNodeHandler.getSelectedNodesUnder(parentNode);\n for (const n of selectedNodesUnderParent) {\n this.selectNodeHandler.removeFromSelection(n);\n }\n }\n\n private loadSubtree(data: NodeData[], parentNode: Node): void {\n parentNode.loadFromData(data);\n\n parentNode.load_on_demand = false;\n parentNode.is_loading = false;\n\n this.refreshElements(parentNode);\n }\n\n private doLoadDataFromUrl(\n urlInfoParam: string | JQuery.AjaxSettings | null,\n parentNode: Node | null,\n onFinished: HandleFinishedLoading | null,\n ): void {\n const urlInfo = urlInfoParam || this.getDataUrlInfo(parentNode);\n\n this.dataLoader.loadFromUrl(urlInfo, parentNode, onFinished);\n }\n\n private loadFolderOnDemand(\n node: Node,\n slide = true,\n onFinished?: OnFinishOpenNode,\n ): void {\n node.is_loading = true;\n\n this.doLoadDataFromUrl(null, node, () => {\n this.openNodeInternal(node, slide, onFinished);\n });\n }\n\n private containsElement(element: HTMLElement): boolean {\n const node = this.getNode(element);\n\n return node != null && node.tree === this.tree;\n }\n\n private isFocusOnTree(): boolean {\n const activeElement = document.activeElement;\n\n return Boolean(\n activeElement &&\n activeElement.tagName === \"SPAN\" &&\n this.containsElement(activeElement as HTMLElement),\n );\n }\n\n private connectHandlers() {\n const {\n autoEscape,\n buttonLeft,\n closedIcon,\n dataFilter,\n dragAndDrop,\n keyboardSupport,\n onCanMove,\n onCanMoveTo,\n onCreateLi,\n onDragMove,\n onDragStop,\n onGetStateFromStorage,\n onIsMoveHandle,\n onLoadFailed,\n onLoading,\n onSetStateFromStorage,\n openedIcon,\n openFolderDelay,\n rtl,\n saveState,\n showEmptyFolder,\n slide,\n tabIndex,\n } = this.options;\n\n const closeNode = this.closeNode.bind(this);\n const getNodeElement = this.getNodeElement.bind(this);\n const getNodeElementForNode = this.getNodeElementForNode.bind(this);\n const getNodeById = this.getNodeById.bind(this);\n const getSelectedNode = this.getSelectedNode.bind(this);\n const getTree = this.getTree.bind(this);\n const isFocusOnTree = this.isFocusOnTree.bind(this);\n const loadData = this.loadData.bind(this);\n const openNode = this.openNodeInternal.bind(this);\n const refreshElements = this.refreshElements.bind(this);\n const refreshHitAreas = this.refreshHitAreas.bind(this);\n const selectNode = this.selectNode.bind(this);\n const $treeElement = this.element;\n const treeElement = this.element.get(0) as HTMLElement;\n const triggerEvent = this.triggerEvent.bind(this);\n\n const selectNodeHandler = new SelectNodeHandler({\n getNodeById,\n });\n\n const addToSelection =\n selectNodeHandler.addToSelection.bind(selectNodeHandler);\n const getSelectedNodes =\n selectNodeHandler.getSelectedNodes.bind(selectNodeHandler);\n const isNodeSelected =\n selectNodeHandler.isNodeSelected.bind(selectNodeHandler);\n const removeFromSelection =\n selectNodeHandler.removeFromSelection.bind(selectNodeHandler);\n const getMouseDelay = () => this.options.startDndDelay ?? 0;\n\n const dataLoader = new DataLoader({\n dataFilter,\n loadData,\n onLoadFailed,\n onLoading,\n treeElement,\n triggerEvent,\n });\n\n const saveStateHandler = new SaveStateHandler({\n addToSelection,\n getNodeById,\n getSelectedNodes,\n getTree,\n onGetStateFromStorage,\n onSetStateFromStorage,\n openNode,\n refreshElements,\n removeFromSelection,\n saveState,\n });\n\n const scrollHandler = new ScrollHandler({\n refreshHitAreas,\n treeElement,\n });\n\n const getScrollLeft = scrollHandler.getScrollLeft.bind(scrollHandler);\n\n const dndHandler = new DragAndDropHandler({\n autoEscape,\n getNodeElement,\n getNodeElementForNode,\n getScrollLeft,\n getTree,\n onCanMove,\n onCanMoveTo,\n onDragMove,\n onDragStop,\n onIsMoveHandle,\n openFolderDelay,\n openNode,\n refreshElements,\n slide,\n treeElement,\n triggerEvent,\n });\n\n const keyHandler = new KeyHandler({\n closeNode,\n getSelectedNode,\n isFocusOnTree,\n keyboardSupport,\n openNode,\n selectNode,\n });\n\n const renderer = new ElementsRenderer({\n autoEscape,\n buttonLeft,\n closedIcon,\n dragAndDrop,\n $element: $treeElement,\n getTree,\n isNodeSelected,\n onCreateLi,\n openedIcon,\n rtl,\n showEmptyFolder,\n tabIndex,\n });\n\n const getNode = this.getNode.bind(this);\n const onMouseCapture = this.mouseCapture.bind(this);\n const onMouseDrag = this.mouseDrag.bind(this);\n const onMouseStart = this.mouseStart.bind(this);\n const onMouseStop = this.mouseStop.bind(this);\n\n const mouseHandler = new MouseHandler({\n element: treeElement,\n getMouseDelay,\n getNode,\n onClickButton: this.toggle.bind(this),\n onClickTitle: this.doSelectNode.bind(this),\n onMouseCapture,\n onMouseDrag,\n onMouseStart,\n onMouseStop,\n triggerEvent,\n useContextMenu: this.options.useContextMenu,\n });\n\n this.dataLoader = dataLoader;\n this.dndHandler = dndHandler;\n this.keyHandler = keyHandler;\n this.mouseHandler = mouseHandler;\n this.renderer = renderer;\n this.saveStateHandler = saveStateHandler;\n this.scrollHandler = scrollHandler;\n this.selectNodeHandler = selectNodeHandler;\n }\n\n private createFolderElement(node: Node) {\n const closedIconElement = this.renderer.closedIconElement;\n const getScrollLeft = this.scrollHandler.getScrollLeft.bind(\n this.scrollHandler,\n );\n const openedIconElement = this.renderer.openedIconElement;\n const tabIndex = this.options.tabIndex;\n const $treeElement = this.element;\n const triggerEvent = this.triggerEvent.bind(this);\n\n return new FolderElement({\n closedIconElement,\n getScrollLeft,\n node,\n openedIconElement,\n tabIndex,\n $treeElement,\n triggerEvent,\n });\n }\n\n private createNodeElement(node: Node) {\n const getScrollLeft = this.scrollHandler.getScrollLeft.bind(\n this.scrollHandler,\n );\n const tabIndex = this.options.tabIndex;\n const $treeElement = this.element;\n\n return new NodeElement({\n getScrollLeft,\n node,\n tabIndex,\n $treeElement,\n });\n }\n\n private openParents(node: Node) {\n const parent = node.parent;\n\n if (parent && parent.parent && !parent.is_open) {\n this.openNode(parent, false);\n }\n }\n}\n\nSimpleWidget.register(JqTreeWidget, \"tree\");\n","const version = \"1.8.2\";\n\nexport default version;\n"],"names":["Position","positionNames","before","Before","after","After","inside","Inside","none","None","getPositionName","position","name","Object","prototype","hasOwnProperty","call","DragElement","constructor","_ref","autoEscape","nodeName","offsetX","offsetY","treeElement","this","element","createElement","appendChild","move","pageX","pageY","style","left","top","remove","document","classList","add","textContent","innerHTML","getBoolString","value","getOffsetTop","getElementPosition","rect","getBoundingClientRect","x","window","scrollX","y","scrollY","generateHitAreasForGroup","hitAreas","positionsInGroup","bottom","positionCount","Math","min","length","areaHeight","round","areaTop","i","push","node","generateHitAreas","tree","currentNode","treeBottom","generateHitAreasFromPositions","hitPositions","previousTop","group","generateHitPositions","lastTop","addHitPosition","iterateVisibleNodes","handleAfterOpenFolder","handleClosedFolder","handleFirstNode","handleNode","handleOpenFolder","isFirstNode","iterate","nextNode","mustIterateInside","is_open","hasChildren","offsetParent","childrenLength","children","forEach","_","child","nextChild","height","clientHeight","DragAndDropHandler","getNodeElement","getNodeElementForNode","getScrollLeft","getTree","onCanMove","onCanMoveTo","onDragMove","onDragStop","onIsMoveHandle","openNode","refreshElements","slide","triggerEvent","hoveredArea","isDragging","currentItem","mouseCapture","positionInfo","target","mustCaptureElement","jQuery","nodeElement","mouseStart","refresh","dragElement","mouseDrag","area","findHoveredArea","canMoveToArea","isFolder","stopOpenFolderTimer","mustOpenFolderTimer","startOpenFolderTimer","updateDropHint","removeDropHint","originalEvent","mouseStop","moveItem","clear","removeHover","removeHitAreas","getTreeDimensions","positionName","previousGhost","dimensions","right","low","high","mid","addDropHint","folder","openFolder","openFolderDelay","openFolderTimer","setTimeout","clearTimeout","movedNode","targetNode","previousParent","parent","doMove","moveNode","move_info","moved_node","target_node","previous_parent","do_move","original_event","isDefaultPrevented","treePosition","clientWidth","ElementsRenderer","buttonLeft","closedIcon","onCreateLi","dragAndDrop","$element","isNodeSelected","openedIcon","rtl","showEmptyFolder","tabIndex","openedIconElement","createButtonElement","closedIconElement","render","fromNode","renderFromNode","renderFromRoot","empty","createDomElements","$previousLi","li","createLi","getLevel","attachNodeData","isRootNode","level","ul","createUl","data","classString","role","className","setAttribute","isSelected","Boolean","isEmptyFolder","createFolderLi","createNodeLi","setTreeItemAriaAttributes","buttonClasses","getButtonClasses","folderClasses","getFolderClasses","iconElement","div","buttonLink","cloneNode","titleSpan","createTitleSpan","liClasses","join","classes","undefined","is_loading","createTextNode","nodeType","DataLoader","dataFilter","loadData","onLoadFailed","onLoading","loadFromUrl","urlInfo","parentNode","onFinished","getDomElement","addLoadingClass","notifyLoading","stopLoading","removeLoadingClass","submitRequest","parseData","jqXHR","isLoading","$el","urlInfoInput","handleSuccess","handleError","ajaxSettings","method","cache","dataType","success","error","url","toUpperCase","ajax","parsedData","JSON","parse","KeyHandler","closeNode","getSelectedNode","isFocusOnTree","keyboardSupport","selectNode","originalSelectNode","handleKeyDownHandler","handleKeyDown","bind","addEventListener","deinit","removeEventListener","moveDown","selectedNode","getNextVisibleNode","moveUp","getPreviousVisibleNode","moveRight","moveLeft","getParent","e","canHandleKeyboard","key","getPositionInfoFromMouseEvent","getPositionInfoFromTouch","touch","MouseHandler","getMouseDelay","getNode","onClickButton","onClickTitle","onMouseCapture","onMouseDrag","onMouseStart","onMouseStop","useContextMenu","handleClick","handleDblclick","mouseDown","passive","touchStart","handleContextmenu","isMouseStarted","mouseDelayTimer","isMouseDelayMet","mouseDownInfo","removeMouseMoveEventListeners","button","handleMouseDown","cancelable","preventDefault","handleMouseUp","handleStartMouse","mouseMove","touchMove","mouseUp","touchEnd","mouseDelay","startMouseDelayTimer","handleMouseMove","touches","clickTarget","getClickTarget","type","stopPropagation","click_event","closest","jqTreeElement","SaveStateHandler","addToSelection","getNodeById","getSelectedNodes","onGetStateFromStorage","onSetStateFromStorage","removeFromSelection","saveState","saveStateOption","state","stringify","getState","supportsLocalStorage","localStorage","setItem","getKeyName","getStateFromStorage","jsonData","loadFromStorage","parseState","open_nodes","getOpenNodeIds","openNodes","id","selected_node","getSelectedNodeIds","selectedNodeIds","setInitialState","mustLoadOnDemand","openInitialNodes","resetSelection","selectInitialNodes","setInitialStateOnDemand","cbFinished","loadingCount","nodeIds","newNodesIds","nodeId","load_on_demand","loadAndOpenNode","getNodeIdToBeSelected","n","getItem","selectCount","_supportsLocalStorage","testSupport","sessionStorage","removeItem","ContainerScrollParent","container","refreshHitAreas","checkHorizontalScrolling","newHorizontalScrollDirection","getNewHorizontalScrollDirection","horizontalScrollDirection","horizontalScrollTimeout","verticalScrollTimeout","scrollHorizontally","checkVerticalScrolling","newVerticalScrollDirection","getNewVerticalScrollDirection","verticalScrollDirection","scrollVertically","scrollLeft","scrollToY","scrollTop","stopScrolling","scrollParentTop","scrollParentBottom","scrollParentOffset","rightEdge","leftEdge","getScrollParentTop","getScrollParentBottom","distance","scrollBy","behavior","DocumentScrollParent","documentElement","treeTop","documentScrollHeight","documentScrollWidth","isNearLeftEdge","innerWidth","canScrollRight","getDocumentScrollWidth","canScrollDown","getDocumentScrollHeight","scrollHeight","scrollWidth","innerHeight","isOverflow","overflowValue","hasOverFlow","getComputedStyle","overflowX","overflowY","createScrollParent","parentElement","getParentWithOverflow","tagName","ScrollHandler","scrollParent","checkScrolling","getScrollParent","SelectNodeHandler","selectedNodes","Set","selectedSingleNode","getSelectedNodesUnder","isParentOf","has","includeChildren","arguments","delete","register","widgetClass","widgetName","getDataKey","getWidgetData","el","dataKey","widget","SimpleWidget","createWidget","options","get","init","fn","argument1","functionName","destroy","removeData","destroyWidget","_len","args","Array","_key","callFunction","result","widgetFunction","apply","static","defaults","isNodeRecordWithChildren","Node","nodeData","isRoot","nodeClass","setData","idMapping","Map","o","loadFromData","removeChildren","childData","createNode","addChild","setParent","addChildAtPosition","index","splice","removeChild","doRemoveChild","getChildIndex","indexOf","callback","_iterate","getData","getDataFromNodes","nodes","map","tmpNode","k","v","getNodeByName","getNodeByCallback","getNodeByNameMustExist","addAfter","nodeInfo","childIndex","loadChildrenFromData","addBefore","addParent","newParent","originalParent","append","prepend","addNodeToIndex","set","removeNodeFromIndex","getPreviousSibling","previousIndex","getNextSibling","nextIndex","getNodesByProperty","filter","f","getNextNode","nextSibling","getPreviousNode","previousSibling","getLastChild","lastChild","initFromData","addChildren","childrenData","addNode","getNodeClass","BorderDropHint","querySelector","hint","width","max","offsetWidth","GhostDropHint","ghost","createGhostElement","circleSpan","lineSpan","NodeElement","$treeElement","mustShowBorderDropHint","select","mustSetFocus","getTitleSpan","toString","focus","deselect","removeAttribute","blur","getUl","FolderElement","super","open","animationSpeed","getButton","icon","doOpen","slideDown","show","close","doClose","slideUp","hide","NODE_PARAM_IS_EMPTY","PARAM_IS_EMPTY","JqTreeWidget","autoOpen","dataUrl","onCanSelectNode","selectable","startDndDelay","toggle","slideParam","Error","optionsParam","doSelectNode","selectNodeHandler","toJson","doLoadData","loadDataFromUrl","param1","param2","param3","doLoadDataFromUrl","reload","getNodeByHtmlElement","inputElement","HTMLElement","parseParams","openNodeInternal","createFolderElement","dndHandler","addNodeAfter","newNodeInfo","existingNode","newNode","addNodeBefore","addParentNode","removeNode","appendNode","parentNodeParam","prependNode","updateNode","idIsChanged","isSelectedNodeInSubtree","subtree","positionIndex","saveStateHandler","openParents","scrollToNode","scrollHandler","setState","setOption","option","keyHandler","getVersion","doOpenNode","_node","_slide","_onFinished","loadFolderOnDemand","mustSelect","renderer","selectCurrentNode","createNodeElement","isInitialized","getRtlOption","getDefaultClosedIcon","connectHandlers","initData","off","mouseHandler","eventName","values","event","Event","trigger","getDataUrlInfo","setUrlInfoData","selectedNodeId","getUrlFromString","initTree","doInit","autoOpenNodes","maxLevel","getAutoOpenMaxLevel","isRestored","restoreState","parseInt","liElement","deselectCurrentNode","dataRtl","selectOptions","mustToggle","canSelect","previous_node","deselectedNode","deselected_node","deselectNodes","loadSubtree","tree_data","parent_node","selectedNodesUnderParent","urlInfoParam","dataLoader","containsElement","activeElement"],"mappings":";;;;;;;;;;;;;;;;;;;oCAAYA,IAAAA,WAAAA,GAAQ,OAARA,EAAAA,EAAQ,OAAA,GAAA,SAARA,EAAAA,EAAQ,MAAA,GAAA,QAARA,EAAAA,EAAQ,OAAA,GAAA,SAARA,EAAAA,EAAQ,KAAA,GAAA,OAARA,CAAQ,EAAA,CAAA,GAOpB,MAAMC,EAA0C,CAC5CC,OAAQF,EAASG,OACjBC,MAAOJ,EAASK,MAChBC,OAAQN,EAASO,OACjBC,KAAMR,EAASS,MAGNC,EAAmBC,IAC5B,IAAK,MAAMC,KAAQX,EACf,GAAIY,OAAOC,UAAUC,eAAeC,KAAKf,EAAeW,IAChDX,EAAcW,KAAUD,EACxB,OAAOC,EAKnB,MAAO,EAAE,ECfb,MAAMK,EAKFC,WAAAA,CAAWC,GAMW,IANVC,WACRA,EAAUC,SACVA,EAAQC,QACRA,EAAOC,QACPA,EAAOC,YACPA,GACgBL,EAChBM,KAAKH,QAAUA,EACfG,KAAKF,QAAUA,EAEfE,KAAKC,QAAUD,KAAKE,cAAcN,EAAUD,GAE5CI,EAAYI,YAAYH,KAAKC,QACjC,CAEOG,IAAAA,CAAKC,EAAeC,GACvBN,KAAKC,QAAQM,MAAMC,KAAUH,EAAQL,KAAKH,QAAf,KAC3BG,KAAKC,QAAQM,MAAME,IAASH,EAAQN,KAAKF,QAAf,IAC9B,CAEOY,MAAAA,GACHV,KAAKC,QAAQS,QACjB,CAEQR,aAAAA,CAAcN,EAAkBD,GACpC,MAAMM,EAAUU,SAAST,cAAc,QAWvC,OAVAD,EAAQW,UAAUC,IAAI,eAAgB,mBAElClB,EACAM,EAAQa,YAAclB,EAEtBK,EAAQc,UAAYnB,EAGxBK,EAAQM,MAAMrB,SAAW,WAElBe,CACX,EClDG,MAKMe,EA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