Compare commits

...

9 Commits

20 changed files with 1072 additions and 80 deletions

View File

@@ -1,6 +1,6 @@
Package: AVSDevR.HTMLUtils Package: AVSDevR.HTMLUtils
Title: Utility Functions For Modifying R HTML Elements Title: Utility Functions For Modifying R HTML Elements
Version: 0.0.0.9000 Version: 1.0.0
Authors@R: Authors@R:
person("Craig", "Williams", , "craig@avsdev.uk", role = c("aut", "cre")) person("Craig", "Williams", , "craig@avsdev.uk", role = c("aut", "cre"))
Description: Collection of utility functions for modifying HTML markup of Description: Collection of utility functions for modifying HTML markup of
@@ -14,7 +14,9 @@ Encoding: UTF-8
Roxygen: list(markdown = TRUE) Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.3 RoxygenNote: 7.3.3
Imports: Imports:
htmltools htmltools,
jsonlite,
stringi
Suggests: Suggests:
shiny, shiny,
shinydashboard, shinydashboard,

View File

@@ -1,12 +1,19 @@
# Generated by roxygen2: do not edit by hand # Generated by roxygen2: do not edit by hand
export(htmlAddBoxAttributes) export(htmlAddBoxAttributes)
export(htmlAddBoxHelpLink)
export(htmlAddBoxRegionFromTitle) export(htmlAddBoxRegionFromTitle)
export(htmlAddClasses)
export(htmlAppendAttributes)
export(htmlButtonStyle)
export(htmlDisableAutocomplete) export(htmlDisableAutocomplete)
export(htmlFixBoxCollapseButtonAria) export(htmlFixBoxCollapseButtonAria)
export(htmlMarkOptional) export(htmlMarkOptional)
export(htmlMarkRequired) export(htmlMarkRequired)
export(htmlRemoveAttributes) export(htmlRemoveAttributes)
export(htmlRemoveBoxTitle)
export(htmlRemoveClasses)
export(htmlReplaceBoxTitleLevel) export(htmlReplaceBoxTitleLevel)
export(htmlSetMaxLength) export(htmlSetMaxLength)
export(htmlSetMinLength) export(htmlSetMinLength)
export(htmlSlugify)

14
R/htmlAppendAttributes.R Normal file
View File

@@ -0,0 +1,14 @@
#' Appends attributes to an HTML element
#'
#' @param el The element to append the attributes to
#' @param ... The attribute names to be appended
#'
#' @return The modified element
#' @export
#'
#' @examples
#' x <- shiny::icon("wrench")
#' htmlAppendAttributes(x, `role` = "presentation")
htmlAppendAttributes <- function(el, ...) {
do.call(htmltools::tagQuery(el)$addAttrs, list(...))$allTags()
}

View File

