mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 02:49:51 +00:00
Add more info lock (#15995)
* Add more info lock * Use same height for pending state * Fix attributes * Add unlocking/locking to switch * Improve code support
This commit is contained in:
40
src/dialogs/enter-code/show-enter-code-dialog.ts
Normal file
40
src/dialogs/enter-code/show-enter-code-dialog.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
|
||||
export interface EnterCodeDialogParams {
|
||||
codeFormat: "text" | "number";
|
||||
codePattern?: string;
|
||||
submitText?: string;
|
||||
cancelText?: string;
|
||||
title?: string;
|
||||
submit?: (code?: string) => void;
|
||||
cancel?: () => void;
|
||||
}
|
||||
|
||||
export const showEnterCodeDialogDialog = (
|
||||
element: HTMLElement,
|
||||
dialogParams: EnterCodeDialogParams
|
||||
) =>
|
||||
new Promise<string | null>((resolve) => {
|
||||
const origCancel = dialogParams.cancel;
|
||||
const origSubmit = dialogParams.submit;
|
||||
|
||||
fireEvent(element, "show-dialog", {
|
||||
dialogTag: "dialog-enter-code",
|
||||
dialogImport: () => import("./dialog-enter-code"),
|
||||
dialogParams: {
|
||||
...dialogParams,
|
||||
cancel: () => {
|
||||
resolve(null);
|
||||
if (origCancel) {
|
||||
origCancel();
|
||||
}
|
||||
},
|
||||
submit: (code: string) => {
|
||||
resolve(code);
|
||||
if (origSubmit) {
|
||||
origSubmit(code);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user