Skip to content

Commit

Permalink
[Porting] TagInput + example
Browse files Browse the repository at this point in the history
  • Loading branch information
filipakkad committed Jun 24, 2022
1 parent 2a10dec commit 4874fae
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export(Tab)
export(Tabs)
export(TabsExpander)
export(Tag)
export(TagInput)
export(TagInput.shinyInput)
export(Text)
export(TextArea)
export(TextArea.shinyInput)
Expand Down
13 changes: 12 additions & 1 deletion R/components.R
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,18 @@ InputGroup <- component("InputGroup")
#' @export
InputGroup.shinyInput <- input("InputGroup", "") # nolint

# TODO: Tag input
#' TagInput
#'
#' Documentation: <https://blueprintjs.com/docs/#core/components/tag-input>
#'
#' @example inst/examples/components/TagInput.R
#' @inherit template params
#' @export
TagInput <- component("TagInput")

#' @rdname TagInput
#' @export
TagInput.shinyInput <- input("TagInput", c()) # nolint

#' Text area
#'
Expand Down
16 changes: 16 additions & 0 deletions inst/examples/components/TagInput.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
library(shiny)
library(appsilon.blueprint)

if (interactive()) shinyApp(
# TagInput must be controlled
ui = tagList(
TagInput.shinyInput(
inputId = "controlledTagInput",
value = c("one", "two", "three")
),
textOutput("controlledTagInputOutput")
),
server = function(input, output) {
output$controlledTagInputOutput <- renderText(input$controlledTagInput)
}
)
2 changes: 1 addition & 1 deletion inst/www/blueprint.min.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions js/src/inputs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export const InputGroup = InputAdapter(Blueprint.InputGroup, (value, setValue) =
onChange: (event) => setValue(event.target.value),
}));

export const TagInput = InputAdapter(Blueprint.TagInput, (values, setValue) => ({
values,
onChange: setValue,
}));

export const TextArea = InputAdapter(Blueprint.TextArea, (value, setValue) => ({
value,
onChange: (event) => setValue(event.target.value),
Expand Down
39 changes: 39 additions & 0 deletions man/TagInput.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4874fae

Please sign in to comment.