@@ -20,12 +20,11 @@ getBoxTitle <- function(box) {
#' #'
#' @examples #' @examples
#' x <- shinydashboard::box() #' x <- shinydashboard::box()
#' htmlAddBoxAttributes(x, role = "region", `aria-label` = "This is a special box") #' htmlAddBoxAttributes(
#' x, role = "region", `aria-label` = "This is a special box"
#' )
htmlAddBoxAttributes <- function(box, ...) { htmlAddBoxAttributes <- function(box, ...) {
htmltools::tagQuery(box)$ htmltools::tagQuery(box)$find(".box")$addAttr(...)$allTags()
find(".box")$
addAttr(...)$
allTags()
} }
#' Creates an aria landmark for a `shinydashboard::box` from the box title #' Creates an aria landmark for a `shinydashboard::box` from the box title
@@ -84,6 +83,84 @@ htmlFixBoxCollapseButtonAria <- function(box, context = NULL) {
} }
htmltools::tagQuery(box)$ htmltools::tagQuery(box)$
find(".box-tools button.btn-box-tool")$ find(".box-tools button.btn-box-tool")$
addAttrs(`aria-label` = paste0("Expand/Collapse ", context))$ addAttrs(`aria-label` = paste0("Expand/Collapse ", context))$allTags()
allTags() }
#' Adds a "help" (question mark) icon to a box tools section (right side)
#'
#' The uri to load can have a replacement marker supplied '%box%' which will be
#' substituded with a sanitized copy of the box title.
#'
#' @param box The box to add a help icon/link to
#' @param href The help uri to load
#' @param title Optional title for the help link. Defaults to box title
#'
#' @return The modified box
#' @export
#'
#' @examples
#' x <- shinydashboard::box(title = "This is a box")
#' htmlAddBoxHelpLink(x, href = "http://example.com/help-guide#%box%")
htmlAddBoxHelpLink <- function(box, href, title = NULL) {
header_tags <- htmltools::tagQuery(box)$find(".box-header")$selectedTags()
if (length(header_tags) == 0) {
return(box)
}
tools_tags <- htmltools::tagQuery(box)$find(".box-tools")$selectedTags()
if (length(tools_tags) == 0) {
box <- htmltools::tagInsertChildren(
box,
after = 0,
.cssSelector = ".box-header",
htmltools::tags$div(class = "box-tools pull-right")
)
}
box_title <- getBoxTitle(box)
if (is.null(box_title)) {
box_title <- "UNDEFINED"
}
if (is.null(title)) {
title <- box_title
}
box_title <- htmlSlugify(box_title)
htmltools::tagInsertChildren(
box,
after = 0,
.cssSelector = ".box-tools",
htmltools::tags$a(
href = gsub("%box%", box_title, href),
target = "_blank",
class = "btn btn-box-tool pl-3 pr-3",
htmlRemoveAttributes(shiny::icon("question"), "aria-label"),
title = paste(trimws(title), " help link"),
`aria-label` = paste(trimws(title), " help link")
)
)
}
#' Removes title from box element (leaving an un-titled box with header if
#' required)
#'
#' @param box The box to remove the title from
#' @param removeHeader Remove the header as well
#'
#' @return The modified box
#' @export
#'
#' @examples
#' x <- shinydashboard::box(title = "TBR")
#' htmlRemoveBoxTitle(x)
htmlRemoveBoxTitle <- function(box, removeHeader = FALSE) {
if (removeHeader) {
htmltools::tagQuery(box)$find(".box-header")$remove()$allTags()
} else {
htmltools::tagQuery(box)$find(".box-title")$replace(
htmltools::tags$span(
class = "empty-box-title", htmltools::HTML("&nbsp;")
)
)$allTags()
}
} }

50
R/htmlClassManipulation.R Normal file
View File

@@ -0,0 +1,50 @@
#' Add classes to an HTML element
#'
#' @param el The element to add the class(es) to
#' @param classes The class(es) to be added
#'
#' @return The modified element
#' @export
#'
#' @examples
#' x <- shiny::tags$div()
#' htmlAddClasses(x, "btn-warning")
htmlAddClasses <- function(el, classes) {
htmltools::tagQuery(el)$addClass(classes)$allTags()
}
#' Remove classes from an HTML element
#'
#' @param el The element to remove the class(es) from
#' @param classes The class(es) to be added
#'
#' @return The modified element
#' @export
#'
#' @examples
#' x <- shiny::tags$div(class = "btn btn-warning")
#' htmlRemoveClasses(x, "btn-warning")
htmlRemoveClasses <- function(el, classes) {
htmltools::tagQuery(el)$removeClass(classes)$allTags()
}
#' Changes the style of a button from btn-default to another style
#'
#' @param el The button
#' @param style The style to change the button on
#'
#' @return The modified element
#' @export
#'
#' @examples
#' x <- shiny::tags$div(class = "btn btn-warning")
#' htmlButtonStyle(x, "warning")
htmlButtonStyle <- function(el, style) {
stopifnot(style %in% c(
"default", "primary", "secondary", "info", "warning", "success", "danger",
"link"
))
el <- htmlRemoveClasses(el, "btn-default")
el <- htmlAddClasses(el, paste0("btn-", style))
el
}

View File

@@ -10,7 +10,5 @@
#' htmlDisableAutocomplete(x) #' htmlDisableAutocomplete(x)
htmlDisableAutocomplete <- function(input) { htmlDisableAutocomplete <- function(input) {
htmltools::tagQuery(input)$ htmltools::tagQuery(input)$
find("input")$ find("input")$addAttr(autocomplete = "off")$allTags()
addAttr(autocomplete = "off")$
allTags()
} }

View File

