Skip to content

Commit 0f992e4

Browse files
add minified argument to html_dependency_vue for debugging and Vue tools
update to Vue `2.1.4` change tree example by removing now-gone json filter and using minified = FALSE
1 parent adce451 commit 0f992e4

File tree

9 files changed

+8265
-16
lines changed

9 files changed

+8265
-16
lines changed

R/dependencies.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#'
33
#' @param offline \code{logical} to use local file dependencies. If \code{FALSE},
44
#' then the dependencies use cdn as its \code{src}.
5+
#' @param minified \code{logical} to use minified (production) version. Use
6+
#' \code{minified = FALSE} for debugging or working with Vue devtools.
57
#'
68
#' @return \code{\link[htmltools]{htmlDependency}}
79
#' @importFrom htmltools htmlDependency
@@ -27,17 +29,21 @@
2729
#' ),
2830
#' html_dependency_vue()
2931
#' )
30-
html_dependency_vue <- function(offline=TRUE){
32+
html_dependency_vue <- function(offline=TRUE, minified=TRUE){
3133
hd <- htmltools::htmlDependency(
3234
name = "vue",
3335
version = vue_version(),
3436
src = system.file("www/vue/dist",package="vueR"),
35-
script = c("vue.min.js")
37+
script = "vue.min.js"
3638
)
3739

40+
if(!minified) {
41+
hd$script <- "vue.js"
42+
}
43+
3844
if(!offline) {
3945
hd$src <- list(href=sprintf(
40-
"//cdnjs.cloudflare.com/ajax/libs/vue/%s",
46+
"//unpkg.com/vue/dist",
4147
vue_version()
4248
))
4349
}

R/meta.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#'@keywords internal
2-
vue_version <- function(){'2.1.3'}
2+
vue_version <- function(){'2.1.4'}

R/vue.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@
1010
#' this will not currently have any impact
1111
#' @param elementId \code{character} id of the htmlwidget container
1212
#' element
13+
#' @param minified \code{logical} to indicate minified (\code{minified=TRUE}) or
14+
#' non-minified (\code{minified=FALSE}) Vue.js
1315
#'
1416
#' @import htmlwidgets
1517
#'
1618
#' @export
1719
#' @example ./inst/examples/vue_widget_examples.R
1820
#' @return vue htmlwidget
1921

20-
vue <- function(app = list(), width = NULL, height = NULL, elementId = NULL) {
22+
vue <- function(
23+
app = list(),
24+
width = NULL, height = NULL, elementId = NULL,
25+
minified = TRUE
26+
) {
2127

2228
# forward options using x
2329
x = app
@@ -33,7 +39,7 @@ vue <- function(app = list(), width = NULL, height = NULL, elementId = NULL) {
3339
)
3440

3541
hw$dependencies <- list(
36-
html_dependency_vue(offline=TRUE)
42+
html_dependency_vue(offline=TRUE, minified=minified)
3743
)
3844

3945
hw

build/getvue.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ download.file(
1919
destfile="./inst/www/vue/dist/vue.min.js"
2020
)
2121

22+
download.file(
23+
url=sprintf(
24+
"https://unpkg.com/vue@%s/dist/vue.js",
25+
get_vue_latest()
26+
),
27+
destfile="./inst/www/vue/dist/vue.js"
28+
)
29+
2230
# write function with newest version
2331
# for use when creating dependencies
2432
cat(

inst/examples/vue_component_examples.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,22 @@ tl_tree <- tagList(
187187
"el-tree",
188188
list(
189189
"ref" = "mytree",
190-
":data" = "data",
190+
":data" = "data.children",
191191
":props" = "defaultProps",
192192
"show-checkbox" = NA,
193193
"@check-change" = "handleCheckChange"
194194
)
195195
),
196-
tags$pre("{{checkedNodes.map(function(d){return d.name}) | json}}")
196+
tags$pre("{{checkedNodes.map(function(d){return d.name})}}")
197197
),
198198
vue(
199199
list(
200200
el="#app",
201201
data = list(
202202
data = d3r::d3_nest(
203203
rhd,
204-
value_cols="x"
204+
value_cols="x",
205+
205206
),
206207
defaultProps = list(
207208
'children' = 'children',
@@ -221,7 +222,8 @@ function(data, checked, indeterminate){
221222
"
222223
)
223224
)
224-
)
225+
),
226+
minified = FALSE
225227
)
226228
)
227229

0 commit comments

Comments
 (0)