/** @jsxImportSource @jgengine/core/ui/jsx */ import { useState } from "@jgengine/core/ui/jsx"; import type { EditorCollection, EditorSession } from "@jgengine/core/editor/index"; import { CONTROL, FOCUS_RING, INPUT_CLS, MICRO_LABEL } from "./shell/theme"; import { shallowArrayEqual, useStoreSelector } from "./useStoreSelector"; const BTN = `${CONTROL} px-2 py-1 text-[11px] disabled:opacity-40`; const CHIP_BTN = `rounded-[4px] px-1.5 py-0.5 text-[10px] ring-1 ring-inset transition-colors ${FOCUS_RING}`; function newCollectionId(): string { return `col_${Date.now().toString(36)}_${Math.floor(Math.random() * 1296).toString(36)}`; } /** * Named selection sets / production groups: bookmark the current selection, restore it later, * add-to / remove-from membership, and toggle a collection's color/lock/visibility. Locking a * collection blocks move and delete on its members at the session level (see `isEditorObjectLocked`). * @internal β mounted by `EditorChrome` as a left-aside tab. */ export function CollectionsPanel({ session }: { session: EditorSession }) { const document = useStoreSelector(session, (state) => state.document); const selection = useStoreSelector(session, (state) => state.selection, shallowArrayEqual); const [name, setName] = useState(""); const collections = document.collections; const createFromSelection = () => { const trimmed = name.trim(); if (trimmed.length === 0 || selection.length === 0) return; session.dispatch({ type: "createCollection", id: newCollectionId(), name: trimmed, memberIds: selection }); setName(""); }; return (