@@ -12,24 +12,18 @@
htmlMarkOptional <- function(input, optClass = "text-muted font-italic") { htmlMarkOptional <- function(input, optClass = "text-muted font-italic") {
opt_span <- htmltools::tags$span(class = optClass, " (optional)") opt_span <- htmltools::tags$span(class = optClass, " (optional)")
tq <- htmltools::tagQuery(input) tq <- htmltools::tagQuery(input)
if (tq$hasClass("shiny-input-checkboxgroup")) { if (tq$find("legend")$length() > 0) {
tq <- tq$ tq <- tq$children("legend")$append(opt_span)$reset()
children("label")$append(opt_span)$ } else if (tq$hasClass("shiny-input-checkboxgroup")) {
reset() tq <- tq$children("label")$append(opt_span)$reset()
} else if (tq$find(".shiny-options-group")$length() > 0) { } else if (tq$find(".shiny-options-group")$length() > 0) {
tq <- tq$ tq <- tq$children("label")$append(opt_span)$reset()
children("label")$append(opt_span)$
reset()
} else if (tq$find(".btn-file")$length() > 0) { } else if (tq$find(".btn-file")$length() > 0) {
tq <- tq$ tq <- tq$children("label")$append(opt_span)$reset()
children("label")$append(opt_span)$
reset()
} else { } else {
tq <- tq$ tq <- tq$
children(".checkbox")$find("label span")$append(opt_span)$ children(".checkbox")$find("label span")$append(opt_span)$reset()$
reset()$ find("label.control-label")$append(opt_span)$reset()
find("label.control-label")$append(opt_span)$
reset()
} }
tq$allTags() tq$allTags()
} }

View File

@@ -12,43 +12,40 @@
htmlMarkRequired <- function(input, reqClass = "text-danger required") { htmlMarkRequired <- function(input, reqClass = "text-danger required") {
req_span <- htmltools::tags$span(class = reqClass, "*") req_span <- htmltools::tags$span(class = reqClass, "*")
tq <- htmltools::tagQuery(input) tq <- htmltools::tagQuery(input)
if (tq$hasClass("shiny-input-checkboxgroup")) { if (tq$find("legend")$length() > 0) {
tq <- tq$ tq <- tq$children("legend")$append(req_span)$reset()
addAttr(`aria-required` = "true")$ tq <- tq$find("input")$addAttr(
reset()$ required = "true", `aria-required` = "true"
children("label")$append(req_span)$ )$reset()
reset() } else if (tq$hasClass("shiny-input-checkboxgroup")) {
tq <- tq$addAttr(`aria-required` = "true")$reset()
tq <- tq$children("label")$append(req_span)$reset()
} else if (tq$find(".shiny-options-group")$length() > 0) { } else if (tq$find(".shiny-options-group")$length() > 0) {
tq <- tq$ tq <- tq$addAttr(`aria-required` = "true")$reset()
children("label")$append(req_span)$ tq <- tq$children("label")$append(req_span)$reset()
reset()$ tq <- tq$find("input")$addAttr(
addAttr(`aria-required` = "true")$ required = "true", `aria-required` = "true"
reset()$ )$reset()
find("input")$addAttr(required = "true", `aria-required` = "true")$
reset()
} else if (tq$find(".btn-file")$length() > 0) { } else if (tq$find(".btn-file")$length() > 0) {
tq <- tq$ tq <- tq$children("label")$append(req_span)$reset()
children("label")$append(req_span)$ tq <- tq$addAttr(`aria-required` = "true")$reset()
reset()$ tq <- tq$find(".shiny-input-file")$addAttr(
addAttr(`aria-required` = "true")$ required = "true", `aria-required` = "true"
reset()$ )$reset()
find(".shiny-input-file")$
addAttr(required = "true", `aria-required` = "true")$
reset()
} else { } else {
tq <- tq$
# Update the label # Update the label
children(".checkbox")$find("label span")$append(req_span)$ tq <- tq$children(".checkbox")$find("label span")$append(req_span)$reset()
reset()$ tq <- tq$find("label.control-label")$append(req_span)$reset()
find("label.control-label")$append(req_span)$
reset()$
# Update the inputs # Update the inputs
find("input")$addAttr(required = "true", `aria-required` = "true")$ tq <- tq$find("input")$addAttr(
reset()$ required = "true", `aria-required` = "true"
find("textarea")$addAttr(required = "true", `aria-required` = "true")$ )$reset()
reset()$ tq <- tq$find("textarea")$addAttr(
find("select")$addAttr(required = "true", `aria-required` = "true")$ required = "true", `aria-required` = "true"
reset() )$reset()
tq <- tq$find("select")$addAttr(
required = "true", `aria-required` = "true"
)$reset()
} }
tq$allTags() tq$allTags()
} }

View File

@@ -10,7 +10,5 @@
#' x <- shiny::icon("wrench") #' x <- shiny::icon("wrench")
#' htmlRemoveAttributes(x, "aria-label") #' htmlRemoveAttributes(x, "aria-label")
htmlRemoveAttributes <- function(el, ...) { htmlRemoveAttributes <- function(el, ...) {
htmltools::tagQuery(el)$ htmltools::tagQuery(el)$removeAttrs(list(...))$allTags()
removeAttrs(list(...))$
allTags()
} }

