Skip to content

Commit 11af9f0

Browse files
committed
Resolve conflicts
Merge branch 'main' into doc/add-tutorials # Conflicts: # R/inputs.R
2 parents 38b162e + 0ef03c9 commit 11af9f0

27 files changed

Lines changed: 366 additions & 3085 deletions

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export(reactable_extras_dependency)
88
export(reactable_extras_server)
99
export(reactable_extras_ui)
1010
export(text_extra)
11+
export(tooltip_extra)

R/dependencies.R

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ reactable_extras_dependency <- function() {
1010
version = "0.0.1",
1111
src = list(file = "assets"),
1212
package = "reactable.extras",
13-
script = c("js/reactable-extras.js", "js/reactable-server.js"),
14-
stylesheet = "css/reactable-server.css"
13+
script = c(
14+
"js/reactable-extras.js",
15+
"js/reactable-server.js",
16+
"js/popper.js",
17+
"js/tippy.js"
18+
),
19+
stylesheet = c(
20+
"css/reactable-server.css",
21+
"css/tippy-light.css",
22+
"css/tippy-light-border.css",
23+
"css/tippy-material.css",
24+
"css/tippy-translucent.css"
25+
)
1526
)
1627
}

R/inputs.R

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ define_key <- function(key) {
2424
if (!is.null(key)) {
2525
key <- paste0("cellInfo.row.", key)
2626
} else {
27-
key <- "(Number(cellInfo.id) + 1)"
27+
key <- paste(
28+
"cellInfo.row['.internal_uuid'] ?",
29+
"cellInfo.row['.internal_uuid'] :",
30+
"(Number(cellInfo.id) + 1)"
31+
)
2832
}
2933

3034
return(key)
@@ -110,7 +114,8 @@ date_extra <- function(id, key = NULL, ...) {
110114
}",
111115
id = id,
112116
key = key,
113-
args = args_js(...))
117+
args = args_js(...)
118+
)
114119
)
115120
)
116121
}
@@ -152,8 +157,9 @@ dropdown_extra <- function(id, choices, key = NULL, ...) {
152157
key = key,
153158
choices = choices_js,
154159
args = args_js(...)
160+
)
155161
)
156-
))
162+
)
157163
}
158164

159165
#' Text input for reactable column cell
@@ -179,7 +185,8 @@ text_extra <- function(id, key = NULL, ...) {
179185
}",
180186
id = id,
181187
key = key,
182-
args = args_js(...))
188+
args = args_js(...)
189+
)
183190
)
184191
)
185192
}

R/reactable-server.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,23 @@ reactable_extras_ui <- function(id, width = "auto", height = "auto") {
234234
)
235235
}
236236

237+
hide_internal_uuid <- function(args) {
238+
if (is.null(args$columns)) {
239+
args$columns <- list()
240+
}
241+
args$columns[[".internal_uuid"]] <- reactable::colDef(show = FALSE)
242+
return(args)
243+
}
244+
237245
#' @rdname reactable-extras-server
238246
#' @export
239247
reactable_extras_server <- function(id, data, total_pages = 4, sortable = TRUE, ...) {
240248

241-
data <- as.data.frame(data, stringsAsFactors = TRUE)
249+
data <- as.data.frame(data, stringsAsFactors = TRUE) |>
250+
dplyr::mutate(.internal_uuid = dplyr::row_number())
242251

243252
# Create and clean-up reactable arguments
244-
reactable_args <- list(...)
253+
reactable_args <- hide_internal_uuid(list(...))
245254

246255
checkmate::assert(
247256
checkmate::check_character(id, len = 1),

R/tooltip.R

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#' Tool-tip for table headers
2+
#'
3+
#' @param content The content to be displayed in the tool-tip
4+
#' @param theme The theme of the tool-tip, either "light", "light-border", "material" or
5+
#' "translucent"
6+
#'
7+
#' @examples
8+
#' reactable::colDef(header = tooltip_extra("This is my tool-tip", theme = "material"))
9+
#'
10+
#' @export
11+
tooltip_extra <- function(content, theme = "light") {
12+
reactable::JS(
13+
htmltools::doRenderTags(
14+
htmltools::htmlTemplate(
15+
text_ = "function(columnInfo) {
16+
return React.createElement(TooltipExtras,
17+
{column: columnInfo.name, tooltip: '{{content}}',
18+
theme: '{{theme}}'})
19+
}",
20+
content = content,
21+
theme = theme
22+
)
23+
)
24+
)
25+
}

inst/assets/css/tippy-light-border.css

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

inst/assets/css/tippy-light.css

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

inst/assets/css/tippy-material.css

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

inst/assets/css/tippy-translucent.css

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

inst/assets/js/popper.js

Lines changed: 6 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)