From ca5fe90fe4a95657526a90c3760f11fe801db35f Mon Sep 17 00:00:00 2001 From: Veerle van Leemput Date: Fri, 26 Apr 2024 13:59:57 +0200 Subject: [PATCH] add input layouts defaults --- NAMESPACE | 1 + R/f7-inputs.R | 21 +++++++++++++++++++++ man/inputLayoutDefaults.Rd | 12 ++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 man/inputLayoutDefaults.Rd diff --git a/NAMESPACE b/NAMESPACE index a15c8a9b..362557b7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -165,4 +165,5 @@ importFrom(jsonlite,toJSON) importFrom(lifecycle,deprecated) importFrom(magrittr,"%>%") importFrom(shiny,registerInputHandler) +importFrom(utils,modifyList) importFrom(utils,packageVersion) diff --git a/R/f7-inputs.R b/R/f7-inputs.R index 89f6ad31..d5ddb093 100644 --- a/R/f7-inputs.R +++ b/R/f7-inputs.R @@ -892,17 +892,38 @@ updateF7SmartSelect <- function(inputId, selected = NULL, choices = NULL, multip session$sendInputMessage(inputId, message) } +#' Input layout default options +#' +#' @keywords internal +inputLayoutDefaults <- function() { + list( + media = NULL, + description = NULL, + floating = FALSE, + outline = FALSE, + clearable = TRUE + ) +} + #' Create common input layout #' #' See \url{https://framework7.io/docs/inputs#inputs-layout}. #' +#' @importFrom utils modifyList +#' #' @keywords internal createInputLayout <- function( ..., label = NULL, style, dropdown = FALSE) { + if (style$floating && is.null(label)) { stop("floating can't be used when label is NULL") } + # make sure style does contain all defaults + # this prevents an error when the users only provides + # a subset of the style options + style <- modifyList(inputLayoutDefaults(), style) + item <- f7ListItem( media = style$media, # icon title = label # label diff --git a/man/inputLayoutDefaults.Rd b/man/inputLayoutDefaults.Rd new file mode 100644 index 00000000..707fac66 --- /dev/null +++ b/man/inputLayoutDefaults.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/f7-inputs.R +\name{inputLayoutDefaults} +\alias{inputLayoutDefaults} +\title{Input layout default options} +\usage{ +inputLayoutDefaults() +} +\description{ +Input layout default options +} +\keyword{internal}