View File

@@ -11,15 +11,9 @@
#' htmlSetMaxLength(x, 50) #' htmlSetMaxLength(x, 50)
htmlSetMaxLength <- function(input, length) { htmlSetMaxLength <- function(input, length) {
htmltools::tagQuery(input)$ htmltools::tagQuery(input)$
find(".shiny-input-password")$ find(".shiny-input-password")$addAttr(maxlength = length)$reset()$
addAttr(maxlength = length)$ find(".shiny-input-text")$addAttr(maxlength = length)$reset()$
reset()$ find("textarea")$addAttr(maxlength = length)$allTags()
find(".shiny-input-text")$
addAttr(maxlength = length)$
reset()$
find("textarea")$
addAttr(maxlength = length)$
allTags()
} }
#' Set the minimum length on a text or textarea input #' Set the minimum length on a text or textarea input
@@ -35,13 +29,7 @@ htmlSetMaxLength <- function(input, length) {
#' htmlSetMinLength(x, 3) #' htmlSetMinLength(x, 3)
htmlSetMinLength <- function(input, length) { htmlSetMinLength <- function(input, length) {
htmltools::tagQuery(input)$ htmltools::tagQuery(input)$
find(".shiny-input-password")$ find(".shiny-input-password")$addAttr(minlength = length)$reset()$
addAttr(minlength = length)$ find(".shiny-input-text")$addAttr(minlength = length)$reset()$
reset()$ find("textarea")$addAttr(minlength = length)$allTags()
find(".shiny-input-text")$
addAttr(minlength = length)$
reset()$
find("textarea")$
addAttr(minlength = length)$
allTags()
} }

46
R/htmlSlugify.R Normal file
View File

@@ -0,0 +1,46 @@
slugify_charmap_env <- new.env()
#' Native(ish) R slugify
#'
#' @param x String to slugify
#' @param repl What to replace spaces with (default: -)
#' @param lower Lower case the output string
#'
#' @return The slugified output string
#' @export
#'
#' @examples
#' x <- c(
#' "A very short example",
#' "This has a $ symbol",
#' "user@example.com",
#' "~~ABC123~~",
#' "τυχαίος",
#' "file:///tmp/some/path"
#' )
#' htmlSlugify(x)
#' htmlSlugify(x, "_")
htmlSlugify <- function(x, repl = "-", lower = TRUE)
{
if (!exists("slugify_charmap", envir = slugify_charmap_env)){
assign(
"slugify_charmap",
jsonlite::fromJSON(
system.file("slugify_charmap.json", package = "AVSDevR.HTMLUtils")
),
envir = slugify_charmap_env
)
}
slugify_charmap <- get("slugify_charmap", envir = slugify_charmap_env)
x <- stringi::stri_replace_all_fixed(
x, names(slugify_charmap), slugify_charmap, vectorize_all = FALSE
)
x <- stringi::stri_replace_all_regex(x, "[^\\P{P}-]", "")
x <- stringi::stri_trim_both(x)
x <- stringi::stri_replace_all_regex(x, "[[:space:]]+", repl)
if (lower) {
x <- stringi::stri_trans_tolower(x)
}
x
}

643
inst/slugify_charmap.json Normal file
View File

@@ -0,0 +1,643 @@
{
"$": "dollar",
"%": "percent",
"&": "and",
"<": "less",
">": "greater",
"|": "or",
"¢": "cent",
"£": "pound",
"¤": "currency",
"¥": "yen",
"©": "(c)",
"ª": "a",
"®": "(r)",
"º": "o",
"À": "A",
"Á": "A",
"Â": "A",
"Ã": "A",
"Ä": "A",
"Å": "A",
"Æ": "AE",
"Ç": "C",
"È": "E",
"É": "E",
"Ê": "E",
"Ë": "E",
"Ì": "I",
"Í": "I",
"Î": "I",
"Ï": "I",
"Ð": "D",
"Ñ": "N",
"Ò": "O",
"Ó": "O",
"Ô": "O",
"Õ": "O",
"Ö": "O",
"Ø": "O",
"Ù": "U",
"Ú": "U",
"Û": "U",
"Ü": "U",
"Ý": "Y",
"Þ": "TH",
"ß": "ss",
"à": "a",
"á": "a",
"â": "a",
"ã": "a",
"ä": "a",
"å": "a",
"æ": "ae",
"ç": "c",
"è": "e",
"é": "e",
"ê": "e",
"ë": "e",
"ì": "i",
"í": "i",
"î": "i",
"ï": "i",
"ð": "d",
"ñ": "n",
"ò": "o",
"ó": "o",
"ô": "o",
"õ": "o",
"ö": "o",
"ø": "o",
"ù": "u",
"ú": "u",
"û": "u",
"ü": "u",
"ý": "y",
"þ": "th",
"ÿ": "y",
"Ā": "A",
"ā": "a",
"Ă": "A",
"ă": "a",
"Ą": "A",
"ą": "a",
"Ć": "C",
"ć": "c",
"Č": "C",
"č": "c",
"Ď": "D",
"ď": "d",
"Đ": "DJ",
"đ": "dj",
"Ē": "E",
"ē": "e",
"Ė": "E",
"ė": "e",
"Ę": "e",
"ę": "e",
"Ě": "E",
"ě": "e",
"Ğ": "G",
"ğ": "g",
"Ģ": "G",
"ģ": "g",
"Ĩ": "I",
"ĩ": "i",
"Ī": "i",
"ī": "i",
"Į": "I",
"į": "i",
"İ": "I",
"ı": "i",
"Ķ": "k",
"ķ": "k",
"Ļ": "L",
"ļ": "l",
"Ľ": "L",
"ľ": "l",
"Ł": "L",
"ł": "l",
"Ń": "N",
"ń": "n",
"Ņ": "N",
"ņ": "n",
"Ň": "N",
"ň": "n",
"Ō": "O",
"ō": "o",
"Ő": "O",
"ő": "o",
"Œ": "OE",
"œ": "oe",
"Ŕ": "R",
"ŕ": "r",
"Ř": "R",
"ř": "r",
"Ś": "S",
"ś": "s",
"Ş": "S",
"ş": "s",
"Š": "S",
"š": "s",
"Ţ": "T",
"ţ": "t",
"Ť": "T",
"ť": "t",
"Ũ": "U",
"ũ": "u",
"Ū": "u",
"ū": "u",
"Ů": "U",
"ů": "u",
"Ű": "U",
"ű": "u",
"Ų": "U",
"ų": "u",
"Ŵ": "W",
"ŵ": "w",
"Ŷ": "Y",
"ŷ": "y",
"Ÿ": "Y",
"Ź": "Z",
"ź": "z",
"Ż": "Z",
"ż": "z",
"Ž": "Z",
"ž": "z",
"Ə": "E",
"ƒ": "f",
"Ơ": "O",
"ơ": "o",
"Ư": "U",
"ư": "u",
"Lj": "LJ",
"lj": "lj",
"Nj": "NJ",
"nj": "nj",
"Ș": "S",
"ș": "s",
"Ț": "T",
"ț": "t",
"ə": "e",
"˚": "o",
"Ά": "A",
"Έ": "E",
"Ή": "H",
"Ί": "I",
"Ό": "O",
"Ύ": "Y",
"Ώ": "W",
"ΐ": "i",
"Α": "A",
"Β": "B",
"Γ": "G",
"Δ": "D",
"Ε": "E",
"Ζ": "Z",
"Η": "H",
"Θ": "8",
"Ι": "I",
"Κ": "K",
"Λ": "L",
"Μ": "M",
"Ν": "N",
"Ξ": "3",
"Ο": "O",
"Π": "P",
"Ρ": "R",
"Σ": "S",
"Τ": "T",
"Υ": "Y",
"Φ": "F",
"Χ": "X",
"Ψ": "PS",
"Ω": "W",
"Ϊ": "I",
"Ϋ": "Y",
"ά": "a",
"έ": "e",
"ή": "h",
"ί": "i",
"ΰ": "y",
"α": "a",
"β": "b",
"γ": "g",
"δ": "d",
"ε": "e",
"ζ": "z",
"η": "h",
"θ": "8",
"ι": "i",
"κ": "k",
"λ": "l",
"μ": "m",
"ν": "n",
"ξ": "3",
"ο": "o",
"π": "p",
"ρ": "r",
"ς": "s",
"σ": "s",
"τ": "t",
"υ": "y",
"φ": "f",
"χ": "x",
"ψ": "ps",
"ω": "w",
"ϊ": "i",
"ϋ": "y",
"ό": "o",
"ύ": "y",
"ώ": "w",
"Ё": "Yo",
"Ђ": "DJ",
"Є": "Ye",
"І": "I",
"Ї": "Yi",
"Ј": "J",
"Љ": "LJ",
"Њ": "NJ",
"Ћ": "C",
"Џ": "DZ",
"А": "A",
"Б": "B",
"В": "V",
"Г": "G",
"Д": "D",
"Е": "E",
"Ж": "Zh",
"З": "Z",
"И": "I",
"Й": "J",
"К": "K",
"Л": "L",
"М": "M",
"Н": "N",
"О": "O",
"П": "P",
"Р": "R",
"С": "S",
"Т": "T",
"У": "U",
"Ф": "F",
"Х": "H",
"Ц": "C",
"Ч": "Ch",
"Ш": "Sh",
"Щ": "Sh",
"Ъ": "U",
"Ы": "Y",
"Ь": "",
"Э": "E",
"Ю": "Yu",
"Я": "Ya",
"а": "a",
"б": "b",
"в": "v",
"г": "g",
"д": "d",
"е": "e",
"ж": "zh",
"з": "z",
"и": "i",
"й": "j",
"к": "k",
"л": "l",
"м": "m",
"н": "n",
"о": "o",
"п": "p",
"р": "r",
"с": "s",
"т": "t",
"у": "u",
"ф": "f",
"х": "h",
"ц": "c",
"ч": "ch",
"ш": "sh",
"щ": "sh",
"ъ": "u",
"ы": "y",
"ь": "",
"э": "e",
"ю": "yu",
"я": "ya",
"ё": "yo",
"ђ": "dj",
"є": "ye",
"і": "i",
"ї": "yi",
"ј": "j",
"љ": "lj",
"њ": "nj",
"ћ": "c",
"ѝ": "u",
"џ": "dz",
"Ґ": "G",
"ґ": "g",
"Ғ": "GH",
"ғ": "gh",
"Қ": "KH",
"қ": "kh",
"Ң": "NG",
"ң": "ng",
"Ү": "UE",
"ү": "ue",
"Ұ": "U",
"ұ": "u",
"Һ": "H",
"һ": "h",
"Ә": "AE",
"ә": "ae",
"Ө": "OE",
"ө": "oe",
"Ա": "A",
"Բ": "B",
"Գ": "G",
"Դ": "D",
"Ե": "E",
"Զ": "Z",
"Է": "E'",
"Ը": "Y'",
"Թ": "T'",
"Ժ": "JH",
"Ի": "I",
"Լ": "L",
"Խ": "X",
"Ծ": "C'",
"Կ": "K",
"Հ": "H",
"Ձ": "D'",
"Ղ": "GH",
"Ճ": "TW",
"Մ": "M",
"Յ": "Y",
"Ն": "N",
"Շ": "SH",
"Չ": "CH",
"Պ": "P",
"Ջ": "J",
"Ռ": "R'",
"Ս": "S",
"Վ": "V",
"Տ": "T",
"Ր": "R",
"Ց": "C",
"Փ": "P'",
"Ք": "Q'",
"Օ": "O''",
"Ֆ": "F",
"և": "EV",
"ء": "a",
"آ": "aa",
"أ": "a",
"ؤ": "u",
"إ": "i",
"ئ": "e",
"ا": "a",
"ب": "b",
"ة": "h",
"ت": "t",
"ث": "th",
"ج": "j",
"ح": "h",
"خ": "kh",
"د": "d",
"ذ": "th",
"ر": "r",
"ز": "z",
"س": "s",
"ش": "sh",
"ص": "s",
"ض": "dh",
"ط": "t",
"ظ": "z",
"ع": "a",
"غ": "gh",
"ف": "f",
"ق": "q",
"ك": "k",
"ل": "l",
"م": "m",
"ن": "n",
"ه": "h",
"و": "w",
"ى": "a",
"ي": "y",
"ً": "an",
"ٌ": "on",
"ٍ": "en",
"َ": "a",
"ُ": "u",
"ِ": "e",
"ْ": "",
"٠": "0",
"١": "1",
"٢": "2",
"٣": "3",
"٤": "4",
"٥": "5",
"٦": "6",
"٧": "7",
"٨": "8",
"٩": "9",
"پ": "p",
"چ": "ch",
"ژ": "zh",
"ک": "k",
"گ": "g",
"ی": "y",
"۰": "0",
"۱": "1",
"۲": "2",
"۳": "3",
"۴": "4",
"۵": "5",
"۶": "6",
"۷": "7",
"۸": "8",
"۹": "9",
"฿": "baht",
"ა": "a",
"ბ": "b",
"გ": "g",
"დ": "d",
"ე": "e",
"ვ": "v",
"ზ": "z",
"თ": "t",
"ი": "i",
"კ": "k",
"ლ": "l",
"მ": "m",
"ნ": "n",
"ო": "o",
"პ": "p",
"ჟ": "zh",
"რ": "r",
"ს": "s",
"ტ": "t",
"უ": "u",
"ფ": "f",
"ქ": "k",
"ღ": "gh",
"": "q",
"შ": "sh",
"ჩ": "ch",
"ც": "ts",
"ძ": "dz",
"წ": "ts",
"ჭ": "ch",
"ხ": "kh",
"ჯ": "j",
"ჰ": "h",
"Ṣ": "S",
"ṣ": "s",
"Ẁ": "W",
"ẁ": "w",
"Ẃ": "W",
"ẃ": "w",
"Ẅ": "W",
"ẅ": "w",
"ẞ": "SS",
"Ạ": "A",
"ạ": "a",
"Ả": "A",
"ả": "a",
"Ấ": "A",
"ấ": "a",
"Ầ": "A",
"ầ": "a",
"Ẩ": "A",
"ẩ": "a",
"Ẫ": "A",
"ẫ": "a",
"Ậ": "A",
"ậ": "a",
"Ắ": "A",
"ắ": "a",
"Ằ": "A",
"ằ": "a",
"Ẳ": "A",
"ẳ": "a",
"Ẵ": "A",
"ẵ": "a",
"Ặ": "A",
"ặ": "a",
"Ẹ": "E",
"ẹ": "e",
"Ẻ": "E",
"ẻ": "e",
"Ẽ": "E",
"ẽ": "e",
"Ế": "E",
"ế": "e",
"Ề": "E",
"ề": "e",
"Ể": "E",
"ể": "e",
"Ễ": "E",
"ễ": "e",
"Ệ": "E",
"ệ": "e",
"Ỉ": "I",
"ỉ": "i",
"Ị": "I",
"ị": "i",
"Ọ": "O",
"ọ": "o",
"Ỏ": "O",
"ỏ": "o",
"Ố": "O",
"ố": "o",
"Ồ": "O",
"ồ": "o",
"Ổ": "O",
"ổ": "o",
"Ỗ": "O",
"ỗ": "o",
"Ộ": "O",
"ộ": "o",
"Ớ": "O",
"ớ": "o",
"Ờ": "O",
"ờ": "o",
"Ở": "O",
"ở": "o",
"Ỡ": "O",
"ỡ": "o",
"Ợ": "O",
"ợ": "o",
"Ụ": "U",
"ụ": "u",
"Ủ": "U",
"ủ": "u",
"Ứ": "U",
"ứ": "u",
"Ừ": "U",
"ừ": "u",
"Ử": "U",
"ử": "u",
"Ữ": "U",
"ữ": "u",
"Ự": "U",
"ự": "u",
"Ỳ": "Y",
"ỳ": "y",
"Ỵ": "Y",
"ỵ": "y",
"Ỷ": "Y",
"ỷ": "y",
"Ỹ": "Y",
"ỹ": "y",
"": "-",
"": "'",
"": "'",
"“": "\\\"",
"”": "\\\"",
"„": "\\\"",
"†": "+",
"•": "*",
"…": "...",
"₠": "ecu",
"₢": "cruzeiro",
"₣": "french franc",
"₤": "lira",
"₥": "mill",
"₦": "naira",
"₧": "peseta",
"₨": "rupee",
"₩": "won",
"₪": "new shequel",
"₫": "dong",
"€": "euro",
"₭": "kip",
"₮": "tugrik",
"₯": "drachma",
"₰": "penny",
"₱": "peso",
"₲": "guarani",
"₳": "austral",
"₴": "hryvnia",
"₵": "cedi",
"₸": "kazakhstani tenge",
"₹": "indian rupee",
"₺": "turkish lira",
"₽": "russian ruble",
"₿": "bitcoin",
"℠": "sm",
"™": "tm",
"∂": "d",
"∆": "delta",
"∑": "sum",
"∞": "infinity",
"♥": "love",
"元": "yuan",
"円": "yen",
"﷼": "rial",
"ﻵ": "laa",
"ﻷ": "laa",
"ﻹ": "lai",
"ﻻ": "la"
}

View File

@@ -19,5 +19,7 @@ Add attributes to .box elements (\code{shinydashboard::box})
} }
\examples{ \examples{
x <- shinydashboard::box() x <- shinydashboard::box()
htmlAddBoxAttributes(x, role = "region", `aria-label` = "This is a special box") htmlAddBoxAttributes(
x, role = "region", `aria-label` = "This is a special box"
)
} }

