Skip to content

Commit

Permalink
filter out tags when used
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi committed Mar 4, 2024
1 parent c0a5369 commit 6c9dfdf
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
streamfy
streamfy==0.2.6
streamlit==1.15.2

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setuptools.setup(
name="streamfy",
version="0.2.5",
version="0.2.6",
author="",
author_email="",
description="",
Expand Down
61 changes: 47 additions & 14 deletions streamfy/frontend/src/Streamfy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@
v-bind="args"
@focus="focused"
@blur="blured"
:data="filtered"
@typing="filteredData"
>
</b-taginput>

Expand Down Expand Up @@ -223,6 +225,7 @@ export default {
setTimeout(() => Streamlit.setFrameHeight(), 1000);
return {
result: this.args.default,
filtered: undefined,
}
},
methods: {
Expand Down Expand Up @@ -253,22 +256,48 @@ export default {
click(value) {
this.result = value
},
filteredData(text) {
if (this.args.component != 'taginput') return;
if (!this.args.data) return;
console.log('x1')

Check warning on line 263 in streamfy/frontend/src/Streamfy.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
const result = this.result;
console.log('x2')

Check warning on line 266 in streamfy/frontend/src/Streamfy.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
this.filtered = this.args.data
.filter(e => {
console.log('x3 ' + e)

Check warning on line 269 in streamfy/frontend/src/Streamfy.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
return !result.includes(e)
})
.filter((datum) => {
console.log('x4 ' + datum + ' ' + text)

Check warning on line 273 in streamfy/frontend/src/Streamfy.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
return datum
.toString()
.toLowerCase()
.indexOf(text.toLowerCase()) >= 0
})
},
},
watch: {
result() {
if (this.result?.isArray && this.result.isArray()) {
Streamlit.setComponentValue([...this.result]);
}
else if (this.result?.constructor?.toString()?.includes("Array")) {
Streamlit.setComponentValue([...this.result]);
}
else if (this.result?.constructor == Object) {
Streamlit.setComponentValue(Object.assign({}, this.result));
}
else {
Streamlit.setComponentValue(this.result);
}
},
result: {
immediate: true,
handler: function() {
if (this.result?.isArray && this.result.isArray()) {
Streamlit.setComponentValue([...this.result]);
}
else if (this.result?.constructor?.toString()?.includes("Array")) {
Streamlit.setComponentValue([...this.result]);
}
else if (this.result?.constructor == Object) {
Streamlit.setComponentValue(Object.assign({}, this.result));
}
else {
Streamlit.setComponentValue(this.result);
}
this.filteredData('');
},
}
},
setup() {
useStreamlit()
Expand Down Expand Up @@ -296,4 +325,8 @@ export default {
.sy-slider {
padding: 30px 20px 10px 20px;
}
.sy-taginput .dropdown-content {
margin-bottom: 20px;
}
</style>

0 comments on commit 6c9dfdf

Please sign in to comment.