Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat: add StateMachine Inspector editor with collapse state preservation

esengine4018babec755
diff --git a/editor/src/plugins/ui.ts b/editor/src/plugins/ui.ts
index 720caa12a..6dc426891 100644
--- a/editor/src/plugins/ui.ts
+++ b/editor/src/plugins/ui.ts
@@ -266,7 +266,7 @@ const StateMachineSchema: ComponentSchema = {
name: 'StateMachine',
category: 'ui',
properties: [
- { name: 'initialState', type: 'string', displayName: 'Initial State' },
+ { name: '*', type: 'state-machine' },
],
};
diff --git a/editor/src/property/editors/index.ts b/editor/src/property/editors/index.ts
index 3f26f0445..9ce978945 100644
--- a/editor/src/property/editors/index.ts
+++ b/editor/src/property/editors/index.ts
@@ -18,6 +18,7 @@ import { createAssetFileEditor, ASSET_FILE_EDITORS } from './assetEditors';
import { createEntityEditor } from './entityEditor';
import { createVec2ArrayEditor, createStringArrayEditor } from './arrayEditors';
import { createCollisionLayerEditor } from './collisionLayerEditor';
+import { createStateMachineEditor } from './stateMachineEditor';
export { getNativeFS, getProjectDir, getMimeType, navigateToAsset, handleAssetDrop, BROWSE_ICON, CLEAR_ICON } from './assetEditors';
@@ -48,4 +49,5 @@ export function registerBuiltinEditors(registrar: PluginRegistrar): void {
registerPropertyEditor('string-array', createStringArrayEditor);
registerPropertyEditor('vec2-array', createVec2ArrayEditor);
registerPropertyEditor('collision-layer', createCollisionLayerEditor);
+ registerPropertyEditor('state-machine', createStateMachineEditor);
}
diff --git a/editor/src/property/editors/stateMachineEditor.ts b/editor/src/property/editors/stateMachineEditor.ts
new file mode 100644
index 000000000..a8a891d1a
--- /dev/null
+++ b/editor/src/property/editors/stateMachineEditor.ts
@@ -0,0 +1,577 @@
+import type { PropertyEditorContext, PropertyEditorInstance } from '../PropertyEditor';
+
+interface InputDef {
+ name: string;
+ type: 'bool' | 'number' | 'trigger';
+ defaultValue?: boolean | number;
+}
+
+interface ListenerDef {
+ event: 'pointerEnter' | 'pointerExit' | 'pointerDown' | 'pointerUp';
+ inputName: string;
+ action: 'set' | 'reset' | 'toggle';
+ value?: boolean | number;
+}
+
+interface Condition {
+ inputName: string;
+ comparator: 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte';
+ value: boolean | number;
+}
+
+interface Transition {
+ target: string;
+ conditions: Condition[];
+ duration: number;
+ exitTime?: number;
+ easing?: string;
+}
+
+interface StateNode {
+ timeline?: string;
+ properties?: Record<string, unknown>;
+ transitions: Transition[];
+}
+
+interface StateMachineData {
+ states: Record<string, StateNode>;
+ inputs: InputDef[];
+ listeners: ListenerDef[];
+ initialState: string;
+}
+
+const CHEVRON_SVG = `<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg>`;
+const REMOVE_SVG = `<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>`;
+
+const EVENT_OPTIONS = ['pointerEnter', 'pointerExit', 'pointerDown', 'pointerUp'];
+const ACTION_OPTIONS = ['set', 'reset', 'toggle'];
+const INPUT_TYPE_OPTIONS = ['bool', 'number', 'trigger'];
+const COMPARATOR_OPTIONS = ['eq', 'neq', 'gt', 'lt', 'gte', 'lte'];
+const EASING_OPTIONS = ['linear', 'easeInQuad', 'easeOutQuad', 'easeInOutQuad', 'easeInCubic', 'easeOutCubic', 'easeInOutCubic', 'easeInBack', 'easeOutBack', 'easeInOutBack', 'easeOutBounce'];
+
+function cloneData(data: StateMachineData): StateMachineData {
+ return JSON.parse(JSON.stringify(data));
+}
+
+function defaultData(): StateMachineData {
+ return { states: {}, inputs: [], listeners: [], initialState: '' };
+}
+
+function createSelect(options: string[], value: string, cls?: string): HTMLSelectElement {
+ const sel = document.createElement('select');
+ sel.className = cls ?? 'es-input es-input-select es-sm-select';
+ for (const opt of options) {
+ const o = document.createElement('option');
+ o.value = opt;
+ o.textContent = opt;
+ sel.appendChild(o);
+ }
+ sel.value = value;
+ return sel;
+}
+
+function createRemoveBtn(): HTMLButtonElement {
+ const btn = document.createElement('button');
+ btn.className = 'es-btn es-btn-icon es-btn-clear';
+ btn.title = 'Remove';
+ btn.innerHTML = REMOVE_SVG;
+ return btn;
+}
+
+function createAddBtn(label: string): HTMLButtonElement {
+ const btn = document.createElement('button');
+ btn.className = 'es-btn es-btn-sm es-btn-add-item';
+ btn.textContent = `+ ${label}`;
+ return btn;
+}
+
+export function createStateMachineEditor(
+ container: HTMLElement,
+ ctx: PropertyEditorContext
+): PropertyEditorInstance {
+ let data = ctx.componentData
+ ? cloneData(ctx.componentData as unknown as StateMachineData)
+ : defaultData();
+ let prevData = cloneData(data);
+
+ const collapsedSections = new Set<string>();
+
+ function createSection(title: string, expanded: boolean, sectionId?: string): { section: HTMLElement; content: HTMLElement } {
+ const key = sectionId ?? title;
+ const section = document.createElement('div');
+ section.className = 'es-sm-section es-collapsible';
+ if (!collapsedSections.has(key) && expanded) section.classList.add('es-expanded');
+ if (sectionId) section.dataset.section = sectionId;
+
+ const header = document.createElement('div');
+ header.className = 'es-sm-section-header';
+ const icon = document.createElement('span');
+ icon.className = 'es-collapse-icon';
+ icon.innerHTML = CHEVRON_SVG;
+ const label = document.createElement('span');
+ label.className = 'es-sm-section-title';
+ label.textContent = title;
+ header.appendChild(icon);
+ header.appendChild(label);
+
+ const content = document.createElement('div');
+ content.className = 'es-collapsible-content es-sm-section-body';
+
+ header.addEventListener('click', () => {
+ section.classList.toggle('es-expanded');
+ if (section.classList.contains('es-expanded')) {
+ collapsedSections.delete(key);
+ } else {
+ collapsedSections.add(key);
+ }
+ });
+
+ section.appendChild(header);
+ section.appendChild(content);
+ return { section, content };
+ }
+
+ const propertyRow = container.closest('.es-property-row');
+ if (propertyRow) (propertyRow as HTMLElement).style.display = 'none';
+
+ const root = document.createElement('div');
+ root.className = 'es-sm-editor';
+ const insertTarget = propertyRow?.parentElement ?? container;
+ insertTarget.appendChild(root);
+
+ function emit() {
+ const changes: { property: string; oldValue: unknown; newValue: unknown }[] = [];
+ for (const key of ['states', 'inputs', 'listeners', 'initialState'] as const) {
+ const oldVal = prevData[key];
+ const newVal = data[key];
+ if (JSON.stringify(oldVal) !== JSON.stringify(newVal)) {
+ changes.push({ property: key, oldValue: cloneData(oldVal as any), newValue: cloneData(newVal as any) });
+ }
+ }
+ if (changes.length > 0) {
+ prevData = cloneData(data);
+ ctx.onChange(changes);
+ }
+ }
+
+ function getInputNames(): string[] {
+ return data.inputs.map(i => i.name);
+ }
+
+ function getStateNames(): string[] {
+ return Object.keys(data.states);
+ }
+
+ // =========================================================================
+ // Initial State
+ // =========================================================================
+ function renderInitialState() {
+ const row = document.createElement('div');
+ row.className = 'es-property-row es-sm-initial-row';
+ const label = document.createElement('label');
+ label.className = 'es-property-label';
+ label.textContent = 'Initial State';
+ const sel = createSelect(getStateNames(), data.initialState);
+ sel.addEventListener('change', () => { data.initialState = sel.value; emit(); });
+ row.appendChild(label);
+ row.appendChild(sel);
+ return row;
+ }
+
+ // =========================================================================
+ // Inputs
+ // =========================================================================
+ function renderInputs(): HTMLElement {
+ const { section, content } = createSection(`Inputs (${data.inputs.length})`, true, 'inputs');
+
+ function renderList() {
+ content.innerHTML = '';
+ data.inputs.forEach((inp, i) => {
+ const row = document.createElement('div');
+ row.className = 'es-sm-list-row';
+
+ const nameInput = document.createElement('input');
+ nameInput.type = 'text';
+ nameInput.className = 'es-input es-input-string es-sm-name';
+ nameInput.value = inp.name;
+ nameInput.placeholder = 'name';
+ nameInput.addEventListener('change', () => { data.inputs[i].name = nameInput.value; emit(); rebuild(); });
+
+ const typeSel = createSelect(INPUT_TYPE_OPTIONS, inp.type);
+ typeSel.addEventListener('change', () => {
+ data.inputs[i].type = typeSel.value as InputDef['type'];
+ data.inputs[i].defaultValue = typeSel.value === 'bool' ? false : 0;
+ emit(); renderList();
+ });
+
+ row.appendChild(nameInput);
+ row.appendChild(typeSel);
+
+ if (inp.type === 'bool') {
+ const cb = document.createElement('input');
+ cb.type = 'checkbox';
+ cb.className = 'es-input es-input-checkbox';
+ cb.checked = !!inp.defaultValue;
+ cb.addEventListener('change', () => { data.inputs[i].defaultValue = cb.checked; emit(); });
+ row.appendChild(cb);
+ } else if (inp.type === 'number') {
+ const numInput = document.createElement('input');
+ numInput.type = 'number';
+ numInput.className = 'es-input es-input-number es-sm-num';
+ numInput.value = String(inp.defaultValue ?? 0);
+ numInput.addEventListener('change', () => { data.inputs[i].defaultValue = parseFloat(numInput.value) || 0; emit(); });
+ row.appendChild(numInput);
+ }
+
+ const rm = createRemoveBtn();
+ rm.addEventListener('click', () => { data.inputs.splice(i, 1); emit(); rebuild(); });
+ row.appendChild(rm);
+
+ content.appendChild(row);
+ });
+
+ const addBtn = createAddBtn('Input');
+ addBtn.addEventListener('click', () => {
+ data.inputs.push({ name: `input${data.inputs.length}`, type: 'bool', defaultValue: false });
+ emit(); rebuild();
+ });
+ content.appendChild(addBtn);
+ }
+
+ renderList();
+ return section;
+ }
+
+ // =========================================================================
+ // Listeners
+ // =========================================================================
+ function renderListeners(): HTMLElement {
+ const { section, content } = createSection(`Listeners (${data.listeners.length})`, true, 'listeners');
+
+ function renderList() {
+ content.innerHTML = '';
+ data.listeners.forEach((lis, i) => {
+ const row = document.createElement('div');
+ row.className = 'es-sm-list-row';
+
+ const eventSel = createSelect(EVENT_OPTIONS, lis.event);
+ eventSel.addEventListener('change', () => { data.listeners[i].event = eventSel.value as ListenerDef['event']; emit(); });
+
+ const inputSel = createSelect(getInputNames(), lis.inputName);
+ inputSel.addEventListener('change', () => { data.listeners[i].inputName = inputSel.value; emit(); });
+
+ const actionSel = createSelect(ACTION_OPTIONS, lis.action);
+ actionSel.addEventListener('change', () => { data.listeners[i].action = actionSel.value as ListenerDef['action']; emit(); });
+
+ const rm = createRemoveBtn();
+ rm.addEventListener('click', () => { data.listeners.splice(i, 1); emit(); rebuild(); });
+
+ row.appendChild(eventSel);
+ row.appendChild(inputSel);
+ row.appendChild(actionSel);
+ row.appendChild(rm);
+ content.appendChild(row);
+ });
+
+ const addBtn = createAddBtn('Listener');
+ addBtn.addEventListener('click', () => {
+ const names = getInputNames();
+ data.listeners.push({ event: 'pointerDown', inputName: names[0] ?? '', action: 'set' });
+ emit(); rebuild();
+ });
+ content.appendChild(addBtn);
+ }
+
+ renderList();
+ return section;
+ }
+
+ // =========================================================================
+ // States
+ // =========================================================================
+ function renderCondition(cond: Condition, onChange: () => void, onRemove: () => void): HTMLElement {
+ const row = document.createElement('div');
+ row.className = 'es-sm-condition-row';
+
+ const inputSel = createSelect(getInputNames(), cond.inputName);
+ inputSel.addEventListener('change', () => { cond.inputName = inputSel.value; onChange(); });
+
+ const compSel = createSelect(COMPARATOR_OPTIONS, cond.comparator);
+ compSel.addEventListener('change', () => { cond.comparator = compSel.value as Condition['comparator']; onChange(); });
+
+ const valInput = document.createElement('input');
+ valInput.className = 'es-input es-input-string es-sm-val';
+ valInput.value = String(cond.value);
+ valInput.addEventListener('change', () => {
+ const v = valInput.value;
+ cond.value = v === 'true' ? true : v === 'false' ? false : parseFloat(v) || 0;
+ onChange();
+ });
+
+ const rm = createRemoveBtn();
+ rm.addEventListener('click', onRemove);
+
+ row.appendChild(inputSel);
+ row.appendChild(compSel);
+ row.appendChild(valInput);
+ row.appendChild(rm);
+ return row;
+ }
+
+ function renderTransition(trans: Transition, stateNames: string[], onChange: () => void, onRemove: () => void): HTMLElement {
+ const wrap = document.createElement('div');
+ wrap.className = 'es-sm-transition';
+
+ const headerRow = document.createElement('div');
+ headerRow.className = 'es-sm-list-row';
+
+ const targetSel = createSelect(stateNames, trans.target);
+ targetSel.addEventListener('change', () => { trans.target = targetSel.value; onChange(); });
+
+ const durInput = document.createElement('input');
+ durInput.type = 'number';
+ durInput.className = 'es-input es-input-number es-sm-num';
+ durInput.value = String(trans.duration);
+ durInput.step = '0.05';
+ durInput.min = '0';
+ durInput.title = 'Duration (s)';
+ durInput.addEventListener('change', () => { trans.duration = parseFloat(durInput.value) || 0; onChange(); });
+
+ const easingSel = createSelect(EASING_OPTIONS, trans.easing ?? 'linear');
+ easingSel.addEventListener('change', () => { trans.easing = easingSel.value; onChange(); });
+
+ const rm = createRemoveBtn();
+ rm.addEventListener('click', onRemove);
+
+ const arrowLabel = document.createElement('span');
+ arrowLabel.className = 'es-sm-arrow';
+ arrowLabel.textContent = '→';
+
+ headerRow.appendChild(arrowLabel);
+ headerRow.appendChild(targetSel);
+ headerRow.appendChild(durInput);
+ headerRow.appendChild(easingSel);
+ headerRow.appendChild(rm);
+ wrap.appendChild(headerRow);
+
+ const condBox = document.createElement('div');
+ condBox.className = 'es-sm-conditions';
+ const condLabel = document.createElement('span');
+ condLabel.className = 'es-sm-sub-label';
+ condLabel.textContent = 'Conditions';
+ condBox.appendChild(condLabel);
+
+ for (let ci = 0; ci < trans.conditions.length; ci++) {
+ condBox.appendChild(renderCondition(trans.conditions[ci], onChange, () => {
+ trans.conditions.splice(ci, 1);
+ onChange();
+ rebuild();
+ }));
+ }
+
+ const addCond = createAddBtn('Condition');
+ addCond.addEventListener('click', () => {
+ const names = getInputNames();
+ trans.conditions.push({ inputName: names[0] ?? '', comparator: 'eq', value: true });
+ onChange();
+ rebuild();
+ });
+ condBox.appendChild(addCond);
+ wrap.appendChild(condBox);
+
+ return wrap;
+ }
+
+ function renderStates(): HTMLElement {
+ const { section, content } = createSection(`States (${Object.keys(data.states).length})`, true, 'states');
+
+ function renderList() {
+ content.innerHTML = '';
+ const stateNames = getStateNames();
+
+ for (const [name, state] of Object.entries(data.states)) {
+ const stateKey = `state:${name}`;
+ const stateSection = document.createElement('div');
+ stateSection.className = 'es-sm-state es-collapsible';
+ if (!collapsedSections.has(stateKey)) stateSection.classList.add('es-expanded');
+
+ const stateHeader = document.createElement('div');
+ stateHeader.className = 'es-sm-state-header';
+
+ const icon = document.createElement('span');
+ icon.className = 'es-collapse-icon';
+ icon.innerHTML = CHEVRON_SVG;
+
+ const nameInput = document.createElement('input');
+ nameInput.type = 'text';
+ nameInput.className = 'es-input es-input-string es-sm-state-name';
+ nameInput.value = name;
+ nameInput.addEventListener('click', (e) => e.stopPropagation());
+ nameInput.addEventListener('change', () => {
+ const newName = nameInput.value.trim();
+ if (!newName || newName === name || data.states[newName]) return;
+ if (collapsedSections.has(stateKey)) {
+ collapsedSections.delete(stateKey);
+ collapsedSections.add(`state:${newName}`);
+ }
+ data.states[newName] = data.states[name];
+ delete data.states[name];
+ if (data.initialState === name) data.initialState = newName;
+ for (const s of Object.values(data.states)) {
+ for (const t of s.transitions) {
+ if (t.target === name) t.target = newName;
+ }
+ }
+ emit(); rebuild();
+ });
+
+ const rmState = createRemoveBtn();
+ rmState.addEventListener('click', (e) => {
+ e.stopPropagation();
+ collapsedSections.delete(stateKey);
+ delete data.states[name];
+ if (data.initialState === name) data.initialState = getStateNames()[0] ?? '';
+ emit(); rebuild();
+ });
+
+ stateHeader.appendChild(icon);
+ stateHeader.appendChild(nameInput);
+ stateHeader.appendChild(rmState);
+ stateHeader.addEventListener('click', () => {
+ stateSection.classList.toggle('es-expanded');
+ if (stateSection.classList.contains('es-expanded')) {
+ collapsedSections.delete(stateKey);
+ } else {
+ collapsedSections.add(stateKey);
+ }
+ });
+
+ const stateBody = document.createElement('div');
+ stateBody.className = 'es-collapsible-content es-sm-state-body';
+
+ // Properties
+ const propLabel = document.createElement('span');
+ propLabel.className = 'es-sm-sub-label es-sm-label-props';
+ propLabel.textContent = 'Properties';
+ stateBody.appendChild(propLabel);
+
+ const props = state.properties ?? {};
+ for (const [pKey, pVal] of Object.entries(props)) {
+ const pRow = document.createElement('div');
+ pRow.className = 'es-sm-list-row';
+
+ const keyInput = document.createElement('input');
+ keyInput.type = 'text';
+ keyInput.className = 'es-input es-input-string es-sm-prop-key';
+ keyInput.value = pKey;
+ keyInput.placeholder = 'Component.field';
+
+ const valInput = document.createElement('input');
+ valInput.type = 'text';
+ valInput.className = 'es-input es-input-string es-sm-val';
+ valInput.value = String(pVal);
+
+ const commitProp = () => {
+ const newKey = keyInput.value.trim();
+ if (!newKey) return;
+ if (!state.properties) state.properties = {};
+ if (newKey !== pKey) delete state.properties[pKey];
+ const raw = valInput.value;
+ state.properties[newKey] = raw === 'true' ? true : raw === 'false' ? false : isNaN(Number(raw)) ? raw : Number(raw);
+ emit();
+ };
+ keyInput.addEventListener('change', commitProp);
+ valInput.addEventListener('change', commitProp);
+
+ const rmP = createRemoveBtn();
+ rmP.addEventListener('click', () => {
+ if (state.properties) delete state.properties[pKey];
+ emit(); rebuild();
+ });
+
+ pRow.appendChild(keyInput);
+ pRow.appendChild(valInput);
+ pRow.appendChild(rmP);
+ stateBody.appendChild(pRow);
+ }
+
+ const addProp = createAddBtn('Property');
+ addProp.addEventListener('click', () => {
+ if (!state.properties) state.properties = {};
+ let idx = Object.keys(state.properties).length;
+ while (state.properties[`prop${idx}`] !== undefined) idx++;
+ state.properties[`prop${idx}`] = 0;
+ emit(); rebuild();
+ });
+ stateBody.appendChild(addProp);
+
+ // Transitions
+ const transLabel = document.createElement('span');
+ transLabel.className = 'es-sm-sub-label es-sm-label-trans';
+ transLabel.textContent = 'Transitions';
+ stateBody.appendChild(transLabel);
+
+ state.transitions.forEach((trans, ti) => {
+ stateBody.appendChild(renderTransition(trans, stateNames, () => emit(), () => {
+ state.transitions.splice(ti, 1);
+ emit(); rebuild();
+ }));
+ });
+
+ const addTrans = createAddBtn('Transition');
+ addTrans.addEventListener('click', () => {
+ const targets = stateNames.filter(n => n !== name);
+ state.transitions.push({ target: targets[0] ?? '', conditions: [], duration: 0.1 });
+ emit(); rebuild();
+ });
+ stateBody.appendChild(addTrans);
+
+ stateSection.appendChild(stateHeader);
+ stateSection.appendChild(stateBody);
+ content.appendChild(stateSection);
+ }
+
+ const addState = createAddBtn('State');
+ addState.addEventListener('click', () => {
+ let idx = Object.keys(data.states).length;
+ while (data.states[`state${idx}`]) idx++;
+ data.states[`state${idx}`] = { transitions: [], properties: {} };
+ if (!data.initialState) data.initialState = `state${idx}`;
+ emit(); rebuild();
+ });
+ content.appendChild(addState);
+ }
+
+ renderList();
+ return section;
+ }
+
+ // =========================================================================
+ // Build
+ // =========================================================================
+ function rebuild() {
+ root.innerHTML = '';
+ root.appendChild(renderInitialState());
+ root.appendChild(renderInputs());
+ root.appendChild(renderListeners());
+ root.appendChild(renderStates());
+ }
+
+ rebuild();
+
+ return {
+ update(v: unknown) {
+ if (v && typeof v === 'object') {
+ data = cloneData(v as StateMachineData);
+ } else {
+ data = defaultData();
+ }
+ prevData = cloneData(data);
+ rebuild();
+ },
+ dispose() {
+ root.remove();
+ if (propertyRow) (propertyRow as HTMLElement).style.display = '';
+ },
+ };
+}
diff --git a/editor/src/styles/base.css b/editor/src/styles/base.css
index 752429352..093f43c45 100644
--- a/editor/src/styles/base.css
+++ b/editor/src/styles/base.css
@@ -709,6 +709,224 @@
margin-bottom: 0;
}
+/* =============================================================================
+ * StateMachine Editor
+ * ============================================================================= */
+
+.es-sm-editor {
+ padding: 0;
+}
+
+.es-sm-initial-row {
+ padding: 6px 8px;
+ background: var(--es-bg-secondary);
+ border-bottom: 1px solid var(--es-border);
+}
+
+.es-sm-initial-row label {
+ color: var(--es-text-secondary);
+ font-size: 10px;
+ text-transform: uppercase;
+ letter-spacing: 0.5px;
+ margin-bottom: 2px;
+ display: block;
+}
+
+.es-sm-initial-row select {
+ width: 100%;
+}
+
+/* Sections */
+
+.es-sm-section {
+ border-top: 1px solid var(--es-border);
+}
+
+.es-sm-section-header {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ padding: 5px 8px;
+ cursor: pointer;
+ font-size: 11px;
+ font-weight: 600;
+}
+
+.es-sm-section-header:hover {
+ background: var(--es-bg-hover);
+}
+
+.es-sm-section-title {
+ flex: 1;
+}
+
+.es-sm-section-body {
+ padding: 4px 8px 6px;
+}
+
+/* Section color coding */
+.es-sm-section[data-section="inputs"] .es-sm-section-header {
+ border-left: 3px solid #5b9bd5;
+}
+
+.es-sm-section[data-section="listeners"] .es-sm-section-header {
+ border-left: 3px solid #70ad47;
+}
+
+.es-sm-section[data-section="states"] .es-sm-section-header {
+ border-left: 3px solid #ed7d31;
+}
+
+/* List rows */
+
+.es-sm-list-row {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ margin-bottom: 3px;
+ padding: 2px 4px;
+ border-radius: 3px;
+ background: var(--es-bg-primary);
+}
+
+.es-sm-list-row select {
+ flex: 1;
+ min-width: 0;
+}
+
+.es-sm-name {
+ flex: 2;
+ min-width: 0;
+}
+
+.es-sm-num {
+ width: 52px;
+ flex: 0 0 52px;
+}
+
+.es-sm-val {
+ width: 52px;
+ flex: 1;
+ min-width: 0;
+}
+
+.es-sm-prop-key {
+ flex: 2;
+ min-width: 0;
+ font-family: monospace;
+ font-size: 11px;
+}
+
+.es-sm-arrow {
+ font-size: 14px;
+ color: #ed7d31;
+ flex: 0 0 auto;
+ font-weight: bold;
+}
+
+.es-sm-sub-label {
+ display: block;
+ font-size: 10px;
+ margin: 6px 0 3px;
+ text-transform: uppercase;
+ letter-spacing: 0.5px;
+ font-weight: 600;
+}
+
+.es-sm-label-props {
+ color: #7eb8e0;
+}
+
+.es-sm-label-trans {
+ color: #ed7d31;
+}
+
+/* State cards */
+
+.es-sm-state {
+ border: 1px solid rgba(237, 125, 49, 0.3);
+ border-radius: 4px;
+ margin-bottom: 6px;
+ overflow: hidden;
+}
+
+.es-sm-state-header {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ padding: 4px 8px;
+ background: rgba(237, 125, 49, 0.08);
+ cursor: pointer;
+ border-bottom: 1px solid rgba(237, 125, 49, 0.15);
+}
+
+.es-sm-state-header:hover {
+ background: rgba(237, 125, 49, 0.15);
+}
+
+.es-sm-state-name {
+ flex: 1;
+ min-width: 0;
+ font-weight: 600;
+ font-size: 11px;
+ color: #ed7d31;
+ background: transparent;
+ border-color: transparent;
+}
+
+.es-sm-state-name:focus {
+ border-color: #ed7d31;
+ color: var(--es-text-primary);
+}
+
+.es-sm-state-body {
+ padding: 6px 8px;
+}
+
+/* Transitions */
+
+.es-sm-transition {
+ border: 1px solid rgba(91, 155, 213, 0.3);
+ border-radius: 3px;
+ padding: 4px 6px;
+ margin-bottom: 4px;
+ background: rgba(91, 155, 213, 0.05);
+}
+
+.es-sm-conditions {
+ padding-left: 12px;
+ border-left: 2px solid rgba(112, 173, 71, 0.3);
+ margin-top: 4px;
+}
+
+.es-sm-condition-row {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ margin-bottom: 2px;
+ padding: 1px 4px;
+ border-radius: 2px;
+ background: rgba(112, 173, 71, 0.06);
+}
+
+.es-sm-condition-row select {
+ flex: 1;
+ min-width: 0;
+}
+
+/* Add buttons */
+
+.es-sm-section-body > .es-btn-add-item,
+.es-sm-state-body > .es-btn-add-item {
+ margin-top: 4px;
+ opacity: 0.7;
+}
+
+.es-sm-section-body > .es-btn-add-item:hover,
+.es-sm-state-body > .es-btn-add-item:hover {
+ opacity: 1;
+}
+
/* =============================================================================
* Container Classes
* ============================================================================= */