'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../config/index.js');
require('../../../../utils/index.js');
require('../../../index.js');
var createNamespace = require('../../../../utils/create-namespace.js');
var headerSearch = require('../config/header-search.js');
var index = require('../../../icon/index.js');

"use strict";
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{
    name: "TableHeaderSearch"
  },
  __name: "header-search",
  props: headerSearch.tableHeaderSearchProps,
  emits: headerSearch.tableHeaderSearchEmits,
  setup(__props, { emit: __emit }) {
    const props = __props;
    const headerSearchRef = vue.ref();
    const contentType = vue.inject("contentType");
    let observer;
    const emits = __emit;
    const bem = createNamespace.createNamespace("table");
    const handleMenuSwitchChange = (event) => {
      const target = event.target;
      const value = target.value;
      props.menuSwitchOptions.onChange && props.menuSwitchOptions.onChange(value);
      emits("change", value);
    };
    vue.watch(
      headerSearchRef,
      () => {
        if (headerSearchRef.value) {
          if (!observer) {
            observer = new MutationObserver(function(mutations) {
              mutations.forEach(function() {
                const newHeight = headerSearchRef.value.getBoundingClientRect().height;
                emits("changeHeaderSearch", newHeight);
              });
            });
            const config = {
              childList: true,
              // 观察直接子节点
              subtree: true
              // 及其更低的后代节点
            };
            observer?.observe(headerSearchRef.value, config);
          }
        }
      },
      {
        immediate: true,
        deep: true
      }
    );
    vue.onUnmounted(() => {
      if (observer) {
        observer.disconnect();
      }
    });
    return (_ctx, _cache) => {
      const _component_a_radio_button = vue.resolveComponent("a-radio-button");
      const _component_a_radio_group = vue.resolveComponent("a-radio-group");
      return vue.openBlock(), vue.createElementBlock(
        "div",
        {
          ref_key: "headerSearchRef",
          ref: headerSearchRef,
          class: vue.normalizeClass(`${vue.unref(bem).e("header-wrapper")}`)
        },
        [
          vue.createElementVNode(
            "div",
            {
              class: vue.normalizeClass(vue.unref(bem).e("header"))
            },
            [
              vue.renderSlot(_ctx.$slots, "header", {}, () => [
                vue.createCommentVNode(" \u5DE6\u8FB9\u7684\u63D2\u69FD "),
                vue.createElementVNode(
                  "div",
                  {
                    class: vue.normalizeClass(vue.unref(bem).e("header-left"))
                  },
                  [
                    vue.renderSlot(_ctx.$slots, "headerLeft")
                  ],
                  2
                  /* CLASS */
                ),
                vue.createCommentVNode(" \u5185\u5BB9\u4E2D\u95F4\u63D2\u69FD "),
                vue.createElementVNode(
                  "div",
                  {
                    class: vue.normalizeClass(vue.unref(bem).e("header-middle"))
                  },
                  [
                    vue.renderSlot(_ctx.$slots, "headerMiddle")
                  ],
                  2
                  /* CLASS */
                ),
                vue.createElementVNode(
                  "div",
                  {
                    class: vue.normalizeClass(vue.unref(bem).e("header-right"))
                  },
                  [
                    vue.renderSlot(_ctx.$slots, "headerRight"),
                    vue.createCommentVNode(" \u5207\u6362table\u548Clist\u83DC\u5355 "),
                    props.menuSwitchOptions?.show ? (vue.openBlock(), vue.createBlock(_component_a_radio_group, {
                      key: 0,
                      value: vue.unref(contentType),
                      "onUpdate:value": _cache[0] || (_cache[0] = ($event) => vue.isRef(contentType) ? contentType.value = $event : null),
                      class: vue.normalizeClass(`${vue.unref(bem).e("header-menu-radio-group")}`),
                      onChange: handleMenuSwitchChange
                    }, {
                      default: vue.withCtx(() => [
                        (vue.openBlock(true), vue.createElementBlock(
                          vue.Fragment,
                          null,
                          vue.renderList(vue.unref(headerSearch.menuSwitchRadioList), (menuItem) => {
                            return vue.openBlock(), vue.createBlock(_component_a_radio_button, {
                              key: menuItem.value,
                              class: vue.normalizeClass(`${vue.unref(bem).e("header-menu-icon")}`),
                              value: menuItem.value
                            }, {
                              default: vue.withCtx(() => [
                                vue.createVNode(vue.unref(index.LlIcon), {
                                  "icon-name": menuItem.icon,
                                  size: 18
                                }, null, 8, ["icon-name"])
                              ]),
                              _: 2
                              /* DYNAMIC */
                            }, 1032, ["class", "value"]);
                          }),
                          128
                          /* KEYED_FRAGMENT */
                        ))
                      ]),
                      _: 1
                      /* STABLE */
                    }, 8, ["value", "class"])) : vue.createCommentVNode("v-if", true)
                  ],
                  2
                  /* CLASS */
                )
              ])
            ],
            2
            /* CLASS */
          )
        ],
        2
        /* CLASS */
      );
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=header-search.vue2.js.map
