Skip to content

AI-native design editor. Open-source Figma alternative.

1.4 KB
Raw Blame
<script setup lang="ts" generic="K extends PropertyListKey">
import type { VNode } from 'vue'

import type { SceneNode } from '@open-pencil/scene-graph'
import { useEditorPropertyList } from '@open-pencil/vue/controls/property-list'
import {
  PropertyListRoot as HeadlessPropertyListRoot,
  type PropertyListKey,
  type PropertyListRootSlotProps
} from '@open-pencil/vue/primitives/PropertyList'

const { propKey, label } = defineProps<{
  propKey: K
  label?: string
}>()
defineSlots<{
  default?(
    props: PropertyListRootSlotProps<K> & {
      isMulti: boolean
      activeNode: SceneNode | null
      selectedNodeIds: string[]
      flush: () => void
    }
  ): VNode[]
}>()

const context = useEditorPropertyList(propKey)
</script>

<template>
  <HeadlessPropertyListRoot
    v-if="context.active.value"
    v-slot="slotProps"
    :prop-key="propKey"
    :label="label"
    :items="context.items.value"
    :mixed="context.isMixed.value"
    @add="context.actions.add"
    @remove="context.actions.remove"
    @update="context.actions.update"
    @patch="context.actions.patch"
    @toggle-visibility="context.actions.toggleVisibility"
    @reorder="context.actions.reorder"
  >
    <slot
      v-bind="slotProps"
      :is-multi="context.isMulti.value"
      :active-node="context.activeNode.value"
      :selected-node-ids="context.selectedNodeIds.value"
      :flush="context.flush"
    />
  </HeadlessPropertyListRoot>
</template>