/**
 * ldesign v0.2.22
 * (c) 2022/12/7 16:21 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/withInstall.js';
import 'lodash/capitalize';
import '../../config.js';
import '../input/input.js';
import '@ldesign/icons-vue';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../chunks/helper2.js';
import '../../chunks/defineProperty-19da3d4c.js';
import '../../chunks/index.js';
import '../../chunks/log.js';
import '../../chunks/_commonjsHelpers-fe796db6.js';
import '../../utils/helper.js';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../../utils/mixins.js';
import '../../utils/event.js';
import '../../utils/render-node.js';
import 'lodash';
import '../input/props.js';
import '../input/group.js';
import '../input/style';
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';
import '../loading/type.js';
import '../loading/plugin.js';
import '../../utils/ripple.js';
import '../button/props.js';
import '../button/style';
import '../button/type.js';
import '../../hooks/useGlobalIcon.js';
import '../../hooks/useConfig.js';
import '../config-provider/useConfig.js';
import '../input-number/props.js';
import '../input-number/hooks/use-input-number.js';
import '../../chunks/isObjectLike-51896b77.js';
import '../../chunks/isArray-6b6e7094.js';
import '../../chunks/isNumber-13851330.js';
import '../../hooks/useCommonClassName.js';
import '../../hooks/useVModel.js';
import '../../hooks/useFormDisabled.js';
import '../input-number/style';
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: () => () => {}
    },
    clearable: {
      type: Boolean,
      default: false
    }
  },
  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) && 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("t-input", {
      "scopedSlots": inputSlots,
      "attrs": {
        "clearable": this.clearable,
        "disabled": this.disabled
      },
      "on": {
        "blur": this.handleChange
      },
      "props": {
        ...{
          ...this.inputProps
        }
      },
      "model": {
        value: this.value,
        callback: $$v => {
          this.value = $$v;
        }
      }
    })]);
  }
});

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