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

'use strict';

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

var helper = require('../../chunks/helper.js');
var VueCompositionAPI = require('@vue/composition-api');
var hooks_useVmodel = require('../../hooks/use-vmodel.js');
var utils_renderNode = require('../../utils/render-node.js');
var components_popup_index = require('../popup/index.js');
var components_colorPicker_props = require('./props.js');
var components_colorPicker_panel_index = require('./panel/index.js');
var components_colorPicker_trigger = require('./trigger.js');
var components_colorPicker_hooks_index = require('./hooks/index.js');
require('lodash/kebabCase');
require('vue');
require('lodash');
require('../../utils/map-props.js');
require('../../utils/with-install.js');
require('../../config.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../../chunks/set-style.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../chunks/log.js');
require('../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../utils/easing.js');
require('../../utils/helper.js');
require('lodash/camelCase');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');
require('../../utils/mixins.js');
require('../popup/props.js');
require('../popup/container.js');
require('../config-provider/useConfig.js');
require('../../hooks/use-common-classname.js');
require('../../chunks/constants.js');
require('../../chunks/color.js');
require('../../chunks/defineProperty-838e4192.js');
require('../../hooks/use-default-value.js');
require('./panel/header.js');
require('../radio/index.js');
require('../radio/radio.js');
require('../../utils/event.js');
require('../radio/props.js');
require('../radio/group.js');
require('lodash/isNumber');
require('../radio/radio-button.js');
require('./panel/linear-gradient.js');
require('lodash/cloneDeep');
require('../input-number/index.js');
require('../input-number/input-number.js');
require('@ldesign/icons-vue');
require('../button/index.js');
require('../button/button.js');
require('../loading/index.js');
require('../loading/loading.js');
require('../../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../../chunks/helper2.js');
require('../loading/plugin.js');
require('../../utils/ripple.js');
require('../button/props.js');
require('../input/index.js');
require('../input/input.js');
require('../input/props.js');
require('../input/group.js');
require('../../hooks/use-global-icon.js');
require('../input-number/props.js');
require('../input-number/hooks/use-input-number.js');
require('../../chunks/isObjectLike-c22c7e3b.js');
require('../../chunks/isArray-cd7357b9.js');
require('../../chunks/isNumber-c4eb560e.js');
require('../../hooks/use-form-disabled.js');
require('./panel/base-props.js');
require('./panel/saturation.js');
require('../select/index.js');
require('../select/select.js');
require('lodash/isFunction');
require('lodash/debounce');
require('lodash/get');
require('lodash/isArray');
require('lodash/isObject');
require('../../hooks/lnode.js');
require('lodash/isEmpty');
require('../../hooks/render-lnode.js');
require('../tag/index.js');
require('../tag/tag.js');
require('../tag/props.js');
require('../tag/check-tag.js');
require('../select-input/index.js');
require('../select-input/select-input.js');
require('../select-input/props.js');
require('../select-input/hooks/use-single.js');
require('lodash/pick');
require('../../hooks/use-config.js');
require('../select-input/hooks/use-multiple.js');
require('../tag-input/index.js');
require('../tag-input/tag-input.js');
require('../tag-input/props.js');
require('../tag-input/hooks/use-tag-scroll.js');
require('../tag-input/hooks/use-tag-list.js');
require('../tag-input/hooks/use-hover.js');
require('../tag-input/hooks/use-drag-sorter.js');
require('../select-input/hooks/use-overlay-innerstyle.js');
require('../common/fake-arrow.js');
require('../select/option.js');
require('../checkbox/index.js');
require('../checkbox/group.js');
require('lodash/intersection');
require('../checkbox/checkbox.js');
require('../checkbox/props.js');
require('../../hooks/use-lazy-load.js');
require('../../chunks/observe.js');
require('../select/utils.js');
require('../select/props.js');
require('../select/select-panel.js');
require('../../hooks/use-virtual-scroll.js');
require('../select/hooks/use-select-options.js');
require('../select/option-group.js');
require('../../chunks/draggable.js');
require('./panel/hue.js');
require('./panel/slider.js');
require('./panel/alpha.js');
require('./panel/format/index.js');
require('lodash/upperCase');
require('./const.js');
require('./panel/format/inputs.js');
require('lodash/throttle');
require('./panel/format/config.js');
require('./panel/swatches.js');

var _ColorPicker = VueCompositionAPI.defineComponent({
  name: "LColorPicker",
  components: {
    LPopup: components_popup_index.Popup,
    ColorPanel: components_colorPicker_panel_index["default"],
    DefaultTrigger: components_colorPicker_trigger["default"]
  },
  props: {
    ...components_colorPicker_props["default"]
  },
  setup(props2) {
    const baseClassName = components_colorPicker_hooks_index.useBaseClassName();
    const visible = VueCompositionAPI.ref(false);
    const setVisible = value2 => visible.value = value2;
    const {
      value
    } = VueCompositionAPI.toRefs(props2);
    const [innerValue, setInnerValue] = hooks_useVmodel["default"](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.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)
      }
    }, [utils_renderNode.renderLNodeJSXDefault(this, "default", h("default-trigger", {
      "attrs": {
        "color": this.innerValue,
        "disabled": disabled,
        "input-props": this.inputProps,
        "handleTriggerChange": this.setInnerValue
      }
    }))])]);
  }
});

exports["default"] = _ColorPicker;
//# sourceMappingURL=color-picker.js.map
