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

import { defineComponent, ref, watch, createVNode, mergeProps } from 'vue';
import { Input } from '../input/index.js';
import './utils/index.js';
import { useBaseClassName } from './hooks.js';
import { Color } from '../_common/js/color-picker/color.js';
import '../utils/withInstall.js';
import '../input/input.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/defineProperty';
import '@ldesign/icons-vue-next';
import 'lodash/isUndefined';
import '../form/hooks.js';
import '../hooks/useConfig.js';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import 'lodash/isFunction';
import 'lodash/isString';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import 'lodash/isArray';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-512eb181.js';
import 'dayjs';
import '../_chunks/dep-ac28b67c.js';
import '../config-provider/type.js';
import '../hooks/useGlobalIcon.js';
import '../hooks/tnode.js';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../utils/render-tnode.js';
import 'lodash/isEmpty';
import 'lodash/isObject';
import '../input/props.js';
import '../input/useInput.js';
import '@babel/runtime/helpers/slicedToArray';
import '../form/const.js';
import '../hooks/index.js';
import '../hooks/icon.js';
import '../hooks/slot.js';
import '../hooks/useCommonClassName.js';
import '../hooks/useDefaultValue.js';
import '../hooks/useDestroyOnClose.js';
import '../hooks/useKeepAnimation.js';
import '../hooks/useRipple.js';
import '../utils/set-style.js';
import '../hooks/useVirtualScroll.js';
import '../hooks/useVModel.js';
import '../input/useLengthLimit.js';
import 'lodash/isNumber';
import '../_common/js/log/index.js';
import '../_common/js/log/log.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'lodash/isNull';
import '../input/useInputEventHandler.js';
import '../input/useInputWidth.js';
import '../input/input-group.js';
import '../input/input-group-props.js';
import '../input/style';
import '../input/type.js';
import '../_common/js/color-picker/index.js';
import '../_common/js/color-picker/cmyk.js';
import '../_common/js/color-picker/draggable.js';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '../_common/js/color-picker/gradient.js';
import 'tinycolor2';

var DefaultTrigger = 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 = useBaseClassName();
    var value = ref(props.color);
    watch(function () {
      return [props.color];
    }, function () {
      return value.value = props.color;
    });
    var handleChange = function handleChange(input) {
      if (input === props.color) return;
      if (input && !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 createVNode("div", {
          "class": ["".concat(baseClassName, "__trigger--default__color"), "".concat(baseClassName, "--bg-alpha")]
        }, [createVNode("span", {
          "class": ["color-inner"],
          "style": {
            background: _this.value
          }
        }, null)]);
      }
    };
    return createVNode(Input, 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);
  }
});

export { DefaultTrigger as default };
//# sourceMappingURL=trigger.js.map
