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

'use strict';

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

var VueCompositionAPI = require('@vue/composition-api');
var components_input_index = require('../input/index.js');
var components_inputNumber_index = require('../input-number/index.js');
var color = require('../../chunks/color.js');
var components_colorPicker_hooks_index = require('./hooks/index.js');
require('../../utils/map-props.js');
require('vue');
require('../../utils/with-install.js');
require('lodash');
require('../../config.js');
require('../input/input.js');
require('@ldesign/icons-vue');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../../chunks/helper2.js');
require('../../chunks/log.js');
require('../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../utils/helper.js');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');
require('../../utils/mixins.js');
require('../../utils/event.js');
require('../../utils/render-node.js');
require('../input/props.js');
require('../input/group.js');
require('../input-number/input-number.js');
require('../../chunks/helper.js');
require('../button/index.js');
require('../button/button.js');
require('../loading/index.js');
require('../loading/loading.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../utils/easing.js');
require('../../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../../chunks/defineProperty-838e4192.js');
require('../../chunks/set-style.js');
require('../loading/plugin.js');
require('../../utils/ripple.js');
require('../button/props.js');
require('../../hooks/use-global-icon.js');
require('../config-provider/useConfig.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-common-classname.js');
require('../../hooks/use-vmodel.js');
require('../../hooks/use-form-disabled.js');
require('../../hooks/use-config.js');

var DefaultTrigger = VueCompositionAPI.defineComponent({
  name: "DefaultTrigger",
  components: {
    TInput: components_input_index.Input,
    TInputNumber: components_inputNumber_index.InputNumber
  },
  inheritAttrs: false,
  props: {
    color: {
      type: String,
      default: ""
    },
    disabled: {
      type: Boolean,
      default: false
    },
    inputProps: {
      type: Object,
      default: () => ({
        autoWidth: true
      })
    },
    handleTriggerChange: {
      type: Function,
      default: () => () => {}
    }
  },
  setup(props) {
    const baseClassName = components_colorPicker_hooks_index.useBaseClassName();
    const value = VueCompositionAPI.ref(props.color);
    VueCompositionAPI.watch(() => [props.color], () => value.value = props.color);
    const handleChange = input => {
      if (input === props.color) return;
      if (!color.Color.isValid(input)) value.value = props.color;else value.value = input;
      props.handleTriggerChange(value.value);
    };
    return {
      baseClassName,
      value,
      handleChange
    };
  },
  render() {
    const h = arguments[0];
    const {
      baseClassName
    } = this;
    const inputSlots = {
      label: () => h("div", {
        "class": [`${baseClassName}__trigger--default__color`, `${baseClassName}--bg-alpha`]
      }, [h("span", {
        "class": ["color-inner"],
        "style": {
          background: this.value
        }
      })])
    };
    return h("div", {
      "class": `${baseClassName}__trigger--default`
    }, [h("l-input", {
      "props": {
        ...{
          ...this.inputProps
        }
      },
      "scopedSlots": inputSlots,
      "attrs": {
        "disabled": this.disabled
      },
      "on": {
        "blur": this.handleChange
      },
      "model": {
        value: this.value,
        callback: $$v => {
          this.value = $$v;
        }
      }
    })]);
  }
});

exports["default"] = DefaultTrigger;
//# sourceMappingURL=trigger.js.map
