Chris Finlayson
commited on
Commit
•
02cc2d7
1
Parent(s):
fd658c3
First commit
Browse files- NLP.ipynb +0 -0
- README.md +5 -5
- app.py +174 -0
- docs/index.html +424 -0
- lib/bindings/utils.js +189 -0
- lib/tom-select/tom-select.complete.min.js +356 -0
- lib/tom-select/tom-select.css +334 -0
- lib/vis-9.0.4/vis-network.css +0 -0
- lib/vis-9.0.4/vis-network.min.js +0 -0
- lib/vis-9.1.2/vis-network.css +0 -0
- lib/vis-9.1.2/vis-network.min.js +0 -0
- requirements.txt +12 -0
NLP.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
---
|
2 |
-
title: Foundry Pdf Knowledge Graph
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
1 |
---
|
2 |
+
title: Foundry Pdf Knowledge Graph
|
3 |
+
emoji: 😻
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: pink
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.8.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
app.py
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr # Importing gradio for creating web interface
|
2 |
+
import os # Importing os for operating system related tasks
|
3 |
+
import fitz # Importing fitz for PDF processing
|
4 |
+
import re # Importing re for regular expressions
|
5 |
+
import spacy # Importing spacy for natural language processing
|
6 |
+
import spacy.cli # Importing spacy's command line interface
|
7 |
+
import pandas as pd # Importing pandas for data manipulation
|
8 |
+
import bs4 # Importing bs4 for web scraping
|
9 |
+
import requests # Importing requests for making HTTP requests
|
10 |
+
from spacy import displacy # Importing displacy from spacy for visualizing NLP results
|
11 |
+
from spacy.matcher import Matcher # Importing Matcher from spacy for matching patterns
|
12 |
+
from spacy.tokens import Span # Importing Span from spacy for handling spans of tokens
|
13 |
+
import networkx as nx # Importing networkx for creating, manipulating, and studying graphs
|
14 |
+
import matplotlib.pyplot as plt # Importing matplotlib.pyplot for data visualization
|
15 |
+
from tqdm import tqdm # Importing tqdm for progress bars
|
16 |
+
|
17 |
+
try:
|
18 |
+
nlp = spacy.load('en_core_web_sm') # Trying to load the English model
|
19 |
+
except OSError:
|
20 |
+
print("Model not found. Downloading...") # If model not found, print a message
|
21 |
+
spacy.cli.download("en_core_web_sm") # Download the English model
|
22 |
+
nlp = spacy.load('en_core_web_sm') # Load the English model
|
23 |
+
|
24 |
+
def read_pdf(file): # Define a function to read a PDF file
|
25 |
+
doc = fitz.open(file) # Open the PDF file
|
26 |
+
text = [] # Initialize an empty list to store the text
|
27 |
+
for page in doc: # For each page in the document
|
28 |
+
for sentence in page.get_text("text").split('\n'): # For each sentence in the page
|
29 |
+
if len(sentence) > 0: # If the sentence is not empty
|
30 |
+
text.append(sentence) # Append the sentence to the list
|
31 |
+
return pd.DataFrame(text, columns=["sentence"]) # Return a DataFrame of the sentences
|
32 |
+
|
33 |
+
def read_csv(file): # Define a function to read a CSV file
|
34 |
+
candidate_sentences = pd.read_csv("/Users/christopherfinlayson/wiki_sentences_v2.csv") # Read the CSV file
|
35 |
+
return candidate_sentences # Return the DataFrame
|
36 |
+
|
37 |
+
def get_entities(sent): # Define a function to get entities from a sentence
|
38 |
+
ent1 = "" # Initialize an empty string for the first entity
|
39 |
+
ent2 = "" # Initialize an empty string for the second entity
|
40 |
+
|
41 |
+
prv_tok_dep = "" # Initialize an empty string for the dependency tag of the previous token
|
42 |
+
prv_tok_text = "" # Initialize an empty string for the previous token
|
43 |
+
|
44 |
+
prefix = "" # Initialize an empty string for the prefix
|
45 |
+
modifier = "" # Initialize an empty string for the modifier
|
46 |
+
|
47 |
+
for tok in nlp(sent): # For each token in the sentence
|
48 |
+
if tok.dep_ != "punct": # If the token is not a punctuation mark
|
49 |
+
if tok.dep_ == "compound": # If the token is a compound word
|
50 |
+
prefix = tok.text # Set the prefix to the token text
|
51 |
+
if prv_tok_dep == "compound": # If the previous token was also a compound word
|
52 |
+
prefix = prv_tok_text + " "+ tok.text # Add the current word to the prefix
|
53 |
+
|
54 |
+
if tok.dep_.endswith("mod") == True: # If the token is a modifier
|
55 |
+
modifier = tok.text # Set the modifier to the token text
|
56 |
+
if prv_tok_dep == "compound": # If the previous token was also a compound word
|
57 |
+
modifier = prv_tok_text + " "+ tok.text # Add the current word to the modifier
|
58 |
+
|
59 |
+
if tok.dep_.find("subj") == True: # If the token is a subject
|
60 |
+
ent1 = modifier +" "+ prefix + " "+ tok.text # Set the first entity to the modifier, prefix, and token text
|
61 |
+
prefix = "" # Reset the prefix
|
62 |
+
modifier = "" # Reset the modifier
|
63 |
+
prv_tok_dep = "" # Reset the dependency tag of the previous token
|
64 |
+
prv_tok_text = "" # Reset the previous token
|
65 |
+
|
66 |
+
if tok.dep_.find("obj") == True: # If the token is an object
|
67 |
+
ent2 = modifier +" "+ prefix +" "+ tok.text # Set the second entity to the modifier, prefix, and token text
|
68 |
+
|
69 |
+
prv_tok_dep = tok.dep_ # Update the dependency tag of the previous token
|
70 |
+
prv_tok_text = tok.text # Update the previous token
|
71 |
+
|
72 |
+
return [ent1.strip(), ent2.strip()] # Return the entities
|
73 |
+
|
74 |
+
def get_relation(sent): # Define a function to get the relation from a sentence
|
75 |
+
doc = nlp(sent) # Process the sentence
|
76 |
+
matcher = Matcher(nlp.vocab) # Initialize a Matcher with the vocabulary
|
77 |
+
pattern = [{'DEP':'ROOT'},
|
78 |
+
{'DEP':'prep','OP':"?"},
|
79 |
+
{'DEP':'agent','OP':"?"},
|
80 |
+
{'POS':'ADJ','OP':"?"}] # Define a pattern
|
81 |
+
matcher.add("matching_1", [pattern]) # Add the pattern to the matcher
|
82 |
+
matches = matcher(doc) # Match the pattern in the document
|
83 |
+
if matches: # If there are matches
|
84 |
+
k = len(matches) - 1 # Get the index of the last match
|
85 |
+
span = doc[matches[k][1]:matches[k][2]] # Get the span of the match
|
86 |
+
return span.text # Return the text of the span
|
87 |
+
else:
|
88 |
+
return "" # If there are no matches, return an empty string
|
89 |
+
|
90 |
+
def render_graph(G):
|
91 |
+
from pyvis.network import Network
|
92 |
+
graph_output_directory = "./docs/index.html"
|
93 |
+
net = Network(
|
94 |
+
notebook=False,
|
95 |
+
# bgcolor="#1a1a1a",
|
96 |
+
cdn_resources="remote",
|
97 |
+
height="900px",
|
98 |
+
width="100%",
|
99 |
+
select_menu=True,
|
100 |
+
# font_color="#cccccc",
|
101 |
+
filter_menu=False,
|
102 |
+
)
|
103 |
+
net.from_nx(G)
|
104 |
+
# net.repulsion(node_distance=150, spring_length=400)
|
105 |
+
net.force_atlas_2based(central_gravity=0.015, gravity=-31)
|
106 |
+
# net.barnes_hut(gravity=-18100, central_gravity=5.05, spring_length=380)
|
107 |
+
net.show_buttons(filter_=["physics"])
|
108 |
+
|
109 |
+
net.show(graph_output_directory)
|
110 |
+
|
111 |
+
with open(graph_output_directory, 'r') as file:
|
112 |
+
html_content = file.read()
|
113 |
+
|
114 |
+
html_content = html_content.replace("'", "\"")
|
115 |
+
|
116 |
+
iframe = f"""<iframe style="width: 100%; height: 480px" name="result" allow="midi; geolocation; microphone; camera;
|
117 |
+
display-capture; encrypted-media;" sandbox="allow-modals allow-forms
|
118 |
+
allow-scripts allow-same-origin allow-popups
|
119 |
+
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
|
120 |
+
allowpaymentrequest="" frameborder="0" srcdoc='{html_content}'></iframe>"""
|
121 |
+
|
122 |
+
return iframe
|
123 |
+
|
124 |
+
def execute_process(file, edge): # Define a function to execute the process
|
125 |
+
candidate_sentences = read_pdf(file) # Read the PDF file
|
126 |
+
|
127 |
+
if 'kg_df' not in globals() or 'file' not in globals() or file != globals()['file']: # Only execute if kg_df is not defined or if the file is not consistent with the persisted global
|
128 |
+
entity_pairs = [] # Initialize an empty list for the entity pairs
|
129 |
+
for i in tqdm(candidate_sentences["sentence"]): # For each sentence in the DataFrame
|
130 |
+
entity_pairs.append(get_entities(i)) # Append the entities to the list
|
131 |
+
relations = [get_relation(i) for i in tqdm(candidate_sentences['sentence'])] # Get the relations for each sentence
|
132 |
+
|
133 |
+
source = [i[0] for i in entity_pairs] # Extract the subjects
|
134 |
+
target = [i[1] for i in entity_pairs] # Extract the objects
|
135 |
+
globals()['kg_df'] = pd.DataFrame({'source':source, 'target':target, 'edge':relations}) # Create a DataFrame of the sources, targets, and edges
|
136 |
+
globals()['file'] = file # Persist the file into a global variable
|
137 |
+
|
138 |
+
unique_edges = kg_df['edge'].unique() if kg_df['edge'].nunique() != 0 else None # Get the unique edges
|
139 |
+
edge_counts = kg_df['edge'].value_counts() # Get the counts of the edges
|
140 |
+
unique_edges_df = pd.DataFrame({'edge': edge_counts.index, 'count': edge_counts.values}) # Create a DataFrame of the unique edges and their counts
|
141 |
+
|
142 |
+
if len(edge)==0: # If no edge is specified
|
143 |
+
G=nx.from_pandas_edgelist(kg_df, "source", "target",
|
144 |
+
edge_attr=True, create_using=nx.MultiDiGraph()) # Create a graph from the DataFrame
|
145 |
+
# plt.figure(figsize=(12,12)) # Create a figure
|
146 |
+
# pos = nx.spring_layout(G) # Get the positions of the nodes
|
147 |
+
# nx.draw(G, with_labels=True, node_color='skyblue', node_size=1500, edge_cmap=plt.cm.Blues, pos = pos) # Draw the graph
|
148 |
+
# plt.savefig("graph.png") # Save the graph as a PNG
|
149 |
+
iframe = render_graph(G)
|
150 |
+
return iframe, unique_edges_df # Return the path to the PNG and the DataFrame of unique edges
|
151 |
+
else: # If an edge is specified
|
152 |
+
G=nx.from_pandas_edgelist(kg_df[kg_df['edge']==edge], "source", "target",
|
153 |
+
edge_attr=True, create_using=nx.MultiDiGraph()) # Create a graph from the DataFrame with the specified edge
|
154 |
+
# plt.figure(figsize=(12,12)) # Create a figure
|
155 |
+
# pos = nx.spring_layout(G) # Get the positions of the nodes
|
156 |
+
iframe = render_graph(G)
|
157 |
+
|
158 |
+
# nx.draw(G, with_labels=True, node_color='skyblue', node_size=1500, edge_cmap=plt.cm.Blues, pos = pos) # Draw the graph
|
159 |
+
# plt.savefig("graph.png") # Save the graph as a PNG
|
160 |
+
return iframe, unique_edges_df # Return the path to the PNG and the DataFrame of unique edges
|
161 |
+
|
162 |
+
inputs = [
|
163 |
+
gr.File(label="Upload PDF"), # Create a file input for uploading a PDF
|
164 |
+
gr.Textbox(label="Graph a particular edge", type="text") # Create a textbox input for specifying an edge
|
165 |
+
]
|
166 |
+
|
167 |
+
outputs = [
|
168 |
+
gr.HTML(label="Generated graph"), # Create an image output for the generated graph
|
169 |
+
gr.Dataframe(label="Unique edges", type="pandas") # Create a DataFrame output for the unique edges
|
170 |
+
]
|
171 |
+
|
172 |
+
description = 'This Python script generates a knowledge graph from a PDF document. It uses several libraries including gradio for the web interface, spacy for natural language processing, networkx and matplotlib for graph generation, and fitz for PDF processing.'
|
173 |
+
iface = gr.Interface(fn=execute_process, inputs=inputs, outputs=outputs, title="PDF Knowledge graph", description=description) # Create an interface
|
174 |
+
iface.launch() # Launch the interface
|
docs/index.html
ADDED
@@ -0,0 +1,424 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<html>
|
2 |
+
<head>
|
3 |
+
<meta charset="utf-8">
|
4 |
+
|
5 |
+
<script>function neighbourhoodHighlight(params) {
|
6 |
+
// console.log("in nieghbourhoodhighlight");
|
7 |
+
allNodes = nodes.get({ returnType: "Object" });
|
8 |
+
// originalNodes = JSON.parse(JSON.stringify(allNodes));
|
9 |
+
// if something is selected:
|
10 |
+
if (params.nodes.length > 0) {
|
11 |
+
highlightActive = true;
|
12 |
+
var i, j;
|
13 |
+
var selectedNode = params.nodes[0];
|
14 |
+
var degrees = 2;
|
15 |
+
|
16 |
+
// mark all nodes as hard to read.
|
17 |
+
for (let nodeId in allNodes) {
|
18 |
+
// nodeColors[nodeId] = allNodes[nodeId].color;
|
19 |
+
allNodes[nodeId].color = "rgba(200,200,200,0.5)";
|
20 |
+
if (allNodes[nodeId].hiddenLabel === undefined) {
|
21 |
+
allNodes[nodeId].hiddenLabel = allNodes[nodeId].label;
|
22 |
+
allNodes[nodeId].label = undefined;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
var connectedNodes = network.getConnectedNodes(selectedNode);
|
26 |
+
var allConnectedNodes = [];
|
27 |
+
|
28 |
+
// get the second degree nodes
|
29 |
+
for (i = 1; i < degrees; i++) {
|
30 |
+
for (j = 0; j < connectedNodes.length; j++) {
|
31 |
+
allConnectedNodes = allConnectedNodes.concat(
|
32 |
+
network.getConnectedNodes(connectedNodes[j])
|
33 |
+
);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
// all second degree nodes get a different color and their label back
|
38 |
+
for (i = 0; i < allConnectedNodes.length; i++) {
|
39 |
+
// allNodes[allConnectedNodes[i]].color = "pink";
|
40 |
+
allNodes[allConnectedNodes[i]].color = "rgba(150,150,150,0.75)";
|
41 |
+
if (allNodes[allConnectedNodes[i]].hiddenLabel !== undefined) {
|
42 |
+
allNodes[allConnectedNodes[i]].label =
|
43 |
+
allNodes[allConnectedNodes[i]].hiddenLabel;
|
44 |
+
allNodes[allConnectedNodes[i]].hiddenLabel = undefined;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
// all first degree nodes get their own color and their label back
|
49 |
+
for (i = 0; i < connectedNodes.length; i++) {
|
50 |
+
// allNodes[connectedNodes[i]].color = undefined;
|
51 |
+
allNodes[connectedNodes[i]].color = nodeColors[connectedNodes[i]];
|
52 |
+
if (allNodes[connectedNodes[i]].hiddenLabel !== undefined) {
|
53 |
+
allNodes[connectedNodes[i]].label =
|
54 |
+
allNodes[connectedNodes[i]].hiddenLabel;
|
55 |
+
allNodes[connectedNodes[i]].hiddenLabel = undefined;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
// the main node gets its own color and its label back.
|
60 |
+
// allNodes[selectedNode].color = undefined;
|
61 |
+
allNodes[selectedNode].color = nodeColors[selectedNode];
|
62 |
+
if (allNodes[selectedNode].hiddenLabel !== undefined) {
|
63 |
+
allNodes[selectedNode].label = allNodes[selectedNode].hiddenLabel;
|
64 |
+
allNodes[selectedNode].hiddenLabel = undefined;
|
65 |
+
}
|
66 |
+
} else if (highlightActive === true) {
|
67 |
+
// console.log("highlightActive was true");
|
68 |
+
// reset all nodes
|
69 |
+
for (let nodeId in allNodes) {
|
70 |
+
// allNodes[nodeId].color = "purple";
|
71 |
+
allNodes[nodeId].color = nodeColors[nodeId];
|
72 |
+
// delete allNodes[nodeId].color;
|
73 |
+
if (allNodes[nodeId].hiddenLabel !== undefined) {
|
74 |
+
allNodes[nodeId].label = allNodes[nodeId].hiddenLabel;
|
75 |
+
allNodes[nodeId].hiddenLabel = undefined;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
highlightActive = false;
|
79 |
+
}
|
80 |
+
|
81 |
+
// transform the object into an array
|
82 |
+
var updateArray = [];
|
83 |
+
if (params.nodes.length > 0) {
|
84 |
+
for (let nodeId in allNodes) {
|
85 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
86 |
+
// console.log(allNodes[nodeId]);
|
87 |
+
updateArray.push(allNodes[nodeId]);
|
88 |
+
}
|
89 |
+
}
|
90 |
+
nodes.update(updateArray);
|
91 |
+
} else {
|
92 |
+
// console.log("Nothing was selected");
|
93 |
+
for (let nodeId in allNodes) {
|
94 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
95 |
+
// console.log(allNodes[nodeId]);
|
96 |
+
// allNodes[nodeId].color = {};
|
97 |
+
updateArray.push(allNodes[nodeId]);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
nodes.update(updateArray);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
function filterHighlight(params) {
|
105 |
+
allNodes = nodes.get({ returnType: "Object" });
|
106 |
+
// if something is selected:
|
107 |
+
if (params.nodes.length > 0) {
|
108 |
+
filterActive = true;
|
109 |
+
let selectedNodes = params.nodes;
|
110 |
+
|
111 |
+
// hiding all nodes and saving the label
|
112 |
+
for (let nodeId in allNodes) {
|
113 |
+
allNodes[nodeId].hidden = true;
|
114 |
+
if (allNodes[nodeId].savedLabel === undefined) {
|
115 |
+
allNodes[nodeId].savedLabel = allNodes[nodeId].label;
|
116 |
+
allNodes[nodeId].label = undefined;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
for (let i=0; i < selectedNodes.length; i++) {
|
121 |
+
allNodes[selectedNodes[i]].hidden = false;
|
122 |
+
if (allNodes[selectedNodes[i]].savedLabel !== undefined) {
|
123 |
+
allNodes[selectedNodes[i]].label = allNodes[selectedNodes[i]].savedLabel;
|
124 |
+
allNodes[selectedNodes[i]].savedLabel = undefined;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
} else if (filterActive === true) {
|
129 |
+
// reset all nodes
|
130 |
+
for (let nodeId in allNodes) {
|
131 |
+
allNodes[nodeId].hidden = false;
|
132 |
+
if (allNodes[nodeId].savedLabel !== undefined) {
|
133 |
+
allNodes[nodeId].label = allNodes[nodeId].savedLabel;
|
134 |
+
allNodes[nodeId].savedLabel = undefined;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
filterActive = false;
|
138 |
+
}
|
139 |
+
|
140 |
+
// transform the object into an array
|
141 |
+
var updateArray = [];
|
142 |
+
if (params.nodes.length > 0) {
|
143 |
+
for (let nodeId in allNodes) {
|
144 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
145 |
+
updateArray.push(allNodes[nodeId]);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
nodes.update(updateArray);
|
149 |
+
} else {
|
150 |
+
for (let nodeId in allNodes) {
|
151 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
152 |
+
updateArray.push(allNodes[nodeId]);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
nodes.update(updateArray);
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
function selectNode(nodes) {
|
160 |
+
network.selectNodes(nodes);
|
161 |
+
neighbourhoodHighlight({ nodes: nodes });
|
162 |
+
return nodes;
|
163 |
+
}
|
164 |
+
|
165 |
+
function selectNodes(nodes) {
|
166 |
+
network.selectNodes(nodes);
|
167 |
+
filterHighlight({nodes: nodes});
|
168 |
+
return nodes;
|
169 |
+
}
|
170 |
+
|
171 |
+
function highlightFilter(filter) {
|
172 |
+
let selectedNodes = []
|
173 |
+
let selectedProp = filter['property']
|
174 |
+
if (filter['item'] === 'node') {
|
175 |
+
let allNodes = nodes.get({ returnType: "Object" });
|
176 |
+
for (let nodeId in allNodes) {
|
177 |
+
if (allNodes[nodeId][selectedProp] && filter['value'].includes((allNodes[nodeId][selectedProp]).toString())) {
|
178 |
+
selectedNodes.push(nodeId)
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
else if (filter['item'] === 'edge'){
|
183 |
+
let allEdges = edges.get({returnType: 'object'});
|
184 |
+
// check if the selected property exists for selected edge and select the nodes connected to the edge
|
185 |
+
for (let edge in allEdges) {
|
186 |
+
if (allEdges[edge][selectedProp] && filter['value'].includes((allEdges[edge][selectedProp]).toString())) {
|
187 |
+
selectedNodes.push(allEdges[edge]['from'])
|
188 |
+
selectedNodes.push(allEdges[edge]['to'])
|
189 |
+
}
|
190 |
+
}
|
191 |
+
}
|
192 |
+
selectNodes(selectedNodes)
|
193 |
+
}</script>
|
194 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/dist/vis-network.min.css" integrity="sha512-WgxfT5LWjfszlPHXRmBWHkV2eceiWTOBvrKCNbdgDYTHrT2AeLCGbF4sZlZw3UMN3WtL0tGUoIAKsu8mllg/XA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
195 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js" integrity="sha512-LnvoEWDFrqGHlHmDD2101OrLcbsfkrzoSpvtSQtxK3RMnRV0eOkhhBN2dXHKRrUU8p2DGRTk35n4O8nWSVe1mQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
196 |
+
|
197 |
+
|
198 |
+
|
199 |
+
|
200 |
+
|
201 |
+
|
202 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tom-select/2.0.0-rc.4/css/tom-select.min.css" integrity="sha512-43fHB3GLgZfz8QXl1RPQ8O66oIgv3po9cJ5erMt1c4QISq9dYb195T3vr5ImnJPXuVroKcGBPXBFKETW8jrPNQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
203 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/tom-select/2.0.0-rc.4/js/tom-select.complete.js" integrity="sha512-jeF9CfnvzDiw9G9xiksVjxR2lib44Gnovvkv+3CgCG6NXCD4gqlA5nDAVW5WjpA+i+/zKsUWV5xNEbW1X/HH0Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
204 |
+
|
205 |
+
|
206 |
+
|
207 |
+
<center>
|
208 |
+
<h1></h1>
|
209 |
+
</center>
|
210 |
+
|
211 |
+
<!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
|
212 |
+
<script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
|
213 |
+
<link
|
214 |
+
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css"
|
215 |
+
rel="stylesheet"
|
216 |
+
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
|
217 |
+
crossorigin="anonymous"
|
218 |
+
/>
|
219 |
+
<script
|
220 |
+
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js"
|
221 |
+
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
|
222 |
+
crossorigin="anonymous"
|
223 |
+
></script>
|
224 |
+
|
225 |
+
|
226 |
+
<center>
|
227 |
+
<h1></h1>
|
228 |
+
</center>
|
229 |
+
<style type="text/css">
|
230 |
+
|
231 |
+
#mynetwork {
|
232 |
+
width: 100%;
|
233 |
+
height: 900px;
|
234 |
+
background-color: #ffffff;
|
235 |
+
border: 1px solid lightgray;
|
236 |
+
position: relative;
|
237 |
+
float: left;
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
|
242 |
+
|
243 |
+
#config {
|
244 |
+
float: left;
|
245 |
+
width: 400px;
|
246 |
+
height: 600px;
|
247 |
+
}
|
248 |
+
|
249 |
+
|
250 |
+
|
251 |
+
</style>
|
252 |
+
</head>
|
253 |
+
|
254 |
+
|
255 |
+
<body>
|
256 |
+
<div class="card" style="width: 100%">
|
257 |
+
|
258 |
+
<div id="select-menu" class="card-header">
|
259 |
+
<div class="row no-gutters">
|
260 |
+
<div class="col-10 pb-2">
|
261 |
+
<select
|
262 |
+
class="form-select"
|
263 |
+
aria-label="Default select example"
|
264 |
+
onchange="selectNode([value]);"
|
265 |
+
id="select-node"
|
266 |
+
placeholder="Select node..."
|
267 |
+
>
|
268 |
+
<option selected>Select a Node by ID</option>
|
269 |
+
|
270 |
+
<option value="special purpose which">special purpose which</option>
|
271 |
+
|
272 |
+
<option value="special purpose scheduler">special purpose scheduler</option>
|
273 |
+
|
274 |
+
<option value=""></option>
|
275 |
+
|
276 |
+
<option value="performance usage">performance usage</option>
|
277 |
+
|
278 |
+
<option value="simplified submission">simplified submission</option>
|
279 |
+
|
280 |
+
<option value="sensitive workloads">sensitive workloads</option>
|
281 |
+
|
282 |
+
<option value="gigabit Ethernet">gigabit Ethernet</option>
|
283 |
+
|
284 |
+
<option value="actual it">actual it</option>
|
285 |
+
|
286 |
+
<option value="which">which</option>
|
287 |
+
|
288 |
+
</select>
|
289 |
+
</div>
|
290 |
+
<div class="col-2 pb-2">
|
291 |
+
<button type="button" class="btn btn-primary btn-block" onclick="neighbourhoodHighlight({nodes: []});">Reset Selection</button>
|
292 |
+
</div>
|
293 |
+
</div>
|
294 |
+
</div>
|
295 |
+
|
296 |
+
|
297 |
+
<div id="mynetwork" class="card-body"></div>
|
298 |
+
</div>
|
299 |
+
|
300 |
+
|
301 |
+
|
302 |
+
<div id="config"></div>
|
303 |
+
|
304 |
+
|
305 |
+
<script type="text/javascript">
|
306 |
+
|
307 |
+
// initialize global variables.
|
308 |
+
var edges;
|
309 |
+
var nodes;
|
310 |
+
var allNodes;
|
311 |
+
var allEdges;
|
312 |
+
var nodeColors;
|
313 |
+
var originalNodes;
|
314 |
+
var network;
|
315 |
+
var container;
|
316 |
+
var options, data;
|
317 |
+
var filter = {
|
318 |
+
item : '',
|
319 |
+
property : '',
|
320 |
+
value : []
|
321 |
+
};
|
322 |
+
|
323 |
+
|
324 |
+
new TomSelect("#select-node",{
|
325 |
+
create: false,
|
326 |
+
sortField: {
|
327 |
+
field: "text",
|
328 |
+
direction: "asc"
|
329 |
+
}
|
330 |
+
});
|
331 |
+
|
332 |
+
|
333 |
+
|
334 |
+
|
335 |
+
// This method is responsible for drawing the graph, returns the drawn network
|
336 |
+
function drawGraph() {
|
337 |
+
var container = document.getElementById('mynetwork');
|
338 |
+
|
339 |
+
|
340 |
+
|
341 |
+
// parsing and collecting nodes and edges from the python
|
342 |
+
nodes = new vis.DataSet([{"color": "#97c2fc", "id": "special purpose which", "label": "special purpose which", "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": "special purpose scheduler", "label": "special purpose scheduler", "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": "", "label": "", "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": "performance usage", "label": "performance usage", "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": "simpli\ufb01ed submission", "label": "simpli\ufb01ed submission", "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": "sensitive workloads", "label": "sensitive workloads", "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": "gigabit Ethernet", "label": "gigabit Ethernet", "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": "actual it", "label": "actual it", "shape": "dot", "size": 10}, {"color": "#97c2fc", "id": "which", "label": "which", "shape": "dot", "size": 10}]);
|
343 |
+
edges = new vis.DataSet([{"edge": "workloads", "from": "special purpose which", "to": "special purpose scheduler", "width": 1}, {"edge": "workloads", "from": "", "to": "performance usage", "width": 1}, {"edge": "workloads", "from": "", "to": "simpli\ufb01ed submission", "width": 1}, {"edge": "workloads", "from": "", "to": "", "width": 1}, {"edge": "workloads", "from": "", "to": "sensitive workloads", "width": 1}, {"edge": "workloads", "from": "", "to": "gigabit Ethernet", "width": 1}, {"edge": "workloads", "from": "actual it", "to": "which", "width": 1}]);
|
344 |
+
|
345 |
+
nodeColors = {};
|
346 |
+
allNodes = nodes.get({ returnType: "Object" });
|
347 |
+
for (nodeId in allNodes) {
|
348 |
+
nodeColors[nodeId] = allNodes[nodeId].color;
|
349 |
+
}
|
350 |
+
allEdges = edges.get({ returnType: "Object" });
|
351 |
+
// adding nodes and edges to the graph
|
352 |
+
data = {nodes: nodes, edges: edges};
|
353 |
+
|
354 |
+
var options = {
|
355 |
+
"configure": {
|
356 |
+
"enabled": true,
|
357 |
+
"filter": [
|
358 |
+
"physics"
|
359 |
+
]
|
360 |
+
},
|
361 |
+
"edges": {
|
362 |
+
"color": {
|
363 |
+
"inherit": true
|
364 |
+
},
|
365 |
+
"smooth": {
|
366 |
+
"enabled": true,
|
367 |
+
"type": "dynamic"
|
368 |
+
}
|
369 |
+
},
|
370 |
+
"interaction": {
|
371 |
+
"dragNodes": true,
|
372 |
+
"hideEdgesOnDrag": false,
|
373 |
+
"hideNodesOnDrag": false
|
374 |
+
},
|
375 |
+
"physics": {
|
376 |
+
"enabled": true,
|
377 |
+
"forceAtlas2Based": {
|
378 |
+
"avoidOverlap": 0,
|
379 |
+
"centralGravity": 0.015,
|
380 |
+
"damping": 0.4,
|
381 |
+
"gravitationalConstant": -31,
|
382 |
+
"springConstant": 0.08,
|
383 |
+
"springLength": 100
|
384 |
+
},
|
385 |
+
"solver": "forceAtlas2Based",
|
386 |
+
"stabilization": {
|
387 |
+
"enabled": true,
|
388 |
+
"fit": true,
|
389 |
+
"iterations": 1000,
|
390 |
+
"onlyDynamicEdges": false,
|
391 |
+
"updateInterval": 50
|
392 |
+
}
|
393 |
+
}
|
394 |
+
};
|
395 |
+
|
396 |
+
|
397 |
+
|
398 |
+
|
399 |
+
|
400 |
+
// if this network requires displaying the configure window,
|
401 |
+
// put it in its div
|
402 |
+
options.configure["container"] = document.getElementById("config");
|
403 |
+
|
404 |
+
|
405 |
+
network = new vis.Network(container, data, options);
|
406 |
+
|
407 |
+
|
408 |
+
|
409 |
+
|
410 |
+
network.on("selectNode", neighbourhoodHighlight);
|
411 |
+
|
412 |
+
|
413 |
+
|
414 |
+
|
415 |
+
|
416 |
+
|
417 |
+
|
418 |
+
return network;
|
419 |
+
|
420 |
+
}
|
421 |
+
drawGraph();
|
422 |
+
</script>
|
423 |
+
</body>
|
424 |
+
</html>
|
lib/bindings/utils.js
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function neighbourhoodHighlight(params) {
|
2 |
+
// console.log("in nieghbourhoodhighlight");
|
3 |
+
allNodes = nodes.get({ returnType: "Object" });
|
4 |
+
// originalNodes = JSON.parse(JSON.stringify(allNodes));
|
5 |
+
// if something is selected:
|
6 |
+
if (params.nodes.length > 0) {
|
7 |
+
highlightActive = true;
|
8 |
+
var i, j;
|
9 |
+
var selectedNode = params.nodes[0];
|
10 |
+
var degrees = 2;
|
11 |
+
|
12 |
+
// mark all nodes as hard to read.
|
13 |
+
for (let nodeId in allNodes) {
|
14 |
+
// nodeColors[nodeId] = allNodes[nodeId].color;
|
15 |
+
allNodes[nodeId].color = "rgba(200,200,200,0.5)";
|
16 |
+
if (allNodes[nodeId].hiddenLabel === undefined) {
|
17 |
+
allNodes[nodeId].hiddenLabel = allNodes[nodeId].label;
|
18 |
+
allNodes[nodeId].label = undefined;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
var connectedNodes = network.getConnectedNodes(selectedNode);
|
22 |
+
var allConnectedNodes = [];
|
23 |
+
|
24 |
+
// get the second degree nodes
|
25 |
+
for (i = 1; i < degrees; i++) {
|
26 |
+
for (j = 0; j < connectedNodes.length; j++) {
|
27 |
+
allConnectedNodes = allConnectedNodes.concat(
|
28 |
+
network.getConnectedNodes(connectedNodes[j])
|
29 |
+
);
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
// all second degree nodes get a different color and their label back
|
34 |
+
for (i = 0; i < allConnectedNodes.length; i++) {
|
35 |
+
// allNodes[allConnectedNodes[i]].color = "pink";
|
36 |
+
allNodes[allConnectedNodes[i]].color = "rgba(150,150,150,0.75)";
|
37 |
+
if (allNodes[allConnectedNodes[i]].hiddenLabel !== undefined) {
|
38 |
+
allNodes[allConnectedNodes[i]].label =
|
39 |
+
allNodes[allConnectedNodes[i]].hiddenLabel;
|
40 |
+
allNodes[allConnectedNodes[i]].hiddenLabel = undefined;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
// all first degree nodes get their own color and their label back
|
45 |
+
for (i = 0; i < connectedNodes.length; i++) {
|
46 |
+
// allNodes[connectedNodes[i]].color = undefined;
|
47 |
+
allNodes[connectedNodes[i]].color = nodeColors[connectedNodes[i]];
|
48 |
+
if (allNodes[connectedNodes[i]].hiddenLabel !== undefined) {
|
49 |
+
allNodes[connectedNodes[i]].label =
|
50 |
+
allNodes[connectedNodes[i]].hiddenLabel;
|
51 |
+
allNodes[connectedNodes[i]].hiddenLabel = undefined;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
// the main node gets its own color and its label back.
|
56 |
+
// allNodes[selectedNode].color = undefined;
|
57 |
+
allNodes[selectedNode].color = nodeColors[selectedNode];
|
58 |
+
if (allNodes[selectedNode].hiddenLabel !== undefined) {
|
59 |
+
allNodes[selectedNode].label = allNodes[selectedNode].hiddenLabel;
|
60 |
+
allNodes[selectedNode].hiddenLabel = undefined;
|
61 |
+
}
|
62 |
+
} else if (highlightActive === true) {
|
63 |
+
// console.log("highlightActive was true");
|
64 |
+
// reset all nodes
|
65 |
+
for (let nodeId in allNodes) {
|
66 |
+
// allNodes[nodeId].color = "purple";
|
67 |
+
allNodes[nodeId].color = nodeColors[nodeId];
|
68 |
+
// delete allNodes[nodeId].color;
|
69 |
+
if (allNodes[nodeId].hiddenLabel !== undefined) {
|
70 |
+
allNodes[nodeId].label = allNodes[nodeId].hiddenLabel;
|
71 |
+
allNodes[nodeId].hiddenLabel = undefined;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
highlightActive = false;
|
75 |
+
}
|
76 |
+
|
77 |
+
// transform the object into an array
|
78 |
+
var updateArray = [];
|
79 |
+
if (params.nodes.length > 0) {
|
80 |
+
for (let nodeId in allNodes) {
|
81 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
82 |
+
// console.log(allNodes[nodeId]);
|
83 |
+
updateArray.push(allNodes[nodeId]);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
nodes.update(updateArray);
|
87 |
+
} else {
|
88 |
+
// console.log("Nothing was selected");
|
89 |
+
for (let nodeId in allNodes) {
|
90 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
91 |
+
// console.log(allNodes[nodeId]);
|
92 |
+
// allNodes[nodeId].color = {};
|
93 |
+
updateArray.push(allNodes[nodeId]);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
nodes.update(updateArray);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
function filterHighlight(params) {
|
101 |
+
allNodes = nodes.get({ returnType: "Object" });
|
102 |
+
// if something is selected:
|
103 |
+
if (params.nodes.length > 0) {
|
104 |
+
filterActive = true;
|
105 |
+
let selectedNodes = params.nodes;
|
106 |
+
|
107 |
+
// hiding all nodes and saving the label
|
108 |
+
for (let nodeId in allNodes) {
|
109 |
+
allNodes[nodeId].hidden = true;
|
110 |
+
if (allNodes[nodeId].savedLabel === undefined) {
|
111 |
+
allNodes[nodeId].savedLabel = allNodes[nodeId].label;
|
112 |
+
allNodes[nodeId].label = undefined;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
for (let i=0; i < selectedNodes.length; i++) {
|
117 |
+
allNodes[selectedNodes[i]].hidden = false;
|
118 |
+
if (allNodes[selectedNodes[i]].savedLabel !== undefined) {
|
119 |
+
allNodes[selectedNodes[i]].label = allNodes[selectedNodes[i]].savedLabel;
|
120 |
+
allNodes[selectedNodes[i]].savedLabel = undefined;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
} else if (filterActive === true) {
|
125 |
+
// reset all nodes
|
126 |
+
for (let nodeId in allNodes) {
|
127 |
+
allNodes[nodeId].hidden = false;
|
128 |
+
if (allNodes[nodeId].savedLabel !== undefined) {
|
129 |
+
allNodes[nodeId].label = allNodes[nodeId].savedLabel;
|
130 |
+
allNodes[nodeId].savedLabel = undefined;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
filterActive = false;
|
134 |
+
}
|
135 |
+
|
136 |
+
// transform the object into an array
|
137 |
+
var updateArray = [];
|
138 |
+
if (params.nodes.length > 0) {
|
139 |
+
for (let nodeId in allNodes) {
|
140 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
141 |
+
updateArray.push(allNodes[nodeId]);
|
142 |
+
}
|
143 |
+
}
|
144 |
+
nodes.update(updateArray);
|
145 |
+
} else {
|
146 |
+
for (let nodeId in allNodes) {
|
147 |
+
if (allNodes.hasOwnProperty(nodeId)) {
|
148 |
+
updateArray.push(allNodes[nodeId]);
|
149 |
+
}
|
150 |
+
}
|
151 |
+
nodes.update(updateArray);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
function selectNode(nodes) {
|
156 |
+
network.selectNodes(nodes);
|
157 |
+
neighbourhoodHighlight({ nodes: nodes });
|
158 |
+
return nodes;
|
159 |
+
}
|
160 |
+
|
161 |
+
function selectNodes(nodes) {
|
162 |
+
network.selectNodes(nodes);
|
163 |
+
filterHighlight({nodes: nodes});
|
164 |
+
return nodes;
|
165 |
+
}
|
166 |
+
|
167 |
+
function highlightFilter(filter) {
|
168 |
+
let selectedNodes = []
|
169 |
+
let selectedProp = filter['property']
|
170 |
+
if (filter['item'] === 'node') {
|
171 |
+
let allNodes = nodes.get({ returnType: "Object" });
|
172 |
+
for (let nodeId in allNodes) {
|
173 |
+
if (allNodes[nodeId][selectedProp] && filter['value'].includes((allNodes[nodeId][selectedProp]).toString())) {
|
174 |
+
selectedNodes.push(nodeId)
|
175 |
+
}
|
176 |
+
}
|
177 |
+
}
|
178 |
+
else if (filter['item'] === 'edge'){
|
179 |
+
let allEdges = edges.get({returnType: 'object'});
|
180 |
+
// check if the selected property exists for selected edge and select the nodes connected to the edge
|
181 |
+
for (let edge in allEdges) {
|
182 |
+
if (allEdges[edge][selectedProp] && filter['value'].includes((allEdges[edge][selectedProp]).toString())) {
|
183 |
+
selectedNodes.push(allEdges[edge]['from'])
|
184 |
+
selectedNodes.push(allEdges[edge]['to'])
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
+
selectNodes(selectedNodes)
|
189 |
+
}
|
lib/tom-select/tom-select.complete.min.js
ADDED
@@ -0,0 +1,356 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Tom Select v2.0.0-rc.4
|
3 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
*/
|
5 |
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TomSelect=t()}(this,(function(){"use strict"
|
6 |
+
function e(e,t){e.split(/\s+/).forEach((e=>{t(e)}))}class t{constructor(){this._events={}}on(t,i){e(t,(e=>{this._events[e]=this._events[e]||[],this._events[e].push(i)}))}off(t,i){var s=arguments.length
|
7 |
+
0!==s?e(t,(e=>{if(1===s)return delete this._events[e]
|
8 |
+
e in this._events!=!1&&this._events[e].splice(this._events[e].indexOf(i),1)})):this._events={}}trigger(t,...i){var s=this
|
9 |
+
e(t,(e=>{if(e in s._events!=!1)for(let t of s._events[e])t.apply(s,i)}))}}var i
|
10 |
+
const s="[̀-ͯ·ʾ]",n=new RegExp(s,"g")
|
11 |
+
var o
|
12 |
+
const r={"æ":"ae","ⱥ":"a","ø":"o"},l=new RegExp(Object.keys(r).join("|"),"g"),a=[[67,67],[160,160],[192,438],[452,652],[961,961],[1019,1019],[1083,1083],[1281,1289],[1984,1984],[5095,5095],[7429,7441],[7545,7549],[7680,7935],[8580,8580],[9398,9449],[11360,11391],[42792,42793],[42802,42851],[42873,42897],[42912,42922],[64256,64260],[65313,65338],[65345,65370]],c=e=>e.normalize("NFKD").replace(n,"").toLowerCase().replace(l,(function(e){return r[e]})),d=(e,t="|")=>{if(1==e.length)return e[0]
|
13 |
+
var i=1
|
14 |
+
return e.forEach((e=>{i=Math.max(i,e.length)})),1==i?"["+e.join("")+"]":"(?:"+e.join(t)+")"},p=e=>{if(1===e.length)return[[e]]
|
15 |
+
var t=[]
|
16 |
+
return p(e.substring(1)).forEach((function(i){var s=i.slice(0)
|
17 |
+
s[0]=e.charAt(0)+s[0],t.push(s),(s=i.slice(0)).unshift(e.charAt(0)),t.push(s)})),t},u=e=>{void 0===o&&(o=(()=>{var e={}
|
18 |
+
a.forEach((t=>{for(let s=t[0];s<=t[1];s++){let t=String.fromCharCode(s),n=c(t)
|
19 |
+
if(n!=t.toLowerCase()){n in e||(e[n]=[n])
|
20 |
+
var i=new RegExp(d(e[n]),"iu")
|
21 |
+
t.match(i)||e[n].push(t)}}}))
|
22 |
+
var t=Object.keys(e)
|
23 |
+
t=t.sort(((e,t)=>t.length-e.length)),i=new RegExp("("+d(t)+"[̀-ͯ·ʾ]*)","g")
|
24 |
+
var s={}
|
25 |
+
return t.sort(((e,t)=>e.length-t.length)).forEach((t=>{var i=p(t).map((t=>(t=t.map((t=>e.hasOwnProperty(t)?d(e[t]):t)),d(t,""))))
|
26 |
+
s[t]=d(i)})),s})())
|
27 |
+
return e.normalize("NFKD").toLowerCase().split(i).map((e=>{if(""==e)return""
|
28 |
+
const t=c(e)
|
29 |
+
if(o.hasOwnProperty(t))return o[t]
|
30 |
+
const i=e.normalize("NFC")
|
31 |
+
return i!=e?d([e,i]):e})).join("")},h=(e,t)=>{if(e)return e[t]},g=(e,t)=>{if(e){for(var i,s=t.split(".");(i=s.shift())&&(e=e[i]););return e}},f=(e,t,i)=>{var s,n
|
32 |
+
return e?-1===(n=(e+="").search(t.regex))?0:(s=t.string.length/e.length,0===n&&(s+=.5),s*i):0},v=e=>(e+"").replace(/([\$\(-\+\.\?\[-\^\{-\}])/g,"\\$1"),m=(e,t)=>{var i=e[t]
|
33 |
+
if("function"==typeof i)return i
|
34 |
+
i&&!Array.isArray(i)&&(e[t]=[i])},y=(e,t)=>{if(Array.isArray(e))e.forEach(t)
|
35 |
+
else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},O=(e,t)=>"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=c(e+"").toLowerCase())>(t=c(t+"").toLowerCase())?1:t>e?-1:0
|
36 |
+
class b{constructor(e,t){this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t,i){if(!e||!e.length)return[]
|
37 |
+
const s=[],n=e.split(/\s+/)
|
38 |
+
var o
|
39 |
+
return i&&(o=new RegExp("^("+Object.keys(i).map(v).join("|")+"):(.*)$")),n.forEach((e=>{let i,n=null,r=null
|
40 |
+
o&&(i=e.match(o))&&(n=i[1],e=i[2]),e.length>0&&(r=v(e),this.settings.diacritics&&(r=u(r)),t&&(r="\\b"+r)),s.push({string:e,regex:r?new RegExp(r,"iu"):null,field:n})})),s}getScoreFunction(e,t){var i=this.prepareSearch(e,t)
|
41 |
+
return this._getScoreFunction(i)}_getScoreFunction(e){const t=e.tokens,i=t.length
|
42 |
+
if(!i)return function(){return 0}
|
43 |
+
const s=e.options.fields,n=e.weights,o=s.length,r=e.getAttrFn
|
44 |
+
if(!o)return function(){return 1}
|
45 |
+
const l=1===o?function(e,t){const i=s[0].field
|
46 |
+
return f(r(t,i),e,n[i])}:function(e,t){var i=0
|
47 |
+
if(e.field){const s=r(t,e.field)
|
48 |
+
!e.regex&&s?i+=1/o:i+=f(s,e,1)}else y(n,((s,n)=>{i+=f(r(t,n),e,s)}))
|
49 |
+
return i/o}
|
50 |
+
return 1===i?function(e){return l(t[0],e)}:"and"===e.options.conjunction?function(e){for(var s,n=0,o=0;n<i;n++){if((s=l(t[n],e))<=0)return 0
|
51 |
+
o+=s}return o/i}:function(e){var s=0
|
52 |
+
return y(t,(t=>{s+=l(t,e)})),s/i}}getSortFunction(e,t){var i=this.prepareSearch(e,t)
|
53 |
+
return this._getSortFunction(i)}_getSortFunction(e){var t,i,s
|
54 |
+
const n=this,o=e.options,r=!e.query&&o.sort_empty?o.sort_empty:o.sort,l=[],a=[]
|
55 |
+
if("function"==typeof r)return r.bind(this)
|
56 |
+
const c=function(t,i){return"$score"===t?i.score:e.getAttrFn(n.items[i.id],t)}
|
57 |
+
if(r)for(t=0,i=r.length;t<i;t++)(e.query||"$score"!==r[t].field)&&l.push(r[t])
|
58 |
+
if(e.query){for(s=!0,t=0,i=l.length;t<i;t++)if("$score"===l[t].field){s=!1
|
59 |
+
break}s&&l.unshift({field:"$score",direction:"desc"})}else for(t=0,i=l.length;t<i;t++)if("$score"===l[t].field){l.splice(t,1)
|
60 |
+
break}for(t=0,i=l.length;t<i;t++)a.push("desc"===l[t].direction?-1:1)
|
61 |
+
const d=l.length
|
62 |
+
if(d){if(1===d){const e=l[0].field,t=a[0]
|
63 |
+
return function(i,s){return t*O(c(e,i),c(e,s))}}return function(e,t){var i,s,n
|
64 |
+
for(i=0;i<d;i++)if(n=l[i].field,s=a[i]*O(c(n,e),c(n,t)))return s
|
65 |
+
return 0}}return null}prepareSearch(e,t){const i={}
|
66 |
+
var s=Object.assign({},t)
|
67 |
+
if(m(s,"sort"),m(s,"sort_empty"),s.fields){m(s,"fields")
|
68 |
+
const e=[]
|
69 |
+
s.fields.forEach((t=>{"string"==typeof t&&(t={field:t,weight:1}),e.push(t),i[t.field]="weight"in t?t.weight:1})),s.fields=e}return{options:s,query:e.toLowerCase().trim(),tokens:this.tokenize(e,s.respect_word_boundaries,i),total:0,items:[],weights:i,getAttrFn:s.nesting?g:h}}search(e,t){var i,s,n=this
|
70 |
+
s=this.prepareSearch(e,t),t=s.options,e=s.query
|
71 |
+
const o=t.score||n._getScoreFunction(s)
|
72 |
+
e.length?y(n.items,((e,n)=>{i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):y(n.items,((e,t)=>{s.items.push({score:1,id:t})}))
|
73 |
+
const r=n._getSortFunction(s)
|
74 |
+
return r&&s.items.sort(r),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}const w=e=>{if(e.jquery)return e[0]
|
75 |
+
if(e instanceof HTMLElement)return e
|
76 |
+
if(e.indexOf("<")>-1){let t=document.createElement("div")
|
77 |
+
return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)},_=(e,t)=>{var i=document.createEvent("HTMLEvents")
|
78 |
+
i.initEvent(t,!0,!1),e.dispatchEvent(i)},I=(e,t)=>{Object.assign(e.style,t)},C=(e,...t)=>{var i=A(t);(e=x(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))},S=(e,...t)=>{var i=A(t);(e=x(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))},A=e=>{var t=[]
|
79 |
+
return y(e,(e=>{"string"==typeof e&&(e=e.trim().split(/[\11\12\14\15\40]/)),Array.isArray(e)&&(t=t.concat(e))})),t.filter(Boolean)},x=e=>(Array.isArray(e)||(e=[e]),e),k=(e,t,i)=>{if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
|
80 |
+
e=e.parentNode}},F=(e,t=0)=>t>0?e[e.length-1]:e[0],L=(e,t)=>{if(!e)return-1
|
81 |
+
t=t||e.nodeName
|
82 |
+
for(var i=0;e=e.previousElementSibling;)e.matches(t)&&i++
|
83 |
+
return i},P=(e,t)=>{y(t,((t,i)=>{null==t?e.removeAttribute(i):e.setAttribute(i,""+t)}))},E=(e,t)=>{e.parentNode&&e.parentNode.replaceChild(t,e)},T=(e,t)=>{if(null===t)return
|
84 |
+
if("string"==typeof t){if(!t.length)return
|
85 |
+
t=new RegExp(t,"i")}const i=e=>3===e.nodeType?(e=>{var i=e.data.match(t)
|
86 |
+
if(i&&e.data.length>0){var s=document.createElement("span")
|
87 |
+
s.className="highlight"
|
88 |
+
var n=e.splitText(i.index)
|
89 |
+
n.splitText(i[0].length)
|
90 |
+
var o=n.cloneNode(!0)
|
91 |
+
return s.appendChild(o),E(n,s),1}return 0})(e):((e=>{if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&("highlight"!==e.className||"SPAN"!==e.tagName))for(var t=0;t<e.childNodes.length;++t)t+=i(e.childNodes[t])})(e),0)
|
92 |
+
i(e)},V="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
|
93 |
+
var j={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"ts-wrapper",controlClass:"ts-control",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
|
94 |
+
const q=e=>null==e?null:D(e),D=e=>"boolean"==typeof e?e?"1":"0":e+"",N=e=>(e+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),z=(e,t)=>{var i
|
95 |
+
return function(s,n){var o=this
|
96 |
+
i&&(o.loading=Math.max(o.loading-1,0),clearTimeout(i)),i=setTimeout((function(){i=null,o.loadedSearches[s]=!0,e.call(o,s,n)}),t)}},R=(e,t,i)=>{var s,n=e.trigger,o={}
|
97 |
+
for(s in e.trigger=function(){var i=arguments[0]
|
98 |
+
if(-1===t.indexOf(i))return n.apply(e,arguments)
|
99 |
+
o[i]=arguments},i.apply(e,[]),e.trigger=n,o)n.apply(e,o[s])},H=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},B=(e,t,i,s)=>{e.addEventListener(t,i,s)},K=(e,t)=>!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0)),M=(e,t)=>{const i=e.getAttribute("id")
|
100 |
+
return i||(e.setAttribute("id",t),t)},Q=e=>e.replace(/[\\"']/g,"\\$&"),G=(e,t)=>{t&&e.append(t)}
|
101 |
+
function U(e,t){var i=Object.assign({},j,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,l=i.optgroupField,a=i.optgroupLabelField,c=i.optgroupValueField,d=e.tagName.toLowerCase(),p=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
|
102 |
+
if(!p&&!i.allowEmptyOption){let t=e.querySelector('option[value=""]')
|
103 |
+
t&&(p=t.textContent)}var u,h,g,f,v,m,O={placeholder:p,options:[],optgroups:[],items:[],maxItems:null}
|
104 |
+
return"select"===d?(h=O.options,g={},f=1,v=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
|
105 |
+
return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},m=(e,t)=>{var s=q(e.value)
|
106 |
+
if(null!=s&&(s||i.allowEmptyOption)){if(g.hasOwnProperty(s)){if(t){var a=g[s][l]
|
107 |
+
a?Array.isArray(a)?a.push(t):g[s][l]=[a,t]:g[s][l]=t}}else{var c=v(e)
|
108 |
+
c[n]=c[n]||e.textContent,c[o]=c[o]||s,c[r]=c[r]||e.disabled,c[l]=c[l]||t,c.$option=e,g[s]=c,h.push(c)}e.selected&&O.items.push(s)}},O.maxItems=e.hasAttribute("multiple")?null:1,y(e.children,(e=>{var t,i,s
|
109 |
+
"optgroup"===(u=e.tagName.toLowerCase())?((s=v(t=e))[a]=s[a]||t.getAttribute("label")||"",s[c]=s[c]||f++,s[r]=s[r]||t.disabled,O.optgroups.push(s),i=s[c],y(t.children,(e=>{m(e,i)}))):"option"===u&&m(e)}))):(()=>{const t=e.getAttribute(s)
|
110 |
+
if(t)O.options=JSON.parse(t),y(O.options,(e=>{O.items.push(e[o])}))
|
111 |
+
else{var r=e.value.trim()||""
|
112 |
+
if(!i.allowEmptyOption&&!r.length)return
|
113 |
+
const t=r.split(i.delimiter)
|
114 |
+
y(t,(e=>{const t={}
|
115 |
+
t[n]=e,t[o]=e,O.options.push(t)})),O.items=t}})(),Object.assign({},j,O,t)}var W=0
|
116 |
+
class J extends(function(e){return e.plugins={},class extends e{constructor(...e){super(...e),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i
|
117 |
+
const s=this,n=[]
|
118 |
+
if(Array.isArray(e))e.forEach((e=>{"string"==typeof e?n.push(e):(s.plugins.settings[e.name]=e.options,n.push(e.name))}))
|
119 |
+
else if(e)for(t in e)e.hasOwnProperty(t)&&(s.plugins.settings[t]=e[t],n.push(t))
|
120 |
+
for(;i=n.shift();)s.require(i)}loadPlugin(t){var i=this,s=i.plugins,n=e.plugins[t]
|
121 |
+
if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin')
|
122 |
+
s.requested[t]=!0,s.loaded[t]=n.fn.apply(i,[i.plugins.settings[t]||{}]),s.names.push(t)}require(e){var t=this,i=t.plugins
|
123 |
+
if(!t.plugins.loaded.hasOwnProperty(e)){if(i.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")')
|
124 |
+
t.loadPlugin(e)}return i.loaded[e]}}}(t)){constructor(e,t){var i
|
125 |
+
super(),this.order=0,this.isOpen=!1,this.isDisabled=!1,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.hasOptions=!1,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],W++
|
126 |
+
var s=w(e)
|
127 |
+
if(s.tomselect)throw new Error("Tom Select already initialized on this element")
|
128 |
+
s.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(s,null)).getPropertyValue("direction")
|
129 |
+
const n=U(s,t)
|
130 |
+
this.settings=n,this.input=s,this.tabIndex=s.tabIndex||0,this.is_select_tag="select"===s.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=M(s,"tomselect-"+W),this.isRequired=s.required,this.sifter=new b(this.options,{diacritics:n.diacritics}),n.mode=n.mode||(1===n.maxItems?"single":"multi"),"boolean"!=typeof n.hideSelected&&(n.hideSelected="multi"===n.mode),"boolean"!=typeof n.hidePlaceholder&&(n.hidePlaceholder="multi"!==n.mode)
|
131 |
+
var o=n.createFilter
|
132 |
+
"function"!=typeof o&&("string"==typeof o&&(o=new RegExp(o)),o instanceof RegExp?n.createFilter=e=>o.test(e):n.createFilter=()=>!0),this.initializePlugins(n.plugins),this.setupCallbacks(),this.setupTemplates()
|
133 |
+
const r=w("<div>"),l=w("<div>"),a=this._render("dropdown"),c=w('<div role="listbox" tabindex="-1">'),d=this.input.getAttribute("class")||"",p=n.mode
|
134 |
+
var u
|
135 |
+
if(C(r,n.wrapperClass,d,p),C(l,n.controlClass),G(r,l),C(a,n.dropdownClass,p),n.copyClassesToDropdown&&C(a,d),C(c,n.dropdownContentClass),G(a,c),w(n.dropdownParent||r).appendChild(a),n.hasOwnProperty("controlInput"))n.controlInput?(u=w(n.controlInput),this.focus_node=u):(u=w("<input/>"),this.focus_node=l)
|
136 |
+
else{u=w('<input type="text" autocomplete="off" size="1" />')
|
137 |
+
y(["autocorrect","autocapitalize","autocomplete"],(e=>{s.getAttribute(e)&&P(u,{[e]:s.getAttribute(e)})})),u.tabIndex=-1,l.appendChild(u),this.focus_node=u}this.wrapper=r,this.dropdown=a,this.dropdown_content=c,this.control=l,this.control_input=u,this.setup()}setup(){const e=this,t=e.settings,i=e.control_input,s=e.dropdown,n=e.dropdown_content,o=e.wrapper,r=e.control,l=e.input,a=e.focus_node,c={passive:!0},d=e.inputId+"-ts-dropdown"
|
138 |
+
P(n,{id:d}),P(a,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":d})
|
139 |
+
const p=M(a,e.inputId+"-ts-control"),u="label[for='"+(e=>e.replace(/['"\\]/g,"\\$&"))(e.inputId)+"']",h=document.querySelector(u),g=e.focus.bind(e)
|
140 |
+
if(h){B(h,"click",g),P(h,{for:p})
|
141 |
+
const t=M(h,e.inputId+"-ts-label")
|
142 |
+
P(a,{"aria-labelledby":t}),P(n,{"aria-labelledby":t})}if(o.style.width=l.style.width,e.plugins.names.length){const t="plugin-"+e.plugins.names.join(" plugin-")
|
143 |
+
C([o,s],t)}(null===t.maxItems||t.maxItems>1)&&e.is_select_tag&&P(l,{multiple:"multiple"}),e.settings.placeholder&&P(i,{placeholder:t.placeholder}),!e.settings.splitOn&&e.settings.delimiter&&(e.settings.splitOn=new RegExp("\\s*"+v(e.settings.delimiter)+"+\\s*")),t.load&&t.loadThrottle&&(t.load=z(t.load,t.loadThrottle)),e.control_input.type=l.type,B(s,"click",(t=>{const i=k(t.target,"[data-selectable]")
|
144 |
+
i&&(e.onOptionSelect(t,i),H(t,!0))})),B(r,"click",(t=>{var s=k(t.target,"[data-ts-item]",r)
|
145 |
+
s&&e.onItemSelect(t,s)?H(t,!0):""==i.value&&(e.onClick(),H(t,!0))})),B(i,"mousedown",(e=>{""!==i.value&&e.stopPropagation()})),B(a,"keydown",(t=>e.onKeyDown(t))),B(i,"keypress",(t=>e.onKeyPress(t))),B(i,"input",(t=>e.onInput(t))),B(a,"resize",(()=>e.positionDropdown()),c),B(a,"blur",(t=>e.onBlur(t))),B(a,"focus",(t=>e.onFocus(t))),B(a,"paste",(t=>e.onPaste(t)))
|
146 |
+
const f=t=>{const i=t.composedPath()[0]
|
147 |
+
if(!o.contains(i)&&!s.contains(i))return e.isFocused&&e.blur(),void e.inputState()
|
148 |
+
H(t,!0)}
|
149 |
+
var m=()=>{e.isOpen&&e.positionDropdown()}
|
150 |
+
B(document,"mousedown",f),B(window,"scroll",m,c),B(window,"resize",m,c),this._destroy=()=>{document.removeEventListener("mousedown",f),window.removeEventListener("sroll",m),window.removeEventListener("resize",m),h&&h.removeEventListener("click",g)},this.revertSettings={innerHTML:l.innerHTML,tabIndex:l.tabIndex},l.tabIndex=-1,l.insertAdjacentElement("afterend",e.wrapper),e.sync(!1),t.items=[],delete t.optgroups,delete t.options,B(l,"invalid",(t=>{e.isValid&&(e.isValid=!1,e.isInvalid=!0,e.refreshState())})),e.updateOriginalInput(),e.refreshItems(),e.close(!1),e.inputState(),e.isSetup=!0,l.disabled?e.disable():e.enable(),e.on("change",this.onChange),C(l,"tomselected","ts-hidden-accessible"),e.trigger("initialize"),!0===t.preload&&e.preload()}setupOptions(e=[],t=[]){this.addOptions(e),y(t,(e=>{this.registerOptionGroup(e)}))}setupTemplates(){var e=this,t=e.settings.labelField,i=e.settings.optgroupLabelField,s={optgroup:e=>{let t=document.createElement("div")
|
151 |
+
return t.className="optgroup",t.appendChild(e.options),t},optgroup_header:(e,t)=>'<div class="optgroup-header">'+t(e[i])+"</div>",option:(e,i)=>"<div>"+i(e[t])+"</div>",item:(e,i)=>"<div>"+i(e[t])+"</div>",option_create:(e,t)=>'<div class="create">Add <strong>'+t(e.input)+"</strong>…</div>",no_results:()=>'<div class="no-results">No results found</div>',loading:()=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>"<div></div>"}
|
152 |
+
e.settings.render=Object.assign({},s,e.settings.render)}setupCallbacks(){var e,t,i={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",item_select:"onItemSelect",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"}
|
153 |
+
for(e in i)(t=this.settings[i[e]])&&this.on(e,t)}sync(e=!0){const t=this,i=e?U(t.input,{delimiter:t.settings.delimiter}):t.settings
|
154 |
+
t.setupOptions(i.options,i.optgroups),t.setValue(i.items,!0),t.lastQuery=null}onClick(){var e=this
|
155 |
+
if(e.activeItems.length>0)return e.clearActiveItems(),void e.focus()
|
156 |
+
e.isFocused&&e.isOpen?e.blur():e.focus()}onMouseDown(){}onChange(){_(this.input,"input"),_(this.input,"change")}onPaste(e){var t=this
|
157 |
+
t.isFull()||t.isInputHidden||t.isLocked?H(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
|
158 |
+
if(e.match(t.settings.splitOn)){var i=e.trim().split(t.settings.splitOn)
|
159 |
+
y(i,(e=>{t.createItem(e)}))}}),0)}onKeyPress(e){var t=this
|
160 |
+
if(!t.isLocked){var i=String.fromCharCode(e.keyCode||e.which)
|
161 |
+
return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void H(e)):void 0}H(e)}onKeyDown(e){var t=this
|
162 |
+
if(t.isLocked)9!==e.keyCode&&H(e)
|
163 |
+
else{switch(e.keyCode){case 65:if(K(V,e))return H(e),void t.selectAll()
|
164 |
+
break
|
165 |
+
case 27:return t.isOpen&&(H(e,!0),t.close()),void t.clearActiveItems()
|
166 |
+
case 40:if(!t.isOpen&&t.hasOptions)t.open()
|
167 |
+
else if(t.activeOption){let e=t.getAdjacent(t.activeOption,1)
|
168 |
+
e&&t.setActiveOption(e)}return void H(e)
|
169 |
+
case 38:if(t.activeOption){let e=t.getAdjacent(t.activeOption,-1)
|
170 |
+
e&&t.setActiveOption(e)}return void H(e)
|
171 |
+
case 13:return void(t.isOpen&&t.activeOption?(t.onOptionSelect(e,t.activeOption),H(e)):t.settings.create&&t.createItem()&&H(e))
|
172 |
+
case 37:return void t.advanceSelection(-1,e)
|
173 |
+
case 39:return void t.advanceSelection(1,e)
|
174 |
+
case 9:return void(t.settings.selectOnTab&&(t.isOpen&&t.activeOption&&(t.onOptionSelect(e,t.activeOption),H(e)),t.settings.create&&t.createItem()&&H(e)))
|
175 |
+
case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!K(V,e)&&H(e)}}onInput(e){var t=this
|
176 |
+
if(!t.isLocked){var i=t.inputValue()
|
177 |
+
t.lastValue!==i&&(t.lastValue=i,t.settings.shouldLoad.call(t,i)&&t.load(i),t.refreshOptions(),t.trigger("type",i))}}onFocus(e){var t=this,i=t.isFocused
|
178 |
+
if(t.isDisabled)return t.blur(),void H(e)
|
179 |
+
t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.preload(),i||t.trigger("focus"),t.activeItems.length||(t.showInput(),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}onBlur(e){if(!1!==document.hasFocus()){var t=this
|
180 |
+
if(t.isFocused){t.isFocused=!1,t.ignoreFocus=!1
|
181 |
+
var i=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")}
|
182 |
+
t.settings.create&&t.settings.createOnBlur?t.createItem(null,!1,i):i()}}}onOptionSelect(e,t){var i,s=this
|
183 |
+
t&&(t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?s.createItem(null,!0,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(i=t.dataset.value)&&(s.lastQuery=null,s.addItem(i),s.settings.closeAfterSelect&&s.close(),!s.settings.hideSelected&&e.type&&/click/.test(e.type)&&s.setActiveOption(t))))}onItemSelect(e,t){var i=this
|
184 |
+
return!i.isLocked&&"multi"===i.settings.mode&&(H(e),i.setActiveItem(t,e),!0)}canLoad(e){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(e)}load(e){const t=this
|
185 |
+
if(!t.canLoad(e))return
|
186 |
+
C(t.wrapper,t.settings.loadingClass),t.loading++
|
187 |
+
const i=t.loadCallback.bind(t)
|
188 |
+
t.settings.load.call(t,e,i)}loadCallback(e,t){const i=this
|
189 |
+
i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(e,t),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||S(i.wrapper,i.settings.loadingClass),i.trigger("load",e,t)}preload(){var e=this.wrapper.classList
|
190 |
+
e.contains("preloaded")||(e.add("preloaded"),this.load(""))}setTextboxValue(e=""){var t=this.control_input
|
191 |
+
t.value!==e&&(t.value=e,_(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){R(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,l,a=this
|
192 |
+
if("single"!==a.settings.mode){if(!e)return a.clearActiveItems(),void(a.isFocused&&a.showInput())
|
193 |
+
if("click"===(i=t&&t.type.toLowerCase())&&K("shiftKey",t)&&a.activeItems.length){for(l=a.getLastActive(),(n=Array.prototype.indexOf.call(a.control.children,l))>(o=Array.prototype.indexOf.call(a.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=a.control.children[s],-1===a.activeItems.indexOf(e)&&a.setActiveItemClass(e)
|
194 |
+
H(t)}else"click"===i&&K(V,t)||"keydown"===i&&K("shiftKey",t)?e.classList.contains("active")?a.removeActiveItem(e):a.setActiveItemClass(e):(a.clearActiveItems(),a.setActiveItemClass(e))
|
195 |
+
a.hideInput(),a.isFocused||a.focus()}}setActiveItemClass(e){const t=this,i=t.control.querySelector(".last-active")
|
196 |
+
i&&S(i,"last-active"),C(e,"active last-active"),t.trigger("item_select",e),-1==t.activeItems.indexOf(e)&&t.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
|
197 |
+
this.activeItems.splice(t,1),S(e,"active")}clearActiveItems(){S(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){e!==this.activeOption&&(this.clearActiveOption(),e&&(this.activeOption=e,P(this.focus_node,{"aria-activedescendant":e.getAttribute("id")}),P(e,{"aria-selected":"true"}),C(e,"active"),this.scrollToOption(e)))}scrollToOption(e,t){if(!e)return
|
198 |
+
const i=this.dropdown_content,s=i.clientHeight,n=i.scrollTop||0,o=e.offsetHeight,r=e.getBoundingClientRect().top-i.getBoundingClientRect().top+n
|
199 |
+
r+o>s+n?this.scroll(r-s+o,t):r<n&&this.scroll(r,t)}scroll(e,t){const i=this.dropdown_content
|
200 |
+
t&&(i.style.scrollBehavior=t),i.scrollTop=e,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(S(this.activeOption,"active"),P(this.activeOption,{"aria-selected":null})),this.activeOption=null,P(this.focus_node,{"aria-activedescendant":null})}selectAll(){if("single"===this.settings.mode)return
|
201 |
+
const e=this.controlChildren()
|
202 |
+
e.length&&(this.hideInput(),this.close(),this.activeItems=e,C(e,"active"))}inputState(){var e=this
|
203 |
+
e.control.contains(e.control_input)&&(P(e.control_input,{placeholder:e.settings.placeholder}),e.activeItems.length>0||!e.isFocused&&e.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0):(e.settings.hidePlaceholder&&e.items.length>0&&P(e.control_input,{placeholder:""}),e.isInputHidden=!1),e.wrapper.classList.toggle("input-hidden",e.isInputHidden))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
|
204 |
+
e.isDisabled||(e.ignoreFocus=!0,e.control_input.offsetWidth?e.control_input.focus():e.focus_node.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e=this.settings,t=e.sortField
|
205 |
+
return"string"==typeof e.sortField&&(t=[{field:e.sortField}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}}search(e){var t,i,s,n=this,o=this.getSearchOptions()
|
206 |
+
if(n.settings.score&&"function"!=typeof(s=n.settings.score.call(n,e)))throw new Error('Tom Select "score" setting must be a function that returns a function')
|
207 |
+
if(e!==n.lastQuery?(n.lastQuery=e,i=n.sifter.search(e,Object.assign(o,{score:s})),n.currentResults=i):i=Object.assign({},n.currentResults),n.settings.hideSelected)for(t=i.items.length-1;t>=0;t--){let e=q(i.items[t].id)
|
208 |
+
e&&-1!==n.items.indexOf(e)&&i.items.splice(t,1)}return i}refreshOptions(e=!0){var t,i,s,n,o,r,l,a,c,d,p
|
209 |
+
const u={},h=[]
|
210 |
+
var g,f=this,v=f.inputValue(),m=f.search(v),O=f.activeOption,b=f.settings.shouldOpen||!1,w=f.dropdown_content
|
211 |
+
for(O&&(c=O.dataset.value,d=O.closest("[data-group]")),n=m.items.length,"number"==typeof f.settings.maxOptions&&(n=Math.min(n,f.settings.maxOptions)),n>0&&(b=!0),t=0;t<n;t++){let e=m.items[t].id,n=f.options[e],l=f.getOption(e,!0)
|
212 |
+
for(f.settings.hideSelected||l.classList.toggle("selected",f.items.includes(e)),o=n[f.settings.optgroupField]||"",i=0,s=(r=Array.isArray(o)?o:[o])&&r.length;i<s;i++)o=r[i],f.optgroups.hasOwnProperty(o)||(o=""),u.hasOwnProperty(o)||(u[o]=document.createDocumentFragment(),h.push(o)),i>0&&(l=l.cloneNode(!0),P(l,{id:n.$id+"-clone-"+i,"aria-selected":null}),l.classList.add("ts-cloned"),S(l,"active")),c==e&&d&&d.dataset.group===o&&(O=l),u[o].appendChild(l)}this.settings.lockOptgroupOrder&&h.sort(((e,t)=>(f.optgroups[e]&&f.optgroups[e].$order||0)-(f.optgroups[t]&&f.optgroups[t].$order||0))),l=document.createDocumentFragment(),y(h,(e=>{if(f.optgroups.hasOwnProperty(e)&&u[e].children.length){let t=document.createDocumentFragment(),i=f.render("optgroup_header",f.optgroups[e])
|
213 |
+
G(t,i),G(t,u[e])
|
214 |
+
let s=f.render("optgroup",{group:f.optgroups[e],options:t})
|
215 |
+
G(l,s)}else G(l,u[e])})),w.innerHTML="",G(w,l),f.settings.highlight&&(g=w.querySelectorAll("span.highlight"),Array.prototype.forEach.call(g,(function(e){var t=e.parentNode
|
216 |
+
t.replaceChild(e.firstChild,e),t.normalize()})),m.query.length&&m.tokens.length&&y(m.tokens,(e=>{T(w,e.regex)})))
|
217 |
+
var _=e=>{let t=f.render(e,{input:v})
|
218 |
+
return t&&(b=!0,w.insertBefore(t,w.firstChild)),t}
|
219 |
+
if(f.loading?_("loading"):f.settings.shouldLoad.call(f,v)?0===m.items.length&&_("no_results"):_("not_loading"),(a=f.canCreate(v))&&(p=_("option_create")),f.hasOptions=m.items.length>0||a,b){if(m.items.length>0){if(!w.contains(O)&&"single"===f.settings.mode&&f.items.length&&(O=f.getOption(f.items[0])),!w.contains(O)){let e=0
|
220 |
+
p&&!f.settings.addPrecedence&&(e=1),O=f.selectable()[e]}}else p&&(O=p)
|
221 |
+
e&&!f.isOpen&&(f.open(),f.scrollToOption(O,"auto")),f.setActiveOption(O)}else f.clearActiveOption(),e&&f.isOpen&&f.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e,t=!1){const i=this
|
222 |
+
if(Array.isArray(e))return i.addOptions(e,t),!1
|
223 |
+
const s=q(e[i.settings.valueField])
|
224 |
+
return null!==s&&!i.options.hasOwnProperty(s)&&(e.$order=e.$order||++i.order,e.$id=i.inputId+"-opt-"+e.$order,i.options[s]=e,i.lastQuery=null,t&&(i.userOptions[s]=t,i.trigger("option_add",s,e)),s)}addOptions(e,t=!1){y(e,(e=>{this.addOption(e,t)}))}registerOption(e){return this.addOption(e)}registerOptionGroup(e){var t=q(e[this.settings.optgroupValueField])
|
225 |
+
return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var i
|
226 |
+
t[this.settings.optgroupValueField]=e,(i=this.registerOptionGroup(t))&&this.trigger("optgroup_add",i,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){const i=this
|
227 |
+
var s,n
|
228 |
+
const o=q(e),r=q(t[i.settings.valueField])
|
229 |
+
if(null===o)return
|
230 |
+
if(!i.options.hasOwnProperty(o))return
|
231 |
+
if("string"!=typeof r)throw new Error("Value must be set in option data")
|
232 |
+
const l=i.getOption(o),a=i.getItem(o)
|
233 |
+
if(t.$order=t.$order||i.options[o].$order,delete i.options[o],i.uncacheValue(r),i.options[r]=t,l){if(i.dropdown_content.contains(l)){const e=i._render("option",t)
|
234 |
+
E(l,e),i.activeOption===l&&i.setActiveOption(e)}l.remove()}a&&(-1!==(n=i.items.indexOf(o))&&i.items.splice(n,1,r),s=i._render("item",t),a.classList.contains("active")&&C(s,"active"),E(a,s)),i.lastQuery=null}removeOption(e,t){const i=this
|
235 |
+
e=D(e),i.uncacheValue(e),delete i.userOptions[e],delete i.options[e],i.lastQuery=null,i.trigger("option_remove",e),i.removeItem(e,t)}clearOptions(){this.loadedSearches={},this.userOptions={},this.clearCache()
|
236 |
+
var e={}
|
237 |
+
y(this.options,((t,i)=>{this.items.indexOf(i)>=0&&(e[i]=this.options[i])})),this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}getOption(e,t=!1){const i=q(e)
|
238 |
+
if(null!==i&&this.options.hasOwnProperty(i)){const e=this.options[i]
|
239 |
+
if(e.$div)return e.$div
|
240 |
+
if(t)return this._render("option",e)}return null}getAdjacent(e,t,i="option"){var s
|
241 |
+
if(!e)return null
|
242 |
+
s="item"==i?this.controlChildren():this.dropdown_content.querySelectorAll("[data-selectable]")
|
243 |
+
for(let i=0;i<s.length;i++)if(s[i]==e)return t>0?s[i+1]:s[i-1]
|
244 |
+
return null}getItem(e){if("object"==typeof e)return e
|
245 |
+
var t=q(e)
|
246 |
+
return null!==t?this.control.querySelector(`[data-value="${Q(t)}"]`):null}addItems(e,t){var i=this,s=Array.isArray(e)?e:[e]
|
247 |
+
for(let e=0,n=(s=s.filter((e=>-1===i.items.indexOf(e)))).length;e<n;e++)i.isPending=e<n-1,i.addItem(s[e],t)}addItem(e,t){R(this,t?[]:["change"],(()=>{var i,s
|
248 |
+
const n=this,o=n.settings.mode,r=q(e)
|
249 |
+
if((!r||-1===n.items.indexOf(r)||("single"===o&&n.close(),"single"!==o&&n.settings.duplicates))&&null!==r&&n.options.hasOwnProperty(r)&&("single"===o&&n.clear(t),"multi"!==o||!n.isFull())){if(i=n._render("item",n.options[r]),n.control.contains(i)&&(i=i.cloneNode(!0)),s=n.isFull(),n.items.splice(n.caretPos,0,r),n.insertAtCaret(i),n.isSetup){if(!n.isPending&&n.settings.hideSelected){let e=n.getOption(r),t=n.getAdjacent(e,1)
|
250 |
+
t&&n.setActiveOption(t)}n.isPending||n.refreshOptions(n.isFocused&&"single"!==o),0!=n.settings.closeAfterSelect&&n.isFull()?n.close():n.isPending||n.positionDropdown(),n.trigger("item_add",r,i),n.isPending||n.updateOriginalInput({silent:t})}(!n.isPending||!s&&n.isFull())&&(n.inputState(),n.refreshState())}}))}removeItem(e=null,t){const i=this
|
251 |
+
if(!(e=i.getItem(e)))return
|
252 |
+
var s,n
|
253 |
+
const o=e.dataset.value
|
254 |
+
s=L(e),e.remove(),e.classList.contains("active")&&(n=i.activeItems.indexOf(e),i.activeItems.splice(n,1),S(e,"active")),i.items.splice(s,1),i.lastQuery=null,!i.settings.persist&&i.userOptions.hasOwnProperty(o)&&i.removeOption(o,t),s<i.caretPos&&i.setCaret(i.caretPos-1),i.updateOriginalInput({silent:t}),i.refreshState(),i.positionDropdown(),i.trigger("item_remove",o,e)}createItem(e=null,t=!0,i=(()=>{})){var s,n=this,o=n.caretPos
|
255 |
+
if(e=e||n.inputValue(),!n.canCreate(e))return i(),!1
|
256 |
+
n.lock()
|
257 |
+
var r=!1,l=e=>{if(n.unlock(),!e||"object"!=typeof e)return i()
|
258 |
+
var s=q(e[n.settings.valueField])
|
259 |
+
if("string"!=typeof s)return i()
|
260 |
+
n.setTextboxValue(),n.addOption(e,!0),n.setCaret(o),n.addItem(s),n.refreshOptions(t&&"single"!==n.settings.mode),i(e),r=!0}
|
261 |
+
return s="function"==typeof n.settings.create?n.settings.create.call(this,e,l):{[n.settings.labelField]:e,[n.settings.valueField]:e},r||l(s),!0}refreshItems(){var e=this
|
262 |
+
e.lastQuery=null,e.isSetup&&e.addItems(e.items),e.updateOriginalInput(),e.refreshState()}refreshState(){const e=this
|
263 |
+
e.refreshValidityState()
|
264 |
+
const t=e.isFull(),i=e.isLocked
|
265 |
+
e.wrapper.classList.toggle("rtl",e.rtl)
|
266 |
+
const s=e.wrapper.classList
|
267 |
+
var n
|
268 |
+
s.toggle("focus",e.isFocused),s.toggle("disabled",e.isDisabled),s.toggle("required",e.isRequired),s.toggle("invalid",!e.isValid),s.toggle("locked",i),s.toggle("full",t),s.toggle("input-active",e.isFocused&&!e.isInputHidden),s.toggle("dropdown-active",e.isOpen),s.toggle("has-options",(n=e.options,0===Object.keys(n).length)),s.toggle("has-items",e.items.length>0)}refreshValidityState(){var e=this
|
269 |
+
e.input.checkValidity&&(e.isValid=e.input.checkValidity(),e.isInvalid=!e.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){const t=this
|
270 |
+
var i,s
|
271 |
+
const n=t.input.querySelector('option[value=""]')
|
272 |
+
if(t.is_select_tag){const e=[]
|
273 |
+
function o(i,s,o){return i||(i=w('<option value="'+N(s)+'">'+N(o)+"</option>")),i!=n&&t.input.append(i),e.push(i),i.selected=!0,i}t.input.querySelectorAll("option:checked").forEach((e=>{e.selected=!1})),0==t.items.length&&"single"==t.settings.mode?o(n,"",""):t.items.forEach((n=>{if(i=t.options[n],s=i[t.settings.labelField]||"",e.includes(i.$option)){o(t.input.querySelector(`option[value="${Q(n)}"]:not(:checked)`),n,s)}else i.$option=o(i.$option,n,s)}))}else t.input.value=t.getValue()
|
274 |
+
t.isSetup&&(e.silent||t.trigger("change",t.getValue()))}open(){var e=this
|
275 |
+
e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,P(e.focus_node,{"aria-expanded":"true"}),e.refreshState(),I(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),I(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,i=t.isOpen
|
276 |
+
e&&(t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&t.hideInput()),t.isOpen=!1,P(t.focus_node,{"aria-expanded":"false"}),I(t.dropdown,{display:"none"}),t.settings.hideSelected&&t.clearActiveOption(),t.refreshState(),i&&t.trigger("dropdown_close",t.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
|
277 |
+
I(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
|
278 |
+
if(t.items.length){var i=t.controlChildren()
|
279 |
+
y(i,(e=>{t.removeItem(e,!0)})),t.showInput(),e||t.updateOriginalInput(),t.trigger("clear")}}insertAtCaret(e){const t=this,i=t.caretPos,s=t.control
|
280 |
+
s.insertBefore(e,s.children[i]),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,o,r=this
|
281 |
+
t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart||0,length:(o.selectionEnd||0)-(o.selectionStart||0)}
|
282 |
+
const l=[]
|
283 |
+
if(r.activeItems.length)n=F(r.activeItems,t),s=L(n),t>0&&s++,y(r.activeItems,(e=>l.push(e)))
|
284 |
+
else if((r.isFocused||"single"===r.settings.mode)&&r.items.length){const e=r.controlChildren()
|
285 |
+
t<0&&0===i.start&&0===i.length?l.push(e[r.caretPos-1]):t>0&&i.start===r.inputValue().length&&l.push(e[r.caretPos])}const a=l.map((e=>e.dataset.value))
|
286 |
+
if(!a.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.call(r,a,e))return!1
|
287 |
+
for(H(e,!0),void 0!==s&&r.setCaret(s);l.length;)r.removeItem(l.pop())
|
288 |
+
return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}advanceSelection(e,t){var i,s,n=this
|
289 |
+
n.rtl&&(e*=-1),n.inputValue().length||(K(V,t)||K("shiftKey",t)?(s=(i=n.getLastActive(e))?i.classList.contains("active")?n.getAdjacent(i,e,"item"):i:e>0?n.control_input.nextElementSibling:n.control_input.previousElementSibling)&&(s.classList.contains("active")&&n.removeActiveItem(i),n.setActiveItemClass(s)):n.moveCaret(e))}moveCaret(e){}getLastActive(e){let t=this.control.querySelector(".last-active")
|
290 |
+
if(t)return t
|
291 |
+
var i=this.control.querySelectorAll(".active")
|
292 |
+
return i?F(i,e):void 0}setCaret(e){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.close(),this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
|
293 |
+
e.input.disabled=!0,e.control_input.disabled=!0,e.focus_node.tabIndex=-1,e.isDisabled=!0,e.lock()}enable(){var e=this
|
294 |
+
e.input.disabled=!1,e.control_input.disabled=!1,e.focus_node.tabIndex=e.tabIndex,e.isDisabled=!1,e.unlock()}destroy(){var e=this,t=e.revertSettings
|
295 |
+
e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,S(e.input,"tomselected","ts-hidden-accessible"),e._destroy(),delete e.input.tomselect}render(e,t){return"function"!=typeof this.settings.render[e]?null:this._render(e,t)}_render(e,t){var i,s,n=""
|
296 |
+
const o=this
|
297 |
+
return"option"!==e&&"item"!=e||(n=D(t[o.settings.valueField])),null==(s=o.settings.render[e].call(this,t,N))||(s=w(s),"option"===e||"option_create"===e?t[o.settings.disabledField]?P(s,{"aria-disabled":"true"}):P(s,{"data-selectable":""}):"optgroup"===e&&(i=t.group[o.settings.optgroupValueField],P(s,{"data-group":i}),t.group[o.settings.disabledField]&&P(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(P(s,{"data-value":n}),"item"===e?(C(s,o.settings.itemClass),P(s,{"data-ts-item":""})):(C(s,o.settings.optionClass),P(s,{role:"option",id:t.$id}),o.options[n].$div=s))),s}clearCache(){y(this.options,((e,t)=>{e.$div&&(e.$div.remove(),delete e.$div)}))}uncacheValue(e){const t=this.getOption(e)
|
298 |
+
t&&t.remove()}canCreate(e){return this.settings.create&&e.length>0&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
|
299 |
+
s[t]=function(){var t,o
|
300 |
+
return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return J.define("change_listener",(function(){B(this.input,"change",(()=>{this.sync()}))})),J.define("checkbox_options",(function(){var e=this,t=e.onOptionSelect
|
301 |
+
e.settings.hideSelected=!1
|
302 |
+
var i=function(e){setTimeout((()=>{var t=e.querySelector("input")
|
303 |
+
e.classList.contains("selected")?t.checked=!0:t.checked=!1}),1)}
|
304 |
+
e.hook("after","setupTemplates",(()=>{var t=e.settings.render.option
|
305 |
+
e.settings.render.option=(i,s)=>{var n=w(t.call(e,i,s)),o=document.createElement("input")
|
306 |
+
o.addEventListener("click",(function(e){H(e)})),o.type="checkbox"
|
307 |
+
const r=q(i[e.settings.valueField])
|
308 |
+
return r&&e.items.indexOf(r)>-1&&(o.checked=!0),n.prepend(o),n}})),e.on("item_remove",(t=>{var s=e.getOption(t)
|
309 |
+
s&&(s.classList.remove("selected"),i(s))})),e.hook("instead","onOptionSelect",((s,n)=>{if(n.classList.contains("selected"))return n.classList.remove("selected"),e.removeItem(n.dataset.value),e.refreshOptions(),void H(s,!0)
|
310 |
+
t.call(e,s,n),i(n)}))})),J.define("clear_button",(function(e){const t=this,i=Object.assign({className:"clear-button",title:"Clear All",html:e=>`<div class="${e.className}" title="${e.title}">×</div>`},e)
|
311 |
+
t.on("initialize",(()=>{var e=w(i.html(i))
|
312 |
+
e.addEventListener("click",(e=>{t.clear(),"single"===t.settings.mode&&t.settings.allowEmptyOption&&t.addItem(""),e.preventDefault(),e.stopPropagation()})),t.control.appendChild(e)}))})),J.define("drag_drop",(function(){var e=this
|
313 |
+
if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".')
|
314 |
+
if("multi"===e.settings.mode){var t=e.lock,i=e.unlock
|
315 |
+
e.hook("instead","lock",(()=>{var i=$(e.control).data("sortable")
|
316 |
+
return i&&i.disable(),t.call(e)})),e.hook("instead","unlock",(()=>{var t=$(e.control).data("sortable")
|
317 |
+
return t&&t.enable(),i.call(e)})),e.on("initialize",(()=>{var t=$(e.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:e.isLocked,start:(e,i)=>{i.placeholder.css("width",i.helper.css("width")),t.css({overflow:"visible"})},stop:()=>{t.css({overflow:"hidden"})
|
318 |
+
var i=[]
|
319 |
+
t.children("[data-value]").each((function(){this.dataset.value&&i.push(this.dataset.value)})),e.setValue(i)}})}))}})),J.define("dropdown_header",(function(e){const t=this,i=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:e=>'<div class="'+e.headerClass+'"><div class="'+e.titleRowClass+'"><span class="'+e.labelClass+'">'+e.title+'</span><a class="'+e.closeClass+'">×</a></div></div>'},e)
|
320 |
+
t.on("initialize",(()=>{var e=w(i.html(i)),s=e.querySelector("."+i.closeClass)
|
321 |
+
s&&s.addEventListener("click",(e=>{H(e,!0),t.close()})),t.dropdown.insertBefore(e,t.dropdown.firstChild)}))})),J.define("caret_position",(function(){var e=this
|
322 |
+
e.hook("instead","setCaret",(t=>{"single"!==e.settings.mode&&e.control.contains(e.control_input)?(t=Math.max(0,Math.min(e.items.length,t)))==e.caretPos||e.isPending||e.controlChildren().forEach(((i,s)=>{s<t?e.control_input.insertAdjacentElement("beforebegin",i):e.control.appendChild(i)})):t=e.items.length,e.caretPos=t})),e.hook("instead","moveCaret",(t=>{if(!e.isFocused)return
|
323 |
+
const i=e.getLastActive(t)
|
324 |
+
if(i){const s=L(i)
|
325 |
+
e.setCaret(t>0?s+1:s),e.setActiveItem()}else e.setCaret(e.caretPos+t)}))})),J.define("dropdown_input",(function(){var e=this
|
326 |
+
e.settings.shouldOpen=!0,e.hook("before","setup",(()=>{e.focus_node=e.control,C(e.control_input,"dropdown-input")
|
327 |
+
const t=w('<div class="dropdown-input-wrap">')
|
328 |
+
t.append(e.control_input),e.dropdown.insertBefore(t,e.dropdown.firstChild)})),e.on("initialize",(()=>{e.control_input.addEventListener("keydown",(t=>{switch(t.keyCode){case 27:return e.isOpen&&(H(t,!0),e.close()),void e.clearActiveItems()
|
329 |
+
case 9:e.focus_node.tabIndex=-1}return e.onKeyDown.call(e,t)})),e.on("blur",(()=>{e.focus_node.tabIndex=e.isDisabled?-1:e.tabIndex})),e.on("dropdown_open",(()=>{e.control_input.focus()}))
|
330 |
+
const t=e.onBlur
|
331 |
+
e.hook("instead","onBlur",(i=>{if(!i||i.relatedTarget!=e.control_input)return t.call(e)})),B(e.control_input,"blur",(()=>e.onBlur())),e.hook("before","close",(()=>{e.isOpen&&e.focus_node.focus()}))}))})),J.define("input_autogrow",(function(){var e=this
|
332 |
+
e.on("initialize",(()=>{var t=document.createElement("span"),i=e.control_input
|
333 |
+
t.style.cssText="position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ",e.wrapper.appendChild(t)
|
334 |
+
for(const e of["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"])t.style[e]=i.style[e]
|
335 |
+
var s=()=>{e.items.length>0?(t.textContent=i.value,i.style.width=t.clientWidth+"px"):i.style.width=""}
|
336 |
+
s(),e.on("update item_add item_remove",s),B(i,"input",s),B(i,"keyup",s),B(i,"blur",s),B(i,"update",s)}))})),J.define("no_backspace_delete",(function(){var e=this,t=e.deleteSelection
|
337 |
+
this.hook("instead","deleteSelection",(i=>!!e.activeItems.length&&t.call(e,i)))})),J.define("no_active_items",(function(){this.hook("instead","setActiveItem",(()=>{})),this.hook("instead","selectAll",(()=>{}))})),J.define("optgroup_columns",(function(){var e=this,t=e.onKeyDown
|
338 |
+
e.hook("instead","onKeyDown",(i=>{var s,n,o,r
|
339 |
+
if(!e.isOpen||37!==i.keyCode&&39!==i.keyCode)return t.call(e,i)
|
340 |
+
r=k(e.activeOption,"[data-group]"),s=L(e.activeOption,"[data-selectable]"),r&&(r=37===i.keyCode?r.previousSibling:r.nextSibling)&&(n=(o=r.querySelectorAll("[data-selectable]"))[Math.min(o.length-1,s)])&&e.setActiveOption(n)}))})),J.define("remove_button",(function(e){const t=Object.assign({label:"×",title:"Remove",className:"remove",append:!0},e)
|
341 |
+
var i=this
|
342 |
+
if(t.append){var s='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+N(t.title)+'">'+t.label+"</a>"
|
343 |
+
i.hook("after","setupTemplates",(()=>{var e=i.settings.render.item
|
344 |
+
i.settings.render.item=(t,n)=>{var o=w(e.call(i,t,n)),r=w(s)
|
345 |
+
return o.appendChild(r),B(r,"mousedown",(e=>{H(e,!0)})),B(r,"click",(e=>{if(H(e,!0),!i.isLocked){var t=o.dataset.value
|
346 |
+
i.removeItem(t),i.refreshOptions(!1)}})),o}}))}})),J.define("restore_on_backspace",(function(e){const t=this,i=Object.assign({text:e=>e[t.settings.labelField]},e)
|
347 |
+
t.on("item_remove",(function(e){if(""===t.control_input.value.trim()){var s=t.options[e]
|
348 |
+
s&&t.setTextboxValue(i.text.call(t,s))}}))})),J.define("virtual_scroll",(function(){const e=this,t=e.canLoad,i=e.clearActiveOption,s=e.loadCallback
|
349 |
+
var n,o={},r=!1
|
350 |
+
if(!e.settings.firstUrl)throw"virtual_scroll plugin requires a firstUrl() method"
|
351 |
+
function l(t){return!("number"==typeof e.settings.maxOptions&&n.children.length>=e.settings.maxOptions)&&!(!(t in o)||!o[t])}e.settings.sortField=[{field:"$order"},{field:"$score"}],e.setNextUrl=function(e,t){o[e]=t},e.getUrl=function(t){if(t in o){const e=o[t]
|
352 |
+
return o[t]=!1,e}return o={},e.settings.firstUrl(t)},e.hook("instead","clearActiveOption",(()=>{if(!r)return i.call(e)})),e.hook("instead","canLoad",(i=>i in o?l(i):t.call(e,i))),e.hook("instead","loadCallback",((t,i)=>{r||e.clearOptions(),s.call(e,t,i),r=!1})),e.hook("after","refreshOptions",(()=>{const t=e.lastValue
|
353 |
+
var i
|
354 |
+
l(t)?(i=e.render("loading_more",{query:t}))&&i.setAttribute("data-selectable",""):t in o&&!n.querySelector(".no-results")&&(i=e.render("no_more_results",{query:t})),i&&(C(i,e.settings.optionClass),n.append(i))})),e.on("initialize",(()=>{n=e.dropdown_content,e.settings.render=Object.assign({},{loading_more:function(){return'<div class="loading-more-results">Loading more results ... </div>'},no_more_results:function(){return'<div class="no-more-results">No more results</div>'}},e.settings.render),n.addEventListener("scroll",(function(){n.clientHeight/(n.scrollHeight-n.scrollTop)<.95||l(e.lastValue)&&(r||(r=!0,e.load.call(e,e.lastValue)))}))}))})),J}))
|
355 |
+
var tomSelect=function(e,t){return new TomSelect(e,t)}
|
356 |
+
//# sourceMappingURL=tom-select.complete.min.js.map
|
lib/tom-select/tom-select.css
ADDED
@@ -0,0 +1,334 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* tom-select.css (v2.0.0-rc.4)
|
3 |
+
* Copyright (c) contributors
|
4 |
+
*
|
5 |
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
6 |
+
* file except in compliance with the License. You may obtain a copy of the License at:
|
7 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
*
|
9 |
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
10 |
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11 |
+
* ANY KIND, either express or implied. See the License for the specific language
|
12 |
+
* governing permissions and limitations under the License.
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
.ts-wrapper.plugin-drag_drop.multi > .ts-control > div.ui-sortable-placeholder {
|
16 |
+
visibility: visible !important;
|
17 |
+
background: #f2f2f2 !important;
|
18 |
+
background: rgba(0, 0, 0, 0.06) !important;
|
19 |
+
border: 0 none !important;
|
20 |
+
box-shadow: inset 0 0 12px 4px #fff; }
|
21 |
+
|
22 |
+
.ts-wrapper.plugin-drag_drop .ui-sortable-placeholder::after {
|
23 |
+
content: '!';
|
24 |
+
visibility: hidden; }
|
25 |
+
|
26 |
+
.ts-wrapper.plugin-drag_drop .ui-sortable-helper {
|
27 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); }
|
28 |
+
|
29 |
+
.plugin-checkbox_options .option input {
|
30 |
+
margin-right: 0.5rem; }
|
31 |
+
|
32 |
+
.plugin-clear_button .ts-control {
|
33 |
+
padding-right: calc( 1em + (3 * 6px)) !important; }
|
34 |
+
|
35 |
+
.plugin-clear_button .clear-button {
|
36 |
+
opacity: 0;
|
37 |
+
position: absolute;
|
38 |
+
top: 8px;
|
39 |
+
right: calc(8px - 6px);
|
40 |
+
margin-right: 0 !important;
|
41 |
+
background: transparent !important;
|
42 |
+
transition: opacity 0.5s;
|
43 |
+
cursor: pointer; }
|
44 |
+
|
45 |
+
.plugin-clear_button.single .clear-button {
|
46 |
+
right: calc(8px - 6px + 2rem); }
|
47 |
+
|
48 |
+
.plugin-clear_button.focus.has-items .clear-button,
|
49 |
+
.plugin-clear_button:hover.has-items .clear-button {
|
50 |
+
opacity: 1; }
|
51 |
+
|
52 |
+
.ts-wrapper .dropdown-header {
|
53 |
+
position: relative;
|
54 |
+
padding: 10px 8px;
|
55 |
+
border-bottom: 1px solid #d0d0d0;
|
56 |
+
background: #f8f8f8;
|
57 |
+
border-radius: 3px 3px 0 0; }
|
58 |
+
|
59 |
+
.ts-wrapper .dropdown-header-close {
|
60 |
+
position: absolute;
|
61 |
+
right: 8px;
|
62 |
+
top: 50%;
|
63 |
+
color: #303030;
|
64 |
+
opacity: 0.4;
|
65 |
+
margin-top: -12px;
|
66 |
+
line-height: 20px;
|
67 |
+
font-size: 20px !important; }
|
68 |
+
|
69 |
+
.ts-wrapper .dropdown-header-close:hover {
|
70 |
+
color: black; }
|
71 |
+
|
72 |
+
.plugin-dropdown_input.focus.dropdown-active .ts-control {
|
73 |
+
box-shadow: none;
|
74 |
+
border: 1px solid #d0d0d0; }
|
75 |
+
|
76 |
+
.plugin-dropdown_input .dropdown-input {
|
77 |
+
border: 1px solid #d0d0d0;
|
78 |
+
border-width: 0 0 1px 0;
|
79 |
+
display: block;
|
80 |
+
padding: 8px 8px;
|
81 |
+
box-shadow: none;
|
82 |
+
width: 100%;
|
83 |
+
background: transparent; }
|
84 |
+
|
85 |
+
.ts-wrapper.plugin-input_autogrow.has-items .ts-control > input {
|
86 |
+
min-width: 0; }
|
87 |
+
|
88 |
+
.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control > input {
|
89 |
+
flex: none;
|
90 |
+
min-width: 4px; }
|
91 |
+
.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control > input::-webkit-input-placeholder {
|
92 |
+
color: transparent; }
|
93 |
+
.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control > input::-ms-input-placeholder {
|
94 |
+
color: transparent; }
|
95 |
+
.ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control > input::placeholder {
|
96 |
+
color: transparent; }
|
97 |
+
|
98 |
+
.ts-dropdown.plugin-optgroup_columns .ts-dropdown-content {
|
99 |
+
display: flex; }
|
100 |
+
|
101 |
+
.ts-dropdown.plugin-optgroup_columns .optgroup {
|
102 |
+
border-right: 1px solid #f2f2f2;
|
103 |
+
border-top: 0 none;
|
104 |
+
flex-grow: 1;
|
105 |
+
flex-basis: 0;
|
106 |
+
min-width: 0; }
|
107 |
+
|
108 |
+
.ts-dropdown.plugin-optgroup_columns .optgroup:last-child {
|
109 |
+
border-right: 0 none; }
|
110 |
+
|
111 |
+
.ts-dropdown.plugin-optgroup_columns .optgroup:before {
|
112 |
+
display: none; }
|
113 |
+
|
114 |
+
.ts-dropdown.plugin-optgroup_columns .optgroup-header {
|
115 |
+
border-top: 0 none; }
|
116 |
+
|
117 |
+
.ts-wrapper.plugin-remove_button .item {
|
118 |
+
display: inline-flex;
|
119 |
+
align-items: center;
|
120 |
+
padding-right: 0 !important; }
|
121 |
+
|
122 |
+
.ts-wrapper.plugin-remove_button .item .remove {
|
123 |
+
color: inherit;
|
124 |
+
text-decoration: none;
|
125 |
+
vertical-align: middle;
|
126 |
+
display: inline-block;
|
127 |
+
padding: 2px 6px;
|
128 |
+
border-left: 1px solid #d0d0d0;
|
129 |
+
border-radius: 0 2px 2px 0;
|
130 |
+
box-sizing: border-box;
|
131 |
+
margin-left: 6px; }
|
132 |
+
|
133 |
+
.ts-wrapper.plugin-remove_button .item .remove:hover {
|
134 |
+
background: rgba(0, 0, 0, 0.05); }
|
135 |
+
|
136 |
+
.ts-wrapper.plugin-remove_button .item.active .remove {
|
137 |
+
border-left-color: #cacaca; }
|
138 |
+
|
139 |
+
.ts-wrapper.plugin-remove_button.disabled .item .remove:hover {
|
140 |
+
background: none; }
|
141 |
+
|
142 |
+
.ts-wrapper.plugin-remove_button.disabled .item .remove {
|
143 |
+
border-left-color: white; }
|
144 |
+
|
145 |
+
.ts-wrapper.plugin-remove_button .remove-single {
|
146 |
+
position: absolute;
|
147 |
+
right: 0;
|
148 |
+
top: 0;
|
149 |
+
font-size: 23px; }
|
150 |
+
|
151 |
+
.ts-wrapper {
|
152 |
+
position: relative; }
|
153 |
+
|
154 |
+
.ts-dropdown,
|
155 |
+
.ts-control,
|
156 |
+
.ts-control input {
|
157 |
+
color: #303030;
|
158 |
+
font-family: inherit;
|
159 |
+
font-size: 13px;
|
160 |
+
line-height: 18px;
|
161 |
+
font-smoothing: inherit; }
|
162 |
+
|
163 |
+
.ts-control,
|
164 |
+
.ts-wrapper.single.input-active .ts-control {
|
165 |
+
background: #fff;
|
166 |
+
cursor: text; }
|
167 |
+
|
168 |
+
.ts-control {
|
169 |
+
border: 1px solid #d0d0d0;
|
170 |
+
padding: 8px 8px;
|
171 |
+
width: 100%;
|
172 |
+
overflow: hidden;
|
173 |
+
position: relative;
|
174 |
+
z-index: 1;
|
175 |
+
box-sizing: border-box;
|
176 |
+
box-shadow: none;
|
177 |
+
border-radius: 3px;
|
178 |
+
display: flex;
|
179 |
+
flex-wrap: wrap; }
|
180 |
+
.ts-wrapper.multi.has-items .ts-control {
|
181 |
+
padding: calc( 8px - 2px - 0) 8px calc( 8px - 2px - 3px - 0); }
|
182 |
+
.full .ts-control {
|
183 |
+
background-color: #fff; }
|
184 |
+
.disabled .ts-control,
|
185 |
+
.disabled .ts-control * {
|
186 |
+
cursor: default !important; }
|
187 |
+
.focus .ts-control {
|
188 |
+
box-shadow: none; }
|
189 |
+
.ts-control > * {
|
190 |
+
vertical-align: baseline;
|
191 |
+
display: inline-block; }
|
192 |
+
.ts-wrapper.multi .ts-control > div {
|
193 |
+
cursor: pointer;
|
194 |
+
margin: 0 3px 3px 0;
|
195 |
+
padding: 2px 6px;
|
196 |
+
background: #f2f2f2;
|
197 |
+
color: #303030;
|
198 |
+
border: 0 solid #d0d0d0; }
|
199 |
+
.ts-wrapper.multi .ts-control > div.active {
|
200 |
+
background: #e8e8e8;
|
201 |
+
color: #303030;
|
202 |
+
border: 0 solid #cacaca; }
|
203 |
+
.ts-wrapper.multi.disabled .ts-control > div, .ts-wrapper.multi.disabled .ts-control > div.active {
|
204 |
+
color: #7d7c7c;
|
205 |
+
background: white;
|
206 |
+
border: 0 solid white; }
|
207 |
+
.ts-control > input {
|
208 |
+
flex: 1 1 auto;
|
209 |
+
min-width: 7rem;
|
210 |
+
display: inline-block !important;
|
211 |
+
padding: 0 !important;
|
212 |
+
min-height: 0 !important;
|
213 |
+
max-height: none !important;
|
214 |
+
max-width: 100% !important;
|
215 |
+
margin: 0 !important;
|
216 |
+
text-indent: 0 !important;
|
217 |
+
border: 0 none !important;
|
218 |
+
background: none !important;
|
219 |
+
line-height: inherit !important;
|
220 |
+
-webkit-user-select: auto !important;
|
221 |
+
-moz-user-select: auto !important;
|
222 |
+
-ms-user-select: auto !important;
|
223 |
+
user-select: auto !important;
|
224 |
+
box-shadow: none !important; }
|
225 |
+
.ts-control > input::-ms-clear {
|
226 |
+
display: none; }
|
227 |
+
.ts-control > input:focus {
|
228 |
+
outline: none !important; }
|
229 |
+
.has-items .ts-control > input {
|
230 |
+
margin: 0 4px !important; }
|
231 |
+
.ts-control.rtl {
|
232 |
+
text-align: right; }
|
233 |
+
.ts-control.rtl.single .ts-control:after {
|
234 |
+
left: 15px;
|
235 |
+
right: auto; }
|
236 |
+
.ts-control.rtl .ts-control > input {
|
237 |
+
margin: 0 4px 0 -2px !important; }
|
238 |
+
.disabled .ts-control {
|
239 |
+
opacity: 0.5;
|
240 |
+
background-color: #fafafa; }
|
241 |
+
.input-hidden .ts-control > input {
|
242 |
+
opacity: 0;
|
243 |
+
position: absolute;
|
244 |
+
left: -10000px; }
|
245 |
+
|
246 |
+
.ts-dropdown {
|
247 |
+
position: absolute;
|
248 |
+
top: 100%;
|
249 |
+
left: 0;
|
250 |
+
width: 100%;
|
251 |
+
z-index: 10;
|
252 |
+
border: 1px solid #d0d0d0;
|
253 |
+
background: #fff;
|
254 |
+
margin: 0.25rem 0 0 0;
|
255 |
+
border-top: 0 none;
|
256 |
+
box-sizing: border-box;
|
257 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
258 |
+
border-radius: 0 0 3px 3px; }
|
259 |
+
.ts-dropdown [data-selectable] {
|
260 |
+
cursor: pointer;
|
261 |
+
overflow: hidden; }
|
262 |
+
.ts-dropdown [data-selectable] .highlight {
|
263 |
+
background: rgba(125, 168, 208, 0.2);
|
264 |
+
border-radius: 1px; }
|
265 |
+
.ts-dropdown .option,
|
266 |
+
.ts-dropdown .optgroup-header,
|
267 |
+
.ts-dropdown .no-results,
|
268 |
+
.ts-dropdown .create {
|
269 |
+
padding: 5px 8px; }
|
270 |
+
.ts-dropdown .option, .ts-dropdown [data-disabled], .ts-dropdown [data-disabled] [data-selectable].option {
|
271 |
+
cursor: inherit;
|
272 |
+
opacity: 0.5; }
|
273 |
+
.ts-dropdown [data-selectable].option {
|
274 |
+
opacity: 1;
|
275 |
+
cursor: pointer; }
|
276 |
+
.ts-dropdown .optgroup:first-child .optgroup-header {
|
277 |
+
border-top: 0 none; }
|
278 |
+
.ts-dropdown .optgroup-header {
|
279 |
+
color: #303030;
|
280 |
+
background: #fff;
|
281 |
+
cursor: default; }
|
282 |
+
.ts-dropdown .create:hover,
|
283 |
+
.ts-dropdown .option:hover,
|
284 |
+
.ts-dropdown .active {
|
285 |
+
background-color: #f5fafd;
|
286 |
+
color: #495c68; }
|
287 |
+
.ts-dropdown .create:hover.create,
|
288 |
+
.ts-dropdown .option:hover.create,
|
289 |
+
.ts-dropdown .active.create {
|
290 |
+
color: #495c68; }
|
291 |
+
.ts-dropdown .create {
|
292 |
+
color: rgba(48, 48, 48, 0.5); }
|
293 |
+
.ts-dropdown .spinner {
|
294 |
+
display: inline-block;
|
295 |
+
width: 30px;
|
296 |
+
height: 30px;
|
297 |
+
margin: 5px 8px; }
|
298 |
+
.ts-dropdown .spinner:after {
|
299 |
+
content: " ";
|
300 |
+
display: block;
|
301 |
+
width: 24px;
|
302 |
+
height: 24px;
|
303 |
+
margin: 3px;
|
304 |
+
border-radius: 50%;
|
305 |
+
border: 5px solid #d0d0d0;
|
306 |
+
border-color: #d0d0d0 transparent #d0d0d0 transparent;
|
307 |
+
animation: lds-dual-ring 1.2s linear infinite; }
|
308 |
+
|
309 |
+
@keyframes lds-dual-ring {
|
310 |
+
0% {
|
311 |
+
transform: rotate(0deg); }
|
312 |
+
100% {
|
313 |
+
transform: rotate(360deg); } }
|
314 |
+
|
315 |
+
.ts-dropdown-content {
|
316 |
+
overflow-y: auto;
|
317 |
+
overflow-x: hidden;
|
318 |
+
max-height: 200px;
|
319 |
+
overflow-scrolling: touch;
|
320 |
+
scroll-behavior: smooth; }
|
321 |
+
|
322 |
+
.ts-hidden-accessible {
|
323 |
+
border: 0 !important;
|
324 |
+
clip: rect(0 0 0 0) !important;
|
325 |
+
-webkit-clip-path: inset(50%) !important;
|
326 |
+
clip-path: inset(50%) !important;
|
327 |
+
height: 1px !important;
|
328 |
+
overflow: hidden !important;
|
329 |
+
padding: 0 !important;
|
330 |
+
position: absolute !important;
|
331 |
+
width: 1px !important;
|
332 |
+
white-space: nowrap !important; }
|
333 |
+
|
334 |
+
/*# sourceMappingURL=tom-select.css.map */
|
lib/vis-9.0.4/vis-network.css
ADDED
The diff for this file is too large to render.
See raw diff
|
|
lib/vis-9.0.4/vis-network.min.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
lib/vis-9.1.2/vis-network.css
ADDED
The diff for this file is too large to render.
See raw diff
|
|
lib/vis-9.1.2/vis-network.min.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
requirements.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
PyMuPDF
|
3 |
+
transformers
|
4 |
+
plotly
|
5 |
+
spacy
|
6 |
+
beautifulsoup4
|
7 |
+
pandas
|
8 |
+
requests
|
9 |
+
networkx
|
10 |
+
matplotlib
|
11 |
+
tqdm
|
12 |
+
scipy
|