26
man/htmlAddBoxHelpLink.Rd Normal file
View File

@@ -0,0 +1,26 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlBoxManipulation.R
\name{htmlAddBoxHelpLink}
\alias{htmlAddBoxHelpLink}
\title{Adds a "help" (question mark) icon to a box tools section (right side)}
\usage{
htmlAddBoxHelpLink(box, href, title = NULL)
}
\arguments{
\item{box}{The box to add a help icon/link to}
\item{href}{The help uri to load}
\item{title}{Optional title for the help link. Defaults to box title}
}
\value{
The modified box
}
\description{
The uri to load can have a replacement marker supplied '\%box\%' which will be
substituded with a sanitized copy of the box title.
}
\examples{
x <- shinydashboard::box(title = "This is a box")
htmlAddBoxHelpLink(x, href = "http://example.com/help-guide#\%box\%")
}

23
man/htmlAddClasses.Rd Normal file
View File

@@ -0,0 +1,23 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlClassManipulation.R
\name{htmlAddClasses}
\alias{htmlAddClasses}
\title{Add classes to an HTML element}
\usage{
htmlAddClasses(el, classes)
}
\arguments{
\item{el}{The element to add the class(es) to}
\item{classes}{The class(es) to be added}
}
\value{
The modified element
}
\description{
Add classes to an HTML element
}
\examples{
x <- shiny::tags$div()
htmlAddClasses(x, "btn-warning")
}

