diff --git a/pkgdown.yml b/pkgdown.yml index fdfda6c2..659cbc99 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -9,7 +9,7 @@ articles: sz-how-to-troubleshoot: sz-how-to-troubleshoot.html sz-how-to-use-fluent-docs: sz-how-to-use-fluent-docs.html topic_react-in-shiny: topic_react-in-shiny.html -last_built: 2023-08-31T12:56Z +last_built: 2023-10-02T14:16Z urls: reference: https://appsilon.github.io/shiny.fluent/reference article: https://appsilon.github.io/shiny.fluent/articles diff --git a/reference/CommandBar.html b/reference/CommandBar.html index fa0f55f8..e2b71764 100644 --- a/reference/CommandBar.html +++ b/reference/CommandBar.html @@ -122,7 +122,7 @@
@@ -154,7 +154,9 @@

Usage

-
CommandBar(...)
+
CommandBar(...)
+
+CommandBar.shinyInput(inputId, ..., itemValueGetter = function(el) el$key)
@@ -163,6 +165,14 @@

Arguments

Value

@@ -203,69 +213,91 @@

Examples
library(shiny)
 library(shiny.fluent)
 
-items <- list(
+items <- function(ns) {
   list(
-    key = "newItem",
-    text = "New",
-    cacheKey = "myCacheKey",
-    iconProps = list(iconName = "Add"),
-    subMenuProps = list(
-      items = list(
-        list(
-          key = "emailMessage",
-          text = "Email message",
-          iconProps = list(iconName = "Mail")
-        ),
-        list(
-          key = "calendarEvent",
-          text = "Calendar event",
-          iconProps = list(iconName = "Calendar")
+    CommandBarItem(
+      key = ns("newItem"),
+      text = "New",
+      cacheKey = "myCacheKey",
+      split = TRUE,
+      iconProps = list(iconName = "Add"),
+      subMenuProps = list(
+        items = list(
+          CommandBarItem(
+            key = ns("emailMessage"),
+            text = "Email message",
+            iconProps = list(iconName = "Mail")
+          ),
+          CommandBarItem(
+            key = ns("calendarEvent"),
+            text = "Calendar event",
+            iconProps = list(iconName = "Calendar")
+          )
         )
       )
+    ),
+    CommandBarItem(
+      key = ns("upload"),
+      text = "Upload",
+      iconProps = list(iconName = "Upload")
+    ),
+    CommandBarItem(
+      key = ns("share"),
+      text = "Share",
+      iconProps = list(iconName = "Share")
+    ),
+    CommandBarItem(
+      key = ns("download"),
+      text = "Download",
+      iconProps = list(iconName = "Download")
     )
-  ),
-  list(
-    key = "upload",
-    text = "Upload",
-    iconProps = list(iconName = "Upload")
-  ),
-  list(
-    key = "share",
-    text = "Share",
-    iconProps = list(iconName = "Share")
-  ),
-  list(
-    key = "download",
-    text = "Download",
-    iconProps = list(iconName = "Download")
   )
-)
+}
 
-farItems <- list(
-  list(
-    key = "tile",
-    text = "Grid view",
-    ariaLabel = "Grid view",
-    iconOnly = TRUE,
-    iconProps = list(iconName = "Tiles")
-  ),
+farItems <- function(ns) {
   list(
-    key = "info",
-    text = "Info",
-    ariaLabel = "Info",
-    iconOnly = TRUE,
-    iconProps = list(iconName = "Info")
+    CommandBarItem(
+      key = ns("tile"),
+      text = "Grid view",
+      ariaLabel = "Grid view",
+      iconOnly = TRUE,
+      iconProps = list(iconName = "Tiles")
+    ),
+    CommandBarItem(
+      key = ns("info"),
+      text = "Info",
+      ariaLabel = "Info",
+      iconOnly = TRUE,
+      iconProps = list(iconName = "Info")
+    )
   )
-)
-
+}
 
 ui <- function(id) {
   ns <- NS(id)
-  CommandBar(items = items, farItems = farItems)
+  tagList(
+    CommandBar(
+      items = items(ns),
+      farItems = farItems(ns)
+    ),
+    textOutput(ns("commandBarItems")),
+    CommandBar.shinyInput(
+      inputId = ns("commandBar"),
+      items = items(identity),
+      farItems = farItems(identity)
+    ),
+    textOutput(ns("commandBar"))
+  )
 }
 
 server <- function(id) {
-  moduleServer(id, function(input, output, session) { })
+  moduleServer(id, function(input, output, session) {
+    commandBarItemClicked <- reactiveVal()
+    observeEvent(input$newItem, commandBarItemClicked("newItem clicked"))
+    observeEvent(input$upload, commandBarItemClicked("upload clicked"))
+    output$commandBarItems <- renderText(commandBarItemClicked())
+    output$commandBar <- renderText(input$commandBar)
+  })
 }
 
 if (interactive()) {
diff --git a/reference/CommandBarItem.html b/reference/CommandBarItem.html
index 955a8053..c54e42be 100644
--- a/reference/CommandBarItem.html
+++ b/reference/CommandBarItem.html
@@ -1,5 +1,5 @@
 
-Command bar item — CommandBarItem • shiny.fluentCommand bar item — CommandBarItem • shiny.fluent