/**
 * ldesign v0.2.2
 * (c) 2022年9月20日 swimly
 * @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 { C as Color } from '../../_chunks/dep-64c83d1d.js';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import { useBaseClassName } from './hooks/index.js';
import '../input/input.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/typeof';
import '@ldesign/icons-vue';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../_chunks/dep-fc383775.js';
import '@babel/runtime/helpers/slicedToArray';
import '../../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../config-provider/config-receiver.js';
import 'vue';
import 'lodash/mergeWith';
import 'lodash';
import '../config-provider/context.js';
import '../../_chunks/dep-a0f2090c.js';
import '../../utils/mixins.js';
import '../../utils/event.js';
import '../input/props.js';
import '../../utils/render-node.js';
import '../input/group.js';
import '../../utils/map-props.js';
import '../../utils/with-install.js';
import '../../config.js';
import '../input-number/input-number.js';
import '../../_chunks/dep-b13ef886.js';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../../_chunks/dep-33b15d9d.js';
import '../../_chunks/dep-85e8b23b.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/plugin.js';
import '../button/props.js';
import '../../utils/ripple.js';
import '../input-number/props.js';
import '../input-number/hooks/use-input-number.js';
import '../../_chunks/dep-5c5da9dd.js';
import '../../_chunks/dep-53d4956d.js';
import '../../_chunks/dep-d204d516.js';
import '../../_chunks/dep-a65fe6e9.js';
import '../../hooks/use-common-classname.js';
import '../config-provider/useConfig.js';
import '../../hooks/use-vmodel.js';
import '../../hooks/use-form-disabled.js';
import '../../hooks/use-global-icon.js';
import '../../hooks/use-config.js';

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("l-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
