Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ignore JS config files/folders
node_modules/
coverage/
src/
lib/
.babelrc
.builderrc
.eslintrc
.npmignore

# demo folder has special meaning in R
# this should hopefully make it still
# allow for the possibility to make R demos
demo/*.js
demo/*.html
demo/*.css

# ignore python files/folders
setup.py
usage.py
setup.py
requirements.txt
MANIFEST.in
CHANGELOG.md
test/
# CRAN has weird LICENSE requirements
LICENSE.txt
^.*\.Rproj$
^\.Rproj\.user$
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ dist/
lib/
lib/bundle.js*
node_modules/
dash_table_experiments/bundle.js*
.npm
vv/
venv/
*.pyc
*.egg-info
*.log
.DS_Store
.Rproj.user
.Rhistory
.idea
16 changes: 16 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Package: dashTable
Title: An experimental dasher table component
Version: 0.0.1
Authors@R: c(
person(family = "plotly", role = c("aut", "cre"), email = "chris@plot.ly"),
person("Carson", "Sievert", role = "aut"))
Description: An experimental dasher table component
Suggests:
testthat,
roxygen2
License: MIT + file LICENSE
URL: https://github.com/plotly/dash-table-experiments
BugReports: https://github.com/plotly/dash-table-experiments/issues
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2017
COPYRIGHT HOLDER: plotly
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generated by roxygen2: do not edit by hand

export(DataTable)
export(EditableTable)
export(VirtualizedTable)
205 changes: 205 additions & 0 deletions R/components.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# Auto-generated by dashRtranspile -- do not edit by hand

#' DataTable component
#' @description
#' @export
#' @param id
#' @param editable Are the cells in the table editable? If `True`, you can listen to `rows` or `row_update` to get the updated data.
#' @param filterable Should the filtering UI in the Table appear? If `True`, you can listen to `rows` or `row_update` to get the updated data.
#' @param sortable Is the table sortable? If `True`, click on the column headers to sort by that column. If `True`, you can listen to `rows` or `row_update` to get the updated data.
#' @param resizable Are the columns resizble? If `True`, then the columns can be resized by clicking and dragging on the border on the edge of the column header. If `False`, they cannot be resized.
#' @param column_widths Column widths (in pixels) of each column
#' @param columns Order of columns. Note that the column names are specified in `rows` but without order. This attribute allows you to specify a custom order for your columns.
#' @param row_selectable
#' @param selected_row_indices
#' @param enable_drag_and_drop
#' @param header_row_height
#' @param min_height
#' @param min_width
#' @param max_rows_in_viewport Maximum number of of rows to display in the viewport. If `max_rows_in_viewport` is 10, then if there are 15 rows, only 10 will be displayed in the viewport but if there are 5 rows, then the viewport will shrink to only show those 5 rows. This takes precedence over `min_height`.
#' @param row_height
#' @param row_scroll_timeout
#' @param tab_index
#' @param filters
#' @param rows
#' @param row_update
#' @param sortColumn
#' @param sortDirection
#' @param setProps

DataTable <- function(id = NULL, editable = TRUE, filterable = FALSE, sortable = TRUE, resizable = TRUE, column_widths = NULL, columns = NULL, row_selectable = FALSE, selected_row_indices = list(), enable_drag_and_drop = NULL, header_row_height = NULL, min_height = NULL, min_width = NULL, max_rows_in_viewport = NULL, row_height = 35, row_scroll_timeout = NULL, tab_index = NULL, filters = list(), rows = NULL, row_update = NULL, sortColumn = NULL, sortDirection = NULL, setProps = NULL) {

component <- list(
props = list(
id=id,
editable=editable,
filterable=filterable,
sortable=sortable,
resizable=resizable,
column_widths=column_widths,
columns=columns,
row_selectable=row_selectable,
selected_row_indices=selected_row_indices,
enable_drag_and_drop=enable_drag_and_drop,
header_row_height=header_row_height,
min_height=min_height,
min_width=min_width,
max_rows_in_viewport=max_rows_in_viewport,
row_height=row_height,
row_scroll_timeout=row_scroll_timeout,
tab_index=tab_index,
filters=filters,
rows=rows,
row_update=row_update,
sortColumn=sortColumn,
sortDirection=sortDirection,
setProps=setProps
),
type = 'DataTable',
namespace = 'dash_table_experiments',
propNames = c('id', 'editable', 'filterable', 'sortable', 'resizable', 'column_widths', 'columns', 'row_selectable', 'selected_row_indices', 'enable_drag_and_drop', 'header_row_height', 'min_height', 'min_width', 'max_rows_in_viewport', 'row_height', 'row_scroll_timeout', 'tab_index', 'filters', 'rows', 'row_update', 'sortColumn', 'sortDirection', 'setProps'),
package = 'dashTable'
)

component$props <- filter_null(component$props)


structure(component, class = c('dash_component', 'list'))
}

# Auto-generated by dashRtranspile -- do not edit by hand

#' EditableTable component
#' @description
#' @export
#' @param id The ID of the component, used to identify the component in Dash callbacks
#' @param changed_data
#' @param dataframe The data of this table, in the form of a Pandas DataFrame.to_dict() The keys of the dict are the column names and the values are a dict that represents the column where the keys of the column are the values of the index and the values are the rows. For example, { "Column 1": {"0": "Value A", "1": "Value B"}, "Column 2": {"0": 3129, "1": 4931}, } If `editable=True`, then this `dataframe` will be updated when the user changes values
#' @param column_order Order of the columns
#' @param index_name The name of the index column. This name is not included in the `dataframe` object
#' @param editable Whether or not this table is editable
#' @param base_styles CSS styles for all of the different elements in this table. The `base_styles` have a default value. If you want to remove all default styles, set `base_styles` to `{}`.
#' @param merged_styles `merged_styles` is recursively merged into `base_styles`. Use `merged_styles` if you want to update or overwrite a small set of the base styles.
#' @param types
#' @param setProps Dash supplied function

EditableTable <- function(id = NULL, changed_data = list(), dataframe = NULL, column_order = NULL, index_name = '', editable = FALSE, base_styles = list(numeric = list(`text-align` = "right", `font-family` = "'Droid Sans Mono', Courier, monospace"), string = list(`text-align` = "left"), input = list(padding = 0, margin = 0, width = "80px", border = "none", `font-size` = "1rem"), `input-active` = list(outline = "#7FDBFF auto 3px"), table = list(`border-collapse` = "collapse", `box-sizing` = "border-box", `font-size` = "1rem"), thead = list(display = "table-row-group"), th = list(`text-align` = "left", `font-weight` = "normal", border = "thin lightgrey solid",
width = "80px"), td = list(`white-space` = "nowrap", border = "thin lightgrey solid", width = "80px", `max-width` = "80px", `text-overflow` = "ellipsis", `overflow-x` = "hidden")), merged_styles = list(), types = list(), setProps = NULL) {

component <- list(
props = list(
id=id,
changed_data=changed_data,
dataframe=dataframe,
column_order=column_order,
index_name=index_name,
editable=editable,
base_styles=base_styles,
merged_styles=merged_styles,
types=types,
setProps=setProps
),
type = 'EditableTable',
namespace = 'dash_table_experiments',
propNames = c('id', 'changed_data', 'dataframe', 'column_order', 'index_name', 'editable', 'base_styles', 'merged_styles', 'types', 'setProps'),
package = 'dashTable'
)

component$props <- filter_null(component$props)


structure(component, class = c('dash_component', 'list'))
}

# Auto-generated by dashRtranspile -- do not edit by hand

#' VirtualizedTable component
#' @description
#' @export
#' @param id The ID of the component, used to identify the component in Dash callbacks
#' @param changed_data
#' @param dataframe The data of this table, in the form of a Pandas DataFrame.to_dict('split') For example, { 'columns': ['Column 1', 'Column 2', 'Column 3'], 'data': [[1, 2, 3], [4, 3, 1]], 'index': [1, 2, 3] } If `editable=True`, then this `dataframe` will be updated when the user changes values
#' @param display_index Whether or not to show the index column
#' @param index_name The name of the index column. This name is not included in the `dataframe` object
#' @param editable Whether or not this table is editable
#' @param styles CSS styles for all of the different elements in this table. The `styles` have a default value. If you want to remove all default styles, set `styles` to `{}`.
#' @param column_width Column width (in pixels)
#' @param row_height Row height (in pixels)
#' @param height Height of entire table (in pixels)
#' @param width Width of entire table (in pixels)
#' @param setProps Dash supplied function

VirtualizedTable <- function(id = NULL, changed_data = NULL, dataframe = NULL, display_index = TRUE, index_name = '', editable = TRUE, styles = list(container = list(`font-size` = "1rem"), cell = list(`white-space` = "nowrap", `border-left` = "thin lightgrey solid", `border-bottom` = "thin lightgrey solid", `border-top` = "none", `border-right` = "none", `text-overflow` = "ellipsis", `overflow-x` = "hidden", `box-sizing` = "border-box"), `cell-rightmost` = list(`border-right` = "thin lightgrey solid"), header = list(`text-align` = "left", `border-left` = "thin lightgrey solid", `border-bottom` = "thin lightgrey solid", `border-top` = "thin lightgrey solid",
`font-weight` = 600, display = "inline-block", `box-sizing` = "border-box"), `header-rightmost` = list(`border-right` = "thin lightgrey solid")), column_width = 80, row_height = 20, height = 500, width = 600, setProps = NULL) {

component <- list(
props = list(
id=id,
changed_data=changed_data,
dataframe=dataframe,
display_index=display_index,
index_name=index_name,
editable=editable,
styles=styles,
column_width=column_width,
row_height=row_height,
height=height,
width=width,
setProps=setProps
),
type = 'VirtualizedTable',
namespace = 'dash_table_experiments',
propNames = c('id', 'changed_data', 'dataframe', 'display_index', 'index_name', 'editable', 'styles', 'column_width', 'row_height', 'height', 'width', 'setProps'),
package = 'dashTable'
)

component$props <- filter_null(component$props)


structure(component, class = c('dash_component', 'list'))
}


filter_null <- function(x) {
if (length(x) == 0 || !is.list(x)) return(x)
x[!vapply(x, is.null, logical(1))]
}

assert_valid_children <- function(..., wildcards = NULL) {
kids <- list(...)
if (length(wildcards)) {
pattern <- paste(paste0('^', wildcards), collapse = '|')
kids <- kids[!grepl(pattern, names2(kids))]
}
if (!length(kids)) return(NULL)
assert_no_names(kids)
}

append_wildcard_props <- function(component, wildcards = NULL, ...) {
attrs <- list(...)
if (!length(attrs) || !length(wildcards)) return(component)
pattern <- paste(paste0('^', wildcards), collapse = '|')
attrs_wild <- attrs[grepl(pattern, names2(attrs))]
if (!length(attrs_wild)) return(component)
component[['props']] <- c(component[['props']] %||% list(), attrs_wild)
component[['propNames']] <- c(component[['propNames']], names(attrs_wild))
component
}

names2 <- function(x) names(x) %||% rep('', length(x))

`%||%` <- function(x, y) if (length(x)) x else y

assert_no_names <- function(x) {
nms <- names(x)
if (!is.null(nms)) {
stop(
sprintf(
"Didn't recognize the following named arguments: '%s'",
paste(nms, collapse = "', '")
), call. = FALSE
)
}
names(x) <- NULL
x
}
17 changes: 17 additions & 0 deletions dash-table-experiments.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
Loading