Skip to content

Commit

Permalink
Merge pull request #35 from eodaGmbH/prepare-cran-release
Browse files Browse the repository at this point in the history
Prepare cran release
  • Loading branch information
crazycapivara authored Sep 18, 2024
2 parents a4c24de + 2e5f12c commit d376a51
Show file tree
Hide file tree
Showing 40 changed files with 154 additions and 117 deletions.
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
Package: rtabulator
Type: Package
Title: R Bindings for Tabulator JS
Version: 0.1.1.9000
Date: 2024-09-15
Version: 0.1.2
Date: 2024-09-18
Authors@R: c(
person("Stefan", "Kuethe", email = "[email protected]", role = c("aut", "cre")),
person("Nico", "Friess", email = "[email protected]", role = c("aut"))
)
Maintainer: Stefan Kuethe <[email protected]>
Description: Provides R bindings for 'Tabulator JS' <https://tabulator.info/>.
Makes it a breeze to create highly customisable interactive tables in markdown documents
and Shiny applications.
Makes it a breeze to create highly customizable interactive tables in markdown documents
and Shiny applications. It includes filtering, grouping, editing, input validation,
history recording, column formatters, packaged themes and more.
URL:
https://github.com/eodaGmbH/rtabulator
https://eodagmbh.github.io/rtabulator/
Expand All @@ -23,7 +24,6 @@ Imports:
glue,
htmltools,
htmlwidgets,
jsonlite,
purrr,
readr,
shiny
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# rtabulator 0.1.1.9000

* Custom input handlers
* `set_pagination`
* `set_group_by`
* `for_each_col` to apply same column settings to multiple columns at once
* `set_tooltip`
* `set_columns_defaults`
* `titanic` data set

# rtabulator 0.1.1

