-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed onServerSearch bug * Removed console.log, used packer * Fixed labelRenderer * Reverted version to 0.8.1.9100 * Added examples * Fixed T shortcut * Documented change of T -> TRUE
- Loading branch information
1 parent
2df0415
commit 3deca87
Showing
6 changed files
with
1,017 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# labelRenderer example ---- | ||
|
||
library(shiny) | ||
library(shinyWidgets) | ||
|
||
ui <- fluidPage( | ||
tags$head( | ||
tags$script(HTML(" | ||
function colorText(data) { | ||
let text = `<span style='color: ${data.label};'>${data.label}</span>`; | ||
return text; | ||
}" | ||
)), | ||
), | ||
tags$h1("Custom LabelRenderer"), | ||
br(), | ||
fluidRow( | ||
column( | ||
width = 6, | ||
virtualSelectInput( | ||
inputId = "search", | ||
label = "Color picker", | ||
choices = c("red", "blue", "green", "#cbf752"), | ||
width = "100%", | ||
keepAlwaysOpen = TRUE, | ||
labelRenderer = "colorText", | ||
allowNewOption = TRUE | ||
) | ||
) | ||
) | ||
|
||
) | ||
|
||
server <- function(input, output, session) {} | ||
|
||
if (interactive()) | ||
shinyApp(ui, server) | ||
|
||
# onServerSearch example ---- | ||
|
||
library(shiny) | ||
library(shinyWidgets) | ||
|
||
ui <- fluidPage( | ||
tags$head( | ||
tags$script(HTML(r"( | ||
// Main function that is called | ||
function searchLabel(searchValue, virtualSelect) { | ||
// Words to search for - split by a space | ||
const searchWords = searchValue.split(/[\s]/); | ||
// Update visibility | ||
const found = virtualSelect.options.map(opt => { | ||
opt.isVisible = searchWords.every(word => opt.label.includes(word)); | ||
return opt; | ||
}); | ||
virtualSelect.setServerOptions(found); | ||
} | ||
)" | ||
)), | ||
), | ||
tags$h1("Custom onServerSearch"), | ||
br(), | ||
fluidRow( | ||
column( | ||
width = 6, | ||
virtualSelectInput( | ||
inputId = "search", | ||
label = "Better search", | ||
choices = c("This is some random long text", | ||
"This text is long and looks differently", | ||
"Writing this text is a pure love", | ||
"I love writing!" | ||
), | ||
width = "100%", | ||
keepAlwaysOpen = TRUE, | ||
search = TRUE, | ||
autoSelectFirstOption = FALSE, | ||
onServerSearch = "searchLabel" | ||
) | ||
) | ||
) | ||
|
||
) | ||
|
||
server <- function(input, output, session) {} | ||
|
||
if (interactive()) | ||
shinyApp(ui, server) |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters