/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

import { h as helper } from '../../chunks/helper.js';
import { defineComponent, ref, toRefs } from '@vue/composition-api';
import useVModel from '../../hooks/use-vmodel.js';
import { renderLNodeJSXDefault } from '../../utils/render-node.js';
import { Popup } from '../popup/index.js';
import props from './props.js';
import ColorPanel from './panel/index.js';
import DefaultTrigger from './trigger.js';
import { useBaseClassName } from './hooks/index.js';
import '../../chunks/_commonjsHelpers.js';
import 'lodash/kebabCase';
import 'vue';
import 'lodash';
import '../../utils/map-props.js';
import '../../utils/with-install.js';
import '../../config.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../../chunks/set-style.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../chunks/index.js';
import '../../chunks/log.js';
import '../../chunks/_commonjsHelpers-2e6815bd.js';
import '../../utils/easing.js';
import '../../utils/helper.js';
import 'lodash/camelCase';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../../utils/mixins.js';
import '../popup/props.js';
import '../popup/container.js';
import '../popup/style';
import '../popup/type.js';
import '../../hooks/use-config.js';
import '../config-provider/useConfig.js';
import '../../hooks/use-common-classname.js';
import './const.js';
import './utils/index.js';
import '../../chunks/defineProperty-838e4192.js';
import '../../hooks/use-default-value.js';
import './panel/header.js';
import '../radio/index.js';
import '../radio/radio.js';
import '../../utils/event.js';
import '../radio/props.js';
import '../radio/group.js';
import 'lodash/isNumber';
import '../radio/radio-button.js';
import '../radio/style';
import '../radio/type.js';
import './panel/linear-gradient.js';
import 'lodash/cloneDeep';
import '../input-number/index.js';
import '../input-number/input-number.js';
import '@ldesign/icons-vue';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../../chunks/helper2.js';
import '../loading/style';
import '../loading/type.js';
import '../loading/plugin.js';
import '../../utils/ripple.js';
import '../button/props.js';
import '../button/style';
import '../button/type.js';
import '../input/index.js';
import '../input/input.js';
import '../input/props.js';
import '../input/group.js';
import '../input/style';
import '../input/type.js';
import '../../hooks/use-global-icon.js';
import '../input-number/props.js';
import '../input-number/hooks/use-input-number.js';
import '../../chunks/isObjectLike-c22c7e3b.js';
import '../../chunks/isArray-cd7357b9.js';
import '../../chunks/isNumber-c4eb560e.js';
import '../../hooks/use-form-disabled.js';
import '../input-number/style';
import '../input-number/type.js';
import './panel/base-props.js';
import './panel/saturation.js';
import '../select/index.js';
import '../select/select.js';
import 'lodash/isFunction';
import 'lodash/debounce';
import 'lodash/get';
import 'lodash/isArray';
import 'lodash/isObject';
import '../../hooks/lnode.js';
import 'lodash/isEmpty';
import '../../hooks/render-lnode.js';
import '../tag/index.js';
import '../tag/tag.js';
import '../tag/props.js';
import '../tag/check-tag.js';
import '../tag/style';
import '../tag/type.js';
import '../select-input/index.js';
import '../select-input/select-input.js';
import '../select-input/props.js';
import '../select-input/hooks/use-single.js';
import 'lodash/pick';
import '../select-input/hooks/use-multiple.js';
import '../tag-input/index.js';
import '../tag-input/tag-input.js';
import '../tag-input/props.js';
import '../tag-input/hooks/use-tag-scroll.js';
import '../tag-input/hooks/use-tag-list.js';
import '../tag-input/hooks/use-hover.js';
import '../tag-input/hooks/use-drag-sorter.js';
import '../tag-input/style';
import '../tag-input/type.js';
import '../select-input/hooks/use-overlay-innerstyle.js';
import '../select-input/style';
import '../select-input/type.js';
import '../common/fake-arrow.js';
import '../select/option.js';
import '../checkbox/index.js';
import '../checkbox/group.js';
import 'lodash/intersection';
import '../checkbox/checkbox.js';
import '../checkbox/props.js';
import '../checkbox/style';
import '../checkbox/type.js';
import '../../hooks/use-lazy-load.js';
import '../../chunks/observe.js';
import '../select/utils.js';
import '../select/props.js';
import '../select/select-panel.js';
import '../../hooks/use-virtual-scroll.js';
import '../select/hooks/use-select-options.js';
import '../select/option-group.js';
import '../select/style';
import '../select/type.js';
import './panel/hue.js';
import './panel/slider.js';
import './panel/alpha.js';
import './panel/format/index.js';
import 'lodash/upperCase';
import './panel/format/inputs.js';
import 'lodash/throttle';
import './panel/format/config.js';
import './panel/swatches.js';

var _ColorPicker = defineComponent({
  name: "LColorPicker",
  components: {
    LPopup: Popup,
    ColorPanel,
    DefaultTrigger
  },
  props: {
    ...props
  },
  setup(props2) {
    const baseClassName = useBaseClassName();
    const visible = ref(false);
    const setVisible = value2 => visible.value = value2;
    const {
      value
    } = toRefs(props2);
    const [innerValue, setInnerValue] = useVModel(value, props2.defaultValue, props2.onChange, "change");
    const handleChange = (value2, context) => {
      setInnerValue(value2, context);
    };
    const handlePaletteChange = context => {
      props2.onPaletteBarChange(context);
    };
    return {
      baseClassName,
      innerValue,
      visible,
      setVisible,
      setInnerValue,
      handleChange,
      handlePaletteChange
    };
  },
  render() {
    const h = arguments[0];
    const {
      popupProps,
      disabled,
      innerValue,
      baseClassName,
      setVisible,
      handleChange,
      handlePaletteChange
    } = this;
    const renderPopupContent = () => {
      if (disabled) return null;
      return h("color-panel", helper([{
        "props": {
          ...{
            ...this.$props,
            value: innerValue
          }
        },
        "attrs": {
          "togglePopup": setVisible
        }
      }, {
        "on": {
          change: handleChange,
          handlePaletteChange
        }
      }, {
        "ref": "refColorPanel"
      }]));
    };
    const popProps = {
      placement: "bottom-left",
      ...(popupProps || {}),
      trigger: "click",
      attach: "body",
      overlayClassName: [baseClassName],
      visible: this.visible,
      overlayInnerStyle: {
        padding: 0
      },
      onVisibleChange: (visible, context) => {
        if (context.trigger === "document") this.setVisible(false);
      }
    };
    return h("l-popup", {
      "props": {
        ...{
          ...popProps
        }
      },
      "attrs": {
        "content": renderPopupContent
      }
    }, [h("div", {
      "class": `${baseClassName}__trigger`,
      "on": {
        "click": () => setVisible(!this.visible)
      }
    }, [renderLNodeJSXDefault(this, "default", h("default-trigger", {
      "attrs": {
        "color": this.innerValue,
        "disabled": disabled,
        "input-props": this.inputProps,
        "handleTriggerChange": this.setInnerValue
      }
    }))])]);
  }
});

export { _ColorPicker as default };
//# sourceMappingURL=color-picker.js.map