* Update docs
Expand Down
37 changes: 19 additions & 18 deletions R/columns.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ for_each_col <- function(widget, columns = NULL, .f, ...) {

# Formatters ####

#' HTML Formatter
#' Set HTML formatter
#' @param widget (\code{\link{tabulator}}) A tabulator widget.
#' @param column (character): The column the formatter is applied to.
#' @param hoz_align (character): The horizontal alignment of the column.
Expand All @@ -98,7 +98,7 @@ set_formatter_html <- function(widget, column, hoz_align = c("left", "center", "
modify_col_def(widget, column, col_update)
}

#' Plain Text Formatter
#' Set plain text formatter
#' @inheritParams set_formatter_html
#' @export
# TODO: Add example
Expand All @@ -107,7 +107,7 @@ set_formatter_plaintext <- function(widget, column, hoz_align = "left") {
modify_col_def(widget, column, col_update)
}

#' Text Area Formatter
#' Set textarea formatter
#' @inheritParams set_formatter_html
#' @example examples/formatters/formatter_textarea.R
#' @export
Expand All @@ -116,7 +116,7 @@ set_formatter_textarea <- function(widget, column, hoz_align = "left") {
modify_col_def(widget, column, col_update)
}

#' Money Formatter
#' Set money formatter
#' @inheritParams set_formatter_html
#' @param decimal (character): Symbol to represent the decimal point.
#' @param thousand (character, bool): Symbol to represent the thousands separator.
Expand Down Expand Up @@ -156,7 +156,7 @@ set_formatter_money <- function(
modify_col_def(widget, column, col_update)
}

#' Image Formatter
#' Set image formatter
#' @inheritParams set_formatter_html
#' @param height (character): A CSS value for the height of the image.
#' @param width (character): A CSS value for the width of the image.
Expand Down Expand Up @@ -187,7 +187,7 @@ set_formatter_image <- function(
modify_col_def(widget, column, col_update)
}

#' Link Formatter
#' Set link formatter
#' @inheritParams set_formatter_html
#' @param label_field (character): Column to be used as label for the link.
#' @param url_prefix (character): Prefix to add to the URL value.
Expand Down Expand Up @@ -218,7 +218,7 @@ set_formatter_link <- function(
modify_col_def(widget, column, col_update)
}

#' Star Rating Formatter
#' Set star rating formatter
#' @inheritParams set_formatter_html
#' @param number_of_stars The maximum number of stars to be displayed.
#' If set to \code{NA}, the maximum value of the column is used.
Expand All @@ -237,7 +237,7 @@ set_formatter_star <- function(widget, column, number_of_stars = NA, hoz_align =
modify_col_def(widget, column, col_update)
}

#' Progress Formatter
#' Set progress formatter
#' @inheritParams set_formatter_html
#' @param min (numeric): The minimum value for progress bar.
#' If set to \code{NA} the minimum value of the column is used.
Expand Down Expand Up @@ -285,7 +285,7 @@ set_formatter_progress <- function(
modify_col_def(widget, column, col_update)
}

#' Tick Cross Formatter
#' Set tick cross formatter
#' @inheritParams set_formatter_html
#' @example examples/formatters/formatter_tick_cross.R
#' @export
Expand All @@ -294,7 +294,7 @@ set_formatter_tick_cross <- function(widget, column) {
modify_col_def(widget, column, col_update)
}

#' Toggle Switch Formatter
#' Set toggle switch formatter
#' @inheritParams set_formatter_html
#' @param size (numeric): The size of the switch in pixels.
#' @param on_value (character): The value of the cell for the switch to be on.
Expand Down Expand Up @@ -331,7 +331,7 @@ set_formatter_toggle_switch <- function(
modify_col_def(widget, column, col_update)
}

#' Datetime Formatter
#' Set datetime formatter
#' @inheritParams set_formatter_html
#' @param input_format (character): The datetime input format.
#' @param output_format (character): The datetime output format.
Expand Down Expand Up @@ -359,7 +359,7 @@ set_formatter_datetime <- function(
modify_col_def(widget, column, col_update)
}

#' Color Formatter
#' Set color formatter
#' @inheritParams set_formatter_html
#' @example examples/formatters/formatter_color.R
#' @export
Expand All @@ -368,7 +368,7 @@ set_formatter_color <- function(widget, column) {
modify_col_def(widget, column, col_update)
}

#' Traffic Light Formatter
#' Set traffic light formatter
#' @inheritParams set_formatter_progress
#' @example examples/formatters/formatter_traffic_light.R
#' @export
Expand Down Expand Up @@ -419,8 +419,9 @@ set_column_editor <- function(widget, columns, type = c("input", "number")) {
#' @param validator (character vector): One or more validators to validate user input.
#' @param ... Optional editor parameters depending on the selected editor.
#' @seealso
#' \url{https://tabulator.info/docs/6.2/edit} for available editors
#' \url{https://tabulator.info/docs/6.2/validate} for available validators.
#' * \url{https://tabulator.info/docs/6.2/edit} for available editors
#' * \url{https://tabulator.info/docs/6.2/validate} for available validators
#' @md
#' @example examples/editors.R
#' @export
set_editor <- function(
Expand All @@ -442,7 +443,7 @@ set_editor <- function(
modify_col_def(widget, column, col_update)
}

#' Add header filter to column
#' Set header filter
#' @inheritParams set_formatter_html
#' @param type (character): The type of the filter.
#' @param values_lookup (bool): Whether to use unique column values for the list filter.
Expand Down Expand Up @@ -479,7 +480,7 @@ set_header_filter <- function(
modify_col_def(widget, column, col_update)
}

#' Add tooltip to column
#' Set tooltip
#' @inheritParams set_formatter_html
#' @example examples/misc/tooltip.R
#' @export
Expand Down Expand Up @@ -520,7 +521,7 @@ set_column_defaults <- function(
return(widget)
}

#' Add a calculation to a column
#' Set calculation
#' @inheritParams set_formatter_html
#' @param column (character): The column the \code{func} is applied to.
#' @param func (character): The calculation function to be applied
Expand Down
8 changes: 4 additions & 4 deletions R/context_calls.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ trigger_get_data <- function(ctx) {
invoke_method(ctx, "getData")
}

#' Add a row to the table
#' Add a row to a table
#' @inheritParams trigger_download
#' @param row (list | NULL) row data or NULL to add an empty row
#' @param row (list | NULL): row data or \code{NULL} to add an empty row
#' @export
add_row <- function(ctx, row = NULL) {
invoke_method(ctx, "addRow", row)
}

#' Delete selected rows from the table
#' Delete selected rows from a table
#' @inheritParams trigger_download
#' @export
delete_selected_rows <- function(ctx) {
Expand All @@ -52,7 +52,7 @@ redo <- function(ctx) {
invoke_method(ctx, "redo")
}

#' Submit data to R
#' Submit sheet data to R
#' @inheritParams trigger_download
#' @export
trigger_get_sheet_data <- function(ctx) {
Expand Down
4 changes: 2 additions & 2 deletions R/experimental.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See example here: https://github.com/eodaGmbH/py-tabulator/blob/main/docs/examples/getting_started/shiny_core_multi_row_headers.py
#' Multi Column Header
#' Set multi column header
#' @inheritParams set_formatter_html
#' @param multi_columns (list): Multi column definitions
#' @param multi_columns (list): Multi column definitions.
#' @example examples/experimental/multi_column_header.R
#' @export
set_multi_column_header <- function(widget, multi_columns) {
Expand Down
2 changes: 1 addition & 1 deletion R/spreadsheet.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Create a spreadsheet definition
#' @param title (character): The name of the spreadsheet.
#' @param key (character): Optional unique key of the spreadsheet.
#' @param data (list) The initial data of the spreadsheet.
#' @param data (list): The initial data of the spreadsheet.
#' Set to \code{NULL} to create an empty spreadsheet.
#' @export
spreadsheet_def <- function(title, key = NULL, data = NULL) {
Expand Down
19 changes: 13 additions & 6 deletions R/tabulator.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#' Create a Tabulator Widget
#' Create a tabulator widget
#'
#' @details
#' Dots in column names are replaced by underscores.
#' @param data (data.frame, character or list): In spreadsheet mode data needs to be a list or \code{NULL}
#' for an empty spreadsheet.
#' @param options (list): Setup options. See \code{\link{tabulator_options}}.
#' @param editable (bool): Whether the table is editable.
#' @param sheetjs (bool): Whether to add sheetjs (\url{https://sheetjs.com/}) dependency,
#' which is needed for xlsx downloads.
#' @param luxon (bool): Whether to add \href{https://moment.github.io/luxon/}{luxon} dependency,
#' which is required for \code{\link{set_formatter_datetime}}.
#' @param sheetjs (bool): Whether to add \href{https://sheetjs.com/}{sheetjs} dependency,
#' which is required for \code{\link{trigger_download}} to support Excel type downloads.
#' @param theme (character): Theme to apply to the table.
#' @param col_select (character vector) Columns to select.
#' Passed to \code{\link[readr]{read_csv}} if \code{data} is a file name.
Expand All @@ -21,13 +24,15 @@ tabulator <- function(
data,
options = tabulator_options(),
editable = FALSE,
luxon = FALSE,
sheetjs = FALSE,
theme = c("default", "midnight", "modern", "simple", "site", "bootstrap3", "bootstrap4", "bootstrap5", "bulma", "materialize", "semanticui"),
col_select = NULL,
width = NULL,
height = NULL,
element_id = NULL,
...) {
# Body
if (is.null(options)) options <- list()

if (is.character(data)) {
Expand Down Expand Up @@ -59,9 +64,11 @@ tabulator <- function(
stylesheetText = stylesheet_text
)

# TODO: Make it optional when datetime formatter is called
dependencies <- list(luxon_dependency)
# dependencies <- list()
dependencies <- list()
if (isTRUE(luxon)) {
dependencies <- c(dependencies, list(luxon_dependency))
}

if (theme != "default") {
dependencies <- c(dependencies, list(get_theme_dependeny(theme)))
}
Expand Down
6 changes: 3 additions & 3 deletions R/tabulator_context.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ invoke_method <- function(widget, method_name, ...) {
invisible(widget)
}

#' Create a Tabulator Context Object
#' Create a tabulator context object
#'
#' @description
#' @details
#' A \code{tabulatorContext} object makes it possible to update your widget in a Shiny application.
#' @param output_id (character): A tabulator output id.
#' @param session shiny session object
#' @param session A shiny session object.
#' @export
tabulatorContext <- function(output_id, session = shiny::getDefaultReactiveDomain()) {
ctx <- list(
Expand Down
7 changes: 6 additions & 1 deletion R/tabulator_options.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Tabulator Setup Options
#' Create a tabulator options object
#' @param height (character) The height of the table in px.
#' @param history (bool): Enable user interaction history functionality.
#' @param columns (list): Column definitions.
Expand Down Expand Up @@ -53,6 +53,11 @@ tabulator_options <- function(
row_height = NULL,
add_row_pos = c("bottom", "top"),
movable_rows = FALSE,
# ---
# movable_rows_connected_tables = NULL,
# movable_rows_receiver = NULL,
# movable_rows_sender = NULL,
# ---
resizable_rows = FALSE,
frozen_rows = NULL,
# Data
Expand Down
10 changes: 5 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ The goal of rtabulator is to make it a breeze creating beautiful and interactive
* Download data
* Freeze data

To learn more about rtabulator, see the documentation at [https://eodagmbh.github.io/rtabulator/](https://eodagmbh.github.io/rtabulator/).

Bindings for Python are available at [https://github.com/eodaGmbH/py-tabulator](https://github.com/eodaGmbH/py-tabulator).

## Installation

Once on CRAN you can install rtabulator with:
Expand All @@ -54,7 +58,7 @@ You can install the development version of rtabulator like so:
remotes::install_github("eodaGmbH/rtabulator")
```

## Basic Usage
## Basic usage

``` r
library(rtabulator)
Expand All @@ -81,7 +85,3 @@ tabulator(data = list(), spreadsheet = TRUE)
``` r
shiny::runGitHub("eodaGmbH/rtabulator", subdir = "examples/shiny/titanic")
```

## Documentation

[rtabulator docs](https://eodagmbh.github.io/rtabulator/)
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ interactive tables in markdown documents and Shiny application using
- Download data
- Freeze data

To learn more about rtabulator, see the documentation at
<https://eodagmbh.github.io/rtabulator/>.

Bindings for Python are available at
<https://github.com/eodaGmbH/py-tabulator>.

## Installation

Once on CRAN you can install rtabulator with:
Expand All @@ -46,7 +52,7 @@ You can install the development version of rtabulator like so:
remotes::install_github("eodaGmbH/rtabulator")
```

## Basic Usage
## Basic usage

``` r
library(rtabulator)
Expand All @@ -73,7 +79,3 @@ tabulator(data = list(), spreadsheet = TRUE)
``` r
shiny::runGitHub("eodaGmbH/rtabulator", subdir = "examples/shiny/titanic")
```

## Documentation

[rtabulator docs](https://eodagmbh.github.io/rtabulator/)
Loading

0 comments on commit d376a51

Please sign in to comment.