Refactor Dialog abstraction (#90)

This PR overhauls the Dialog abstractions in `studio-ui` to be more
flexible for a wider variety of use cases, and adds a placeholder
"Import Asset" sub-dialog to the Media Library dialog.
This commit is contained in:
Danny McGee
2024-03-21 22:38:33 -04:00
committed by GitHub
parent 67a12e42e2
commit 701ba04765
17 changed files with 835 additions and 283 deletions
+16
View File
@@ -0,0 +1,16 @@
import { Ref } from "lit/directives/ref.js";
export function deref<T>(refOrValue: Ref<T> | T | null | undefined): T | undefined {
if (isRef(refOrValue))
return refOrValue.value;
return (refOrValue ?? undefined);
}
function isRef<T>(refOrValue: Ref<T> | T): refOrValue is Ref<T> {
if (!refOrValue || typeof refOrValue !== "object")
return false;
const keys = Object.keys(refOrValue);
return keys.length === 1 && keys[0] === "value"
}