Skip to content

Commit 82dbfdd

Browse files
authored
CRAN release, upversion to 0.4.1 [skip vbump] (#195)
Related to #189
1 parent 971e592 commit 82dbfdd

14 files changed

+142
-61
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: teal.widgets
22
Title: 'shiny' Widgets for 'teal' Applications
3-
Version: 0.4.0.9013
3+
Version: 0.4.1
44
Date: 2023-10-02
55
Authors@R: c(
66
person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre")),
@@ -36,6 +36,7 @@ Imports:
3636
shinyWidgets (>= 0.5.1),
3737
styler (>= 1.2.0)
3838
Suggests:
39+
DT,
3940
knitr (>= 1.42),
4041
lattice (>= 0.18-4),
4142
magrittr (>= 1.5),

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
# teal.widgets 0.4.0.9013
1+
# teal.widgets 0.4.1
22

33
### Miscellaneous
44

55
* Documentation enhancements - code formatting package names and R objects.
66
* Add `grDevices` to Imports.
77
* Specified minimal version of package dependencies.
8+
* Improved logic and documentation for `optionalSelectInput`.
89

910
# teal.widgets 0.4.0
1011

R/get_dt_rows.R

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,36 @@
66
#'
77
#' @name get_dt_rows
88
#'
9+
#' @return (`shiny::tagList`) A `shiny` tagList.
10+
#'
911
#' @examples
10-
#' \dontrun{
1112
#' library(shiny)
12-
#' # in Shiny UI function
13-
#' tagList(
14-
#' get_dt_rows(ns("data_table"), ns("dt_rows")),
15-
#' ...
16-
#' )
13+
#' ui <- function(id) {
14+
#' ns <- NS(id)
15+
#' tagList(
16+
#' DT::DTOutput(ns("data_table")),
17+
#' get_dt_rows(ns("data_table"), ns("dt_rows"))
18+
#' )
19+
#' }
1720
#'
1821
#' # use the input$dt_rows in the Shiny Server function
19-
#' if (!is.null(input$dt_rows)) {
20-
#' dt_args$options$pageLength <- input$dt_rows
21-
#' } # nolint
22-
#' do.call(DT::datatable, dt_args)
22+
#' server <- function(id) {
23+
#' moduleServer(id, function(input, output, session) {
24+
#' output$data_table <- DT::renderDataTable(
25+
#' {
26+
#' iris
27+
#' },
28+
#' options = list(pageLength = input$dt_rows)
29+
#' )
30+
#' })
2331
#' }
2432
#'
33+
#' if (interactive()) {
34+
#' shinyApp(
35+
#' ui = ui("my_table_module"),
36+
#' server = function(input, output, session) server("my_table_module")
37+
#' )
38+
#' }
2539
#' @export
2640
get_dt_rows <- function(dt_name, dt_rows) {
2741
tags$head(

R/optionalInput.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#' @param width (`character(1)`)\cr
2727
#' The width of the input passed to `pickerInput` e.g. `'auto'`, `'fit'`, `'100px'` or `'75%'`
2828
#'
29+
#' @return (`shiny.tag`) HTML tag with `pickerInput` widget and
30+
#' non-interactive element listing selected values.
31+
#'
2932
#' @export
3033
#'
3134
#' @examples
@@ -471,6 +474,8 @@ extract_raw_choices <- function(choices, sep) {
471474
#' an object of class `shiny.tag`. E.g. an object returned by [shiny::helpText()]
472475
#' @param ... optional arguments to `sliderInput`
473476
#'
477+
#' @return (`shiny.tag`) HTML tag with `sliderInput` widget.
478+
#'
474479
#' @export
475480
#'
476481
#' @examples
@@ -532,6 +537,8 @@ optionalSliderInput <- function(inputId, label, min, max, value, label_help = NU
532537
#' Otherwise, if it is of length three the three elements will map to `value`, `min` and `max` of
533538
#' the [optionalSliderInput()] function.
534539
#'
540+
#' @return (`shiny.tag`) HTML tag with range `sliderInput` widget.
541+
#'
535542
#' @export
536543
#'
537544
#' @examples

R/plot_with_settings.R

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
#' UI part of plot-with-settings module
2-
#'
3-
#' @description `r lifecycle::badge("stable")`
1+
#' @rdname plot_with_settings
42
#' @export
5-
#'
6-
#' @param id (\code{character}) module ID
73
plot_with_settings_ui <- function(id) {
84
checkmate::assert_string(id)
95

@@ -62,12 +58,16 @@ plot_with_settings_ui <- function(id) {
6258
)
6359
}
6460

65-
#' Server part of plot-with-settings module
61+
#' Plot-with-settings module
6662
#'
63+
#' @rdname plot_with_settings
6764
#' @description `r lifecycle::badge("stable")`
65+
#' Universal module for plots with settings for height, width, and download.
66+
#'
6867
#' @export
6968
#'
70-
#' @inheritParams shiny::moduleServer
69+
#' @param id (`character(1)`) `shiny` module id.
70+
#'
7171
#' @param plot_r (`reactive` or `function`)\cr
7272
#' `reactive` expression or a simple `function` to draw a plot.
7373
#' A simple `function` is needed e.g. for base plots like `plot(1)` as the output can not be caught when downloading.
@@ -106,11 +106,12 @@ plot_with_settings_ui <- function(id) {
106106
#' `options(teal.plot_dpi = 96)`. The minimum allowed `dpi` value is `24` and it must be a whole number.
107107
#' If an invalid value is set then the default value is used and a warning is outputted to the console.
108108
#'
109+
#' @return A `shiny` module.
110+
#'
109111
#' @examples
110-
#' \dontrun{
111112
#' # Example using a reactive as input to plot_r
112113
#' library(shiny)
113-
#' shinyApp(
114+
#' app1 <- shinyApp(
114115
#' ui = fluidPage(
115116
#' plot_with_settings_ui(
116117
#' id = "plot_with_settings"
@@ -130,8 +131,12 @@ plot_with_settings_ui <- function(id) {
130131
#' }
131132
#' )
132133
#'
134+
#' if (interactive()) {
135+
#' runApp(app1)
136+
#' }
137+
#'
133138
#' # Example using a function as input to plot_r
134-
#' shinyApp(
139+
#' app2 <- shinyApp(
135140
#' ui = fluidPage(
136141
#' radioButtons("download_option", "Select the Option", list("ggplot", "trellis", "grob", "base")),
137142
#' plot_with_settings_ui(
@@ -167,8 +172,12 @@ plot_with_settings_ui <- function(id) {
167172
#' }
168173
#' )
169174
#'
175+
#' if (interactive()) {
176+
#' runApp(app2)
177+
#' }
178+
#'
170179
#' # Example with brushing/hovering/clicking/double-clicking
171-
#' shinyApp(
180+
#' app3 <- shinyApp(
172181
#' ui = fluidPage(
173182
#' plot_with_settings_ui(
174183
#' id = "plot_with_settings"
@@ -202,10 +211,14 @@ plot_with_settings_ui <- function(id) {
202211
#' }
203212
#' )
204213
#'
214+
#' if (interactive()) {
215+
#' runApp(app3)
216+
#' }
217+
#'
205218
#' # Example which allows module to be hidden/shown
206219
#' library("shinyjs")
207220
#'
208-
#' shinyApp(
221+
#' app4 <- shinyApp(
209222
#' ui = fluidPage(
210223
#' useShinyjs(),
211224
#' actionButton("button", "Show/Hide"),
@@ -229,7 +242,11 @@ plot_with_settings_ui <- function(id) {
229242
#' )
230243
#' }
231244
#' )
245+
#'
246+
#' if (interactive()) {
247+
#' runApp(app4)
232248
#' }
249+
#'
233250
plot_with_settings_srv <- function(id,
234251
plot_r,
235252
height = c(600, 200, 2000),

R/table_with_settings.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ table_with_settings_ui <- function(id, ...) {
4242
#' a mechanism to allow modules which call this module to show/hide the table_with_settings UI.
4343
#'
4444
#' @rdname table_with_settings
45+
#'
46+
#' @return A `shiny` module.
47+
#'
4548
#' @export
4649
#'
4750
#' @examples
48-
#' \dontrun{
4951
#' library(shiny)
5052
#' library(rtables)
5153
#' library(magrittr)
52-
#' shinyApp(
54+
#' app <- shinyApp(
5355
#' ui = fluidPage(
5456
#' table_with_settings_ui(
5557
#' id = "table_with_settings"
@@ -69,6 +71,8 @@ table_with_settings_ui <- function(id, ...) {
6971
#' table_with_settings_srv(id = "table_with_settings", table_r = table_r)
7072
#' }
7173
#' )
74+
#' if (interactive()) {
75+
#' runApp(app)
7276
#' }
7377
#'
7478
table_with_settings_srv <- function(id, table_r, show_hide_signal = reactive(TRUE)) {

inst/WORDLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ draggable
77
funder
88
pre
99
repo
10+
tagList

man/get_dt_rows.Rd

Lines changed: 25 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/optionalSelectInput.Rd

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/optionalSliderInput.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)