/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

var vue = require('vue');
var input_index = require('../input/index.js');
var colorPicker_hooks = require('./hooks.js');
var _common_js_colorPicker_color = require('../_common/js/color-picker/color.js');
require('../utils/withInstall.js');
require('../input/input.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/defineProperty');
require('@ldesign/icons-vue-next');
require('lodash/isUndefined');
require('../form/hooks.js');
require('../hooks/useConfig.js');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('lodash/isFunction');
require('lodash/isString');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('lodash/isArray');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-7f0559c3.js');
require('dayjs');
require('../hooks/useGlobalIcon.js');
require('../hooks/tnode.js');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isObject');
require('../input/props.js');
require('../input/useInput.js');
require('@babel/runtime/helpers/slicedToArray');
require('../form/const.js');
require('../hooks/useVModel.js');
require('../input/useLengthLimit.js');
require('lodash/isNumber');
require('../_common/js/log/log.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/toConsumableArray');
require('lodash/isNull');
require('../input/useInputEventHandler.js');
require('../input/useInputWidth.js');
require('../input/input-group.js');
require('../input/input-group-props.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('tinycolor2');
require('../_common/js/color-picker/cmyk.js');
require('../_common/js/color-picker/gradient.js');

var DefaultTrigger = vue.defineComponent({
  name: "DefaultTrigger",
  inheritAttrs: false,
  props: {
    color: {
      type: String,
      "default": ""
    },
    disabled: {
      type: Boolean,
      "default": false
    },
    clearable: {
      type: Boolean,
      "default": false
    },
    inputProps: {
      type: Object,
      "default": function _default() {
        return {
          autoWidth: true
        };
      }
    },
    onTriggerChange: {
      type: Function,
      "default": function _default() {
        return function () {};
      }
    }
  },
  setup: function setup(props) {
    var baseClassName = colorPicker_hooks.useBaseClassName();
    var value = vue.ref(props.color);
    vue.watch(function () {
      return [props.color];
    }, function () {
      return value.value = props.color;
    });
    var handleChange = function handleChange(input) {
      if (input === props.color) return;
      if (input && !_common_js_colorPicker_color.Color.isValid(input)) value.value = props.color;else value.value = input;
      props.onTriggerChange(value.value);
    };
    return {
      baseClassName: baseClassName,
      value: value,
      handleChange: handleChange
    };
  },
  render: function render() {
    var _this = this;
    var baseClassName = this.baseClassName;
    var inputSlots = {
      label: function label() {
        return vue.createVNode("div", {
          "class": ["".concat(baseClassName, "__trigger--default__color"), "".concat(baseClassName, "--bg-alpha")]
        }, [vue.createVNode("span", {
          "class": ["color-inner"],
          "style": {
            background: _this.value
          }
        }, null)]);
      }
    };
    return vue.createVNode(input_index.Input, vue.mergeProps({
      "clearable": this.clearable
    }, this.inputProps, {
      "modelValue": _this.value,
      "onUpdate:modelValue": function onUpdateModelValue($event) {
        return _this.value = $event;
      },
      "disabled": this.disabled,
      "onBlur": this.handleChange
    }), inputSlots);
  }
});

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