mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-26 08:38:10 +00:00
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:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user