Skip to content

Commit

Permalink
v2 Support Datetime Component (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
RFDarter authored Apr 23, 2024
1 parent beec790 commit d60667a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
49 changes: 49 additions & 0 deletions packages/v2/src/esp-entity-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,29 @@ class ActionRenderer {
</div>`;
}

private _datetime(
entity: entityConfig,
type: string,
action: string,
opt: string,
value: string,
) {
return html`
<input
type="${type}"
name="${entity.unique_id}"
id="${entity.unique_id}"
value="${value}"
@change="${(e: Event) => {
const val = (<HTMLTextAreaElement>e.target)?.value;
this.actioner?.restAction(
entity,
`${action}?${opt}=${val}`
);
}}"
/>
`;
}

private _textinput(
entity: entityConfig,
Expand Down Expand Up @@ -411,6 +434,32 @@ class ActionRenderer {
);
}

render_date() {
if (!this.entity) return;
return html`
${this._datetime(
this.entity,
"date",
"set",
"value",
this.entity.value,
)}
`;
}

render_time() {
if (!this.entity) return;
return html`
${this._datetime(
this.entity,
"time",
"set",
"value",
this.entity.value,
)}
`;
}

render_text() {
if (!this.entity) return;
return this._textinput(
Expand Down
2 changes: 2 additions & 0 deletions packages/v2/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export default defineConfig({
"/climate": proxy_target,
"/events": proxy_target,
"/text": proxy_target,
"/date": proxy_target,
"/time": proxy_target,
},
},
});

0 comments on commit d60667a

Please sign in to comment.