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

import { defineComponent, ref, watch } from '@vue/composition-api';
import { Input } from '../input/index.js';
import { InputNumber } from '../input-number/index.js';
import { Color } from './utils/index.js';
import { useBaseClassName } from './hooks/index.js';
import '../../utils/map-props.js';
import 'vue';
import '../../utils/with-install.js';
import 'lodash';
import '../../config.js';
import '../input/input.js';
import '@ldesign/icons-vue';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../chunks/helper2.js';
import '../../chunks/defineProperty-838e4192.js';
import '../../chunks/index.js';
import '../../chunks/log.js';
import '../../chunks/_commonjsHelpers-2e6815bd.js';
import '../../utils/helper.js';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../../utils/mixins.js';
import '../../utils/event.js';
import '../../utils/render-node.js';
import '../input/props.js';
import '../input/group.js';
import '../input/style/css.js';
import '../input/type.js';
import '../input-number/input-number.js';
import '../../chunks/helper.js';
import '../../chunks/_commonjsHelpers.js';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/loading.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/icon/gradient.js';
import '../../chunks/set-style.js';
import '../loading/style/css.js';
import '../loading/type.js';
import '../loading/plugin.js';
import '../../utils/ripple.js';
import '../button/props.js';
import '../button/style/css.js';
import '../button/type.js';
import '../../hooks/use-global-icon.js';
import '../../hooks/use-config.js';
import '../config-provider/useConfig.js';
import '../input-number/props.js';
import '../input-number/hooks/use-input-number.js';
import '../../chunks/isObjectLike-c22c7e3b.js';
import '../../chunks/isArray-cd7357b9.js';
import '../../chunks/isNumber-c4eb560e.js';
import '../../hooks/use-common-classname.js';
import '../../hooks/use-vmodel.js';
import '../../hooks/use-form-disabled.js';
import '../input-number/style/css.js';
import '../input-number/type.js';

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: () => ({
        autoWidth: true
      })
    },
    handleTriggerChange: {
      type: Function,
      default: () => () => {}
    }
  },
  setup(props) {
    const baseClassName = useBaseClassName();
    const value = ref(props.color);
    watch(() => [props.color], () => value.value = props.color);
    const 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,
      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;
        }
      }
    })]);
  }
});

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