AI-native design editor. Open-source Figma alternative.
fix: open selects over their field and share one list design (#1040)
Danila Poyarkovd5ec72cdf281
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ae445635d..5f01ba6be 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -139,6 +139,7 @@- Clicking selects layers as in Figma: inside a top-level frame or section, a click selects the frame's direct child rather than the deepest layer, the empty part of a top-level frame or section that holds layers selects nothing, while the gaps and padding of a top-level auto layout frame select, highlight, and drag it, and a frame inside a top-level frame, or an empty frame, is selected by its empty area even without a fill, which ⌘-click looks through, so every top-level frame shows its name above it, in the selection color while selected or hovered, and clicking or dragging the name selects or moves the frame; once a layer is selected, clicks reach its siblings and cousins. Double-click goes one level deeper, as does another click inside a selected frame, component, or instance, so repeated clicks at one point reach the layer under it; ⌘-click (Ctrl-click on Windows and Linux) selects the deepest layer, which holding ⌘ highlights. Double-clicking a frame's or component's name renames it in place. A layer is never selected together with its own parent or child: Shift-clicking one replaces the other. A marquee started inside a top-level frame or section selects that container's layers, and from the page it selects a frame or section that holds layers only when fully enclosed.- Drag, draw, duplicate, and paste follow Figma. A dragged layer lands in the frame under the cursor and leaves its frame as soon as the cursor does; groups and locked frames never take a drop, a component set takes back only its own variants, and a layer inside a group stays in it unless dropped on another frame. Groups and booleans fit their children after a move or nudge, and a group whose last layer leaves is removed. Pressing inside a selected frame, group, or component set drags it rather than the layer under the cursor, and an auto layout child dragged out lands where you drop it. Hold Space while dragging to keep layers in their parents, Shift to move along one axis, or Control to drop into auto layout as an absolute-positioned layer. Locked layers stay put when the rest of the selection moves. Shapes drawn inside a frame, auto layout, or slot go into it, a frame drawn over layers takes in the ones it fully covers, and a section does so when moved or resized too. Wrapped auto layout inserts on the line under the cursor. Duplicates keep their names, and duplicating a main component with ⌘D or Alt-drag creates an instance. ⌘D duplicates in place, placing a lone top-level frame's copy to its right, and ⌘V keeps the copied position, in the browser too, centering an axis that doesn't fit the selected frame, and an instance pasted into its own main component, or into a layer inside it, lands over that layer in the component's parent instead of inside it; **Paste here** still pastes at the cursor.- Give popovers, menus, dropdowns, and pickers one look and motion: the same rounded panel with a thin outline that reads in light and dark themes, a short fade and grow from the side they open on, and an immediate close; with reduced motion they appear at once.+- Selects open over their field with the chosen option on the field's label, so the value stays in place, and lists use the window's height instead of scrolling after nine rows. Menus behind a chevron or icon, such as the size, gap, and line height modes, open under it with the same rows and check marks. Blend modes are grouped by effect.- Add and remove items the same way across the properties panel: a section's + adds an item and a row's − removes it, now including grid columns and rows and variant properties. The + of a component set adds Property 1 ready to rename instead of showing a form, and a variant is removed with Delete like any layer.- Pick variables, shared styles, and swap components from one searchable list that groups preferred components first and works with the keyboard.- Recommend the latest models in the AI model picker: Claude Sonnet 5.5 (the new Anthropic and OpenRouter default), Claude Opus 5.5, GPT-6.1 Sol (the new OpenAI default), GPT-6 Astra, and GPT-6 Luna, and replace the free OpenRouter models OpenRouter retired with Qwen3.8 27B and Gemma 4 31B. Saved profiles keep the model they chose.@@ -156,6 +157,7 @@### Fixed+- The font picker opens at the current font instead of the top of the list.- Cmd+Z and Shift+Cmd+Z undo and redo while a fill, stroke, or colour picker is open, as in Figma, and undo reverts the picker's latest change rather than the edit before it.- A frame's name reads on the section it sits in: on a dark page, frames in a white section had white names on white. Names now fade more on light backgrounds than on dark ones, as Figma's do.- `lineHeight` and `letterSpacing` in the plugin API and `eval` scripts read and write Figma's `{ unit, value }`, including percent of the font size and `{ unit: 'AUTO' }`; assigning those objects used to leave the text undrawn.diff --git a/packages/vue/src/primitives/FontPicker/FontPickerRoot.vue b/packages/vue/src/primitives/FontPicker/FontPickerRoot.vueindex e82b8f79b..14fc997af 100644--- a/packages/vue/src/primitives/FontPicker/FontPickerRoot.vue+++ b/packages/vue/src/primitives/FontPicker/FontPickerRoot.vue@@ -13,7 +13,7 @@ import {ComboboxViewport,type AcceptableValue} from 'reka-ui'-import { nextTick } from 'vue'+import { nextTick, useTemplateRef, watch } from 'vue'import { useRetainedPopup } from '#vue/lifecycle/retention/popup'import type { FontPickerUI } from '#vue/primitives/FontPicker/types'@@ -53,13 +53,38 @@ const { searchTerm, open, filtered, loading, accessState, requestAccess, selectonSelect: (family) => emit('select', family)})const { portalActive } = useRetainedPopup(open)+const root = useTemplateRef<{ highlightItem: (value: AcceptableValue) => void }>('root')++// The families arrive after the list opens, too late for Reka's own scroll to the chosen font.+watch(+ () => open.value && !loading.value && filtered.value.length > 0,+ async (ready) => {+ if (!ready || searchTerm.value) return+ await nextTick()+ root.value?.highlightItem(modelValue.value)+ }+)++/**+ * The list holds font options and the value is a family name; Reka compares them to find the+ * chosen font, so opening scrolls to it.+ */+function sameFamily(left: unknown, right: unknown): boolean {+ return familyOf(left) === familyOf(right)+}++function familyOf(value: unknown): unknown {+ return typeof value === 'object' && value !== null && 'family' in value ? value.family : value+}</script><template><ComboboxRoot+ ref="root"v-model:open="open":model-value="modelValue":ignore-filter="true"+ :by="sameFamily"@update:model-value="(v: AcceptableValue) => {if (typeof v === 'string') select(v)diff --git a/src/components/properties/AppearanceSection.vue b/src/components/properties/AppearanceSection.vueindex 85f2800fe..6c04b44fe 100644--- a/src/components/properties/AppearanceSection.vue+++ b/src/components/properties/AppearanceSection.vue@@ -3,7 +3,7 @@ import type { BlendMode } from '@open-pencil/scene-graph'import { AppearanceControlsRoot, MIXED, useI18n } from '@open-pencil/vue'import NumberField from '@/components/inputs/NumberField.vue'-import { useBlendModeOptions } from '@/components/properties/blend-mode/use'+import { useBlendModeGroups } from '@/components/properties/blend-mode/use'import VariableNumberField from '@/components/properties/VariableNumberField.vue'import IconButton from '@/components/ui/button/IconButton.vue'import PanelFieldGroup from '@/components/ui/panel/PanelFieldGroup.vue'@@ -17,12 +17,15 @@ import PropertyBoundField from './component-properties/PropertyBoundField.vue'const { panels } = useI18n()type BlendModeSelectValue = BlendMode | 'MIXED'-const baseBlendModeOptions = useBlendModeOptions(true)+const baseBlendModeGroups = useBlendModeGroups(true)-function blendModeOptions(value: BlendMode | typeof MIXED) {+function blendModeGroups(value: BlendMode | typeof MIXED) {return value === MIXED- ? [{ value: 'MIXED' as const, label: panels.value.mixed }, ...baseBlendModeOptions.value]- : baseBlendModeOptions.value+ ? [+ { options: [{ value: 'MIXED' as const, label: panels.value.mixed }] },+ ...baseBlendModeGroups.value+ ]+ : baseBlendModeGroups.value}</script>@@ -65,7 +68,7 @@ function blendModeOptions(value: BlendMode | typeof MIXED) {:model-value="blendModeValue === MIXED ? 'MIXED' : blendModeValue"class="w-full":label="panels.blendMode"- :options="blendModeOptions(blendModeValue)"+ :groups="blendModeGroups(blendModeValue)"@update:model-value="(value: BlendModeSelectValue) => value !== 'MIXED' && actions.setBlendMode(value)"diff --git a/src/components/properties/EffectsSection.vue b/src/components/properties/EffectsSection.vueindex 2964567b7..e83870934 100644--- a/src/components/properties/EffectsSection.vue+++ b/src/components/properties/EffectsSection.vue@@ -6,7 +6,7 @@ import ColorInput from '@/components/ColorPicker/ColorInput.vue'import NumberField from '@/components/inputs/NumberField.vue'import {commitDiscretePropertyListChange,- useBlendModeOptions+ useBlendModeGroups} from '@/components/properties/blend-mode/use'import PropertyItemRow from '@/components/properties/item-list/PropertyItemRow.vue'import PropertyListRoot from '@/components/properties/PropertyListRoot.vue'@@ -20,7 +20,7 @@ import AppSelect from '@/components/ui/select/AppSelect.vue'const effectsCtx = useEffectsControls()const { panels } = useI18n()-const blendModeOptions = useBlendModeOptions()+const blendModeGroups = useBlendModeGroups()const {visible: stylesVisible,hasStyle,@@ -144,7 +144,7 @@ function effectPreview(effect: Effect): Fill {<PanelFieldGroup :label="panels.blendMode"><AppSelect:model-value="effect.blendMode ?? 'NORMAL'"- :options="blendModeOptions"+ :groups="blendModeGroups":label="panels.blendMode"data-property="effect-blend-mode"@update:model-value="diff --git a/src/components/properties/FillSection.vue b/src/components/properties/FillSection.vueindex 6da22582f..da7a66b9a 100644--- a/src/components/properties/FillSection.vue+++ b/src/components/properties/FillSection.vue@@ -16,7 +16,7 @@ import PaintField from '@/components/inputs/PaintField.vue'import VariableBindingPicker from '@/components/properties/binding/VariableBindingPicker.vue'import {commitDiscretePropertyListChange,- useBlendModeOptions+ useBlendModeGroups} from '@/components/properties/blend-mode/use'import { fillLabel } from '@/components/properties/fill-label'import PropertyItemRow from '@/components/properties/item-list/PropertyItemRow.vue'@@ -52,7 +52,7 @@ function onPickerOpenChange(}const colorProvider = useColorBindingProvider()const { panels, common } = useI18n()-const blendModeOptions = useBlendModeOptions()+const blendModeGroups = useBlendModeGroups()const {visible: stylesVisible,hasStyle,@@ -205,7 +205,7 @@ function updateSolidColor(<PanelFieldGroup :label="panels.blendMode"><AppSelect:model-value="fill.blendMode ?? 'NORMAL'"- :options="blendModeOptions"+ :groups="blendModeGroups":label="panels.blendMode"data-property="fill-blend-mode"@update:model-value="diff --git a/src/components/properties/blend-mode/use.ts b/src/components/properties/blend-mode/use.tsindex 8666aec24..141dce94c 100644--- a/src/components/properties/blend-mode/use.ts+++ b/src/components/properties/blend-mode/use.ts@@ -3,37 +3,59 @@ import { computed } from 'vue'import type { BlendMode } from '@open-pencil/scene-graph'import { useI18n } from '@open-pencil/vue'+import type { AppSelectGroup } from '@/components/ui/select/select'+export function commitDiscretePropertyListChange(flush: () => void, update: () => void): void {update()flush()}-export interface BlendModeOption {- value: BlendMode- label: string-}--export function useBlendModeOptions(includePassThrough = false) {+/** Blend modes by what they do: darken, lighten, contrast, compare, and the component modes. */+export function useBlendModeGroups(includePassThrough = false) {const { panels } = useI18n()- return computed<BlendModeOption[]>(() => [- ...(includePassThrough- ? [{ value: 'PASS_THROUGH' as const, label: panels.value.blendModePassThrough }]- : []),- { value: 'NORMAL', label: panels.value.blendModeNormal },- { value: 'DARKEN', label: panels.value.blendModeDarken },- { value: 'MULTIPLY', label: panels.value.blendModeMultiply },- { value: 'COLOR_BURN', label: panels.value.blendModeColorBurn },- { value: 'LIGHTEN', label: panels.value.blendModeLighten },- { value: 'SCREEN', label: panels.value.blendModeScreen },- { value: 'COLOR_DODGE', label: panels.value.blendModeColorDodge },- { value: 'OVERLAY', label: panels.value.blendModeOverlay },- { value: 'SOFT_LIGHT', label: panels.value.blendModeSoftLight },- { value: 'HARD_LIGHT', label: panels.value.blendModeHardLight },- { value: 'DIFFERENCE', label: panels.value.blendModeDifference },- { value: 'EXCLUSION', label: panels.value.blendModeExclusion },- { value: 'HUE', label: panels.value.blendModeHue },- { value: 'SATURATION', label: panels.value.blendModeSaturation },- { value: 'COLOR', label: panels.value.blendModeColor },- { value: 'LUMINOSITY', label: panels.value.blendModeLuminosity }+ return computed<AppSelectGroup<BlendMode>[]>(() => [+ {+ options: [+ ...(includePassThrough+ ? [{ value: 'PASS_THROUGH' as const, label: panels.value.blendModePassThrough }]+ : []),+ { value: 'NORMAL', label: panels.value.blendModeNormal }+ ]+ },+ {+ options: [+ { value: 'DARKEN', label: panels.value.blendModeDarken },+ { value: 'MULTIPLY', label: panels.value.blendModeMultiply },+ { value: 'COLOR_BURN', label: panels.value.blendModeColorBurn }+ ]+ },+ {+ options: [+ { value: 'LIGHTEN', label: panels.value.blendModeLighten },+ { value: 'SCREEN', label: panels.value.blendModeScreen },+ { value: 'COLOR_DODGE', label: panels.value.blendModeColorDodge }+ ]+ },+ {+ options: [+ { value: 'OVERLAY', label: panels.value.blendModeOverlay },+ { value: 'SOFT_LIGHT', label: panels.value.blendModeSoftLight },+ { value: 'HARD_LIGHT', label: panels.value.blendModeHardLight }+ ]+ },+ {+ options: [+ { value: 'DIFFERENCE', label: panels.value.blendModeDifference },+ { value: 'EXCLUSION', label: panels.value.blendModeExclusion }+ ]+ },+ {+ options: [+ { value: 'HUE', label: panels.value.blendModeHue },+ { value: 'SATURATION', label: panels.value.blendModeSaturation },+ { value: 'COLOR', label: panels.value.blendModeColor },+ { value: 'LUMINOSITY', label: panels.value.blendModeLuminosity }+ ]+ }])}diff --git a/src/components/properties/frame-presets/FramePresetSelect.vue b/src/components/properties/frame-presets/FramePresetSelect.vueindex 5983caaf7..770df7b27 100644--- a/src/components/properties/frame-presets/FramePresetSelect.vue+++ b/src/components/properties/frame-presets/FramePresetSelect.vue@@ -10,7 +10,7 @@ import {FRAME_RESIZE_PRESETS} from '@/app/editor/frame-presets'import PanelSection from '@/components/ui/panel/PanelSection.vue'-import AppGroupedSelect from '@/components/ui/select/AppGroupedSelect.vue'+import AppSelect from '@/components/ui/select/AppSelect.vue'const store = useEditorStore()const { selectedNode } = useSelectionState()@@ -31,25 +31,19 @@ const selectedPresetId = computed({const groups = computed(() =>FRAME_RESIZE_PRESET_CATEGORIES.map((category) => ({label: panels.value[category.labelKey],- items: category.presets.map((preset) => ({ value: preset.id, label: preset.name }))+ options: category.presets.map((preset) => ({ value: preset.id, label: preset.name }))})))-const displayValue = computed(() => selectedPreset.value?.name ?? panels.value.framePresetCustom)-const selectUI = {- content: 'max-h-80',- viewport: 'max-h-80'-}</script><template><PanelSection :label="panels.frame">- <AppGroupedSelect+ <AppSelectv-model="selectedPresetId"data-property="frame-preset"- :aria-label="panels.framePreset"+ :label="panels.framePreset":groups="groups"- :display-value="displayValue"- :ui="selectUI"+ :placeholder="panels.framePresetCustom"/></PanelSection></template>diff --git a/src/components/properties/layout/flex/FlexGapField.vue b/src/components/properties/layout/flex/FlexGapField.vueindex e8a957fe6..f16c4bade 100644--- a/src/components/properties/layout/flex/FlexGapField.vue+++ b/src/components/properties/layout/flex/FlexGapField.vue@@ -1,20 +1,12 @@<script setup lang="ts">-import {- SelectRoot,- SelectTrigger,- SelectPortal,- SelectContent,- SelectViewport,- SelectItem,- SelectItemText,- SelectItemIndicator-} from 'reka-ui'+import { SelectRoot, SelectTrigger } from 'reka-ui'import { computed, ref } from 'vue'import { useI18n, useLayoutControlsContext, useRetainedPopup } from '@open-pencil/vue'import VariableNumberField from '@/components/properties/VariableNumberField.vue'-import { useSelectUI } from '@/components/ui/select/select'+import AppSelectContent from '@/components/ui/select/AppSelectContent.vue'+import AppSelectItem from '@/components/ui/select/AppSelectItem.vue'const { axis = 'primary' } = defineProps<{ axis?: 'primary' | 'counter' }>()const ctx = useLayoutControlsContext()@@ -28,7 +20,6 @@ const label = computed(() =>)const auto = computed(() => axis === 'primary' && ctx.gapAuto && ctx.node.layoutWrap !== 'WRAP')const allowAuto = computed(() => axis === 'primary' && ctx.node.layoutWrap !== 'WRAP')-const menu = useSelectUI({ item: 'rounded py-1.5 pr-2 pl-6 text-xs' })function setMode(value: string) {ctx.setGapAuto(value === 'AUTO')}@@ -90,24 +81,10 @@ function setMode(value: string) {</template></VariableNumberField></div>- <SelectPortal v-if="allowAuto && portalActive">- <SelectContent position="popper" align="start" :side-offset="4" :class="menu.content">- <SelectViewport class="p-0.5">- <SelectItem- v-for="mode in ['FIXED', 'AUTO']"- :key="mode"- :value="mode"- :class="menu.item"- >- <SelectItemIndicator class="absolute left-1.5 inline-flex items-center justify-center"- ><icon-lucide-check class="size-3 text-primary"- /></SelectItemIndicator>- <SelectItemText>{{- mode === 'AUTO' ? panels.auto : Math.round(ctx.node.itemSpacing)- }}</SelectItemText>- </SelectItem>- </SelectViewport>- </SelectContent>- </SelectPortal>+ <AppSelectContent v-if="allowAuto && portalActive" align="end">+ <AppSelectItem v-for="mode in ['FIXED', 'AUTO']" :key="mode" :value="mode">+ {{ mode === 'AUTO' ? panels.auto : Math.round(ctx.node.itemSpacing) }}+ </AppSelectItem>+ </AppSelectContent></SelectRoot></template>diff --git a/src/components/properties/layout/size/SizeAxisField.vue b/src/components/properties/layout/size/SizeAxisField.vueindex 73b261d34..ea79e23b4 100644--- a/src/components/properties/layout/size/SizeAxisField.vue+++ b/src/components/properties/layout/size/SizeAxisField.vue@@ -1,14 +1,5 @@<script setup lang="ts">-import {- SelectContent,- SelectItem,- SelectItemIndicator,- SelectItemText,- SelectPortal,- SelectRoot,- SelectTrigger,- SelectViewport-} from 'reka-ui'+import { SelectRoot, SelectSeparator, SelectTrigger } from 'reka-ui'import type { LayoutSizing } from '@open-pencil/scene-graph'import { useI18n, useLayoutControlsContext, useRetainedPopup } from '@open-pencil/vue'@@ -17,6 +8,8 @@ import type { SizeLimitProp } from '@open-pencil/vue'import type { SizeAxisFieldProps } from '@/components/properties/layout/size/types'import VariableNumberField from '@/components/properties/VariableNumberField.vue'import Tip from '@/components/ui/overlay/Tip.vue'+import AppSelectContent from '@/components/ui/select/AppSelectContent.vue'+import AppSelectItem from '@/components/ui/select/AppSelectItem.vue'import { useSelectUI } from '@/components/ui/select/select'type SizeSelectValue = LayoutSizing | `add-${SizeLimitProp}` | `remove-${SizeLimitProp}`@@ -26,7 +19,7 @@ const { axis, icon, label } = defineProps<SizeAxisFieldProps>()const ctx = useLayoutControlsContext()const { open: popupOpen, portalActive } = useRetainedPopup()const { panels } = useI18n()-const selectUI = useSelectUI({ item: 'rounded py-1.5 pr-2 pl-6 text-xs' })+const selectUI = useSelectUI()const sizing = () => (axis === 'width' ? ctx.widthSizing : ctx.heightSizing)const sizingOptions = () => (axis === 'width' ? ctx.widthSizingOptions : ctx.heightSizingOptions)@@ -102,40 +95,23 @@ function handleSelect(value: SizeSelectValue) {<span v-if="sizingLabel()">{{ sizingLabel() }}</span><icon-lucide-chevron-down class="size-3" /></SelectTrigger>- <SelectPortal v-if="portalActive">- <SelectContent- position="popper"- align="start"- :side-offset="4"- :class="selectUI.content"+ <AppSelectContent v-if="portalActive" align="end">+ <AppSelectItem+ v-for="option in sizingOptions()"+ :key="option.value"+ :value="option.value">- <SelectViewport class="p-0.5">- <SelectItem- v-for="option in sizingOptions()"- :key="option.value"- :value="option.value"- :class="selectUI.item"- >- <SelectItemIndicator- class="absolute left-1.5 inline-flex items-center justify-center"- >- <icon-lucide-check class="size-3 text-primary" />- </SelectItemIndicator>- <SelectItemText>{{ option.label }}</SelectItemText>- </SelectItem>- <SelectItem- v-for="item in limitItems()"- :key="item.prop"- :value="`${ctx.node[item.prop] == null ? 'add' : 'remove'}-${item.prop}`"- :class="selectUI.item"- >- <SelectItemText>- {{ ctx.node[item.prop] == null ? item.addLabel : item.removeLabel }}- </SelectItemText>- </SelectItem>- </SelectViewport>- </SelectContent>- </SelectPortal>+ {{ option.label }}+ </AppSelectItem>+ <SelectSeparator :class="selectUI.separator" />+ <AppSelectItem+ v-for="item in limitItems()"+ :key="item.prop"+ :value="`${ctx.node[item.prop] == null ? 'add' : 'remove'}-${item.prop}`"+ >+ {{ ctx.node[item.prop] == null ? item.addLabel : item.removeLabel }}+ </AppSelectItem>+ </AppSelectContent></SelectRoot></template></VariableNumberField>diff --git a/src/components/properties/layout/size/SizeLimitField.vue b/src/components/properties/layout/size/SizeLimitField.vueindex d23feec51..f9532003e 100644--- a/src/components/properties/layout/size/SizeLimitField.vue+++ b/src/components/properties/layout/size/SizeLimitField.vue@@ -1,26 +1,18 @@<script setup lang="ts">-import {- SelectContent,- SelectItem,- SelectItemText,- SelectPortal,- SelectRoot,- SelectTrigger,- SelectViewport-} from 'reka-ui'+import { SelectRoot, SelectTrigger } from 'reka-ui'import { useLayoutControlsContext, useRetainedPopup } from '@open-pencil/vue'import type { SizeLimitFieldProps } from '@/components/properties/layout/size/types'import VariableNumberField from '@/components/properties/VariableNumberField.vue'import Tip from '@/components/ui/overlay/Tip.vue'-import { useSelectUI } from '@/components/ui/select/select'+import AppSelectContent from '@/components/ui/select/AppSelectContent.vue'+import AppSelectItem from '@/components/ui/select/AppSelectItem.vue'const { item } = defineProps<SizeLimitFieldProps>()const ctx = useLayoutControlsContext()const { open: popupOpen, portalActive } = useRetainedPopup()-const selectUI = useSelectUI({ item: 'rounded py-1.5 px-2 text-xs' })function handleSelect(value: string) {if (value === 'CURRENT') ctx.setSizeLimitToCurrent(item.prop)@@ -55,23 +47,10 @@ function handleSelect(value: string) {><icon-lucide-chevron-down class="size-3" /></SelectTrigger>- <SelectPortal v-if="portalActive">- <SelectContent- position="popper"- align="start"- :side-offset="4"- :class="selectUI.content"- >- <SelectViewport class="p-0.5">- <SelectItem value="CURRENT" :class="selectUI.item">- <SelectItemText>{{ item.setLabel }}</SelectItemText>- </SelectItem>- <SelectItem value="REMOVE" :class="selectUI.item">- <SelectItemText>{{ item.removeLabel }}</SelectItemText>- </SelectItem>- </SelectViewport>- </SelectContent>- </SelectPortal>+ <AppSelectContent v-if="portalActive" align="end">+ <AppSelectItem value="CURRENT">{{ item.setLabel }}</AppSelectItem>+ <AppSelectItem value="REMOVE">{{ item.removeLabel }}</AppSelectItem>+ </AppSelectContent></SelectRoot></template></VariableNumberField>diff --git a/src/components/properties/typography/LineHeightField.vue b/src/components/properties/typography/LineHeightField.vueindex b8c375666..06eda10f9 100644--- a/src/components/properties/typography/LineHeightField.vue+++ b/src/components/properties/typography/LineHeightField.vue@@ -1,20 +1,13 @@<script setup lang="ts">-import {- SelectRoot,- SelectTrigger,- SelectPortal,- SelectContent,- SelectViewport,- SelectItem,- SelectItemText-} from 'reka-ui'+import { SelectRoot, SelectTrigger } from 'reka-ui'import { computed } from 'vue'import type { SceneNode } from '@open-pencil/scene-graph'import { MIXED, useEditor, useI18n, useRetainedPopup } from '@open-pencil/vue'import VariableNumberField from '@/components/properties/VariableNumberField.vue'-import { useSelectUI } from '@/components/ui/select/select'+import AppSelectContent from '@/components/ui/select/AppSelectContent.vue'+import AppSelectItem from '@/components/ui/select/AppSelectItem.vue'/** Every selected text layer; the field reads Mixed when their line heights differ. */const { nodes } = defineProps<{ nodes: readonly SceneNode[] }>()@@ -32,7 +25,6 @@ const value = computed(() => {})const nodeId = computed(() => nodes.at(0)?.id ?? '')const nodeIds = computed(() => nodes.map((node) => node.id))-const menu = useSelectUI()function setMode(mode: string) {if (mode === 'AUTO') {editor.undo.runBatch('Use automatic line height', () => {@@ -78,18 +70,10 @@ function setMode(mode: string) {@pointerdown.stop><icon-lucide-chevron-down class="size-3"/></SelectTrigger>- <SelectPortal v-if="portalActive">- <SelectContent position="popper" :side-offset="4" :class="menu.content">- <SelectViewport>- <SelectItem value="AUTO" :class="menu.item"- ><SelectItemText>{{ panels.auto }}</SelectItemText></SelectItem- >- <SelectItem value="FIXED" :class="menu.item"- ><SelectItemText>{{ panels.sizingFixed }}</SelectItemText></SelectItem- >- </SelectViewport>- </SelectContent>- </SelectPortal>+ <AppSelectContent v-if="portalActive" align="end">+ <AppSelectItem value="AUTO">{{ panels.auto }}</AppSelectItem>+ <AppSelectItem value="FIXED">{{ panels.sizingFixed }}</AppSelectItem>+ </AppSelectContent></SelectRoot></template></VariableNumberField>diff --git a/src/components/settings/provider-select/ProviderSelect.vue b/src/components/settings/provider-select/ProviderSelect.vueindex e95e68137..55191d07b 100644--- a/src/components/settings/provider-select/ProviderSelect.vue+++ b/src/components/settings/provider-select/ProviderSelect.vue@@ -10,7 +10,8 @@ import {type AIProviderID} from '@open-pencil/core/constants'-import AppGroupedSelect from '@/components/ui/select/AppGroupedSelect.vue'+import AppSelect from '@/components/ui/select/AppSelect.vue'+import type { AppSelectGroup } from '@/components/ui/select/select'const mcpAvailable = ref(false)@@ -72,12 +73,12 @@ const displayName = computed(() => {})const groups = computed(() => {- const result: Array<{ label?: string; items: Array<{ value: string; label: string }> }> = []+ const result: AppSelectGroup<string>[] = []if (acpAgents.value.length) {result.push({label: 'Your agents',- items: acpAgents.value.map((agent) => ({+ options: acpAgents.value.map((agent) => ({value: `acp:${agent.id}`,label: agent.name}))@@ -86,7 +87,7 @@ const groups = computed(() => {result.push({label: acpAgents.value.length ? 'Providers' : undefined,- items: [...AI_PROVIDERS]+ options: [...AI_PROVIDERS].sort((left, right) => left.name.localeCompare(right.name)).map((provider) => ({value: provider.id,@@ -99,5 +100,5 @@ const groups = computed(() => {</script><template>- <AppGroupedSelect v-model="providerID" :groups="groups" :display-value="displayName" :ui="ui" />+ <AppSelect v-model="providerID" :groups="groups" :placeholder="displayName" :ui="ui" /></template>diff --git a/src/components/ui/select/AppGroupedSelect.vue b/src/components/ui/select/AppGroupedSelect.vuedeleted file mode 100644index ff99513ba..000000000--- a/src/components/ui/select/AppGroupedSelect.vue+++ /dev/null@@ -1,84 +0,0 @@-<script setup lang="ts" generic="T extends string | number">-import {- SelectContent,- SelectGroup,- SelectItem,- SelectItemText,- SelectLabel,- SelectPortal,- SelectRoot,- SelectSeparator,- SelectTrigger,- SelectViewport-} from 'reka-ui'-import { tv } from 'tailwind-variants'--import { useRetainedPopup } from '@open-pencil/vue'--import type { ComponentUI } from '@/components/ui/types'-import theme from '@/theme/select/grouped'-import type { AppGroupedSelectTheme } from '@/theme/select/grouped'--interface SelectOption<TValue extends string | number> {- value: TValue- label: string-}--interface SelectGroupDef<TValue extends string | number> {- label?: string- items: SelectOption<TValue>[]-}--interface AppGroupedSelectProps<TValue extends string | number> {- groups: SelectGroupDef<TValue>[]- displayValue: string- ui?: ComponentUI<AppGroupedSelectTheme>-}--defineOptions({ inheritAttrs: false })--const { groups, displayValue, ui } = defineProps<AppGroupedSelectProps<T>>()--const modelValue = defineModel<T>({ required: true })--const styles = tv(theme)()-const { open: popupOpen, portalActive } = useRetainedPopup()-</script>--<template>- <SelectRoot v-model="modelValue" v-model:open="popupOpen">- <SelectTrigger v-bind="$attrs" :class="styles.trigger({ class: ui?.trigger })">- <slot name="value">{{ displayValue }}</slot>- <icon-lucide-chevron-down class="size-2.5 shrink-0 text-muted" />- </SelectTrigger>- <SelectPortal v-if="portalActive">- <SelectContent- position="popper"- :side-offset="4"- :class="styles.content({ class: ui?.content })"- >- <SelectViewport :class="styles.viewport({ class: ui?.viewport })">- <template v-for="(group, index) in groups" :key="index">- <SelectGroup>- <SelectLabel v-if="group.label" :class="styles.label({ class: ui?.label })">- {{ group.label }}- </SelectLabel>- <SelectItem- v-for="item in group.items"- :key="String(item.value)"- :value="item.value"- :class="styles.item({ class: ui?.item })"- >- <SelectItemText>{{ item.label }}</SelectItemText>- </SelectItem>- </SelectGroup>- <SelectSeparator- v-if="index < groups.length - 1"- :class="styles.separator({ class: ui?.separator })"- />- </template>- </SelectViewport>- </SelectContent>- </SelectPortal>- </SelectRoot>-</template>diff --git a/src/components/ui/select/AppSelect.stories.ts b/src/components/ui/select/AppSelect.stories.tsindex d3e3ac95a..f4df3519e 100644--- a/src/components/ui/select/AppSelect.stories.ts+++ b/src/components/ui/select/AppSelect.stories.ts@@ -30,3 +30,33 @@ export default metatype Story = StoryObj<typeof meta>export const ReactiveLabels: Story = {}++export const Grouped: Story = {+ render: () => ({+ components: { AppSelect },+ setup() {+ const value = ref('MULTIPLY')+ const groups = [+ { options: [{ value: 'NORMAL', label: 'Normal' }] },+ {+ options: [+ { value: 'DARKEN', label: 'Darken' },+ { value: 'MULTIPLY', label: 'Multiply' }+ ]+ },+ {+ label: 'Lighten',+ options: [+ { value: 'LIGHTEN', label: 'Lighten' },+ { value: 'SCREEN', label: 'Screen' }+ ]+ }+ ]+ return { value, groups }+ },+ template: `+ <div class="w-40 p-16">+ <AppSelect v-model="value" :groups="groups" label="Blend mode" />+ </div>`+ })+}diff --git a/src/components/ui/select/AppSelect.vue b/src/components/ui/select/AppSelect.vueindex 462ea72fa..434427134 100644--- a/src/components/ui/select/AppSelect.vue+++ b/src/components/ui/select/AppSelect.vue@@ -1,88 +1,104 @@<script setup lang="ts" generic="T extends string | number">import {- SelectContent,- SelectItem,- SelectItemIndicator,- SelectItemText,- SelectPortal,+ SelectGroup,+ SelectLabel,SelectRoot,- SelectScrollDownButton,- SelectScrollUpButton,+ SelectSeparator,SelectTrigger,- SelectValue,- SelectViewport+ SelectValue} from 'reka-ui'import { tv } from 'tailwind-variants'-import { computed } from 'vue'+import { computed, useSlots } from 'vue'import { useRetainedPopup } from '@open-pencil/vue'+import AppSelectContent from '@/components/ui/select/AppSelectContent.vue'+import AppSelectItem from '@/components/ui/select/AppSelectItem.vue'+import type {+ AppSelectGroup,+ AppSelectOption,+ SelectPlacement+} from '@/components/ui/select/select'import type { ComponentUI } from '@/components/ui/types'import theme from '@/theme/select/app'import type { AppSelectTheme } from '@/theme/select/app'interface AppSelectProps<TValue extends string | number> {label?: string- options: { value: TValue; label: string; disabled?: boolean }[]+ /** A flat list; pass `groups` instead to divide it. */+ options?: AppSelectOption<TValue>[]+ groups?: AppSelectGroup<TValue>[]+ /** Shown when the value matches no option, such as a size that fits no preset. */placeholder?: string+ /**+ * Defaults to `over` when the built-in trigger shows a chosen option, and to `below` for a+ * `trigger` slot or a value outside the options: there is no row to line up with the trigger.+ */+ placement?: SelectPlacementui?: ComponentUI<AppSelectTheme>}defineOptions({ inheritAttrs: false })-const { options, label, placeholder, ui } = defineProps<AppSelectProps<T>>()+const { options, groups, label, placeholder, placement, ui } = defineProps<AppSelectProps<T>>()const modelValue = defineModel<T>({ required: true })+const slots = useSlots()const styles = tv(theme)()const { open: popupOpen, portalActive } = useRetainedPopup()++const optionGroups = computed<AppSelectGroup<T>[]>(() => groups ?? [{ options: options ?? [] }])const selectedLabel = computed(- () => options.find((option) => option.value === modelValue.value)?.label+ () =>+ optionGroups.value+ .flatMap((group) => group.options)+ .find((option) => option.value === modelValue.value)?.label+)+const contentPlacement = computed(+ () => placement ?? (slots.trigger || selectedLabel.value === undefined ? 'below' : 'over'))+const contentUI = computed(() => ({+ content: ui?.content,+ viewport: ui?.viewport,+ scrollButton: ui?.scrollButton+}))+const itemUI = computed(() => ({ item: ui?.item, indicator: ui?.indicator }))</script><template><SelectRoot v-model="modelValue" v-model:open="popupOpen">- <SelectTrigger v-if="$slots.trigger" as-child v-bind="$attrs" :aria-label="label">+ <SelectTrigger v-if="$slots.trigger" as-child :aria-label="label" v-bind="$attrs"><slot name="trigger" /></SelectTrigger><SelectTriggerv-else+ :aria-label="label"v-bind="$attrs":class="styles.trigger({ class: ui?.trigger })"- :aria-label="label"><SelectValue :placeholder="placeholder" :class="styles.value({ class: ui?.value })">{{ selectedLabel ?? placeholder }}</SelectValue>- <icon-lucide-chevron-down class="ml-1 size-3 shrink-0 text-muted" />+ <icon-lucide-chevron-down :class="styles.chevron({ class: ui?.chevron })" /></SelectTrigger>- <SelectPortal v-if="portalActive">- <SelectContent- position="popper"- :side-offset="2"- :class="styles.content({ class: ui?.content })"- >- <SelectScrollUpButton class="flex items-center justify-center py-0.5 text-muted">- <icon-lucide-chevron-up class="size-3.5" />- </SelectScrollUpButton>- <SelectViewport :class="styles.viewport({ class: ui?.viewport })">- <SelectItem- v-for="opt in options"- :key="String(opt.value)"- :value="opt.value"- :disabled="opt.disabled"- :class="styles.item({ class: ui?.item })"+ <AppSelectContent v-if="portalActive" :placement="contentPlacement" :ui="contentUI">+ <template v-for="(group, index) in optionGroups" :key="index">+ <SelectSeparator v-if="index > 0" :class="styles.separator({ class: ui?.separator })" />+ <SelectGroup>+ <SelectLabel v-if="group.label" :class="styles.label({ class: ui?.label })">+ {{ group.label }}+ </SelectLabel>+ <AppSelectItem+ v-for="option in group.options"+ :key="String(option.value)"+ :value="option.value"+ :disabled="option.disabled"+ :ui="itemUI">- <SelectItemIndicator :class="styles.indicator({ class: ui?.indicator })">- <icon-lucide-check class="size-3 text-primary" />- </SelectItemIndicator>- <SelectItemText>{{ opt.label }}</SelectItemText>- <slot name="option-end" :option="opt" />- </SelectItem>- </SelectViewport>- <SelectScrollDownButton class="flex items-center justify-center py-0.5 text-muted">- <icon-lucide-chevron-down class="size-3.5" />- </SelectScrollDownButton>- </SelectContent>- </SelectPortal>+ {{ option.label }}+ <template #end><slot name="option-end" :option="option" /></template>+ </AppSelectItem>+ </SelectGroup>+ </template>+ </AppSelectContent></SelectRoot></template>diff --git a/src/components/ui/select/AppSelectContent.vue b/src/components/ui/select/AppSelectContent.vuenew file mode 100644index 000000000..b5974164f--- /dev/null+++ b/src/components/ui/select/AppSelectContent.vue@@ -0,0 +1,48 @@+<script setup lang="ts">+import {+ SelectContent,+ SelectPortal,+ SelectScrollDownButton,+ SelectScrollUpButton,+ SelectViewport+} from 'reka-ui'+import { computed } from 'vue'++import { useSelectUI } from '@/components/ui/select/select'+import type { SelectPlacement } from '@/components/ui/select/select'+import type { ComponentUI } from '@/components/ui/types'+import type theme from '@/theme/select/select'++interface AppSelectContentProps {+ /**+ * `over` needs a `SelectValue` in the trigger: Reka lines the chosen row's label up with it.+ * `below` suits triggers that show an icon or a mode instead of the value.+ */+ placement?: SelectPlacement+ align?: 'start' | 'center' | 'end'+ ui?: ComponentUI<typeof theme>+}++const { placement = 'below', align = 'start', ui } = defineProps<AppSelectContentProps>()++const styles = computed(() => useSelectUI({ ...ui, contentVariants: { placement } }))+const positioning = computed(() =>+ placement === 'over'+ ? { position: 'item-aligned' as const }+ : { position: 'popper' as const, align, sideOffset: 4, collisionPadding: 8 }+)+</script>++<template>+ <SelectPortal>+ <SelectContent v-bind="positioning" :class="styles.content">+ <SelectScrollUpButton :class="styles.scrollButton">+ <icon-lucide-chevron-up class="size-3" />+ </SelectScrollUpButton>+ <SelectViewport :class="styles.viewport"><slot /></SelectViewport>+ <SelectScrollDownButton :class="styles.scrollButton">+ <icon-lucide-chevron-down class="size-3" />+ </SelectScrollDownButton>+ </SelectContent>+ </SelectPortal>+</template>diff --git a/src/components/ui/select/AppSelectItem.vue b/src/components/ui/select/AppSelectItem.vuenew file mode 100644index 000000000..394775a81--- /dev/null+++ b/src/components/ui/select/AppSelectItem.vue@@ -0,0 +1,29 @@+<script setup lang="ts">+import { SelectItem, SelectItemIndicator, SelectItemText } from 'reka-ui'+import { computed } from 'vue'++import { useSelectUI } from '@/components/ui/select/select'+import type { ComponentUI } from '@/components/ui/types'+import type theme from '@/theme/select/select'++interface AppSelectItemProps {+ value: string | number+ disabled?: boolean+ textValue?: string+ ui?: Pick<ComponentUI<typeof theme>, 'item' | 'indicator'>+}++const { value, disabled, textValue, ui } = defineProps<AppSelectItemProps>()++const styles = computed(() => useSelectUI(ui))+</script>++<template>+ <SelectItem :value="value" :disabled="disabled" :text-value="textValue" :class="styles.item">+ <SelectItemIndicator :class="styles.indicator">+ <icon-lucide-check class="size-3" />+ </SelectItemIndicator>+ <SelectItemText><slot /></SelectItemText>+ <slot name="end" />+ </SelectItem>+</template>diff --git a/src/components/ui/select/select.ts b/src/components/ui/select/select.tsindex 5388be8b6..36177bf96 100644--- a/src/components/ui/select/select.ts+++ b/src/components/ui/select/select.ts@@ -3,7 +3,22 @@ import { tv } from 'tailwind-variants'import type { ComponentUI } from '@/components/ui/types'import theme from '@/theme/select/select'+export interface AppSelectOption<TValue extends string | number> {+ value: TValue+ label: string+ disabled?: boolean+}++export interface AppSelectGroup<TValue extends string | number> {+ /** Heading above the group; groups without one are only set apart by a separator. */+ label?: string+ options: AppSelectOption<TValue>[]+}++export type SelectPlacement = keyof typeof theme.variants.placement+export interface SelectContentVariants {+ placement?: SelectPlacementpadding?: keyof typeof theme.variants.padding}@@ -16,8 +31,13 @@ export function useSelectUI(ui?: SelectUI) {return {trigger: styles.trigger({ class: ui?.trigger }),value: styles.value({ class: ui?.value }),+ chevron: styles.chevron({ class: ui?.chevron }),content: styles.content({ class: ui?.content }),viewport: styles.viewport({ class: ui?.viewport }),- item: styles.item({ class: ui?.item })+ scrollButton: styles.scrollButton({ class: ui?.scrollButton }),+ item: styles.item({ class: ui?.item }),+ indicator: styles.indicator({ class: ui?.indicator }),+ label: styles.label({ class: ui?.label }),+ separator: styles.separator({ class: ui?.separator })}}diff --git a/src/theme/select/app.ts b/src/theme/select/app.tsindex c2dbeeed3..45429e34c 100644--- a/src/theme/select/app.ts+++ b/src/theme/select/app.ts@@ -3,12 +3,7 @@ import selectTheme from './select'const appSelectTheme = {slots: {...selectTheme.slots,- trigger: [selectTheme.slots.trigger, 'w-full min-w-0 px-1.5'],- value: [selectTheme.slots.value, 'min-w-0 flex-1 truncate text-left'],- content: [selectTheme.slots.content, 'max-h-56'],- viewport: [selectTheme.slots.viewport, 'p-0.5'],- item: [selectTheme.slots.item, 'py-0 pr-2 pl-6 text-[11px]'],- indicator: 'absolute left-1.5 inline-flex items-center justify-center'+ trigger: [selectTheme.slots.trigger, 'w-full min-w-0 px-1.5']},variants: selectTheme.variants,defaultVariants: selectTheme.defaultVariantsdiff --git a/src/theme/select/grouped.ts b/src/theme/select/grouped.tsdeleted file mode 100644index 0ed21dcd4..000000000--- a/src/theme/select/grouped.ts+++ /dev/null@@ -1,19 +0,0 @@-import selectTheme from './select'--const appGroupedSelectTheme = {- slots: {- ...selectTheme.slots,- trigger: [selectTheme.slots.trigger, 'w-full justify-between px-2 text-[11px] text-surface'],- content: [selectTheme.slots.content, 'isolate z-[52]'],- item: [selectTheme.slots.item, 'rounded px-2 py-1 text-[11px]'],- label: 'px-2 py-1 text-[10px] text-muted',- separator: 'mx-1 my-1 h-px bg-border'- },- variants: selectTheme.variants,- defaultVariants: {- padding: 'md' as const- }-}--export type AppGroupedSelectTheme = typeof appGroupedSelectTheme-export default appGroupedSelectThemediff --git a/src/theme/select/select.ts b/src/theme/select/select.tsindex bf88156d4..30e7a9287 100644--- a/src/theme/select/select.ts+++ b/src/theme/select/select.ts@@ -2,19 +2,36 @@ import { motionStyles } from '../motion/styles'import { floatingSurface } from '../overlay'import { panelFieldBase } from '../panel/field'+/**+ * Every select list shares one row anatomy: a fixed check gutter, so labels never shift between+ * checked and unchecked rows, and group headings that line up with the labels below them.+ */export default {slots: {trigger: [panelFieldBase, 'flex items-center justify-between text-[11px]'],value: 'min-w-0 flex-1 truncate text-left',- content: [- 'z-[110] min-w-[var(--reka-select-trigger-width)] overflow-hidden text-[11px]',- floatingSurface,- motionStyles.floating- ],+ chevron: 'ml-1 size-3 shrink-0 text-muted',+ content: ['z-[110] overflow-hidden text-[11px]', floatingSurface, motionStyles.floating],viewport: '',- item: 'relative flex h-6 cursor-pointer items-center text-surface outline-none select-none data-[disabled]:pointer-events-none data-[highlighted]:bg-hover data-[disabled]:opacity-50'+ scrollButton: 'flex h-5 cursor-default items-center justify-center text-muted',+ item: 'relative flex h-6 cursor-pointer items-center gap-2 rounded-md pr-2 pl-6 text-surface outline-none select-none data-[disabled]:pointer-events-none data-[highlighted]:bg-hover data-[disabled]:opacity-50',+ indicator: 'absolute inset-y-0 left-0 inline-flex w-6 items-center justify-center text-primary',+ label: 'flex h-6 items-center pr-2 pl-6 text-[10px] text-muted',+ separator: 'mx-1 my-1 h-px bg-border'},variants: {+ /**+ * `over` lays the list on its trigger with the chosen row's label on the trigger's label, for+ * triggers that show the value; Reka sizes and clamps it to the window. `below` drops it under+ * triggers that show an icon or a mode.+ */+ placement: {+ over: { content: '' },+ below: {+ content:+ 'max-h-[min(var(--reka-select-content-available-height),20rem)] min-w-[var(--reka-select-trigger-width)]'+ }+ },padding: {none: { content: '' },sm: { content: 'p-0.5' },@@ -22,6 +39,7 @@ export default {}},defaultVariants: {- padding: 'sm' as const+ placement: 'below' as const,+ padding: 'md' as const}}