View File

@@ -0,0 +1,23 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlAppendAttributes.R
\name{htmlAppendAttributes}
\alias{htmlAppendAttributes}
\title{Appends attributes to an HTML element}
\usage{
htmlAppendAttributes(el, ...)
}
\arguments{
\item{el}{The element to append the attributes to}
\item{...}{The attribute names to be appended}
}
\value{
The modified element
}
\description{
Appends attributes to an HTML element
}
\examples{
x <- shiny::icon("wrench")
htmlAppendAttributes(x, `role` = "presentation")
}

23
man/htmlButtonStyle.Rd Normal file
View File

@@ -0,0 +1,23 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlClassManipulation.R
\name{htmlButtonStyle}
\alias{htmlButtonStyle}
\title{Changes the style of a button from btn-default to another style}
\usage{
htmlButtonStyle(el, style)
}
\arguments{
\item{el}{The button}
\item{style}{The style to change the button on}
}
\value{
The modified element
}
\description{
Changes the style of a button from btn-default to another style
}
\examples{
x <- shiny::tags$div(class = "btn btn-warning")
htmlButtonStyle(x, "warning")
}

25
man/htmlRemoveBoxTitle.Rd Normal file
View File

@@ -0,0 +1,25 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlBoxManipulation.R
\name{htmlRemoveBoxTitle}
\alias{htmlRemoveBoxTitle}
\title{Removes title from box element (leaving an un-titled box with header if
required)}
\usage{
htmlRemoveBoxTitle(box, removeHeader = FALSE)
}
\arguments{
\item{box}{The box to remove the title from}
\item{removeHeader}{Remove the header as well}
}
\value{
The modified box
}
\description{
Removes title from box element (leaving an un-titled box with header if
required)
}
\examples{
x <- shinydashboard::box(title = "TBR")
htmlRemoveBoxTitle(x)
}

