@molecule/app-image-gallery-editor-vue
@molecule/app-image-gallery-editor-vue — hero drop zone + side grid of
thumbnail slots, the Vue counterpart of @molecule/app-image-gallery-editor-react
with the same props and the same DOM for the same input. Click an empty slot
or the drop zone to upload, or drop image files on the drop zone to fill the
empty slots in order; click a filled slot to remove (confirmed via the
shared ConfirmDialog from @molecule/app-ui-vue). The drop zone and every
slot are keyboard buttons: Enter and Space do what a click does.
Stateless about persistence — the consumer owns the slot array and handles
uploads via onPickFiles. The editor owns the lifetime of default local previews.
Auto-generated, AI-first package reference for the molecule.dev ecosystem.
It is written to be read by coding agents as much as by people, and is generated from this
package's source — edit src/index.ts JSDoc, not this file.
Quick Start
import { createApp, defineComponent, h, ref } from 'vue'
import type { PickedFile } from '@molecule/app-filesystem'
import { ImageGalleryEditor } from '@molecule/app-image-gallery-editor-vue'
import { uploadImage } from './uploads.js'
const GalleryEditor = defineComponent({
setup() {
const slots = ref<(string | null)[]>(Array(4).fill(null))
return () =>
h(ImageGalleryEditor, {
slots: slots.value,
onChange: (next) => (slots.value = next),
onPickFiles: (files: readonly PickedFile[]) => Promise.all(files.map(uploadImage)),
counter: `${slots.value.filter(Boolean).length} / 24 Photos`,
})
},
})
createApp(GalleryEditor).mount('#app')
Type
feature
Installation
npm install @molecule/app-image-gallery-editor-vue @molecule/app-filesystem @molecule/app-icons @molecule/app-logger @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue base64-js vue
API
Interfaces
ImageGalleryEditorProps
Props accepted by {@link ImageGalleryEditor} — the same props
@molecule/app-image-gallery-editor-react accepts. Node-valued props
(header, counter, dropZoneTitle, dropZoneHint, statusMessage)
take a Vue VNodeChild (or a string) instead of a React node, and may
also arrive as a same-named slot.
interface ImageGalleryEditorProps {
/** Ordered slots, `null` for empty. Length determines slot count. */
slots: (string | null)[]
/** Called with the next slots array when a slot is filled or removed. */
onChange: (slots: (string | null)[]) => void
/** Returns URLs for the ordered selection. Defaults to local previews owned by the editor. */
onPickFiles?: (files: readonly PickedFile[]) => Promise<(string | null)[]> | (string | null)[]
/** The highest slot index a drop may fill (default 24). */
maxImages?: number
/** Header heading + subtitle slot (renders left of the photo counter). */
header?: VNodeChild
/** Photo-counter label (e.g. "3 / 24 Photos"). */
counter?: VNodeChild
/** Drop-zone heading. Defaults through i18n (English "Drag and drop assets here"). */
dropZoneTitle?: VNodeChild
/** Drop-zone hint. Defaults through i18n (English "or click to browse local files"). */
dropZoneHint?: VNodeChild
/** Remove-confirmation message. Defaults through i18n (English "Remove this image?"). */
confirmRemoveMessage?: string
/** Status line rendered under the grid. */
statusMessage?: VNodeChild
/**
* Glyph rendered in empty slots — a typed {@link IconName} from the bonded
* `@molecule/app-icons` set (an unknown name is a type error, not a blank).
*/
emptySlotIcon?: IconName
}
Constants
ImageGalleryEditor
Editable image gallery primitive.
const ImageGalleryEditor: DefineComponent<
ExtractPropTypes<{
slots: { type: PropType<ImageGalleryEditorProps['slots']>; required: true }
onPickFiles: { type: PropType<ImageGalleryEditorProps['onPickFiles']>; default: undefined }
maxImages: { type: PropType<ImageGalleryEditorProps['maxImages']>; default: number }
header: null
counter: null
dropZoneTitle: null
dropZoneHint: null
confirmRemoveMessage: StringConstructor
statusMessage: null
emptySlotIcon: { type: PropType<IconName>; default: string }
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{ change: (_slots: Parameters<ImageGalleryEditorProps['onChange']>[0]) => true },
string,
PublicProps,
Readonly<
ExtractPropTypes<{
slots: { type: PropType<ImageGalleryEditorProps['slots']>; required: true }
onPickFiles: { type: PropType<ImageGalleryEditorProps['onPickFiles']>; default: undefined }
maxImages: { type: PropType<ImageGalleryEditorProps['maxImages']>; default: number }
header: null
counter: null
dropZoneTitle: null
dropZoneHint: null
confirmRemoveMessage: StringConstructor
statusMessage: null
emptySlotIcon: { type: PropType<IconName>; default: string }
}>
> &
Readonly<{ onChange?: ((_slots: (string | null)[]) => any) | undefined }>,
{
onPickFiles:
((files: readonly PickedFile[]) => Promise<(string | null)[]> | (string | null)[]) | undefined
maxImages: number | undefined
emptySlotIcon: IconName
},
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props — Component props (see {@link ImageGalleryEditorProps}).
Returns: The image gallery editor component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-filesystem ^1.1.0
@molecule/app-icons ^1.0.1
@molecule/app-logger ^1.1.0
@molecule/app-ui ^1.0.1
@molecule/app-ui-vue ^1.1.0
@molecule/app-vue ^3.13.0 || ^4.0.0
vue ^3.4.0
Runtime Dependencies
-
@molecule/app-filesystem
-
@molecule/app-icons
-
@molecule/app-logger
-
@molecule/app-ui
-
@molecule/app-ui-vue
-
@molecule/app-vue
-
base64-js
-
vue
-
Styling is 100% ClassMap (getClassMap() / cm.*) — the editor renders
correctly out of the box under any bonded styling library and needs NO
per-app Tailwind @source scan of this package. The few style values
(grid-column span, aspect ratio, corner radius, the dashed drop-zone
border, object-fit, dim opacity, display:none) are the documented
ClassMap-can't-express cases and use real theme tokens.
-
Icons are real SVG glyphs from @molecule/app-ui-vue's Icon
(upload, trash, and the emptySlotIcon — a typed IconName) — NO
Material Symbols font to load. Requires a bonded @molecule/app-icons set.
-
The filled-slot delete affordance is always visible (touch-friendly)
rather than hover-revealed.
-
Its text (the drop-zone heading and hint, the remove confirmation, the
slots' accessible names) flows through t() with English defaultValue
fallbacks under the imageGalleryEditor.* keys, so the
@molecule/app-locales-image-gallery-editor companion bond (or the host
app's own locale) translates it. dropZoneTitle, dropZoneHint and
confirmRemoveMessage override it per instance, and node-valued props
arrive as a prop AND a same-named slot.
-
A drop that carries a file other than an image is refused, as the picker
(accept="image/*") would refuse it.
-
getClassMap() requires a bonded ClassMap for the layout primitives.
Translations
Translation strings are provided by @molecule/app-locales-image-gallery-editor.