From 6b0034c65f1632c872d21ab74256772b44c97a3d Mon Sep 17 00:00:00 2001 From: pvictor Date: Mon, 11 Nov 2019 18:34:41 +0100 Subject: [PATCH] remove unnecessary refresh in picker bindings --- R/input-selectpicker.R | 161 +---------- examples/picker-limits.R | 54 ++++ examples/picker-select-all.R | 45 ++++ examples/picker-value-display.R | 66 +++++ inst/assets/selectPicker/picker-bindings.js | 2 +- inst/assets/shinyWidgets-bindings.min.js | 2 +- man/pickerInput.Rd | 280 +++++++++++--------- 7 files changed, 331 insertions(+), 279 deletions(-) create mode 100644 examples/picker-limits.R create mode 100644 examples/picker-select-all.R create mode 100644 examples/picker-value-display.R diff --git a/R/input-selectpicker.R b/R/input-selectpicker.R index f2e3e1c7..4b74577a 100644 --- a/R/input-selectpicker.R +++ b/R/input-selectpicker.R @@ -30,168 +30,31 @@ #' shinyWidgetsGallery() #' #' -#' # Simple example +#' # Basic usage #' library("shiny") -#' ui <- fluidPage( -#' pickerInput(inputId = "somevalue", label = "A label", choices = c("a", "b")), -#' verbatimTextOutput("value") -#' ) -#' server <- function(input, output) { -#' output$value <- renderPrint({ input$somevalue }) -#' } -#' shinyApp(ui, server) -#' -#' -#' ### Add actions box for selecting -#' # deselecting all options -#' -#' library("shiny") -#' library("shinyWidgets") -#' -#' ui <- fluidPage( -#' br(), -#' pickerInput( -#' inputId = "p1", -#' label = "Select all option", -#' choices = rownames(mtcars), -#' multiple = TRUE, -#' options = list(`actions-box` = TRUE) -#' ), -#' br(), -#' pickerInput( -#' inputId = "p2", -#' label = "Select all option / custom text", -#' choices = rownames(mtcars), -#' multiple = TRUE, -#' options = list( -#' `actions-box` = TRUE, -#' `deselect-all-text` = "None...", -#' `select-all-text` = "Yeah, all !", -#' `none-selected-text` = "zero" -#' ) -#' ) -#' ) -#' -#' server <- function(input, output, session) { -#' -#' } -#' -#' shinyApp(ui = ui, server = server) -#' -#' -#' -#' ### Customize the values displayed in the box ---- -#' -#' library("shiny") -#' library("shinyWidgets") +#' library(shinyWidgets) #' #' ui <- fluidPage( -#' br(), #' pickerInput( -#' inputId = "p1", -#' label = "Default", -#' multiple = TRUE, -#' choices = rownames(mtcars), -#' selected = rownames(mtcars)[1:5] +#' inputId = "somevalue", +#' label = "A label", +#' choices = c("a", "b") #' ), -#' br(), -#' pickerInput( -#' inputId = "p1b", -#' label = "Default with | separator", -#' multiple = TRUE, -#' choices = rownames(mtcars), -#' selected = rownames(mtcars)[1:5], -#' options = list(`multiple-separator` = " | ") -#' ), -#' br(), -#' pickerInput( -#' inputId = "p2", -#' label = "Static", -#' multiple = TRUE, -#' choices = rownames(mtcars), -#' selected = rownames(mtcars)[1:5], -#' options = list(`selected-text-format`= "static", -#' title = "Won't change") -#' ), -#' br(), -#' pickerInput( -#' inputId = "p3", -#' label = "Count", -#' multiple = TRUE, -#' choices = rownames(mtcars), -#' selected = rownames(mtcars)[1:5], -#' options = list(`selected-text-format`= "count") -#' ), -#' br(), -#' pickerInput( -#' inputId = "p3", -#' label = "Customize count", -#' multiple = TRUE, -#' choices = rownames(mtcars), -#' selected = rownames(mtcars)[1:5], -#' options = list( -#' `selected-text-format`= "count", -#' `count-selected-text` = "{0} models choosed (on a total of {1})" -#' ) -#' ) +#' verbatimTextOutput("value") #' ) #' -#' server <- function(input, output, session) { -#' -#' } -#' -#' shinyApp(ui = ui, server = server) -#' -#' -#' -#' ### Limit the number of selections ---- -#' -#' library(shiny) -#' library(shinyWidgets) -#' ui <- fluidPage( -#' pickerInput( -#' inputId = "groups", -#' label = "Select one from each group below:", -#' choices = list( -#' Group1 = c("1", "2", "3", "4"), -#' Group2 = c("A", "B", "C", "D") -#' ), -#' multiple = TRUE, -#' options = list("max-options-group" = 1) -#' ), -#' verbatimTextOutput(outputId = "res_grp"), -#' pickerInput( -#' inputId = "groups_2", -#' label = "Select two from each group below:", -#' choices = list( -#' Group1 = c("1", "2", "3", "4"), -#' Group2 = c("A", "B", "C", "D") -#' ), -#' multiple = TRUE, -#' options = list("max-options-group" = 2) -#' ), -#' verbatimTextOutput(outputId = "res_grp_2"), -#' pickerInput( -#' inputId = "classic", -#' label = "Select max two option below:", -#' choices = c("A", "B", "C", "D"), -#' multiple = TRUE, -#' options = list( -#' "max-options" = 2, -#' "max-options-text" = "No more!" -#' ) -#' ), -#' verbatimTextOutput(outputId = "res_classic") -#' ) #' server <- function(input, output) { -#' output$res_grp <- renderPrint(input$groups) -#' output$res_grp_2 <- renderPrint(input$groups_2) -#' output$res_classic <- renderPrint(input$classic) +#' output$value <- renderPrint(input$somevalue) #' } +#' #' shinyApp(ui, server) #' #' } #' +#' @example examples/picker-select-all.R +#' @example examples/picker-value-display.R +#' @example examples/picker-limits.R +#' #' @importFrom shiny restoreInput #' @importFrom htmltools tags htmlEscape validateCssUnit #' tagAppendAttributes tagAppendChildren tag diff --git a/examples/picker-limits.R b/examples/picker-limits.R new file mode 100644 index 00000000..d8804aa1 --- /dev/null +++ b/examples/picker-limits.R @@ -0,0 +1,54 @@ +### Limit the number of selections ---- + +if (interactive()) { + + library(shiny) + library(shinyWidgets) + + ui <- fluidPage( + pickerInput( + inputId = "groups", + label = "Select one from each group below:", + choices = list( + Group1 = c("1", "2", "3", "4"), + Group2 = c("A", "B", "C", "D") + ), + multiple = TRUE, + options = list("max-options-group" = 1) + ), + verbatimTextOutput(outputId = "res_grp"), + pickerInput( + inputId = "groups_2", + label = "Select two from each group below:", + choices = list( + Group1 = c("1", "2", "3", "4"), + Group2 = c("A", "B", "C", "D") + ), + multiple = TRUE, + options = list("max-options-group" = 2) + ), + verbatimTextOutput(outputId = "res_grp_2"), + pickerInput( + inputId = "classic", + label = "Select max two option below:", + choices = c("A", "B", "C", "D"), + multiple = TRUE, + options = list( + "max-options" = 2, + "max-options-text" = "No more!" + ) + ), + verbatimTextOutput(outputId = "res_classic") + ) + + server <- function(input, output) { + + output$res_grp <- renderPrint(input$groups) + output$res_grp_2 <- renderPrint(input$groups_2) + output$res_classic <- renderPrint(input$classic) + + } + + shinyApp(ui, server) + +} diff --git a/examples/picker-select-all.R b/examples/picker-select-all.R new file mode 100644 index 00000000..e6b48483 --- /dev/null +++ b/examples/picker-select-all.R @@ -0,0 +1,45 @@ +### Add actions box for selecting ---- +### deselecting all options + +if (interactive()) { + + library(shiny) + library(shinyWidgets) + + ui <- fluidPage( + tags$h2("Select / Deselect all"), + pickerInput( + inputId = "p1", + label = "Select all option", + choices = rownames(mtcars), + multiple = TRUE, + options = list(`actions-box` = TRUE) + ), + verbatimTextOutput("r1"), + br(), + pickerInput( + inputId = "p2", + label = "Select all option / custom text", + choices = rownames(mtcars), + multiple = TRUE, + options = list( + `actions-box` = TRUE, + `deselect-all-text` = "None...", + `select-all-text` = "Yeah, all !", + `none-selected-text` = "zero" + ) + ), + verbatimTextOutput("r2") + ) + + server <- function(input, output, session) { + + output$r1 <- renderPrint(input$p1) + output$r2 <- renderPrint(input$p2) + + } + + shinyApp(ui = ui, server = server) + +} + diff --git a/examples/picker-value-display.R b/examples/picker-value-display.R new file mode 100644 index 00000000..f0aba7a9 --- /dev/null +++ b/examples/picker-value-display.R @@ -0,0 +1,66 @@ +### Customize the values displayed in the box ---- + +if (interactive()) { + + library(shiny) + library(shinyWidgets) + + ui <- fluidPage( + br(), + pickerInput( + inputId = "p1", + label = "Default", + multiple = TRUE, + choices = rownames(mtcars), + selected = rownames(mtcars)[1:5] + ), + br(), + pickerInput( + inputId = "p1b", + label = "Default with | separator", + multiple = TRUE, + choices = rownames(mtcars), + selected = rownames(mtcars)[1:5], + options = list(`multiple-separator` = " | ") + ), + br(), + pickerInput( + inputId = "p2", + label = "Static", + multiple = TRUE, + choices = rownames(mtcars), + selected = rownames(mtcars)[1:5], + options = list(`selected-text-format`= "static", + title = "Won't change") + ), + br(), + pickerInput( + inputId = "p3", + label = "Count", + multiple = TRUE, + choices = rownames(mtcars), + selected = rownames(mtcars)[1:5], + options = list(`selected-text-format`= "count") + ), + br(), + pickerInput( + inputId = "p3", + label = "Customize count", + multiple = TRUE, + choices = rownames(mtcars), + selected = rownames(mtcars)[1:5], + options = list( + `selected-text-format`= "count", + `count-selected-text` = "{0} models choosed (on a total of {1})" + ) + ) + ) + + server <- function(input, output, session) { + + } + + shinyApp(ui = ui, server = server) + +} + diff --git a/inst/assets/selectPicker/picker-bindings.js b/inst/assets/selectPicker/picker-bindings.js index e29c20ef..bf63f481 100644 --- a/inst/assets/selectPicker/picker-bindings.js +++ b/inst/assets/selectPicker/picker-bindings.js @@ -61,7 +61,7 @@ var pickerInputBinding = new Shiny.InputBinding(); }, subscribe: function subscribe(el, callback) { $(el).on('changed.bs.select', function (event) { - $(el).selectpicker('refresh'); + //$(el).selectpicker('refresh'); callback(); }); }, diff --git a/inst/assets/shinyWidgets-bindings.min.js b/inst/assets/shinyWidgets-bindings.min.js index 2c46867e..ec6d3edf 100644 --- a/inst/assets/shinyWidgets-bindings.min.js +++ b/inst/assets/shinyWidgets-bindings.min.js @@ -1 +1 @@ -var AirPickerInputBinding=new Shiny.InputBinding;function getFormattedDate(e){var n=e.getFullYear(),t=e.getMonth()+1,i=e.getDate();return t>9?i>9?n+"-"+t+"-"+i:n+"-"+t+"-0"+i:i>9?n+"-0"+t+"-"+i:n+"-0"+t+"-0"+i}$.extend(AirPickerInputBinding,{initialize:function(e){var n,t={},i={};if($(e).attr("data-start-date")){for(var a=JSON.parse($(e).attr("data-start-date")),r=[],o=0;o0?"false"===t?n.map((function(e){return(n=e)instanceof Date?n.getFullYear()+"-"+i(n.getMonth()+1,2)+"-"+i(n.getDate(),2):null;var n})):n.map((function(e){return e.valueOf()})):null},setValue:function(e,n){n=JSON.parse(n);for(var t=[],i=0;i9?"":"0")+e,(n>9?"":"0")+n].join("-")};var $escapeAw=(exportsAw=window.Shiny=window.Shiny||{}).$escape=function(e){return e.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")},awesomeCheckboxBinding=new Shiny.InputBinding;$.extend(awesomeCheckboxBinding,{find:function(e){return $(e).find(".awesome-checkbox-class")},getId:function(e){return e.id},getValue:function(e){return $('input:checkbox[name="'+$escapeAw(e.id)+'"]:checked').val()},setValue:function(e,n){$('input:checkbox[name="'+$escapeAw(e.id)+'"][value="'+$escapeAw(n)+'"]').prop("checked",!0)},subscribe:function(e,n){$(e).on("change.awesomeCheckboxBinding",(function(e){n()}))},unsubscribe:function(e){$(e).off(".awesomeCheckboxBinding")},getState:function(e){for(var n=$('input:checkbox[name="'+$escapeAw(e.id)+'"]'),t=new Array(n.length),i=0;i?@\[\\\]^`{|}~])/g,"\\$1")};var exportsAw,awesomeRadioBinding=new Shiny.InputBinding;$.extend(awesomeRadioBinding,{find:function(e){return $(e).find(".awesome-radio-class")},getId:function(e){return e.id},getValue:function(e){return $('input:radio[name="'+$escapeAw(e.id)+'"]:checked').val()},setValue:function(e,n){$('input:radio[name="'+$escapeAw(e.id)+'"][value="'+$escapeAw(n)+'"]').prop("checked",!0)},subscribe:function(e,n){$(e).on("change.awesomeRadioBinding",(function(e){n()}))},unsubscribe:function(e){$(e).off(".awesomeRadioBinding")},getState:function(e){for(var n=$('input:radio[name="'+$escapeAw(e.id)+'"]'),t=new Array(n.length),i=0;i?@\[\\\]^`{|}~])/g,"\\$1")},checkboxGroupButtonsBinding=new Shiny.InputBinding;$.extend(checkboxGroupButtonsBinding,{find:function(e){return $(e).find(".checkboxGroupButtons")},getId:function(e){return e.id},getValue:function(e){for(var n=$('input:checkbox[name="'+$escape4but(e.id)+'"]:checked'),t=new Array(n.length),i=0;i?@\[\\\]^`{|}~])/g,"\\$1")};function tron_skin(){if("tron"==this.$.data("skin")){this.cursorExt=.3;var e,n=this.arc(this.cv);return this.g.lineWidth=this.lineWidth,this.o.displayPrevious&&(e=this.arc(this.v),this.g.beginPath(),this.g.strokeStyle=this.pColor,this.g.arc(this.xy,this.xy,this.radius-this.lineWidth,e.s,e.e,e.d),this.g.stroke()),this.g.beginPath(),this.g.strokeStyle=this.o.fgColor,this.g.arc(this.xy,this.xy,this.radius-this.lineWidth,n.s,n.e,n.d),this.g.stroke(),this.g.lineWidth=2,this.g.beginPath(),this.g.strokeStyle=this.o.fgColor,this.g.arc(this.xy,this.xy,this.radius-this.lineWidth+1+2*this.lineWidth/3,0,2*Math.PI,!1),this.g.stroke(),!1}}var knobInputBinding=new Shiny.InputBinding;$.extend(knobInputBinding,{find:function(e){return $(e).find(".knob-input")},initialize:function(e){var n=$(e).data("value");e.value=n,$(e).knob({draw:tron_skin})},getValue:function(e){return parseFloat(e.value)},subscribe:function(e,n){$(e).data("immediate")?($(e).on("keyup.knobInputBinding",(function(e){n(!0)})),$(e).trigger("configure",{change:function(e){n(!1)},release:function(e){n(!1)}}),$(e).on("change.knobInputBinding",(function(e){n(!1)}))):($(e).on("keyup.knobInputBinding",(function(e){n(!0)})),$(e).trigger("configure",{release:function(e){n(!0)}}))},unsubscribe:function(e){$(e).off(".knobInputBinding")},receiveMessage:function(e,n){n.hasOwnProperty("value")&&$(e).val(n.value).trigger("change"),n.hasOwnProperty("readOnly")&&$(e).trigger("configure",{readOnly:n.readOnly}),n.hasOwnProperty("options")&&$(e).trigger("configure",n.options),n.hasOwnProperty("label")&&$(e).parent().parent().find('label[for="'+$escapeKnob(e.id)+'"]').text(n.label),$(e).trigger("change")},getState:function(e){return{label:$(e).parent().parent().find('label[for="'+$escapeKnob(e.id)+'"]').text(),value:e.value}},getRatePolicy:function(){return{policy:"debounce",delay:500}}}),Shiny.inputBindings.register(knobInputBinding,"shiny.knobInput");var exportsMulti=window.Shiny=window.Shiny||{},$escapeMulti=exportsMulti.$escape=function(e){return e.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")},multiInputBinding=new Shiny.InputBinding;$.extend(multiInputBinding,{initialize:function(e){var n=$(e).parent().find('script[data-for="'+$escapeMulti(e.id)+'"]');n=JSON.parse(n.html()),$(e).multi(n),$(e).trigger("change")},find:function(e){return $(e).find(".multijs")},getId:function(e){return e.id},getValue:function(e){return $(e).val()},setValue:function(e,n){$(e).val(n),$(e).multi(),$(e).trigger("change")},getState:function(e){for(var n=new Array(e.length),t=0;t?@\[\\\]^`{|}~])/g,"\\$1")},noUiSliderBinding=new Shiny.InputBinding;$.extend(noUiSliderBinding,{find:function(e){return $(e).find(".sw-no-ui-slider")},getId:function(e){return e.id},getType:function(e){var n=$(e).data("data-type");return"date"===n?"shiny.date":"datetime"===n&&"shiny.datetime"},getValue:function(e){var n,t=document.getElementById(e.id).noUiSlider.get(),i=$(e).parent().find('script[data-for="'+$escapenoUi(e.id)+'"]');return void 0!==(i=JSON.parse(i.html())).format?(numformat=wNumb(i.format),n=Array.isArray(t)?t.map(numformat.from):numformat.from(t)):n=Array.isArray(t)?t.map(Number):Number(t),n},setValue:function(e,n){document.getElementById(e.id).noUiSlider.set(n)},subscribe:function(e,n){var t=document.getElementById(e.id);"end"==$("#"+e.id).data("update")?(t.noUiSlider.on("change",(function(e){n()})),t.noUiSlider.on("set",(function(e){n()}))):(t.noUiSlider.on("slide",(function(e){n()})),t.noUiSlider.on("set",(function(e){n()})))},unsubscribe:function(e){$(e).off(".noUiSliderBinding")},receiveMessage:function(e,n){var t=document.getElementById(e.id);n.disable?t.setAttribute("disabled",!0):t.removeAttribute("disabled"),n.hasOwnProperty("range")&&t.noUiSlider.updateOptions({range:{min:n.range[0],max:n.range[1]}}),t.noUiSlider.set(n.value),$(e).trigger("change")},getRatePolicy:function(){return{policy:"debounce",delay:250}},getState:function(e){},initialize:function(e){var n=$(e).parent().find('script[data-for="'+$escapenoUi(e.id)+'"]');void 0!==(n=JSON.parse(n.html())).format&&(n.format=wNumb(n.format));var t=document.getElementById(e.id);"vertical"===n.orientation&&(t.style.margin="0 auto 30px"),noUiSlider.create(t,n)}}),Shiny.inputBindings.register(noUiSliderBinding,"shiny.noUiSlider");var numericRangeInputBinding=new Shiny.InputBinding;$.extend(numericRangeInputBinding,{find:function(e){return $(e).find(".shiny-numeric-range-input")},getValue:function(e){var n=$(e).find("input"),t=n[0].value,i=n[1].value;return[t=/^\s*$/.test(t)?null:isNaN(t)?t:+t,i=/^\s*$/.test(i)?null:isNaN(i)?i:+i]},setValue:function(e,n){e.find("input")[0].value=n[0],e.find("input")[1].value=n[1]},subscribe:function(e,n){$(e).on("change.numericRangeInputBinding",(function(e){n()}))},receiveMessage:function(e,n){var t=$(e);n.hasOwnProperty("value")&&(t.find("input")[0].value=n.value[0]),t.find("input")[1].value=n.value[1],$(e).trigger("change")},unsubscribe:function(e){$(e).off(".numericRangeInputBinding")}}),Shiny.inputBindings.register(numericRangeInputBinding,"wd.numericRangeInputBin"),Shiny.addCustomMessageHandler("update-progressBar-shinyWidgets",(function(e){var n,t=e.id,i=e.total,a=Math.round(e.value);i>0?(n=Math.round(a/i*100),$("#"+t+"-value").text(a),$("#"+t+"-total").text(i),a=Math.round(a/i*100)):n=e.percent>0?e.percent:a,$("#"+t).css("width",n+"%"),""!==$("#"+t).text()&&$("#"+t).text(a+e.unit_mark),null!==e.status&&($("#"+t).removeClass(),$("#"+t).addClass("progress-bar progress-bar-"+e.status)),null!==e.title&&$("#"+t+"-title").text(e.title)}));$escape4but=(exports4but=window.Shiny=window.Shiny||{}).$escape=function(e){return e.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")};var exports4but,radioGroupButtonsBinding=new Shiny.InputBinding;$.extend(radioGroupButtonsBinding,{find:function(e){return $(e).find(".radioGroupButtons")},getId:function(e){return e.id},getValue:function(e){return $('input:radio[name="'+$escape4but(e.id)+'"]:checked').val()},setValue:function(e,n){$('input:radio[name="'+$escape4but(e.id)+'"][value="'+$escape4but(n)+'"]').prop("checked",!0),$('input:radio[name="'+$escape4but(e.id)+'"]').parent().removeClass("active"),$('input:radio[name="'+$escape4but(e.id)+'"][value="'+$escape4but(n)+'"]').parent().addClass("active")},subscribe:function(e,n){$(e).on("change.radioGroupButtonsBinding",(function(e){n()}))},unsubscribe:function(e){$(e).off(".radioGroupButtonsBinding")},getState:function(e){for(var n=$('input:radio[name="'+$escape4but(e.id)+'"]'),t=new Array(n.length),i=0;i?@\[\\\]^`{|}~])/g,"\\$1")},searchInputBinding=new Shiny.InputBinding;$.extend(searchInputBinding,{find:function(e){return $(e).find(".search-text")},getId:function(e){return $(e).attr("id")},getValue:function(e){return $("#"+$escapeSearch(e.id)+"_text").val()},setValue:function(e,n){$("#"+$escapeSearch(e.id)+"_text").val(n)},subscribe:function(e,n){$("#"+$escapeSearch(e.id)+"_text").on("keyup.searchInputBinding input.searchInputBinding",(function(e){13==e.keyCode&&n()})),$("#"+$escapeSearch(e.id)+"_search").on("click",(function(e){n()})),$("#"+$escapeSearch(e.id)+"_reset").on("click",(function(t){if("TRUE"==$("#"+$escapeSearch(e.id)).data("reset")){var i=$("#"+$escapeSearch(e.id)).data("reset-value");$("#"+$escapeSearch(e.id)+"_text").val(i)}n()}))},unsubscribe:function(e){$(e).off(".searchInputBinding")},receiveMessage:function(e,n){n.hasOwnProperty("value")&&this.setValue(e,n.value),n.hasOwnProperty("label")&&$(e).parent().find('label[for="'+e.id+'"]').text(n.label),n.hasOwnProperty("placeholder")&&($("#"+e.id+"_text")[0].placeholder=n.placeholder),n.trigger&&$("#"+e.id+"_search").click(),$(e).trigger("change")},getState:function(e){return{value:this.getValue(e)}},getRatePolicy:function(){return{policy:"debounce",delay:250}}}),Shiny.inputBindings.register(searchInputBinding,"shiny.searchInput");var exportsPicker=window.Shiny=window.Shiny||{},$escapePicker=exportsPicker.$escape=function(e){return e.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")},pickerInputBinding=new Shiny.InputBinding;function forceIonSliderTextUpdate(e){e.$cache&&e.$cache.input?e.$cache.input.trigger("change"):console.log("Couldn't force ion slider to update")}$.extend(pickerInputBinding,{find:function(e){return $(e).find(".selectpicker")},getId:function(e){return e.id},getValue:function(e){return $(e).val()},setValue:function(e,n){$(e).val(n),$(e.id).selectpicker("refresh")},getState:function(e){for(var n=new Array(e.length),t=0;t?@\[\\\]^`{|}~])/g,"\\$1")},sliderTextBinding=new Shiny.InputBinding;$.extend(sliderTextBinding,{find:function(e){return $.fn.ionRangeSlider?$(e).find(".sw-slider-text"):[]},getType:function(e){var n=$(e).data("data-type");return"date"===n?"shiny.date":"datetime"===n&&"shiny.datetime"},getValue:function(e){var n=$(e).data("ionRangeSlider"),t=n.result,i=n.options.values;return 2===this._numValues(e)?[i[t.from],i[t.to]]:i[t.from]},setValue:function(e,n){var t=$(e),i=t.data("ionRangeSlider");t.data("immediate",!0);try{2===this._numValues(e)&&n instanceof Array?i.update({from:n[0],to:n[1]}):i.update({from:n}),forceIonSliderTextUpdate(i)}finally{t.data("immediate",!1)}},subscribe:function(e,n){$(e).on("change.sliderInputBinding",(function(t){n(!$(e).data("immediate")&&!$(e).data("animating"))}))},unsubscribe:function(e){$(e).off(".sliderInputBinding")},receiveMessage:function(e,n){var t=$(e),i=t.data("ionRangeSlider"),a={},r=i.options.values;n.hasOwnProperty("choices")&&(a.values=n.choices,r=n.choices),n.hasOwnProperty("selected")&&(2===this._numValues(e)&&n.selected instanceof Array?(a.from=r.indexOf(n.selected[0]),a.to=r.indexOf(n.selected[1])):a.from=r.indexOf(n.selected)),n.hasOwnProperty("from_fixed")&&(a.from_fixed=n.from_fixed),n.hasOwnProperty("to_fixed")&&(a.to_fixed=n.to_fixed),n.hasOwnProperty("label")&&t.parent().find('label[for="'+$escapeST(e.id)+'"]').text(n.label),t.data("immediate",!0);try{i.update(a),forceIonSliderTextUpdate(i)}finally{t.data("immediate",!1)}},getRatePolicy:function(){return{policy:"debounce",delay:250}},getState:function(e){},initialize:function(e){var n={},t=$(e),i=$(e).data("swvalues");n.values=i,t.ionRangeSlider(n)},_numValues:function(e){return"double"===$(e).data("ionRangeSlider").options.type?2:1}}),Shiny.inputBindings.register(sliderTextBinding,"shiny.sliderText");var spectrumInputBinding=new Shiny.InputBinding;$.extend(spectrumInputBinding,{find:function(e){return $(e).find(".sw-spectrum")},getId:function(e){return $(e).attr("id")},getValue:function(e){return $(e).spectrum("get").toHexString()},setValue:function(e,n){$(e).spectrum("set",n)},subscribe:function(e,n){$(e).on("change",(function(e){n()}))},unsubscribe:function(e){$(e).off(".spectrumInputBinding")},receiveMessage:function(e,n){n.hasOwnProperty("value")&&this.setValue(e,n.value),$(e).trigger("change")},getState:function(e){return{value:this.getValue(e)}},initialize:function(e){var n={},t=$(e).attr("data-update-on");$(e).removeAttr("data-update-on"),"dragstop"==t&&$(e).on("dragstop.spectrum",(function(n){$(e).trigger("change")})),"move"==t&&(n.move=function(){$(e).trigger("change")}),"change"==t&&(n.change=function(){$(e).trigger("change")}),$(e).spectrum(n)},getRatePolicy:function(){return{policy:"debounce",delay:250}}}),Shiny.inputBindings.register(spectrumInputBinding,"shiny.spectrumInput"),Shiny.addCustomMessageHandler("sweetalert-sw",(function(e){if(e.as_html){var n=document.createElement("span");n.innerHTML=e.text,e.html=n,Swal.fire(e).then((function(n){$("#"+e.sw_id).each((function(e,n){return window.Shiny.unbindAll(n,!0),$(n).remove(),!0}))}))}else Swal.fire(e)})),Shiny.addCustomMessageHandler("sweetalert-sw-confirm",(function(e){Shiny.onInputChange(e.id,null),e.as_html?Swal.fire(e.swal).then((function(n){n.value?Shiny.onInputChange(e.id,!0):Shiny.onInputChange(e.id,!1),$("#"+e.sw_id).each((function(e,n){return window.Shiny.unbindAll(n,!0),$(n).remove(),!0}))})):Swal.fire(e.swal).then((function(n){n.value?Shiny.onInputChange(e.id,!0):Shiny.onInputChange(e.id,!1)}))})),Shiny.addCustomMessageHandler("sweetalert-sw-input",(function(e){e.reset_input&&Shiny.setInputValue(e.id,null),Swal.fire(e.swal).then((function(n){Shiny.setInputValue(e.id,n.value,{priority:"event"})}))})),Shiny.addCustomMessageHandler("sweetalert-sw-progress",(function(e){var n=document.getElementById(e.idel);n.style.display="block",e.content=n,Swal.fire(e)})),Shiny.addCustomMessageHandler("sweetalert-toast",(function(e){Swal.fire(e)})),Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var e=this.length-1;e>=0;e--)this[e]&&this[e].parentElement&&this[e].parentElement.removeChild(this[e])},Shiny.addCustomMessageHandler("sweetalert-sw-close",(function(e){Swal.close()}));var VerticalTabInputBinding=new Shiny.InputBinding;$.extend(VerticalTabInputBinding,{find:function(e){return $(e).find(".vertical-tab-panel")},getId:function(e){return e.id},getValue:function(e){return $(e).find(".active").attr("data-value")},setValue:function(e,n){},receiveMessage:function(e,n){var t=$(e);if(n.hasOwnProperty("value"))t.find("[data-value='"+n.value+"']").click();else if(n.hasOwnProperty("validate"))0===t.children(".active").length&&t.children().length>0&&t.children().last().click();else if(n.hasOwnProperty("reorder")){var i=t.children();i.detach(),t.append($.map(n.reorder,(function(e){return i[e-1]})))}},subscribe:function(e,n){$(e).on("click",(function(e){n()}))},unsubscribe:function(e){$(e).off(".VerticalTabInputBinding")}}),Shiny.inputBindings.register(VerticalTabInputBinding,"shiny.VerticalTabInput"); +var AirPickerInputBinding=new Shiny.InputBinding;function getFormattedDate(e){var n=e.getFullYear(),t=e.getMonth()+1,i=e.getDate();return t>9?i>9?n+"-"+t+"-"+i:n+"-"+t+"-0"+i:i>9?n+"-0"+t+"-"+i:n+"-0"+t+"-0"+i}$.extend(AirPickerInputBinding,{initialize:function(e){var n,t={},i={};if($(e).attr("data-start-date")){for(var a=JSON.parse($(e).attr("data-start-date")),r=[],o=0;o0?"false"===t?n.map((function(e){return(n=e)instanceof Date?n.getFullYear()+"-"+i(n.getMonth()+1,2)+"-"+i(n.getDate(),2):null;var n})):n.map((function(e){return e.valueOf()})):null},setValue:function(e,n){n=JSON.parse(n);for(var t=[],i=0;i9?"":"0")+e,(n>9?"":"0")+n].join("-")};var $escapeAw=(exportsAw=window.Shiny=window.Shiny||{}).$escape=function(e){return e.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")},awesomeCheckboxBinding=new Shiny.InputBinding;$.extend(awesomeCheckboxBinding,{find:function(e){return $(e).find(".awesome-checkbox-class")},getId:function(e){return e.id},getValue:function(e){return $('input:checkbox[name="'+$escapeAw(e.id)+'"]:checked').val()},setValue:function(e,n){$('input:checkbox[name="'+$escapeAw(e.id)+'"][value="'+$escapeAw(n)+'"]').prop("checked",!0)},subscribe:function(e,n){$(e).on("change.awesomeCheckboxBinding",(function(e){n()}))},unsubscribe:function(e){$(e).off(".awesomeCheckboxBinding")},getState:function(e){for(var n=$('input:checkbox[name="'+$escapeAw(e.id)+'"]'),t=new Array(n.length),i=0;i?@\[\\\]^`{|}~])/g,"\\$1")};var exportsAw,awesomeRadioBinding=new Shiny.InputBinding;$.extend(awesomeRadioBinding,{find:function(e){return $(e).find(".awesome-radio-class")},getId:function(e){return e.id},getValue:function(e){return $('input:radio[name="'+$escapeAw(e.id)+'"]:checked').val()},setValue:function(e,n){$('input:radio[name="'+$escapeAw(e.id)+'"][value="'+$escapeAw(n)+'"]').prop("checked",!0)},subscribe:function(e,n){$(e).on("change.awesomeRadioBinding",(function(e){n()}))},unsubscribe:function(e){$(e).off(".awesomeRadioBinding")},getState:function(e){for(var n=$('input:radio[name="'+$escapeAw(e.id)+'"]'),t=new Array(n.length),i=0;i?@\[\\\]^`{|}~])/g,"\\$1")},checkboxGroupButtonsBinding=new Shiny.InputBinding;$.extend(checkboxGroupButtonsBinding,{find:function(e){return $(e).find(".checkboxGroupButtons")},getId:function(e){return e.id},getValue:function(e){for(var n=$('input:checkbox[name="'+$escape4but(e.id)+'"]:checked'),t=new Array(n.length),i=0;i?@\[\\\]^`{|}~])/g,"\\$1")};function tron_skin(){if("tron"==this.$.data("skin")){this.cursorExt=.3;var e,n=this.arc(this.cv);return this.g.lineWidth=this.lineWidth,this.o.displayPrevious&&(e=this.arc(this.v),this.g.beginPath(),this.g.strokeStyle=this.pColor,this.g.arc(this.xy,this.xy,this.radius-this.lineWidth,e.s,e.e,e.d),this.g.stroke()),this.g.beginPath(),this.g.strokeStyle=this.o.fgColor,this.g.arc(this.xy,this.xy,this.radius-this.lineWidth,n.s,n.e,n.d),this.g.stroke(),this.g.lineWidth=2,this.g.beginPath(),this.g.strokeStyle=this.o.fgColor,this.g.arc(this.xy,this.xy,this.radius-this.lineWidth+1+2*this.lineWidth/3,0,2*Math.PI,!1),this.g.stroke(),!1}}var knobInputBinding=new Shiny.InputBinding;$.extend(knobInputBinding,{find:function(e){return $(e).find(".knob-input")},initialize:function(e){var n=$(e).data("value");e.value=n,$(e).knob({draw:tron_skin})},getValue:function(e){return parseFloat(e.value)},subscribe:function(e,n){$(e).data("immediate")?($(e).on("keyup.knobInputBinding",(function(e){n(!0)})),$(e).trigger("configure",{change:function(e){n(!1)},release:function(e){n(!1)}}),$(e).on("change.knobInputBinding",(function(e){n(!1)}))):($(e).on("keyup.knobInputBinding",(function(e){n(!0)})),$(e).trigger("configure",{release:function(e){n(!0)}}))},unsubscribe:function(e){$(e).off(".knobInputBinding")},receiveMessage:function(e,n){n.hasOwnProperty("value")&&$(e).val(n.value).trigger("change"),n.hasOwnProperty("readOnly")&&$(e).trigger("configure",{readOnly:n.readOnly}),n.hasOwnProperty("options")&&$(e).trigger("configure",n.options),n.hasOwnProperty("label")&&$(e).parent().parent().find('label[for="'+$escapeKnob(e.id)+'"]').text(n.label),$(e).trigger("change")},getState:function(e){return{label:$(e).parent().parent().find('label[for="'+$escapeKnob(e.id)+'"]').text(),value:e.value}},getRatePolicy:function(){return{policy:"debounce",delay:500}}}),Shiny.inputBindings.register(knobInputBinding,"shiny.knobInput");var exportsMulti=window.Shiny=window.Shiny||{},$escapeMulti=exportsMulti.$escape=function(e){return e.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")},multiInputBinding=new Shiny.InputBinding;$.extend(multiInputBinding,{initialize:function(e){var n=$(e).parent().find('script[data-for="'+$escapeMulti(e.id)+'"]');n=JSON.parse(n.html()),$(e).multi(n),$(e).trigger("change")},find:function(e){return $(e).find(".multijs")},getId:function(e){return e.id},getValue:function(e){return $(e).val()},setValue:function(e,n){$(e).val(n),$(e).multi(),$(e).trigger("change")},getState:function(e){for(var n=new Array(e.length),t=0;t?@\[\\\]^`{|}~])/g,"\\$1")},noUiSliderBinding=new Shiny.InputBinding;$.extend(noUiSliderBinding,{find:function(e){return $(e).find(".sw-no-ui-slider")},getId:function(e){return e.id},getType:function(e){var n=$(e).data("data-type");return"date"===n?"shiny.date":"datetime"===n&&"shiny.datetime"},getValue:function(e){var n,t=document.getElementById(e.id).noUiSlider.get(),i=$(e).parent().find('script[data-for="'+$escapenoUi(e.id)+'"]');return void 0!==(i=JSON.parse(i.html())).format?(numformat=wNumb(i.format),n=Array.isArray(t)?t.map(numformat.from):numformat.from(t)):n=Array.isArray(t)?t.map(Number):Number(t),n},setValue:function(e,n){document.getElementById(e.id).noUiSlider.set(n)},subscribe:function(e,n){var t=document.getElementById(e.id);"end"==$("#"+e.id).data("update")?(t.noUiSlider.on("change",(function(e){n()})),t.noUiSlider.on("set",(function(e){n()}))):(t.noUiSlider.on("slide",(function(e){n()})),t.noUiSlider.on("set",(function(e){n()})))},unsubscribe:function(e){$(e).off(".noUiSliderBinding")},receiveMessage:function(e,n){var t=document.getElementById(e.id);n.disable?t.setAttribute("disabled",!0):t.removeAttribute("disabled"),n.hasOwnProperty("range")&&t.noUiSlider.updateOptions({range:{min:n.range[0],max:n.range[1]}}),t.noUiSlider.set(n.value),$(e).trigger("change")},getRatePolicy:function(){return{policy:"debounce",delay:250}},getState:function(e){},initialize:function(e){var n=$(e).parent().find('script[data-for="'+$escapenoUi(e.id)+'"]');void 0!==(n=JSON.parse(n.html())).format&&(n.format=wNumb(n.format));var t=document.getElementById(e.id);"vertical"===n.orientation&&(t.style.margin="0 auto 30px"),noUiSlider.create(t,n)}}),Shiny.inputBindings.register(noUiSliderBinding,"shiny.noUiSlider");var numericRangeInputBinding=new Shiny.InputBinding;$.extend(numericRangeInputBinding,{find:function(e){return $(e).find(".shiny-numeric-range-input")},getValue:function(e){var n=$(e).find("input"),t=n[0].value,i=n[1].value;return[t=/^\s*$/.test(t)?null:isNaN(t)?t:+t,i=/^\s*$/.test(i)?null:isNaN(i)?i:+i]},setValue:function(e,n){e.find("input")[0].value=n[0],e.find("input")[1].value=n[1]},subscribe:function(e,n){$(e).on("change.numericRangeInputBinding",(function(e){n()}))},receiveMessage:function(e,n){var t=$(e);n.hasOwnProperty("value")&&(t.find("input")[0].value=n.value[0]),t.find("input")[1].value=n.value[1],$(e).trigger("change")},unsubscribe:function(e){$(e).off(".numericRangeInputBinding")}}),Shiny.inputBindings.register(numericRangeInputBinding,"wd.numericRangeInputBin"),Shiny.addCustomMessageHandler("update-progressBar-shinyWidgets",(function(e){var n,t=e.id,i=e.total,a=Math.round(e.value);i>0?(n=Math.round(a/i*100),$("#"+t+"-value").text(a),$("#"+t+"-total").text(i),a=Math.round(a/i*100)):n=e.percent>0?e.percent:a,$("#"+t).css("width",n+"%"),""!==$("#"+t).text()&&$("#"+t).text(a+e.unit_mark),null!==e.status&&($("#"+t).removeClass(),$("#"+t).addClass("progress-bar progress-bar-"+e.status)),null!==e.title&&$("#"+t+"-title").text(e.title)}));$escape4but=(exports4but=window.Shiny=window.Shiny||{}).$escape=function(e){return e.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")};var exports4but,radioGroupButtonsBinding=new Shiny.InputBinding;$.extend(radioGroupButtonsBinding,{find:function(e){return $(e).find(".radioGroupButtons")},getId:function(e){return e.id},getValue:function(e){return $('input:radio[name="'+$escape4but(e.id)+'"]:checked').val()},setValue:function(e,n){$('input:radio[name="'+$escape4but(e.id)+'"][value="'+$escape4but(n)+'"]').prop("checked",!0),$('input:radio[name="'+$escape4but(e.id)+'"]').parent().removeClass("active"),$('input:radio[name="'+$escape4but(e.id)+'"][value="'+$escape4but(n)+'"]').parent().addClass("active")},subscribe:function(e,n){$(e).on("change.radioGroupButtonsBinding",(function(e){n()}))},unsubscribe:function(e){$(e).off(".radioGroupButtonsBinding")},getState:function(e){for(var n=$('input:radio[name="'+$escape4but(e.id)+'"]'),t=new Array(n.length),i=0;i?@\[\\\]^`{|}~])/g,"\\$1")},searchInputBinding=new Shiny.InputBinding;$.extend(searchInputBinding,{find:function(e){return $(e).find(".search-text")},getId:function(e){return $(e).attr("id")},getValue:function(e){return $("#"+$escapeSearch(e.id)+"_text").val()},setValue:function(e,n){$("#"+$escapeSearch(e.id)+"_text").val(n)},subscribe:function(e,n){$("#"+$escapeSearch(e.id)+"_text").on("keyup.searchInputBinding input.searchInputBinding",(function(e){13==e.keyCode&&n()})),$("#"+$escapeSearch(e.id)+"_search").on("click",(function(e){n()})),$("#"+$escapeSearch(e.id)+"_reset").on("click",(function(t){if("TRUE"==$("#"+$escapeSearch(e.id)).data("reset")){var i=$("#"+$escapeSearch(e.id)).data("reset-value");$("#"+$escapeSearch(e.id)+"_text").val(i)}n()}))},unsubscribe:function(e){$(e).off(".searchInputBinding")},receiveMessage:function(e,n){n.hasOwnProperty("value")&&this.setValue(e,n.value),n.hasOwnProperty("label")&&$(e).parent().find('label[for="'+e.id+'"]').text(n.label),n.hasOwnProperty("placeholder")&&($("#"+e.id+"_text")[0].placeholder=n.placeholder),n.trigger&&$("#"+e.id+"_search").click(),$(e).trigger("change")},getState:function(e){return{value:this.getValue(e)}},getRatePolicy:function(){return{policy:"debounce",delay:250}}}),Shiny.inputBindings.register(searchInputBinding,"shiny.searchInput");var exportsPicker=window.Shiny=window.Shiny||{},$escapePicker=exportsPicker.$escape=function(e){return e.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")},pickerInputBinding=new Shiny.InputBinding;function forceIonSliderTextUpdate(e){e.$cache&&e.$cache.input?e.$cache.input.trigger("change"):console.log("Couldn't force ion slider to update")}$.extend(pickerInputBinding,{find:function(e){return $(e).find(".selectpicker")},getId:function(e){return e.id},getValue:function(e){return $(e).val()},setValue:function(e,n){$(e).val(n),$(e.id).selectpicker("refresh")},getState:function(e){for(var n=new Array(e.length),t=0;t?@\[\\\]^`{|}~])/g,"\\$1")},sliderTextBinding=new Shiny.InputBinding;$.extend(sliderTextBinding,{find:function(e){return $.fn.ionRangeSlider?$(e).find(".sw-slider-text"):[]},getType:function(e){var n=$(e).data("data-type");return"date"===n?"shiny.date":"datetime"===n&&"shiny.datetime"},getValue:function(e){var n=$(e).data("ionRangeSlider"),t=n.result,i=n.options.values;return 2===this._numValues(e)?[i[t.from],i[t.to]]:i[t.from]},setValue:function(e,n){var t=$(e),i=t.data("ionRangeSlider");t.data("immediate",!0);try{2===this._numValues(e)&&n instanceof Array?i.update({from:n[0],to:n[1]}):i.update({from:n}),forceIonSliderTextUpdate(i)}finally{t.data("immediate",!1)}},subscribe:function(e,n){$(e).on("change.sliderInputBinding",(function(t){n(!$(e).data("immediate")&&!$(e).data("animating"))}))},unsubscribe:function(e){$(e).off(".sliderInputBinding")},receiveMessage:function(e,n){var t=$(e),i=t.data("ionRangeSlider"),a={},r=i.options.values;n.hasOwnProperty("choices")&&(a.values=n.choices,r=n.choices),n.hasOwnProperty("selected")&&(2===this._numValues(e)&&n.selected instanceof Array?(a.from=r.indexOf(n.selected[0]),a.to=r.indexOf(n.selected[1])):a.from=r.indexOf(n.selected)),n.hasOwnProperty("from_fixed")&&(a.from_fixed=n.from_fixed),n.hasOwnProperty("to_fixed")&&(a.to_fixed=n.to_fixed),n.hasOwnProperty("label")&&t.parent().find('label[for="'+$escapeST(e.id)+'"]').text(n.label),t.data("immediate",!0);try{i.update(a),forceIonSliderTextUpdate(i)}finally{t.data("immediate",!1)}},getRatePolicy:function(){return{policy:"debounce",delay:250}},getState:function(e){},initialize:function(e){var n={},t=$(e),i=$(e).data("swvalues");n.values=i,t.ionRangeSlider(n)},_numValues:function(e){return"double"===$(e).data("ionRangeSlider").options.type?2:1}}),Shiny.inputBindings.register(sliderTextBinding,"shiny.sliderText");var spectrumInputBinding=new Shiny.InputBinding;$.extend(spectrumInputBinding,{find:function(e){return $(e).find(".sw-spectrum")},getId:function(e){return $(e).attr("id")},getValue:function(e){return $(e).spectrum("get").toHexString()},setValue:function(e,n){$(e).spectrum("set",n)},subscribe:function(e,n){$(e).on("change",(function(e){n()}))},unsubscribe:function(e){$(e).off(".spectrumInputBinding")},receiveMessage:function(e,n){n.hasOwnProperty("value")&&this.setValue(e,n.value),$(e).trigger("change")},getState:function(e){return{value:this.getValue(e)}},initialize:function(e){var n={},t=$(e).attr("data-update-on");$(e).removeAttr("data-update-on"),"dragstop"==t&&$(e).on("dragstop.spectrum",(function(n){$(e).trigger("change")})),"move"==t&&(n.move=function(){$(e).trigger("change")}),"change"==t&&(n.change=function(){$(e).trigger("change")}),$(e).spectrum(n)},getRatePolicy:function(){return{policy:"debounce",delay:250}}}),Shiny.inputBindings.register(spectrumInputBinding,"shiny.spectrumInput"),Shiny.addCustomMessageHandler("sweetalert-sw",(function(e){if(e.as_html){var n=document.createElement("span");n.innerHTML=e.text,e.html=n,Swal.fire(e).then((function(n){$("#"+e.sw_id).each((function(e,n){return window.Shiny.unbindAll(n,!0),$(n).remove(),!0}))}))}else Swal.fire(e)})),Shiny.addCustomMessageHandler("sweetalert-sw-confirm",(function(e){Shiny.onInputChange(e.id,null),e.as_html?Swal.fire(e.swal).then((function(n){n.value?Shiny.onInputChange(e.id,!0):Shiny.onInputChange(e.id,!1),$("#"+e.sw_id).each((function(e,n){return window.Shiny.unbindAll(n,!0),$(n).remove(),!0}))})):Swal.fire(e.swal).then((function(n){n.value?Shiny.onInputChange(e.id,!0):Shiny.onInputChange(e.id,!1)}))})),Shiny.addCustomMessageHandler("sweetalert-sw-input",(function(e){e.reset_input&&Shiny.setInputValue(e.id,null),Swal.fire(e.swal).then((function(n){Shiny.setInputValue(e.id,n.value,{priority:"event"})}))})),Shiny.addCustomMessageHandler("sweetalert-sw-progress",(function(e){var n=document.getElementById(e.idel);n.style.display="block",e.content=n,Swal.fire(e)})),Shiny.addCustomMessageHandler("sweetalert-toast",(function(e){Swal.fire(e)})),Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var e=this.length-1;e>=0;e--)this[e]&&this[e].parentElement&&this[e].parentElement.removeChild(this[e])},Shiny.addCustomMessageHandler("sweetalert-sw-close",(function(e){Swal.close()}));var VerticalTabInputBinding=new Shiny.InputBinding;$.extend(VerticalTabInputBinding,{find:function(e){return $(e).find(".vertical-tab-panel")},getId:function(e){return e.id},getValue:function(e){return $(e).find(".active").attr("data-value")},setValue:function(e,n){},receiveMessage:function(e,n){var t=$(e);if(n.hasOwnProperty("value"))t.find("[data-value='"+n.value+"']").click();else if(n.hasOwnProperty("validate"))0===t.children(".active").length&&t.children().length>0&&t.children().last().click();else if(n.hasOwnProperty("reorder")){var i=t.children();i.detach(),t.append($.map(n.reorder,(function(e){return i[e-1]})))}},subscribe:function(e,n){$(e).on("click",(function(e){n()}))},unsubscribe:function(e){$(e).off(".VerticalTabInputBinding")}}),Shiny.inputBindings.register(VerticalTabInputBinding,"shiny.VerticalTabInput"); diff --git a/man/pickerInput.Rd b/man/pickerInput.Rd index b251f852..76ac7b33 100644 --- a/man/pickerInput.Rd +++ b/man/pickerInput.Rd @@ -45,168 +45,192 @@ if (interactive()) { shinyWidgetsGallery() -# Simple example +# Basic usage library("shiny") +library(shinyWidgets) + ui <- fluidPage( - pickerInput(inputId = "somevalue", label = "A label", choices = c("a", "b")), + pickerInput( + inputId = "somevalue", + label = "A label", + choices = c("a", "b") + ), verbatimTextOutput("value") ) + server <- function(input, output) { - output$value <- renderPrint({ input$somevalue }) + output$value <- renderPrint(input$somevalue) } + shinyApp(ui, server) +} -### Add actions box for selecting -# deselecting all options +### Add actions box for selecting ---- +### deselecting all options -library("shiny") -library("shinyWidgets") +if (interactive()) { -ui <- fluidPage( - br(), - pickerInput( - inputId = "p1", - label = "Select all option", - choices = rownames(mtcars), - multiple = TRUE, - options = list(`actions-box` = TRUE) - ), - br(), - pickerInput( - inputId = "p2", - label = "Select all option / custom text", - choices = rownames(mtcars), - multiple = TRUE, - options = list( - `actions-box` = TRUE, - `deselect-all-text` = "None...", - `select-all-text` = "Yeah, all !", - `none-selected-text` = "zero" - ) + library(shiny) + library(shinyWidgets) + + ui <- fluidPage( + tags$h2("Select / Deselect all"), + pickerInput( + inputId = "p1", + label = "Select all option", + choices = rownames(mtcars), + multiple = TRUE, + options = list(`actions-box` = TRUE) + ), + verbatimTextOutput("r1"), + br(), + pickerInput( + inputId = "p2", + label = "Select all option / custom text", + choices = rownames(mtcars), + multiple = TRUE, + options = list( + `actions-box` = TRUE, + `deselect-all-text` = "None...", + `select-all-text` = "Yeah, all !", + `none-selected-text` = "zero" + ) + ), + verbatimTextOutput("r2") ) -) -server <- function(input, output, session) { + server <- function(input, output, session) { -} + output$r1 <- renderPrint(input$p1) + output$r2 <- renderPrint(input$p2) -shinyApp(ui = ui, server = server) + } + shinyApp(ui = ui, server = server) +} ### Customize the values displayed in the box ---- -library("shiny") -library("shinyWidgets") +if (interactive()) { -ui <- fluidPage( - br(), - pickerInput( - inputId = "p1", - label = "Default", - multiple = TRUE, - choices = rownames(mtcars), - selected = rownames(mtcars)[1:5] - ), - br(), - pickerInput( - inputId = "p1b", - label = "Default with | separator", - multiple = TRUE, - choices = rownames(mtcars), - selected = rownames(mtcars)[1:5], - options = list(`multiple-separator` = " | ") - ), - br(), - pickerInput( - inputId = "p2", - label = "Static", - multiple = TRUE, - choices = rownames(mtcars), - selected = rownames(mtcars)[1:5], - options = list(`selected-text-format`= "static", - title = "Won't change") - ), - br(), - pickerInput( - inputId = "p3", - label = "Count", - multiple = TRUE, - choices = rownames(mtcars), - selected = rownames(mtcars)[1:5], - options = list(`selected-text-format`= "count") - ), - br(), - pickerInput( - inputId = "p3", - label = "Customize count", - multiple = TRUE, - choices = rownames(mtcars), - selected = rownames(mtcars)[1:5], - options = list( - `selected-text-format`= "count", - `count-selected-text` = "{0} models choosed (on a total of {1})" + library(shiny) + library(shinyWidgets) + + ui <- fluidPage( + br(), + pickerInput( + inputId = "p1", + label = "Default", + multiple = TRUE, + choices = rownames(mtcars), + selected = rownames(mtcars)[1:5] + ), + br(), + pickerInput( + inputId = "p1b", + label = "Default with | separator", + multiple = TRUE, + choices = rownames(mtcars), + selected = rownames(mtcars)[1:5], + options = list(`multiple-separator` = " | ") + ), + br(), + pickerInput( + inputId = "p2", + label = "Static", + multiple = TRUE, + choices = rownames(mtcars), + selected = rownames(mtcars)[1:5], + options = list(`selected-text-format`= "static", + title = "Won't change") + ), + br(), + pickerInput( + inputId = "p3", + label = "Count", + multiple = TRUE, + choices = rownames(mtcars), + selected = rownames(mtcars)[1:5], + options = list(`selected-text-format`= "count") + ), + br(), + pickerInput( + inputId = "p3", + label = "Customize count", + multiple = TRUE, + choices = rownames(mtcars), + selected = rownames(mtcars)[1:5], + options = list( + `selected-text-format`= "count", + `count-selected-text` = "{0} models choosed (on a total of {1})" + ) ) ) -) - -server <- function(input, output, session) { -} + server <- function(input, output, session) { -shinyApp(ui = ui, server = server) + } + shinyApp(ui = ui, server = server) +} ### Limit the number of selections ---- -library(shiny) -library(shinyWidgets) -ui <- fluidPage( - pickerInput( - inputId = "groups", - label = "Select one from each group below:", - choices = list( - Group1 = c("1", "2", "3", "4"), - Group2 = c("A", "B", "C", "D") +if (interactive()) { + + library(shiny) + library(shinyWidgets) + + ui <- fluidPage( + pickerInput( + inputId = "groups", + label = "Select one from each group below:", + choices = list( + Group1 = c("1", "2", "3", "4"), + Group2 = c("A", "B", "C", "D") + ), + multiple = TRUE, + options = list("max-options-group" = 1) ), - multiple = TRUE, - options = list("max-options-group" = 1) - ), - verbatimTextOutput(outputId = "res_grp"), - pickerInput( - inputId = "groups_2", - label = "Select two from each group below:", - choices = list( - Group1 = c("1", "2", "3", "4"), - Group2 = c("A", "B", "C", "D") + verbatimTextOutput(outputId = "res_grp"), + pickerInput( + inputId = "groups_2", + label = "Select two from each group below:", + choices = list( + Group1 = c("1", "2", "3", "4"), + Group2 = c("A", "B", "C", "D") + ), + multiple = TRUE, + options = list("max-options-group" = 2) ), - multiple = TRUE, - options = list("max-options-group" = 2) - ), - verbatimTextOutput(outputId = "res_grp_2"), - pickerInput( - inputId = "classic", - label = "Select max two option below:", - choices = c("A", "B", "C", "D"), - multiple = TRUE, - options = list( - "max-options" = 2, - "max-options-text" = "No more!" - ) - ), - verbatimTextOutput(outputId = "res_classic") -) -server <- function(input, output) { - output$res_grp <- renderPrint(input$groups) - output$res_grp_2 <- renderPrint(input$groups_2) - output$res_classic <- renderPrint(input$classic) -} -shinyApp(ui, server) + verbatimTextOutput(outputId = "res_grp_2"), + pickerInput( + inputId = "classic", + label = "Select max two option below:", + choices = c("A", "B", "C", "D"), + multiple = TRUE, + options = list( + "max-options" = 2, + "max-options-text" = "No more!" + ) + ), + verbatimTextOutput(outputId = "res_classic") + ) -} + server <- function(input, output) { + + output$res_grp <- renderPrint(input$groups) + output$res_grp_2 <- renderPrint(input$groups_2) + output$res_classic <- renderPrint(input$classic) + } + + shinyApp(ui, server) + +} } \seealso{ \link{updatePickerInput} to update value server-side.