1- # ' Initializes `FilterState`
1+ # ' Initialize `FilterState`
22# '
3- # ' Initializes `FilterState` depending on a variable class.
3+ # ' Initializes a `FilterState` object corresponding to the class of the filtered variable .
44# '
55# ' @param x (`vector`)
6- # ' values of the variable used in filter
6+ # ' variable to be filtered.
77# ' @param x_reactive (`reactive`)
88# ' returning vector of the same type as `x`. Is used to update
99# ' counts following the change in values of the filtered dataset.
1010# ' If it is set to `reactive(NULL)` then counts based on filtered
1111# ' dataset are not shown.
1212# ' @param slice (`teal_slice`)
13- # ' object created using [teal_slice()].
13+ # ' specification of this filter state.
14+ # ' `teal_slice` is stored in the object and `set_state` directly manipulates values within `teal_slice`.
15+ # ' `get_state` returns `teal_slice` object which can be reused in other places.
16+ # ' Note that `teal_slice` is a `reactiveValues`, which means it has reference semantics, i.e.
17+ # ' changes made to an object are automatically reflected in all places that refer to the same `teal_slice`.
1418# ' @param extract_type (`character`)
1519# ' specifying whether condition calls should be prefixed by `dataname`. Possible values:
1620# ' - `character(0)` (default) `varname` in the condition call will not be prefixed
1721# ' - `"list"` `varname` in the condition call will be returned as `<dataname>$<varname>`
1822# ' - `"matrix"` `varname` in the condition call will be returned as `<dataname>[, <varname>]`
19- # ' @param ... additional arguments to be saved as a list in `private$extras` field
2023# '
2124# ' @examples
2225# ' # use non-exported function from teal.slice
23- # ' include_js_files <- getFromNamespace("include_js_files", "teal.slice")
2426# ' init_filter_state <- getFromNamespace("init_filter_state", "teal.slice")
2527# '
2628# ' filter_state <- init_filter_state(
2729# ' x = c(1:10, NA, Inf),
2830# ' x_reactive = reactive(c(1:10, NA, Inf)),
2931# ' slice = teal_slice(
30- # ' varname = "x ",
32+ # ' varname = "varname ",
3133# ' dataname = "dataname"
3234# ' ),
3335# ' extract_type = "matrix"
@@ -218,11 +220,7 @@ init_filter_state.POSIXlt <- function(x,
218220# ' Initialize a `FilterStateExpr` object
219221# '
220222# ' @param slice (`teal_slice_expr`)
221- # ' object created using [teal_slice()]. `teal_slice` is stored
222- # ' in the class and `set_state` directly manipulates values within `teal_slice`. `get_state`
223- # ' returns `teal_slice` object which can be reused in other places. Beware, that `teal_slice`
224- # ' is a `reactiveValues` which means that changes in particular object are automatically
225- # ' reflected in all places which refer to the same `teal_slice`.
223+ # ' specifying this filter state.
226224# '
227225# ' @return `FilterStateExpr` object
228226# ' @keywords internal
@@ -241,6 +239,13 @@ init_filter_state_expr <- function(slice) {
241239# ' set to NULL to omit adding the alpha channel
242240# '
243241# ' @return Named `character(1)` containing a hexadecimal color representation.
242+ # '
243+ # ' @examples
244+ # ' fetch_bs_color <- getFromNamespace("fetch_bs_color", "teal.slice")
245+ # ' fetch_bs_color("primary")
246+ # ' fetch_bs_color("danger", 0.35)
247+ # ' fetch_bs_color("danger", "80")
248+ # '
244249# ' @keywords internal
245250# '
246251fetch_bs_color <- function (color , alpha = NULL ) {
@@ -251,7 +256,6 @@ fetch_bs_color <- function(color, alpha = NULL) {
251256 )
252257
253258 # locate file that describes the current theme
254- # # TODO this is not ideal
255259 sass_file <- if (utils :: packageVersion(" bslib" ) < as.package_version(" 0.5.1.9000" )) {
256260 bslib :: bs_theme()[[" layers" ]][[2 ]][[" defaults" ]][[1 ]]
257261 } else {
0 commit comments