Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
6 changes: 6 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ parser: '@typescript-eslint/parser'
parserOptions:
ecmaVersion: 2018
sourceType: module
project:
- './tsconfig.json'
plugins:
- '@typescript-eslint'
- prettier
Expand Down Expand Up @@ -68,6 +70,10 @@ rules:

"@typescript-eslint/consistent-type-imports":
- error

"@typescript-eslint/no-floating-promises":
- error

"@typescript-eslint/naming-convention":
- error

Expand Down
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ Suggests:
magrittr,
rappdirs,
rmarkdown (>= 2.7),
shiny (>= 1.6.0),
shiny (>= 1.7.5.9001),
testthat,
thematic,
withr
Remotes:
rstudio/htmltools
Config/Needs/deploy:
rstudio/htmltools,
rstudio/shiny
Config/Needs/deploy:
BH,
chiflights22,
colourpicker,
Expand Down
143 changes: 85 additions & 58 deletions inst/components/dist/components.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions inst/components/dist/components.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions inst/components/dist/components.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions inst/components/dist/components.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"devDependencies": {
"@types/bootstrap": "5.2.2",
"@types/node": "^18.11.18",
"@types/rstudio-shiny": "https://github.com/rstudio/shiny#v1.7.4",
"@types/rstudio-shiny": "https://github.com/rstudio/shiny#async-receivemessage",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"esbuild": "^0.16.14",
Expand Down
20 changes: 10 additions & 10 deletions srcts/src/components/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class AccordionInputBinding extends InputBinding {
$(el).off(".accordionInputBinding");
}

receiveMessage(el: HTMLElement, data: MessageData) {
async receiveMessage(el: HTMLElement, data: MessageData) {
const method = data.method;
if (method === "set") {
this._setItems(el, data);
Expand All @@ -94,9 +94,9 @@ class AccordionInputBinding extends InputBinding {
} else if (method === "remove") {
this._removeItem(el, data);
} else if (method === "insert") {
this._insertItem(el, data);
await this._insertItem(el, data);
} else if (method === "update") {
this._updateItem(el, data);
await this._updateItem(el, data);
} else {
throw new Error(`Method not yet implemented: ${method}`);
}
Expand Down Expand Up @@ -126,7 +126,7 @@ class AccordionInputBinding extends InputBinding {
});
}

protected _insertItem(el: HTMLElement, data: InsertMessage) {
protected async _insertItem(el: HTMLElement, data: InsertMessage) {
let targetItem = this._findItem(el, data.target);

// If no target was specified, or the target was not found, then default
Expand All @@ -141,13 +141,13 @@ class AccordionInputBinding extends InputBinding {

// If there is still no targetItem, then there are no items in the accordion
if (targetItem) {
Shiny.renderContent(
await Shiny.renderContent(
targetItem,
panel,
data.position === "before" ? "beforeBegin" : "afterEnd"
);
} else {
Shiny.renderContent(el, panel);
await Shiny.renderContent(el, panel);
}

// Need to add a reference to the parent id that makes autoclose to work
Expand All @@ -172,7 +172,7 @@ class AccordionInputBinding extends InputBinding {
});
}

protected _updateItem(el: HTMLElement, data: UpdateMessage) {
protected async _updateItem(el: HTMLElement, data: UpdateMessage) {
const target = this._findItem(el, data.target);

if (!target) {
Expand All @@ -187,21 +187,21 @@ class AccordionInputBinding extends InputBinding {

if (hasDefinedProperty(data, "body")) {
const body = target.querySelector(".accordion-body") as HTMLElement; // always exists
Shiny.renderContent(body, data.body);
await Shiny.renderContent(body, data.body);
}

const header = target.querySelector(".accordion-header") as HTMLElement; // always exists

if (hasDefinedProperty(data, "title")) {
const title = header.querySelector(".accordion-title") as HTMLElement; // always exists
Shiny.renderContent(title, data.title);
await Shiny.renderContent(title, data.title);
}

if (hasDefinedProperty(data, "icon")) {
const icon = header.querySelector(
".accordion-button > .accordion-icon"
) as HTMLElement; // always exists
Shiny.renderContent(icon, data.icon);
await Shiny.renderContent(icon, data.icon);
}
}

Expand Down
5 changes: 3 additions & 2 deletions srcts/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { shinyAddCustomMessageHandlers } from "./_shinyAddCustomMessageHandlers"

const bslibMessageHandlers = {
// eslint-disable-next-line @typescript-eslint/naming-convention
"bslib.toggle-input-binary": (msg: any) => {
"bslib.toggle-input-binary": async (msg: any) => {
// This handler was written for `toggle_switch()`, but could be used for any
// binary Shiny input, e.g. checkbox.
const el = document.getElementById(msg.id) as HTMLElement;
Expand All @@ -31,7 +31,8 @@ const bslibMessageHandlers = {
if (typeof value === "undefined") {
value = !binding.getValue(el);
}
binding.receiveMessage(el, { value });

await binding.receiveMessage(el, { value });
},
};

Expand Down