Skip to content
Merged
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
5 changes: 3 additions & 2 deletions inst/www/shared/shiny.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/www/shared/shiny.js.map

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions inst/www/shared/shiny.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions inst/www/shared/shiny.min.js.map

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions srcts/src/bindings/input/checkbox.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import $ from "jquery";
import type { HtmlDep } from "../../shiny/render";
import { renderContent } from "../../shiny/render";
import { hasDefinedProperty } from "../../utils";
import { InputBinding } from "./inputBinding";

type CheckedHTMLElement = HTMLInputElement;

type CheckboxChecked = CheckedHTMLElement["checked"];
type CheckboxReceiveMessageData = { value?: CheckboxChecked; label?: string };
type CheckboxReceiveMessageData = {
value?: CheckboxChecked;
label?: { html: string; deps: HtmlDep[] };
};

class CheckboxInputBinding extends InputBinding {
find(scope: HTMLElement): JQuery<HTMLElement> {
Expand All @@ -32,18 +37,19 @@ class CheckboxInputBinding extends InputBinding {
value: el.checked,
};
}
receiveMessage(
async receiveMessage(
el: CheckedHTMLElement,
data: CheckboxReceiveMessageData
): void {
): Promise<void> {
if (hasDefinedProperty(data, "value")) {
el.checked = data.value;
}

// checkboxInput()'s label works different from other
// input labels...the label container should always exist
if (hasDefinedProperty(data, "label")) {
$(el).parent().find("span").text(data.label);
const labelSpan = $(el).parent().find("span");
await renderContent(labelSpan, data.label);
}

$(el).trigger("change");
Expand Down
8 changes: 6 additions & 2 deletions srcts/types/src/bindings/input/checkbox.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import type { HtmlDep } from "../../shiny/render";
import { InputBinding } from "./inputBinding";
type CheckedHTMLElement = HTMLInputElement;
type CheckboxChecked = CheckedHTMLElement["checked"];
type CheckboxReceiveMessageData = {
value?: CheckboxChecked;
label?: string;
label?: {
html: string;
deps: HtmlDep[];
};
};
declare class CheckboxInputBinding extends InputBinding {
find(scope: HTMLElement): JQuery<HTMLElement>;
Expand All @@ -15,7 +19,7 @@ declare class CheckboxInputBinding extends InputBinding {
label: string;
value: CheckboxChecked;
};
receiveMessage(el: CheckedHTMLElement, data: CheckboxReceiveMessageData): void;
receiveMessage(el: CheckedHTMLElement, data: CheckboxReceiveMessageData): Promise<void>;
}
export { CheckboxInputBinding };
export type { CheckedHTMLElement, CheckboxReceiveMessageData };
Loading