1515# '
1616# ' @import htmlwidgets
1717# '
18+ # ' @family htmlwidget
1819# ' @export
1920# ' @example ./inst/examples/vue_widget_examples.R
2021# ' @return vue htmlwidget
@@ -45,6 +46,56 @@ vue <- function(
4546 hw
4647}
4748
49+ # ' 'Vue.js 3' 'htmlwidget'
50+ # '
51+ # ' Use 'Vue.js 3' with the convenience and flexibility of 'htmlwidgets'.
52+ # ' \code{vue3} is a little different from other 'htmlwidgets' though
53+ # ' since it requires specification of the HTML tags/elements separately.
54+ # '
55+ # ' @param app \code{list} with \code{el} and \code{data} and other pieces
56+ # ' of a 'Vue.js 3' app
57+ # ' @param width,height any valid \code{CSS} size unit, but in reality
58+ # ' this will not currently have any impact
59+ # ' @param elementId \code{character} id of the htmlwidget container
60+ # ' element
61+ # ' @param minified \code{logical} to indicate minified (\code{minified=TRUE}) or
62+ # ' non-minified (\code{minified=FALSE}) Vue.js
63+ # '
64+ # ' @import htmlwidgets
65+ # '
66+ # ' @family htmlwidget
67+ # ' @export
68+ # ' @example ./inst/examples/vue3_widget_examples.R
69+ # ' @return vue htmlwidget
70+
71+ vue3 <- function (
72+ app = list (),
73+ width = NULL , height = NULL , elementId = NULL ,
74+ minified = TRUE
75+ ) {
76+
77+ # forward options using x
78+ x = app
79+
80+ # will try to convert data that is not a function in widget JS
81+
82+ # create widget
83+ hw <- htmlwidgets :: createWidget(
84+ name = ' vue3' ,
85+ x ,
86+ width = width ,
87+ height = height ,
88+ package = ' vueR' ,
89+ elementId = elementId
90+ )
91+
92+ hw $ dependencies <- list (
93+ html_dependency_vue3(offline = TRUE , minified = minified )
94+ )
95+
96+ hw
97+ }
98+
4899# ' Shiny bindings for vue
49100# '
50101# ' Output and render functions for using vue within Shiny
@@ -62,6 +113,7 @@ vue <- function(
62113# ' @name vue-shiny
63114# '
64115# ' @export
116+ # ' @example ./inst/examples/vue3_shiny_examples.R
65117vueOutput <- function (outputId , width = ' 100%' , height = ' 400px' ){
66118 htmlwidgets :: shinyWidgetOutput(outputId , ' vue' , width , height , package = ' vueR' )
67119}
@@ -72,3 +124,32 @@ renderVue <- function(expr, env = parent.frame(), quoted = FALSE) {
72124 if (! quoted ) { expr <- substitute(expr ) } # force quoted
73125 htmlwidgets :: shinyRenderWidget(expr , vueOutput , env , quoted = TRUE )
74126}
127+
128+
129+ # ' Shiny bindings for 'vue 3'
130+ # '
131+ # ' Output and render functions for using 'vue 3' within Shiny
132+ # ' applications and interactive Rmd documents.
133+ # '
134+ # ' @param outputId output variable to read from
135+ # ' @param width,height Must be a valid CSS unit (like \code{'100\%'},
136+ # ' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a
137+ # ' string and have \code{'px'} appended.
138+ # ' @param expr An expression that generates a vue
139+ # ' @param env The environment in which to evaluate \code{expr}.
140+ # ' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
141+ # ' is useful if you want to save an expression in a variable.
142+ # '
143+ # ' @name vue-shiny
144+ # '
145+ # ' @export
146+ vue3Output <- function (outputId , width = ' 100%' , height = ' 400px' ){
147+ htmlwidgets :: shinyWidgetOutput(outputId , ' vue3' , width , height , package = ' vueR' )
148+ }
149+
150+ # ' @rdname vue-shiny
151+ # ' @export
152+ renderVue3 <- function (expr , env = parent.frame(), quoted = FALSE ) {
153+ if (! quoted ) { expr <- substitute(expr ) } # force quoted
154+ htmlwidgets :: shinyRenderWidget(expr , vueOutput , env , quoted = TRUE )
155+ }
0 commit comments