23
man/htmlRemoveClasses.Rd Normal file
View File

@@ -0,0 +1,23 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlClassManipulation.R
\name{htmlRemoveClasses}
\alias{htmlRemoveClasses}
\title{Remove classes from an HTML element}
\usage{
htmlRemoveClasses(el, classes)
}
\arguments{
\item{el}{The element to remove the class(es) from}
\item{classes}{The class(es) to be added}
}
\value{
The modified element
}
\description{
Remove classes from an HTML element
}
\examples{
x <- shiny::tags$div(class = "btn btn-warning")
htmlRemoveClasses(x, "btn-warning")
}

33
man/htmlSlugify.Rd Normal file
View File

@@ -0,0 +1,33 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlSlugify.R
\name{htmlSlugify}
\alias{htmlSlugify}
\title{Native(ish) R slugify}
\usage{
htmlSlugify(x, repl = "-", lower = TRUE)
}
\arguments{
\item{x}{String to slugify}
\item{repl}{What to replace spaces with (default: -)}
\item{lower}{Lower case the output string}
}
\value{
The slugified output string
}
\description{
Native(ish) R slugify
}
\examples{
x <- c(
"A very short example",
"This has a $ symbol",
"user@example.com",
"~~ABC123~~",
"τυχαίος",
"file:///tmp/some/path"
)
htmlSlugify(x)
htmlSlugify(x, "_")
}