UNPKG

tdesign-vue

Version:
277 lines (273 loc) 10.2 kB
/** * tdesign v1.15.0 * (c) 2026 tdesign * @license MIT */ import { h as helper } from '../../../_chunks/dep-53490f85.js'; import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { defineComponent, reactive, watch } from '@vue/composition-api'; import { throttle } from 'lodash-es'; import props from '../../props.js'; import { Select, Option } from '../../../select/index.js'; import { Input } from '../../../input/index.js'; import { InputNumber } from '../../../input-number/index.js'; import { getColorFormatInputs, getColorFormatMap } from '../../../_common/js/color-picker/format.js'; import { Color } from '../../../_common/js/color-picker/color.js'; import '../../../select/select.js'; import '@babel/runtime/helpers/objectWithoutProperties'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/typeof'; import '@babel/runtime/helpers/slicedToArray'; import '../../../hooks/useDefaultValue.js'; import '../../../hooks/useVModel.js'; import '../../../hooks/tnode.js'; import '../../../hooks/render-tnode.js'; import '../../../config-provider/useConfig.js'; import '../../../config-provider/context.js'; import '../../../_common/js/global-config/default-config.js'; import '../../../_common/js/global-config/locale/zh_CN.js'; import '../../../_chunks/dep-e5d497fb.js'; import '../../../_chunks/dep-1618e1d6.js'; import 'dayjs'; import '../../../_common/js/global-config/t.js'; import '../../../select/props.js'; import '../../../loading/index.js'; import '../../../loading/directive.js'; import '../../../loading/plugin.js'; import 'vue'; import '../../../loading/loading.js'; import '../../../loading/icon/gradient.js'; import '../../../_common/js/loading/circle-adapter.js'; import '../../../_common/js/utils/setStyle.js'; import '../../../_common/js/utils/helper.js'; import '../../../config-provider/config-receiver.js'; import '../../../utils/mixins.js'; import '../../../utils/dom.js'; import 'raf'; import '../../../utils/easing.js'; import '../../../utils/render-tnode.js'; import '@babel/runtime/helpers/readOnlyError'; import '../../../utils/transfer-dom.js'; import '../../../loading/props.js'; import '../../../config.js'; import '../../../utils/withInstall.js'; import '../../../popup/index.js'; import '../../../popup/popup.js'; import '@popperjs/core'; import '../../../utils/helper.js'; import '../../../popup/props.js'; import '../../../popup/container.js'; import '../../../utils/event.js'; import '../../../popup/utils.js'; import '../../../utils/map-props.js'; import '../../../popup/plugin.js'; import '../../../_common/js/log/log.js'; import '../../../tag/index.js'; import '../../../tag/tag.js'; import 'tdesign-icons-vue'; import 'tinycolor2'; import '../../../tag/props.js'; import '../../../tag/check-tag.js'; import '../../../tag/check-tag-props.js'; import '../../../hooks/useConfig.js'; import '../../../_common/js/common.js'; import '../../../tag/check-tag-group.js'; import '../../../tag/check-tag-group-props.js'; import '../../../select-input/index.js'; import '../../../select-input/select-input.js'; import '../../../select-input/props.js'; import '../../../select-input/useSingle.js'; import '../../../input/input.js'; import '../../../input/props.js'; import '../../../input/input-group.js'; import '../../../select-input/useMultiple.js'; import '../../../tag-input/index.js'; import '../../../tag-input/tag-input.js'; import '../../../tag-input/props.js'; import '../../../tag-input/hooks/useTagScroll.js'; import '../../../tag-input/useTagList.js'; import '../../../tag-input/hooks/useHover.js'; import '../../../tag-input/hooks/useDragSorter.js'; import '../../../hooks/useGlobalIcon.js'; import '../../../select-input/useOverlayInnerStyle.js'; import '../../../common-components/fake-arrow.js'; import '../../../select/option.js'; import '../../../utils/ripple.js'; import '../../../select/option-props.js'; import '../../../checkbox/index.js'; import '../../../checkbox/group.js'; import '../../../checkbox/checkbox.js'; import '../../../checkbox/props.js'; import '../../../checkbox/constants.js'; import '../../../checkbox/store.js'; import '@babel/runtime/helpers/classCallCheck'; import '@babel/runtime/helpers/createClass'; import '../../../checkbox/hooks/useKeyboardEvent.js'; import '../../../hooks/useFormDisabled.js'; import '../../../hooks/useElementLazyRender.js'; import '../../../_common/js/utils/observe.js'; import '../../../checkbox/checkbox-group-props.js'; import '../../../hooks/slots.js'; import '../../../hooks/useLazyLoad.js'; import '../../../select/util.js'; import '../../../hooks/useCommonClassName.js'; import '../../../select/select-panel.js'; import '../../../select/optionGroup.js'; import '../../../select/option-group-props.js'; import '../../../hooks/useVirtualScroll.js'; import '../../../select/hooks/useSelectOptions.js'; import '../../../input-number/input-number.js'; import '../../../button/index.js'; import '../../../button/button.js'; import '../../../button/props.js'; import '../../../input-number/props.js'; import '../../../input-number/useInputNumber.js'; import '../../../_common/js/input-number/number.js'; import '../../../_common/js/input-number/large-number.js'; import '../../../_common/js/color-picker/constants.js'; import '../../../_common/js/color-picker/cmyk.js'; import '../../../_common/js/color-picker/gradient.js'; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var FormatInputs = defineComponent({ name: "FormatInputs", components: { TSelect: Select, TOption: Option, TInput: Input, TInputNumber: InputNumber }, inheritAttrs: false, props: _objectSpread(_objectSpread({}, props), {}, { color: { type: Object }, handleFormatInputChange: { type: Function, "default": function _default() { return function () {}; } } }), setup: function setup(props2) { var modelValues = reactive({ r: 0, g: 0, b: 0, a: 0, c: 0, m: 0, y: 0, k: 0, h: 0, l: 0, s: 0, v: 0, hex: "", css: "" }); var lastModelValue = reactive({}); var updateModelValue = function updateModelValue() { var format = props2.format, color = props2.color; var values = getColorFormatMap(color, "encode")[format]; values.a = Math.round(color.alpha * 100); Object.keys(values).forEach(function (key) { modelValues[key] = values[key]; lastModelValue[key] = values[key]; }); }; updateModelValue(); var throttleUpdate = throttle(updateModelValue, 100); watch(function () { var _props2$color = props2.color, saturation = _props2$color.saturation, hue = _props2$color.hue, value = _props2$color.value, alpha = _props2$color.alpha; return [saturation, hue, value, alpha, props2.format]; }, throttleUpdate); var handleChange = function handleChange(key, v) { if (v === lastModelValue[key]) return; if (key === "a") { props2.color.alpha = v / 100; } else if (key === "hex" || key === "css") { props2.color.update(v); } else { props2.color.update(Color.object2color(modelValues, props2.format)); } var value = getColorFormatMap(props2.color, "decode")[props2.format]; props2.handleFormatInputChange(value, props2.color.alpha, key, v); }; return { modelValues: modelValues, handleChange: handleChange }; }, render: function render() { var _this = this; var h = arguments[0]; var inputProps = _objectSpread({}, this.inputProps || {}); return h("div", { "class": "input-group" }, [getColorFormatInputs(this.format, this.enableAlpha).map(function (config) { return h("div", { "class": "input-group__item", "key": config.key, "style": { flex: config.flex || 1 } }, [config.type === "input" ? h("t-input", helper([{}, inputProps, { "attrs": { "align": "center", "size": "small", "disabled": _this.disabled, "maxlength": _this.format === "HEX" ? 9 : void 0, "title": _this.modelValues[config.key] }, "on": { "blur": function blur(v) { return _this.handleChange(config.key, v); }, "enter": function enter(v) { return _this.handleChange(config.key, v); } }, "model": { value: _this.modelValues[config.key], callback: function callback($$v) { _this.$set(_this.modelValues, config.key, $$v); } } }])) : h("t-input-number", helper([{}, inputProps, { "attrs": { "align": "center", "theme": "normal", "size": "small", "disabled": _this.disabled, "title": _this.modelValues[config.key], "min": config.min, "max": config.max, "step": 1, "format": config.format }, "on": { "blur": function blur(v) { return _this.handleChange(config.key, v); }, "enter": function enter(v) { return _this.handleChange(config.key, v); } }, "model": { value: _this.modelValues[config.key], callback: function callback($$v) { _this.$set(_this.modelValues, config.key, $$v); } } }]))]); })]); } }); export { FormatInputs as default }; //# sourceMappingURL=inputs.js.map