[feat] add AssetBrowserModal

And all related sub components
This commit is contained in:
Arjan Singh
2025-09-11 20:54:44 -07:00
committed by Arjan Singh
parent 294bba0d32
commit e8b969394f
21 changed files with 2303 additions and 51 deletions

View File

@@ -0,0 +1,68 @@
import { useDialogStore } from '@/stores/dialogStore'
import AssetBrowserModal from '../components/AssetBrowserModal.vue'
interface AssetBrowserDialogProps {
/** ComfyUI node type for context (e.g., 'CheckpointLoaderSimple') */
nodeType: string
/** Widget input name (e.g., 'ckpt_name') */
inputName: string
/** Current selected asset value */
currentValue?: string
/** Callback for when an asset is selected */
onAssetSelected?: (assetPath: string) => void
}
export const useAssetBrowserDialog = () => {
const dialogStore = useDialogStore()
const dialogKey = 'global-asset-browser'
function hide() {
dialogStore.closeDialog({ key: dialogKey })
}
function show(props: AssetBrowserDialogProps) {
const handleAssetSelected = (assetPath: string) => {
props.onAssetSelected?.(assetPath)
hide() // Auto-close on selection
}
const handleClose = () => {
hide()
}
// Default dialog configuration for AssetBrowserModal
const dialogComponentProps = {
headless: true,
modal: true,
closable: false,
pt: {
root: {
class:
'rounded-2xl overflow-hidden h-[80vh] w-[80vw] max-h-[80vh] max-w-[80vw]'
},
header: {
class: 'p-0! hidden'
},
content: {
class: 'p-0! m-0! h-full w-full'
}
}
}
dialogStore.showDialog({
key: dialogKey,
component: AssetBrowserModal,
props: {
nodeType: props.nodeType,
inputName: props.inputName,
currentValue: props.currentValue,
onSelect: handleAssetSelected,
onClose: handleClose
},
dialogComponentProps
})
}
return { show, hide }
}