/**
 * Web Component wrapper for ContextMenu (auto-generated).
 * Custom element: <hf-context-menu>
 *
 * @generated by scripts/generate-wc-components.ts
 * DO NOT EDIT MANUALLY
 */

import React from 'react';
import {
  ContextMenu,
  ContextMenuPopup,
  ContextMenuTrigger,
} from '../components/organisms/menus/ContextMenu';
import {
  BaseCompoundWC,
  camelToKebab,
  installPropAccessors,
  type PropDefs,
  registerWC,
  portalNode,
  dispatchEvent,
} from './_shared';

const PROP_DEFS: PropDefs = {
  open: 'boolean',
  defaultOpen: 'boolean',
};

class ContextMenuWC extends BaseCompoundWC {
  get propDefs() {
    return PROP_DEFS;
  }

  static get observedAttributes() {
    return Object.keys(PROP_DEFS).map(camelToKebab);
  }

  protected _renderReact(): React.ReactElement {
    const props = this._readAllProps();

    const triggerSlot = this._getSlot('trigger');
    const contentSlot = this._getDefaultSlot();

    return React.createElement(
      ContextMenu,
      {
        open: props.open as boolean | undefined,
        defaultOpen: (props.defaultOpen as boolean) || false,
        onOpenChange: (open: boolean) => dispatchEvent(this, 'open-change', open),
      },
      triggerSlot ? React.createElement(ContextMenuTrigger, null, portalNode(triggerSlot)) : null,
      contentSlot ? React.createElement(ContextMenuPopup, null, portalNode(contentSlot)) : null,
    );
  }
}

installPropAccessors(ContextMenuWC, PROP_DEFS);
registerWC('hf-context-menu', ContextMenuWC);

export { ContextMenuWC };
export default ContextMenuWC;
