shiny

repository·main·Indexed 26 days ago

https://github.com/rstudio/shiny

An R package for building interactive web applications without requiring HTML, CSS, or JavaScript. It utilizes a reactive programming model to automatically update outputs based on user inputs. The package includes tools for UI definition, reactive expressions, file uploads/downloads, and supports custom HTML pages. Version 1.14.0-alpha.9000.

Tokens
4.8K
Snippets
14
Records
51
Agent score
91%

What's inside shiny

  1. Update and patch selectize

    main

    To update selectize and its accessibility plugin, run the updateSelectize.R script. This script downloads specific versions and applies patches from tools/selectize-patches.

    To create a new patch:

    1. Modify files in inst/www/shared/selectize.
    2. Do not commit changes.
    3. Create a patch file using git diff and save it to tools/selectize-patches/. Use an alphanumeric prefix (e.g., 000-description.patch) to ensure it is applied in the correct order.
    4. Run updateSelectize.R to download the library and apply patches.
    5. Test the changes.
    6. git add the new .patch file and any resulting changes.
    git diff > tools/selectize-patches/000-assign-unique-id-per-option.patch
    updateSelectize.R
  2. Use reactive expressions for efficient computation

    main

    Use Reactive expressions to create values that automatically re-evaluate only when their specific dependencies change.

    For example, if a reactive expression depends on a specific input field (e.g., a Variable field), it will re-calculate when that field changes, but it will not re-calculate if other unrelated inputs (e.g., a Show Outliers checkbox) are toggled. This optimizes performance by avoiding unnecessary computations.

  3. Update and patch ion.rangeSlider

    main

    To update ion.rangeSlider, run the updateIonRangeSlider.R script. This script downloads a specific version and applies existing patches located in tools/ion.rangeSlider-patches.

    To create a new patch:

    1. Modify files in inst/www/shared/ion.rangeSlider.
    2. Do not commit changes.
    3. Create a patch file using git diff and save it to tools/ion.rangeSlider-patches/. Use an alphanumeric prefix (e.g., 0004-description.patch) to ensure it is applied last.
    4. Run updateIonRangeSlider.R to download the library and apply patches.
    5. Test the changes.
    6. Run devtools::document().
    7. git add the new .patch file and any resulting changes.
    git diff > tools/ion.rangeSlider-patches/0004-a-description.patch
    updateIonRangeSlider.R
    devtools::document()
  4. Update and patch bootstrap-datepicker

    main

    To update the bootstrap-datepicker library, run the updateBootstrapDatepicker.R script.

    To create a new patch:

    1. Modify files in inst/www/shared/datepicker.
    2. Do not commit changes.
    3. Create a patch file using git diff and save it to tools/datepicker-patches/. Use an alphanumeric prefix (e.g., 012-description.patch) to ensure it is applied in the correct order (patches are applied alphabetically).
    4. Source updateBootstrapDatepicker.R to download the library and apply all patches.
    5. Test the changes.
    6. git add the new .patch file and any resulting changes.
  5. Load compiled Shiny files

    main
    Ensure your compiled JavaScript files are loaded after shiny.js has been loaded into the page. If you use htmlDependency() to add your code to a Shiny page, your script will automatically be loaded after shiny.js.
  6. Implement file downloads in Shiny

    main

    To enable file downloads in a Shiny application, you must combine two components:

    1. UI Component: Add a downloadButton() to your user interface to provide the trigger for the user.
    2. Server Logic: Implement a downloadHandler() within your server function. This handler manages the file content and the filename provided to the browser.
  7. Install Shiny TypeScript definitions

    main

    When developing TypeScript projects that interact with window.Shiny, install the Shiny TypeScript definitions to your package. Match the GitHub tag to your current Shiny CRAN release (e.g., v1.11.0).

    If prompted to select a version of @types/jquery, choose the version that most closely matches your project's version.