Skip to content

Commit 799b7e9

Browse files
authored
Merge branch 'main' into 291_enable_livesearch_delayed@main
2 parents e638046 + c3afc4e commit 799b7e9

File tree

11 files changed

+44
-202
lines changed

11 files changed

+44
-202
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ default_language_version:
66
python: python3
77
repos:
88
- repo: https://github.com/lorenzwalthert/precommit
9-
rev: v0.4.3.9005
9+
rev: v0.4.3.9008
1010
hooks:
1111
- id: style-files
1212
name: Style code with `styler`

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: teal.widgets
22
Title: 'shiny' Widgets for 'teal' Applications
3-
Version: 0.4.3.9001
4-
Date: 2025-03-11
3+
Version: 0.4.3.9002
4+
Date: 2025-04-11
55
Authors@R: c(
66
person("Dawid", "Kaledkowski", , "[email protected]", role = c("aut", "cre")),
77
person("Pawel", "Rucki", , "[email protected]", role = "aut"),

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# teal.widgets 0.4.3.9001
1+
# teal.widgets 0.4.3.9002
22

33
### Breaking changes
44
* `panel_group()` and `panel_item()` are deprecated. Please use the `bslib::accordion()` and `bslib::accordion_panel()` instead.

R/plot_with_settings.R

Lines changed: 20 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,10 @@ plot_with_settings_ui <- function(id) {
2424
shinyjs::useShinyjs(),
2525
bslib::card(
2626
id = ns("plot-with-settings"),
27+
full_screen = TRUE,
2728
tags$div(
2829
tags$div(
2930
class = "teal-widgets settings-buttons",
30-
bslib::tooltip(
31-
trigger = tags$div(type_download_ui(ns("downbutton"))),
32-
options = list(trigger = "hover"),
33-
class = "download-button",
34-
"Download"
35-
),
3631
bslib::tooltip(
3732
trigger = tags$div(
3833
bslib::popover(
@@ -47,22 +42,14 @@ plot_with_settings_ui <- function(id) {
4742
"Resize"
4843
),
4944
bslib::tooltip(
50-
trigger = tags$div(
51-
actionLink(
52-
ns("expand"),
53-
label = character(0),
54-
icon = icon("up-right-and-down-left-from-center"),
55-
class = "btn-sm",
56-
style = "color: #000;"
57-
)
58-
),
45+
trigger = tags$div(type_download_ui(ns("downbutton"))),
5946
options = list(trigger = "hover"),
60-
class = "expand-button",
61-
"Expand"
62-
),
47+
class = "download-button",
48+
"Download"
49+
)
6350
),
64-
tags$br(),
6551
tags$div(
52+
id = ns("plot-out-main"),
6653
class = "teal-widgets plot-content",
6754
uiOutput(ns("plot_out_main"))
6855
)
@@ -87,29 +74,27 @@ plot_with_settings_ui <- function(id) {
8774
#' Take into account that simple functions are less efficient than reactive, as not catching the result.
8875
#' @param height (`numeric`) optional\cr
8976
#' vector with three elements c(VAL, MIN, MAX), where VAL is the starting value of the slider in
90-
#' the main and modal plot display. The value in the modal display is taken from the value of the
91-
#' slider in the main plot display.
77+
#' the main and expanded plot display.
9278
#' @param width (`numeric`) optional\cr
9379
#' vector with three elements `c(VAL, MIN, MAX)`, where VAL is the starting value of the slider in
94-
#' the main and modal plot display; `NULL` for default display. The value in the modal
95-
#' display is taken from the value of the slider in the main plot display.
80+
#' the main and expanded plot display; `NULL` for default display.
9681
#' @param show_hide_signal optional, (`reactive logical` a mechanism to allow modules which call this
9782
#' module to show/hide the plot_with_settings UI)
9883
#' @param brushing (`logical`) optional\cr
99-
#' mechanism to enable / disable brushing on the main plot (in particular: not the one displayed
100-
#' in modal). All the brushing data is stored as a reactive object in the `"brush"` element of
84+
#' mechanism to enable / disable brushing on the main plot.
85+
#' All the brushing data is stored as a reactive object in the `"brush"` element of
10186
#' returned list. See the example for details.
10287
#' @param clicking (`logical`)\cr
103-
#' a mechanism to enable / disable clicking on data points on the main plot (in particular: not the
104-
#' one displayed in modal). All the clicking data is stored as a reactive object in the `"click"`
88+
#' a mechanism to enable / disable clicking on data points on the main plot.
89+
#' All the clicking data is stored as a reactive object in the `"click"`
10590
#' element of returned list. See the example for details.
10691
#' @param dblclicking (`logical`) optional\cr
107-
#' mechanism to enable / disable double-clicking on data points on the main plot (in particular:
108-
#' not the one displayed in modal). All the double clicking data is stored as a reactive object in
92+
#' mechanism to enable / disable double-clicking on data points on the main plot.
93+
#' All the double clicking data is stored as a reactive object in the
10994
#' the `"dblclick"` element of returned list. See the example for details.
11095
#' @param hovering (`logical(1)`) optional\cr
111-
#' mechanism to enable / disable hovering over data points on the main plot (in particular: not
112-
#' the one displayed in modal). All the hovering data is stored as a reactive object in the
96+
#' mechanism to enable / disable hovering over data points on the main plot.
97+
#' All the hovering data is stored as a reactive object in the
11398
#' `"hover"` element of returned list. See the example for details.
11499
#' @param graph_align (`character(1)`) optional,\cr
115100
#' one of `"left"` (default), `"center"`, `"right"` or `"justify"`. The alignment of the graph on
@@ -298,10 +283,9 @@ plot_with_settings_srv <- function(id,
298283
ns <- session$ns
299284
shinyjs::runjs(
300285
sprintf(
301-
'establishPlotResizing("%s", "%s", "%s");',
302-
ns("plot_main"), # graph parent id
303-
ns("flex_width"), # session input$ variable name
304-
ns("plot_modal_width") # session input$ variable name
286+
'establishPlotResizing("%s", "%s");',
287+
ns("plot-out-main"), # graph parent id
288+
ns("flex_width") # session input$ variable name
305289
)
306290
)
307291
default_w <- function() session$clientData[[paste0("output_", ns("plot_main_width"))]]
@@ -430,25 +414,14 @@ plot_with_settings_srv <- function(id,
430414
width = p_width
431415
)
432416

433-
output$plot_modal <- renderPlot(
434-
apply_plot_modifications(
435-
plot_obj = plot_suppress(plot_r()),
436-
plot_type = plot_suppress(plot_type()),
437-
dblclicking = dblclicking,
438-
ranges = ranges
439-
),
440-
res = get_plot_dpi(),
441-
height = reactive(input$height_in_modal),
442-
width = reactive(input$width_in_modal)
443-
)
444-
445417
output$plot_out_main <- renderUI({
446418
req(plot_suppress(plot_r()))
447419
tags$div(
448420
align = graph_align,
449421
plotOutput(
450422
ns("plot_main"),
451423
height = "100%",
424+
width = p_width(),
452425
brush = `if`(brushing, brushOpts(ns("plot_brush"), resetOnNew = FALSE), NULL),
453426
click = `if`(clicking, clickOpts(ns("plot_click")), NULL),
454427
dblclick = `if`(dblclicking, dblclickOpts(ns("plot_dblclick")), NULL),
@@ -479,72 +452,6 @@ plot_with_settings_srv <- function(id,
479452
default_h = default_h
480453
)
481454

482-
output$plot_out_modal <- renderUI({
483-
plotOutput(ns("plot_modal"), height = input$height_in_modal, width = input$width_in_modal)
484-
})
485-
486-
observeEvent(input$expand, {
487-
showModal(
488-
tags$div(
489-
class = "teal-widgets plot-modal",
490-
modalDialog(
491-
easyClose = TRUE,
492-
tags$div(
493-
class = "plot-modal-sliders",
494-
optionalSliderInputValMinMax(
495-
inputId = ns("height_in_modal"),
496-
label = "Plot height",
497-
value_min_max = round(c(p_height(), height[2:3])),
498-
ticks = FALSE,
499-
step = 1L,
500-
round = TRUE,
501-
width = "30vw"
502-
),
503-
optionalSliderInputValMinMax(
504-
inputId = ns("width_in_modal"),
505-
label = "Plot width",
506-
value_min_max = round(c(
507-
ifelse(
508-
is.null(input$width) || !isFALSE(input$width_resize_switch),
509-
ifelse(
510-
is.null(input$plot_modal_width) || input$plot_modal_width > default_slider_width()[3],
511-
default_slider_width()[1],
512-
input$plot_modal_width
513-
),
514-
input$width
515-
),
516-
default_slider_width()[2:3]
517-
)),
518-
ticks = FALSE,
519-
step = 1L,
520-
round = TRUE,
521-
width = "30vw"
522-
),
523-
bslib::tooltip(
524-
trigger = tags$div(type_download_ui(ns("modal_downbutton"))),
525-
options = list(trigger = "hover"),
526-
"Download"
527-
)
528-
),
529-
tags$div(
530-
class = "teal-widgets plot-modal-content",
531-
uiOutput(ns("plot_out_modal"))
532-
)
533-
)
534-
)
535-
)
536-
})
537-
538-
type_download_srv(
539-
id = "modal_downbutton",
540-
plot_reactive = plot_r,
541-
plot_type = plot_type,
542-
plot_w = reactive(input$width_in_modal),
543-
default_w = default_w,
544-
plot_h = reactive(input$height_in_modal),
545-
default_h = default_h
546-
)
547-
548455
list(
549456
brush = reactive({
550457
# refresh brush data on the main plot size change

R/table_with_settings.R

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,14 @@ table_with_settings_ui <- function(id, ...) {
3333
shinyjs::useShinyjs(),
3434
bslib::card(
3535
id = ns("table-with-settings"),
36+
full_screen = TRUE,
3637
tags$div(
3738
class = "teal-widgets settings-buttons",
3839
bslib::tooltip(
3940
trigger = tags$div(type_download_ui_table(ns("downbutton"))),
4041
options = list(trigger = "hover"),
4142
class = "download-button",
4243
"Download"
43-
),
44-
bslib::tooltip(
45-
trigger = tags$div(
46-
actionLink(
47-
ns("expand"),
48-
label = character(0),
49-
icon = icon("up-right-and-down-left-from-center"),
50-
class = "btn-sm",
51-
style = "color: #000;"
52-
)
53-
),
54-
options = list(trigger = "hover"),
55-
class = "expand-button",
56-
"Expand"
5744
)
5845
),
5946
tags$div(
@@ -132,34 +119,6 @@ table_with_settings_srv <- function(id, table_r, show_hide_signal = reactive(TRU
132119
id = "downbutton",
133120
table_reactive = table_r
134121
)
135-
136-
observeEvent(input$expand, {
137-
showModal(
138-
tags$div(
139-
class = "teal-widgets output-modal",
140-
modalDialog(
141-
easyClose = TRUE,
142-
tags$div(
143-
class = "float-right",
144-
bslib::tooltip(
145-
trigger = tags$div(type_download_ui_table(ns("modal_downbutton"))),
146-
options = list(trigger = "hover"),
147-
"Download"
148-
)
149-
),
150-
tags$div(
151-
class = "teal-widgets table-modal-content",
152-
uiOutput(ns("table_out_modal"))
153-
)
154-
)
155-
)
156-
)
157-
})
158-
159-
type_download_srv_table(
160-
id = "modal_downbutton",
161-
table_reactive = table_r
162-
)
163122
})
164123
}
165124

inst/plot-with-settings/plot-with-settings.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
.teal-widgets.plot-content,
1313
.teal-widgets.plot-modal-content {
14-
overflow: scroll;
14+
overflow: auto;
1515
}
1616

1717
.teal-widgets.settings-buttons {

inst/plot-with-settings/plot-with-settings.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// Function that registers resize observer for particular parent elements.
22
// Arguments are namespaced ids of DOM elements.
3-
var establishPlotResizing = function (plot_out, flex_width, plot_modal_width) {
3+
var establishPlotResizing = function (plot_out, flex_width) {
44
// Create resize observer to trigger shiny actions when plot container is resized.
55
var plotObserver = new ResizeObserver(function () {
6+
const paddingTolerance = 10;
67
Shiny.onInputChange(
78
flex_width,
8-
document.getElementById(plot_out).clientWidth
9+
document.getElementById(plot_out).clientWidth - paddingTolerance // Reducing the plot width to avoid overflow
910
);
10-
Shiny.onInputChange(plot_modal_width, 0.87 * window.innerWidth);
11-
//based on modal CSS property, also accounting for margins
1211
});
1312

1413
// Create mutation observer to delay activation of resize observer.

inst/standard-layout/standard-layout.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
.teal-widgets.standard-layout .standard-layout-output > .well {
2626
border: none;
2727
}
28-
28+
.teal-widgets.standard-layout .standard-layout-output > .well-sm {
29+
padding: 1rem;
30+
}
2931
.teal-widgets.standard-layout-wrapper {
30-
padding-right: 0;
32+
padding: 0;
3133
}

inst/table-with-settings/table-with-settings.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
.teal-widgets.table-content,
2222
.teal-widgets.table-modal-content {
23-
overflow: scroll;
23+
overflow: auto;
2424
}
2525

2626
.teal-widgets.settings-buttons {

man/plot_with_settings.Rd

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

0 commit comments

Comments
 (0)