Skip to content

Commit

Permalink
Merge pull request #29 from timelyportfolio/update
Browse files Browse the repository at this point in the history
Update jsoneditor and react-json-view
  • Loading branch information
timelyportfolio authored Oct 7, 2018
2 parents f203adc + 81cfa2d commit 107e5cb
Show file tree
Hide file tree
Showing 18 changed files with 501 additions and 407 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: listviewer
Type: Package
Title: 'htmlwidget' for Interactive Views of R Lists
Version: 2.0.0
Date: 2018-03-25
Version: 2.1.0
Date: 2018-10-06
Authors@R: c(
person("Jos", "de Jong", role = c("aut", "cph"), comment = "jsoneditor.js library in htmlwidgets/jsoneditor, http://github.com/josdejong/jsoneditor/" ),
person("Mac"," Gainer", role = c("aut", "cph"), comment = "react-json-view library in htmlwidgets/react-json, https://github.com/mac-s-g/react-json-view"),
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# listviewer 2.1.0

* update `jsoneditor` to [5.24.6](https://github.com/josdejong/jsoneditor/releases/tag/v5.24.6)
* update `react-json-view` to 2.5.7
* add full set of `props` for `react-json-view`

# listviewer 2.0.0

* change `reactjson()` to use [`react-json-view`](https://github.com/mac-s-g/react-json-view) instead of [`react-json`](https://github.com/arqex/react-json)
Expand Down
58 changes: 56 additions & 2 deletions R/reactjson.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@
#' be any data source that can be rendered into \code{JSON} with \code{jsonlite}. Alternately,
#' \code{listdata} could be a \code{String} of valid \code{JSON}. This might be helpful
#' when dealing with an API response.
#' @param name \code{string} name of the root node. Default is \code{"root"}.
#' @param theme \code{string} name of the theme. Default is \code{"rjv-default"}.
#' @param iconStyle \code{string} shape for the expand/collapse icon. Options are circle,
#' triangle, and square with the default as \code{"circle"}.
#' @param indentWidth \code{integer} for the indent width for nested objects. Default is \code{4}.
#' @param collapsed \code{logical} or \code{integer}. Use \code{logical} to expand/collapse all nodes.
#' Use \code{integer} to specify the depth at which to collapse.
#' @param collapseStringsAfterLength \code{integer} for the length at which strings will be cut off
#' Collapsed strings are followed by an ellipsis. String content can be expanded and
#' collapsed by clicking on the string value.
#' @param groupArraysAfterLength \code{integer} for the count at which arrays will be displayed in groups.
#' Groups are displayed with bracket notation and can be expanded and collapsed.
#' by clicking on the brackets.
#' @param enableClipboard \code{logical} whether the user can copy objects and arrays
#' clicking on the clipboard icon. Copy callbacks are supported. Default is \code{TRUE}.
#' @param displayObjectSize \code{logical} whether or not objects and arrays are labeled with size.
#' Default is \code{TRUE}.
#' @param displayDataTypes \code{logical} whether or not data type labels prefix values.
#' Default is \code{TRUE}.
#' @param onEdit \code{htmlwidgets::JS} function for callback to perform on edit.
#' @param onAdd \code{htmlwidgets::JS} function for callback to perform on add.
#' @param onDelete \code{htmlwidgets::JS} function for callback to perform on delete.
#' @param onSelect \code{htmlwidgets::JS} function for callback to perform on select.
#' @param sortKeys \code{logical} whether or not to sort object keys. Default is \code{FALSE}.
#' @param width integer in pixels defining the width of the \code{div} container.
#' @param height integer in pixels defining the height of the \code{div} container.
#' @param elementId character to specify valid \code{CSS} id of the
Expand All @@ -16,6 +40,21 @@
#' @example inst/examples/examples_reactjson.R
reactjson <- function(
listdata = list(),
name = "root",
theme = "rjv-default",
iconStyle = c("circle", "triangle", "square"),
indentWidth = 4,
collapsed = FALSE,
collapseStringsAfterLength = FALSE,
groupArraysAfterLength = 100,
enableClipboard = TRUE,
displayObjectSize = TRUE,
displayDataTypes = TRUE,
onEdit = FALSE,
onAdd = FALSE,
onDelete = FALSE,
onSelect = FALSE,
sortKeys = FALSE,
width = NULL, height = NULL, elementId = NULL
) {

Expand All @@ -27,7 +66,22 @@ reactjson <- function(

# forward options using x
x = list(
data = listdata
data = listdata,
name = name,
theme = theme,
iconStyle = iconStyle[1],
indentWidth = indentWidth,
collapsed = collapsed,
collapseStringsAfterLength = collapseStringsAfterLength,
groupArraysAfterLength = groupArraysAfterLength,
enableClipboard = enableClipboard,
displayObjectSize = displayObjectSize,
displayDataTypes = displayDataTypes,
onEdit = onEdit,
onAdd = onAdd,
onDelete = onDelete,
onSelect = onSelect,
sortKeys = sortKeys
)

# create widget
Expand All @@ -52,7 +106,7 @@ reactjson <- function(
reactR::html_dependency_react(),
htmltools::htmlDependency(
name = "react-json-view",
version = "1.16.1",
version = "2.5.7",
src = system.file("htmlwidgets/reactjson/dist", package="listviewer"),
script = "main.js",
all_files = FALSE
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ reactjson(

### Shiny example

`listviewer` works with `Shiny` but the implementation is crude and likely to change. Here is an example. If you really want to use it, I would recommend `debouncing` the `change` callback.
`listviewer` works with `Shiny` but the implementation is crude and likely to change for `jsonedit` while `reactjson` integration is much better. If you really want to use `jsonedit` with `Shiny`, I would recommend `debouncing` the `change` callback. Here are examples with each.

```r
library(shiny)
Expand Down Expand Up @@ -137,6 +137,33 @@ runApp( list( ui = ui, server = server ) )

```

```r
library(shiny)
library(listviewer)

# put some data in environment so it will show up
data(mtcars)

ui <- shinyUI(
fluidPage(
reactjsonOutput( "rjed" )
)
)

server <- function(input,output){
output$rjed <- renderReactjson({
reactjson( as.list( .GlobalEnv ) )
})

observeEvent(input$rjed_edit, {
str(input$rjed_edit, max.level=2)
})
}

runApp( list( ui = ui, server = server ) )

```


### code of conduct

Expand Down
2 changes: 1 addition & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Test environments
* local Windows 10 install, R 3.4.3
* ubuntu (on travis-ci), R 3.2.3
* ubuntu (on travis-ci), R 3.5.1
* rhub check_for_cran

## R CMD check results
Expand Down
25 changes: 24 additions & 1 deletion docs/index.html

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

12 changes: 12 additions & 0 deletions docs/news/index.html

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

2 changes: 1 addition & 1 deletion docs/reference/index.html

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

12 changes: 7 additions & 5 deletions docs/reference/jsonedit.html

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

3 changes: 1 addition & 2 deletions docs/reference/number_unnamed.html

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

78 changes: 76 additions & 2 deletions docs/reference/reactjson.html

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

2 changes: 1 addition & 1 deletion inst/htmlwidgets/jsonedit.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: jsoneditor
version: 5.5.5
version: 5.25.6
src: htmlwidgets/jsoneditor/dist
script: jsoneditor.min.js
stylesheet: jsoneditor.min.css
Loading

0 comments on commit 107e5cb

Please sign in to comment.