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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var input_index = require('../input/index.js');
var inputNumber_index = require('../input-number/index.js');
var colorPicker_hooks = require('./hooks.js');
var _common_js_colorPicker_color = require('../_common/js/color-picker/color.js');
require('../utils/map-props.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('vue');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('../input/input.js');
require('../_chunks/dep-c3e1ffac.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/typeof');
require('@babel/runtime/helpers/slicedToArray');
require('@ldesign/icons-vue');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../_common/js/utils/helper.js');
require('lodash/isString');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
require('lodash/isArray');
require('../utils/helper.js');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-7c884501.js');
require('dayjs');
require('../utils/mixins.js');
require('../utils/event.js');
require('../utils/render-tnode.js');
require('../_common/js/log/log.js');
require('../input/props.js');
require('../input/input-group.js');
require('../input-number/input-number.js');
require('../button/index.js');
require('../button/button.js');
require('../loading/index.js');
require('../loading/directive.js');
require('lodash/isObject');
require('lodash/mapKeys');
require('lodash/isEqual');
require('../loading/plugin.js');
require('../config.js');
require('../utils/dom.js');
require('raf');
require('../utils/easing.js');
require('../loading/loading.js');
require('../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/set-style.js');
require('../utils/ripple.js');
require('../button/props.js');
require('../hooks/useGlobalIcon.js');
require('../config-provider/useConfig.js');
require('../input-number/props.js');
require('../input-number/useInputNumber.js');
require('../hooks/useCommonClassName.js');
require('../hooks/useVModel.js');
require('../_common/js/input-number/number.js');
require('lodash/isNil');
require('../_common/js/input-number/large-number.js');
require('../hooks/useFormDisabled.js');
require('../hooks/useConfig.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('tinycolor2');
require('../_common/js/color-picker/cmyk.js');
require('../_common/js/color-picker/gradient.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

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__default["default"](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 = VueCompositionAPI.defineComponent({
  name: "DefaultTrigger",
  components: {
    TInput: input_index.Input,
    TInputNumber: inputNumber_index.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 () {};
      }
    },
    clearable: {
      type: Boolean,
      "default": false
    }
  },
  setup: function setup(props) {
    var baseClassName = colorPicker_hooks.useBaseClassName();
    var value = VueCompositionAPI.ref(props.color);
    VueCompositionAPI.watch(function () {
      return [props.color];
    }, function () {
      return value.value = props.color;
    });
    var handleChange = function handleChange(input) {
      if (input === props.color) return;
      if (!_common_js_colorPicker_color.Color.isValid(input) && 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", {
      "scopedSlots": inputSlots,
      "attrs": {
        "clearable": this.clearable,
        "disabled": this.disabled
      },
      "on": {
        "blur": this.handleChange
      },
      "props": _objectSpread({}, _objectSpread({}, this.inputProps)),
      "model": {
        value: _this.value,
        callback: function callback($$v) {
          _this.value = $$v;
        }
      }
    })]);
  }
});

exports["default"] = DefaultTrigger;
//# sourceMappingURL=trigger.js.map
