/**
 * tdesign v0.46.4
 * (c) 2022 tdesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, ref, watch } from '@vue/composition-api';
import { Input } from '../input/index.js';
import { InputNumber } from '../input-number/index.js';
import './utils/index.js';
import { useBaseClassName } from './hooks.js';
import { Color } from '../_common/js/color-picker/color.js';
import '../input/input.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/typeof';
import 'tdesign-icons-vue';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../utils/helper.js';
import '../config-provider/config-receiver.js';
import 'vue';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../config-provider/type.js';
import '../utils/mixins.js';
import '../utils/event.js';
import '../input/props.js';
import '../utils/render-tnode.js';
import '../input/input-group.js';
import '../utils/map-props.js';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/index.js';
import '../input/type.js';
import '../input-number/input-number.js';
import '../_chunks/dep-a4bd011a.js';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/set-style.js';
import '../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/type.js';
import '../loading/plugin.js';
import '../config.js';
import '../button/props.js';
import '../utils/ripple.js';
import '../button/type.js';
import '../input-number/props.js';
import '../input-number/useInputNumber.js';
import '../hooks/useCommonClassName.js';
import '../config-provider/useConfig.js';
import '../hooks/useVModel.js';
import '../_common/js/input-number/number.js';
import 'lodash/isNumber';
import '../_common/js/input-number/large-number.js';
import '../_common/js/log/log.js';
import '../_common/js/log/index.js';
import '../hooks/useFormDisabled.js';
import '../hooks/useGlobalIcon.js';
import '../hooks/useConfig.js';
import '../input-number/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';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var DefaultTrigger = defineComponent({
  name: "DefaultTrigger",
  components: {
    TInput: Input,
    TInputNumber: InputNumber
  },
  inheritAttrs: false,
  props: {
    color: {
      type: String,
      "default": ""
    },
    disabled: {
      type: Boolean,
      "default": false
    },
    inputProps: {
      type: Object,
      "default": function _default() {
        return {
          autoWidth: true
        };
      }
    },
    handleTriggerChange: {
      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 (!Color.isValid(input)) {
        value.value = props.color;
      } else {
        value.value = input;
      }

      props.handleTriggerChange(value.value);
    };

    return {
      baseClassName: baseClassName,
      value: value,
      handleChange: handleChange
    };
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    var baseClassName = this.baseClassName;
    var inputSlots = {
      label: function label() {
        return h("div", {
          "class": ["".concat(baseClassName, "__trigger--default__color"), "".concat(baseClassName, "--bg-alpha")]
        }, [h("span", {
          "class": ["color-inner"],
          "style": {
            background: _this.value
          }
        })]);
      }
    };
    return h("div", {
      "class": "".concat(baseClassName, "__trigger--default")
    }, [h("t-input", {
      "props": _objectSpread({}, _objectSpread({}, this.inputProps)),
      "scopedSlots": inputSlots,
      "attrs": {
        "disabled": this.disabled
      },
      "on": {
        "blur": this.handleChange
      },
      "model": {
        value: _this.value,
        callback: function callback($$v) {
          _this.value = $$v;
        }
      }
    })]);
  }
});

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