ingenious-flow-designer
Version:
[演示地址](http://antd-vben5-pro.madong.tech/)
1,600 lines • 83.4 kB
JavaScript
import { z as filterEmpty, _ as _extends, P as PropTypes, s as stringType, c as classNames, b as _objectSpread2, A as eventType, g as genComponentStyleHook, y as resetComponent, m as merge, B as clearFix, u as useConfigInject, C as useInjectDisabled, t as tuple, i as anyType, n as warning, r as isValidElement } from "./index-33HV6VHr.js";
import { defineComponent, ref, createVNode, shallowRef, watch, computed, onMounted, Fragment, nextTick, onBeforeUpdate, onBeforeUnmount, watchEffect, getCurrentInstance } from "vue";
import { u as useInjectFormItemContext, b as FormItemInputContext, N as NoFormStatus } from "./FormItemContext-HkeO47QQ.js";
import { B as BaseInput$1, g as getMergedStatus, a as getStatusClassNames, S as SearchOutlined, R as ResizeObserver } from "./index-BfmxBNKP.js";
import { o as omit } from "./omit-CjG-67uI.js";
import { c as cloneElement } from "./vnode-CWR_0A0u.js";
import { C as CloseCircleFilled } from "./CloseCircleFilled-BNjiZWvd.js";
import { u as useCompactItemContext, N as NoCompactStyle } from "./Compact-JU9bybmf.js";
import { g as genCompactItemStyle } from "./compact-item-CaKUqZoL.js";
import { B as Button } from "./index-Dt1kRNAk.js";
import { g as isPlainObject } from "./index-D1VwbMai.js";
import { w as wrapperRaf } from "./raf-5zkQ7Vyi.js";
import { I as Icon } from "./AntdIcon-BAqDAULg.js";
const isValid$1 = (value) => {
return value !== void 0 && value !== null && (Array.isArray(value) ? filterEmpty(value).length : true);
};
function hasPrefixSuffix(propsAndSlots) {
return isValid$1(propsAndSlots.prefix) || isValid$1(propsAndSlots.suffix) || isValid$1(propsAndSlots.allowClear);
}
function hasAddon$1(propsAndSlots) {
return isValid$1(propsAndSlots.addonBefore) || isValid$1(propsAndSlots.addonAfter);
}
function fixControlledValue(value) {
if (typeof value === "undefined" || value === null) {
return "";
}
return String(value);
}
function resolveOnChange(target, e, onChange, targetValue) {
if (!onChange) {
return;
}
const event = e;
if (e.type === "click") {
Object.defineProperty(event, "target", {
writable: true
});
Object.defineProperty(event, "currentTarget", {
writable: true
});
const currentTarget = target.cloneNode(true);
event.target = currentTarget;
event.currentTarget = currentTarget;
currentTarget.value = "";
onChange(event);
return;
}
if (targetValue !== void 0) {
Object.defineProperty(event, "target", {
writable: true
});
Object.defineProperty(event, "currentTarget", {
writable: true
});
event.target = target;
event.currentTarget = target;
target.value = targetValue;
onChange(event);
return;
}
onChange(event);
}
function triggerFocus(element, option) {
if (!element) return;
element.focus(option);
const {
cursor
} = option || {};
if (cursor) {
const len = element.value.length;
switch (cursor) {
case "start":
element.setSelectionRange(0, 0);
break;
case "end":
element.setSelectionRange(len, len);
break;
default:
element.setSelectionRange(0, len);
}
}
}
const commonInputProps = () => {
return {
addonBefore: PropTypes.any,
addonAfter: PropTypes.any,
prefix: PropTypes.any,
suffix: PropTypes.any,
clearIcon: PropTypes.any,
affixWrapperClassName: String,
groupClassName: String,
wrapperClassName: String,
inputClassName: String,
allowClear: {
type: Boolean,
default: void 0
}
};
};
const baseInputProps = () => {
return _extends(_extends({}, commonInputProps()), {
value: {
type: [String, Number, Symbol],
default: void 0
},
defaultValue: {
type: [String, Number, Symbol],
default: void 0
},
inputElement: PropTypes.any,
prefixCls: String,
disabled: {
type: Boolean,
default: void 0
},
focused: {
type: Boolean,
default: void 0
},
triggerFocus: Function,
readonly: {
type: Boolean,
default: void 0
},
handleReset: Function,
hidden: {
type: Boolean,
default: void 0
}
});
};
const inputProps$1 = () => _extends(_extends({}, baseInputProps()), {
id: String,
placeholder: {
type: [String, Number]
},
autocomplete: String,
type: stringType("text"),
name: String,
size: {
type: String
},
autofocus: {
type: Boolean,
default: void 0
},
lazy: {
type: Boolean,
default: true
},
maxlength: Number,
loading: {
type: Boolean,
default: void 0
},
bordered: {
type: Boolean,
default: void 0
},
showCount: {
type: [Boolean, Object]
},
htmlSize: Number,
onPressEnter: Function,
onKeydown: Function,
onKeyup: Function,
onFocus: Function,
onBlur: Function,
onChange: Function,
onInput: Function,
"onUpdate:value": Function,
onCompositionstart: Function,
onCompositionend: Function,
valueModifiers: Object,
hidden: {
type: Boolean,
default: void 0
},
status: String
});
const BaseInput = defineComponent({
name: "BaseInput",
inheritAttrs: false,
props: baseInputProps(),
setup(props, _ref) {
let {
slots,
attrs
} = _ref;
const containerRef = ref();
const onInputMouseDown = (e) => {
var _a;
if ((_a = containerRef.value) === null || _a === void 0 ? void 0 : _a.contains(e.target)) {
const {
triggerFocus: triggerFocus2
} = props;
triggerFocus2 === null || triggerFocus2 === void 0 ? void 0 : triggerFocus2();
}
};
const getClearIcon = () => {
var _a;
const {
allowClear,
value,
disabled,
readonly,
handleReset,
suffix = slots.suffix,
prefixCls
} = props;
if (!allowClear) {
return null;
}
const needClear = !disabled && !readonly && value;
const className = `${prefixCls}-clear-icon`;
const iconNode = ((_a = slots.clearIcon) === null || _a === void 0 ? void 0 : _a.call(slots)) || "*";
return createVNode("span", {
"onClick": handleReset,
"onMousedown": (e) => e.preventDefault(),
"class": classNames({
[`${className}-hidden`]: !needClear,
[`${className}-has-suffix`]: !!suffix
}, className),
"role": "button",
"tabindex": -1
}, [iconNode]);
};
return () => {
var _a, _b;
const {
focused,
value,
disabled,
allowClear,
readonly,
hidden,
prefixCls,
prefix = (_a = slots.prefix) === null || _a === void 0 ? void 0 : _a.call(slots),
suffix = (_b = slots.suffix) === null || _b === void 0 ? void 0 : _b.call(slots),
addonAfter = slots.addonAfter,
addonBefore = slots.addonBefore,
inputElement,
affixWrapperClassName,
wrapperClassName,
groupClassName
} = props;
let element = cloneElement(inputElement, {
value,
hidden
});
if (hasPrefixSuffix({
prefix,
suffix,
allowClear
})) {
const affixWrapperPrefixCls = `${prefixCls}-affix-wrapper`;
const affixWrapperCls = classNames(affixWrapperPrefixCls, {
[`${affixWrapperPrefixCls}-disabled`]: disabled,
[`${affixWrapperPrefixCls}-focused`]: focused,
[`${affixWrapperPrefixCls}-readonly`]: readonly,
[`${affixWrapperPrefixCls}-input-with-clear-btn`]: suffix && allowClear && value
}, !hasAddon$1({
addonAfter,
addonBefore
}) && attrs.class, affixWrapperClassName);
const suffixNode = (suffix || allowClear) && createVNode("span", {
"class": `${prefixCls}-suffix`
}, [getClearIcon(), suffix]);
element = createVNode("span", {
"class": affixWrapperCls,
"style": attrs.style,
"hidden": !hasAddon$1({
addonAfter,
addonBefore
}) && hidden,
"onMousedown": onInputMouseDown,
"ref": containerRef
}, [prefix && createVNode("span", {
"class": `${prefixCls}-prefix`
}, [prefix]), cloneElement(inputElement, {
style: null,
value,
hidden: null
}), suffixNode]);
}
if (hasAddon$1({
addonAfter,
addonBefore
})) {
const wrapperCls = `${prefixCls}-group`;
const addonCls = `${wrapperCls}-addon`;
const mergedWrapperClassName = classNames(`${prefixCls}-wrapper`, wrapperCls, wrapperClassName);
const mergedGroupClassName = classNames(`${prefixCls}-group-wrapper`, attrs.class, groupClassName);
return createVNode("span", {
"class": mergedGroupClassName,
"style": attrs.style,
"hidden": hidden
}, [createVNode("span", {
"class": mergedWrapperClassName
}, [addonBefore && createVNode("span", {
"class": addonCls
}, [addonBefore]), cloneElement(element, {
style: null,
hidden: null
}), addonAfter && createVNode("span", {
"class": addonCls
}, [addonAfter])])]);
}
return element;
};
}
});
var __rest$3 = function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
const VcInput = defineComponent({
name: "VCInput",
inheritAttrs: false,
props: inputProps$1(),
setup(props, _ref) {
let {
slots,
attrs,
expose,
emit
} = _ref;
const stateValue = shallowRef(props.value === void 0 ? props.defaultValue : props.value);
const focused = shallowRef(false);
const inputRef = shallowRef();
const rootRef = shallowRef();
watch(() => props.value, () => {
stateValue.value = props.value;
});
watch(() => props.disabled, () => {
if (props.disabled) {
focused.value = false;
}
});
const focus = (option) => {
if (inputRef.value) {
triggerFocus(inputRef.value.input, option);
}
};
const blur = () => {
var _a;
(_a = inputRef.value.input) === null || _a === void 0 ? void 0 : _a.blur();
};
const setSelectionRange = (start, end, direction) => {
var _a;
(_a = inputRef.value.input) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end, direction);
};
const select = () => {
var _a;
(_a = inputRef.value.input) === null || _a === void 0 ? void 0 : _a.select();
};
expose({
focus,
blur,
input: computed(() => {
var _a;
return (_a = inputRef.value.input) === null || _a === void 0 ? void 0 : _a.input;
}),
stateValue,
setSelectionRange,
select
});
const triggerChange = (e) => {
emit("change", e);
};
const setValue = (value, callback) => {
if (stateValue.value === value) {
return;
}
if (props.value === void 0) {
stateValue.value = value;
} else {
nextTick(() => {
var _a;
if (inputRef.value.input.value !== stateValue.value) {
(_a = rootRef.value) === null || _a === void 0 ? void 0 : _a.$forceUpdate();
}
});
}
nextTick(() => {
callback && callback();
});
};
const handleChange = (e) => {
const {
value
} = e.target;
if (stateValue.value === value) return;
const newVal = e.target.value;
resolveOnChange(inputRef.value.input, e, triggerChange);
setValue(newVal);
};
const handleKeyDown = (e) => {
if (e.keyCode === 13) {
emit("pressEnter", e);
}
emit("keydown", e);
};
const handleFocus = (e) => {
focused.value = true;
emit("focus", e);
};
const handleBlur = (e) => {
focused.value = false;
emit("blur", e);
};
const handleReset = (e) => {
resolveOnChange(inputRef.value.input, e, triggerChange);
setValue("", () => {
focus();
});
};
const getInputElement = () => {
var _a, _b;
const {
addonBefore = slots.addonBefore,
addonAfter = slots.addonAfter,
disabled,
valueModifiers = {},
htmlSize,
autocomplete,
prefixCls,
inputClassName,
prefix = (_a = slots.prefix) === null || _a === void 0 ? void 0 : _a.call(slots),
suffix = (_b = slots.suffix) === null || _b === void 0 ? void 0 : _b.call(slots),
allowClear,
type = "text"
} = props;
const otherProps = omit(props, [
"prefixCls",
"onPressEnter",
"addonBefore",
"addonAfter",
"prefix",
"suffix",
"allowClear",
// Input elements must be either controlled or uncontrolled,
// specify either the value prop, or the defaultValue prop, but not both.
"defaultValue",
"size",
"bordered",
"htmlSize",
"lazy",
"showCount",
"valueModifiers",
"showCount",
"affixWrapperClassName",
"groupClassName",
"inputClassName",
"wrapperClassName"
]);
const inputProps2 = _extends(_extends(_extends({}, otherProps), attrs), {
autocomplete,
onChange: handleChange,
onInput: handleChange,
onFocus: handleFocus,
onBlur: handleBlur,
onKeydown: handleKeyDown,
class: classNames(prefixCls, {
[`${prefixCls}-disabled`]: disabled
}, inputClassName, !hasAddon$1({
addonAfter,
addonBefore
}) && !hasPrefixSuffix({
prefix,
suffix,
allowClear
}) && attrs.class),
ref: inputRef,
key: "ant-input",
size: htmlSize,
type,
lazy: props.lazy
});
if (valueModifiers.lazy) {
delete inputProps2.onInput;
}
if (!inputProps2.autofocus) {
delete inputProps2.autofocus;
}
const inputNode = createVNode(BaseInput$1, omit(inputProps2, ["size"]), null);
return inputNode;
};
const getSuffix = () => {
var _a;
const {
maxlength,
suffix = (_a = slots.suffix) === null || _a === void 0 ? void 0 : _a.call(slots),
showCount,
prefixCls
} = props;
const hasMaxLength = Number(maxlength) > 0;
if (suffix || showCount) {
const valueLength = [...fixControlledValue(stateValue.value)].length;
const dataCount = typeof showCount === "object" ? showCount.formatter({
count: valueLength,
maxlength
}) : `${valueLength}${hasMaxLength ? ` / ${maxlength}` : ""}`;
return createVNode(Fragment, null, [!!showCount && createVNode("span", {
"class": classNames(`${prefixCls}-show-count-suffix`, {
[`${prefixCls}-show-count-has-suffix`]: !!suffix
})
}, [dataCount]), suffix]);
}
return null;
};
onMounted(() => {
if (process.env.NODE_ENV === "test") {
if (props.autofocus) {
focus();
}
}
});
return () => {
const {
prefixCls,
disabled
} = props, rest = __rest$3(props, ["prefixCls", "disabled"]);
return createVNode(BaseInput, _objectSpread2(_objectSpread2(_objectSpread2({}, rest), attrs), {}, {
"ref": rootRef,
"prefixCls": prefixCls,
"inputElement": getInputElement(),
"handleReset": handleReset,
"value": fixControlledValue(stateValue.value),
"focused": focused.value,
"triggerFocus": focus,
"suffix": getSuffix(),
"disabled": disabled
}), slots);
};
}
});
const inputProps = () => {
return omit(inputProps$1(), ["wrapperClassName", "groupClassName", "inputClassName", "affixWrapperClassName"]);
};
const textAreaProps = () => _extends(_extends({}, omit(inputProps(), ["prefix", "addonBefore", "addonAfter", "suffix"])), {
rows: Number,
autosize: {
type: [Boolean, Object],
default: void 0
},
autoSize: {
type: [Boolean, Object],
default: void 0
},
onResize: {
type: Function
},
onCompositionstart: eventType(),
onCompositionend: eventType(),
valueModifiers: Object
});
const genPlaceholderStyle = (color) => ({
// Firefox
"&::-moz-placeholder": {
opacity: 1
},
"&::placeholder": {
color,
userSelect: "none"
// https://github.com/ant-design/ant-design/pull/32639
},
"&:placeholder-shown": {
textOverflow: "ellipsis"
}
});
const genHoverStyle = (token) => ({
borderColor: token.inputBorderHoverColor,
borderInlineEndWidth: token.lineWidth
});
const genActiveStyle = (token) => ({
borderColor: token.inputBorderHoverColor,
boxShadow: `0 0 0 ${token.controlOutlineWidth}px ${token.controlOutline}`,
borderInlineEndWidth: token.lineWidth,
outline: 0
});
const genDisabledStyle = (token) => ({
color: token.colorTextDisabled,
backgroundColor: token.colorBgContainerDisabled,
borderColor: token.colorBorder,
boxShadow: "none",
cursor: "not-allowed",
opacity: 1,
"&:hover": _extends({}, genHoverStyle(merge(token, {
inputBorderHoverColor: token.colorBorder
})))
});
const genInputLargeStyle = (token) => {
const {
inputPaddingVerticalLG,
fontSizeLG,
lineHeightLG,
borderRadiusLG,
inputPaddingHorizontalLG
} = token;
return {
padding: `${inputPaddingVerticalLG}px ${inputPaddingHorizontalLG}px`,
fontSize: fontSizeLG,
lineHeight: lineHeightLG,
borderRadius: borderRadiusLG
};
};
const genInputSmallStyle = (token) => ({
padding: `${token.inputPaddingVerticalSM}px ${token.controlPaddingHorizontalSM - 1}px`,
borderRadius: token.borderRadiusSM
});
const genStatusStyle = (token, parentCls) => {
const {
componentCls,
colorError,
colorWarning,
colorErrorOutline,
colorWarningOutline,
colorErrorBorderHover,
colorWarningBorderHover
} = token;
return {
[`&-status-error:not(${parentCls}-disabled):not(${parentCls}-borderless)${parentCls}`]: {
borderColor: colorError,
"&:hover": {
borderColor: colorErrorBorderHover
},
"&:focus, &-focused": _extends({}, genActiveStyle(merge(token, {
inputBorderActiveColor: colorError,
inputBorderHoverColor: colorError,
controlOutline: colorErrorOutline
}))),
[`${componentCls}-prefix`]: {
color: colorError
}
},
[`&-status-warning:not(${parentCls}-disabled):not(${parentCls}-borderless)${parentCls}`]: {
borderColor: colorWarning,
"&:hover": {
borderColor: colorWarningBorderHover
},
"&:focus, &-focused": _extends({}, genActiveStyle(merge(token, {
inputBorderActiveColor: colorWarning,
inputBorderHoverColor: colorWarning,
controlOutline: colorWarningOutline
}))),
[`${componentCls}-prefix`]: {
color: colorWarning
}
}
};
};
const genBasicInputStyle = (token) => _extends(_extends({
position: "relative",
display: "inline-block",
width: "100%",
minWidth: 0,
padding: `${token.inputPaddingVertical}px ${token.inputPaddingHorizontal}px`,
color: token.colorText,
fontSize: token.fontSize,
lineHeight: token.lineHeight,
backgroundColor: token.colorBgContainer,
backgroundImage: "none",
borderWidth: token.lineWidth,
borderStyle: token.lineType,
borderColor: token.colorBorder,
borderRadius: token.borderRadius,
transition: `all ${token.motionDurationMid}`
}, genPlaceholderStyle(token.colorTextPlaceholder)), {
"&:hover": _extends({}, genHoverStyle(token)),
"&:focus, &-focused": _extends({}, genActiveStyle(token)),
"&-disabled, &[disabled]": _extends({}, genDisabledStyle(token)),
"&-borderless": {
"&, &:hover, &:focus, &-focused, &-disabled, &[disabled]": {
backgroundColor: "transparent",
border: "none",
boxShadow: "none"
}
},
// Reset height for `textarea`s
"textarea&": {
maxWidth: "100%",
height: "auto",
minHeight: token.controlHeight,
lineHeight: token.lineHeight,
verticalAlign: "bottom",
transition: `all ${token.motionDurationSlow}, height 0s`,
resize: "vertical"
},
// Size
"&-lg": _extends({}, genInputLargeStyle(token)),
"&-sm": _extends({}, genInputSmallStyle(token)),
// RTL
"&-rtl": {
direction: "rtl"
},
"&-textarea-rtl": {
direction: "rtl"
}
});
const genInputGroupStyle = (token) => {
const {
componentCls,
antCls
} = token;
return {
position: "relative",
display: "table",
width: "100%",
borderCollapse: "separate",
borderSpacing: 0,
// Undo padding and float of grid classes
[`&[class*='col-']`]: {
paddingInlineEnd: token.paddingXS,
"&:last-child": {
paddingInlineEnd: 0
}
},
// Sizing options
[`&-lg ${componentCls}, &-lg > ${componentCls}-group-addon`]: _extends({}, genInputLargeStyle(token)),
[`&-sm ${componentCls}, &-sm > ${componentCls}-group-addon`]: _extends({}, genInputSmallStyle(token)),
[`> ${componentCls}`]: {
display: "table-cell",
"&:not(:first-child):not(:last-child)": {
borderRadius: 0
}
},
[`${componentCls}-group`]: {
[`&-addon, &-wrap`]: {
display: "table-cell",
width: 1,
whiteSpace: "nowrap",
verticalAlign: "middle",
"&:not(:first-child):not(:last-child)": {
borderRadius: 0
}
},
"&-wrap > *": {
display: "block !important"
},
"&-addon": {
position: "relative",
padding: `0 ${token.inputPaddingHorizontal}px`,
color: token.colorText,
fontWeight: "normal",
fontSize: token.fontSize,
textAlign: "center",
backgroundColor: token.colorFillAlter,
border: `${token.lineWidth}px ${token.lineType} ${token.colorBorder}`,
borderRadius: token.borderRadius,
transition: `all ${token.motionDurationSlow}`,
lineHeight: 1,
// Reset Select's style in addon
[`${antCls}-select`]: {
margin: `-${token.inputPaddingVertical + 1}px -${token.inputPaddingHorizontal}px`,
[`&${antCls}-select-single:not(${antCls}-select-customize-input)`]: {
[`${antCls}-select-selector`]: {
backgroundColor: "inherit",
border: `${token.lineWidth}px ${token.lineType} transparent`,
boxShadow: "none"
}
},
"&-open, &-focused": {
[`${antCls}-select-selector`]: {
color: token.colorPrimary
}
}
},
// https://github.com/ant-design/ant-design/issues/31333
[`${antCls}-cascader-picker`]: {
margin: `-9px -${token.inputPaddingHorizontal}px`,
backgroundColor: "transparent",
[`${antCls}-cascader-input`]: {
textAlign: "start",
border: 0,
boxShadow: "none"
}
}
},
"&-addon:first-child": {
borderInlineEnd: 0
},
"&-addon:last-child": {
borderInlineStart: 0
}
},
[`${componentCls}`]: {
float: "inline-start",
width: "100%",
marginBottom: 0,
textAlign: "inherit",
"&:focus": {
zIndex: 1,
borderInlineEndWidth: 1
},
"&:hover": {
zIndex: 1,
borderInlineEndWidth: 1,
[`${componentCls}-search-with-button &`]: {
zIndex: 0
}
}
},
// Reset rounded corners
[`> ${componentCls}:first-child, ${componentCls}-group-addon:first-child`]: {
borderStartEndRadius: 0,
borderEndEndRadius: 0,
// Reset Select's style in addon
[`${antCls}-select ${antCls}-select-selector`]: {
borderStartEndRadius: 0,
borderEndEndRadius: 0
}
},
[`> ${componentCls}-affix-wrapper`]: {
[`&:not(:first-child) ${componentCls}`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0
},
[`&:not(:last-child) ${componentCls}`]: {
borderStartEndRadius: 0,
borderEndEndRadius: 0
}
},
[`> ${componentCls}:last-child, ${componentCls}-group-addon:last-child`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0,
// Reset Select's style in addon
[`${antCls}-select ${antCls}-select-selector`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0
}
},
[`${componentCls}-affix-wrapper`]: {
"&:not(:last-child)": {
borderStartEndRadius: 0,
borderEndEndRadius: 0,
[`${componentCls}-search &`]: {
borderStartStartRadius: token.borderRadius,
borderEndStartRadius: token.borderRadius
}
},
[`&:not(:first-child), ${componentCls}-search &:not(:first-child)`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0
}
},
[`&${componentCls}-group-compact`]: _extends(_extends({
display: "block"
}, clearFix()), {
[`${componentCls}-group-addon, ${componentCls}-group-wrap, > ${componentCls}`]: {
"&:not(:first-child):not(:last-child)": {
borderInlineEndWidth: token.lineWidth,
"&:hover": {
zIndex: 1
},
"&:focus": {
zIndex: 1
}
}
},
"& > *": {
display: "inline-block",
float: "none",
verticalAlign: "top",
borderRadius: 0
},
[`& > ${componentCls}-affix-wrapper`]: {
display: "inline-flex"
},
[`& > ${antCls}-picker-range`]: {
display: "inline-flex"
},
"& > *:not(:last-child)": {
marginInlineEnd: -token.lineWidth,
borderInlineEndWidth: token.lineWidth
},
// Undo float for .ant-input-group .ant-input
[`${componentCls}`]: {
float: "none"
},
// reset border for Select, DatePicker, AutoComplete, Cascader, Mention, TimePicker, Input
[`& > ${antCls}-select > ${antCls}-select-selector,
& > ${antCls}-select-auto-complete ${componentCls},
& > ${antCls}-cascader-picker ${componentCls},
& > ${componentCls}-group-wrapper ${componentCls}`]: {
borderInlineEndWidth: token.lineWidth,
borderRadius: 0,
"&:hover": {
zIndex: 1
},
"&:focus": {
zIndex: 1
}
},
[`& > ${antCls}-select-focused`]: {
zIndex: 1
},
// update z-index for arrow icon
[`& > ${antCls}-select > ${antCls}-select-arrow`]: {
zIndex: 1
// https://github.com/ant-design/ant-design/issues/20371
},
[`& > *:first-child,
& > ${antCls}-select:first-child > ${antCls}-select-selector,
& > ${antCls}-select-auto-complete:first-child ${componentCls},
& > ${antCls}-cascader-picker:first-child ${componentCls}`]: {
borderStartStartRadius: token.borderRadius,
borderEndStartRadius: token.borderRadius
},
[`& > *:last-child,
& > ${antCls}-select:last-child > ${antCls}-select-selector,
& > ${antCls}-cascader-picker:last-child ${componentCls},
& > ${antCls}-cascader-picker-focused:last-child ${componentCls}`]: {
borderInlineEndWidth: token.lineWidth,
borderStartEndRadius: token.borderRadius,
borderEndEndRadius: token.borderRadius
},
// https://github.com/ant-design/ant-design/issues/12493
[`& > ${antCls}-select-auto-complete ${componentCls}`]: {
verticalAlign: "top"
},
[`${componentCls}-group-wrapper + ${componentCls}-group-wrapper`]: {
marginInlineStart: -token.lineWidth,
[`${componentCls}-affix-wrapper`]: {
borderRadius: 0
}
},
[`${componentCls}-group-wrapper:not(:last-child)`]: {
[`&${componentCls}-search > ${componentCls}-group`]: {
[`& > ${componentCls}-group-addon > ${componentCls}-search-button`]: {
borderRadius: 0
},
[`& > ${componentCls}`]: {
borderStartStartRadius: token.borderRadius,
borderStartEndRadius: 0,
borderEndEndRadius: 0,
borderEndStartRadius: token.borderRadius
}
}
}
}),
[`&&-sm ${antCls}-btn`]: {
fontSize: token.fontSizeSM,
height: token.controlHeightSM,
lineHeight: "normal"
},
[`&&-lg ${antCls}-btn`]: {
fontSize: token.fontSizeLG,
height: token.controlHeightLG,
lineHeight: "normal"
},
// Fix https://github.com/ant-design/ant-design/issues/5754
[`&&-lg ${antCls}-select-single ${antCls}-select-selector`]: {
height: `${token.controlHeightLG}px`,
[`${antCls}-select-selection-item, ${antCls}-select-selection-placeholder`]: {
// -2 is for the border size & override default
lineHeight: `${token.controlHeightLG - 2}px`
},
[`${antCls}-select-selection-search-input`]: {
height: `${token.controlHeightLG}px`
}
},
[`&&-sm ${antCls}-select-single ${antCls}-select-selector`]: {
height: `${token.controlHeightSM}px`,
[`${antCls}-select-selection-item, ${antCls}-select-selection-placeholder`]: {
// -2 is for the border size & override default
lineHeight: `${token.controlHeightSM - 2}px`
},
[`${antCls}-select-selection-search-input`]: {
height: `${token.controlHeightSM}px`
}
}
};
};
const genInputStyle = (token) => {
const {
componentCls,
controlHeightSM,
lineWidth
} = token;
const FIXED_CHROME_COLOR_HEIGHT = 16;
const colorSmallPadding = (controlHeightSM - lineWidth * 2 - FIXED_CHROME_COLOR_HEIGHT) / 2;
return {
[componentCls]: _extends(_extends(_extends(_extends({}, resetComponent(token)), genBasicInputStyle(token)), genStatusStyle(token, componentCls)), {
'&[type="color"]': {
height: token.controlHeight,
[`&${componentCls}-lg`]: {
height: token.controlHeightLG
},
[`&${componentCls}-sm`]: {
height: controlHeightSM,
paddingTop: colorSmallPadding,
paddingBottom: colorSmallPadding
}
}
})
};
};
const genAllowClearStyle = (token) => {
const {
componentCls
} = token;
return {
// ========================= Input =========================
[`${componentCls}-clear-icon`]: {
margin: 0,
color: token.colorTextQuaternary,
fontSize: token.fontSizeIcon,
verticalAlign: -1,
// https://github.com/ant-design/ant-design/pull/18151
// https://codesandbox.io/s/wizardly-sun-u10br
cursor: "pointer",
transition: `color ${token.motionDurationSlow}`,
"&:hover": {
color: token.colorTextTertiary
},
"&:active": {
color: token.colorText
},
"&-hidden": {
visibility: "hidden"
},
"&-has-suffix": {
margin: `0 ${token.inputAffixPadding}px`
}
},
// ======================= TextArea ========================
"&-textarea-with-clear-btn": {
padding: "0 !important",
border: "0 !important",
[`${componentCls}-clear-icon`]: {
position: "absolute",
insetBlockStart: token.paddingXS,
insetInlineEnd: token.paddingXS,
zIndex: 1
}
}
};
};
const genAffixStyle = (token) => {
const {
componentCls,
inputAffixPadding,
colorTextDescription,
motionDurationSlow,
colorIcon,
colorIconHover,
iconCls
} = token;
return {
[`${componentCls}-affix-wrapper`]: _extends(_extends(_extends(_extends(_extends({}, genBasicInputStyle(token)), {
display: "inline-flex",
[`&:not(${componentCls}-affix-wrapper-disabled):hover`]: _extends(_extends({}, genHoverStyle(token)), {
zIndex: 1,
[`${componentCls}-search-with-button &`]: {
zIndex: 0
}
}),
"&-focused, &:focus": {
zIndex: 1
},
"&-disabled": {
[`${componentCls}[disabled]`]: {
background: "transparent"
}
},
[`> input${componentCls}`]: {
padding: 0,
fontSize: "inherit",
border: "none",
borderRadius: 0,
outline: "none",
"&:focus": {
boxShadow: "none !important"
}
},
"&::before": {
width: 0,
visibility: "hidden",
content: '"\\a0"'
},
[`${componentCls}`]: {
"&-prefix, &-suffix": {
display: "flex",
flex: "none",
alignItems: "center",
"> *:not(:last-child)": {
marginInlineEnd: token.paddingXS
}
},
"&-show-count-suffix": {
color: colorTextDescription
},
"&-show-count-has-suffix": {
marginInlineEnd: token.paddingXXS
},
"&-prefix": {
marginInlineEnd: inputAffixPadding
},
"&-suffix": {
marginInlineStart: inputAffixPadding
}
}
}), genAllowClearStyle(token)), {
// password
[`${iconCls}${componentCls}-password-icon`]: {
color: colorIcon,
cursor: "pointer",
transition: `all ${motionDurationSlow}`,
"&:hover": {
color: colorIconHover
}
}
}), genStatusStyle(token, `${componentCls}-affix-wrapper`))
};
};
const genGroupStyle = (token) => {
const {
componentCls,
colorError,
colorSuccess,
borderRadiusLG,
borderRadiusSM
} = token;
return {
[`${componentCls}-group`]: _extends(_extends(_extends({}, resetComponent(token)), genInputGroupStyle(token)), {
"&-rtl": {
direction: "rtl"
},
"&-wrapper": {
display: "inline-block",
width: "100%",
textAlign: "start",
verticalAlign: "top",
"&-rtl": {
direction: "rtl"
},
// Size
"&-lg": {
[`${componentCls}-group-addon`]: {
borderRadius: borderRadiusLG
}
},
"&-sm": {
[`${componentCls}-group-addon`]: {
borderRadius: borderRadiusSM
}
},
// Status
"&-status-error": {
[`${componentCls}-group-addon`]: {
color: colorError,
borderColor: colorError
}
},
"&-status-warning": {
[`${componentCls}-group-addon:last-child`]: {
color: colorSuccess,
borderColor: colorSuccess
}
}
}
})
};
};
const genSearchInputStyle = (token) => {
const {
componentCls,
antCls
} = token;
const searchPrefixCls = `${componentCls}-search`;
return {
[searchPrefixCls]: {
[`${componentCls}`]: {
"&:hover, &:focus": {
borderColor: token.colorPrimaryHover,
[`+ ${componentCls}-group-addon ${searchPrefixCls}-button:not(${antCls}-btn-primary)`]: {
borderInlineStartColor: token.colorPrimaryHover
}
}
},
[`${componentCls}-affix-wrapper`]: {
borderRadius: 0
},
// fix slight height diff in Firefox:
// https://ant.design/components/auto-complete-cn/#components-auto-complete-demo-certain-category
[`${componentCls}-lg`]: {
lineHeight: token.lineHeightLG - 2e-4
},
[`> ${componentCls}-group`]: {
[`> ${componentCls}-group-addon:last-child`]: {
insetInlineStart: -1,
padding: 0,
border: 0,
[`${searchPrefixCls}-button`]: {
paddingTop: 0,
paddingBottom: 0,
borderStartStartRadius: 0,
borderStartEndRadius: token.borderRadius,
borderEndEndRadius: token.borderRadius,
borderEndStartRadius: 0
},
[`${searchPrefixCls}-button:not(${antCls}-btn-primary)`]: {
color: token.colorTextDescription,
"&:hover": {
color: token.colorPrimaryHover
},
"&:active": {
color: token.colorPrimaryActive
},
[`&${antCls}-btn-loading::before`]: {
insetInlineStart: 0,
insetInlineEnd: 0,
insetBlockStart: 0,
insetBlockEnd: 0
}
}
}
},
[`${searchPrefixCls}-button`]: {
height: token.controlHeight,
"&:hover, &:focus": {
zIndex: 1
}
},
[`&-large ${searchPrefixCls}-button`]: {
height: token.controlHeightLG
},
[`&-small ${searchPrefixCls}-button`]: {
height: token.controlHeightSM
},
"&-rtl": {
direction: "rtl"
},
// ===================== Compact Item Customized Styles =====================
[`&${componentCls}-compact-item`]: {
[`&:not(${componentCls}-compact-last-item)`]: {
[`${componentCls}-group-addon`]: {
[`${componentCls}-search-button`]: {
marginInlineEnd: -token.lineWidth,
borderRadius: 0
}
}
},
[`&:not(${componentCls}-compact-first-item)`]: {
[`${componentCls},${componentCls}-affix-wrapper`]: {
borderRadius: 0
}
},
[`> ${componentCls}-group-addon ${componentCls}-search-button,
> ${componentCls},
${componentCls}-affix-wrapper`]: {
"&:hover,&:focus,&:active": {
zIndex: 2
}
},
[`> ${componentCls}-affix-wrapper-focused`]: {
zIndex: 2
}
}
}
};
};
function initInputToken(token) {
return merge(token, {
inputAffixPadding: token.paddingXXS,
inputPaddingVertical: Math.max(Math.round((token.controlHeight - token.fontSize * token.lineHeight) / 2 * 10) / 10 - token.lineWidth, 3),
inputPaddingVerticalLG: Math.ceil((token.controlHeightLG - token.fontSizeLG * token.lineHeightLG) / 2 * 10) / 10 - token.lineWidth,
inputPaddingVerticalSM: Math.max(Math.round((token.controlHeightSM - token.fontSize * token.lineHeight) / 2 * 10) / 10 - token.lineWidth, 0),
inputPaddingHorizontal: token.paddingSM - token.lineWidth,
inputPaddingHorizontalSM: token.paddingXS - token.lineWidth,
inputPaddingHorizontalLG: token.controlPaddingHorizontal - token.lineWidth,
inputBorderHoverColor: token.colorPrimaryHover,
inputBorderActiveColor: token.colorPrimaryHover
});
}
const genTextAreaStyle = (token) => {
const {
componentCls,
inputPaddingHorizontal,
paddingLG
} = token;
const textareaPrefixCls = `${componentCls}-textarea`;
return {
[textareaPrefixCls]: {
position: "relative",
[`${textareaPrefixCls}-suffix`]: {
position: "absolute",
top: 0,
insetInlineEnd: inputPaddingHorizontal,
bottom: 0,
zIndex: 1,
display: "inline-flex",
alignItems: "center",
margin: "auto"
},
[`&-status-error,
&-status-warning,
&-status-success,
&-status-validating`]: {
[`&${textareaPrefixCls}-has-feedback`]: {
[`${componentCls}`]: {
paddingInlineEnd: paddingLG
}
}
},
"&-show-count": {
// https://github.com/ant-design/ant-design/issues/33049
[`> ${componentCls}`]: {
height: "100%"
},
"&::after": {
color: token.colorTextDescription,
whiteSpace: "nowrap",
content: "attr(data-count)",
pointerEvents: "none",
float: "right"
}
},
"&-rtl": {
"&::after": {
float: "left"
}
}
}
};
};
const useStyle = genComponentStyleHook("Input", (token) => {
const inputToken = initInputToken(token);
return [
genInputStyle(inputToken),
genTextAreaStyle(inputToken),
genAffixStyle(inputToken),
genGroupStyle(inputToken),
genSearchInputStyle(inputToken),
// =====================================================
// == Space Compact ==
// =====================================================
genCompactItemStyle(inputToken)
];
});
var __rest$2 = function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
const Input = defineComponent({
compatConfig: {
MODE: 3
},
name: "AInput",
inheritAttrs: false,
props: inputProps(),
setup(props, _ref) {
let {
slots,
attrs,
expose,
emit
} = _ref;
const inputRef = ref();
const formItemContext = useInjectFormItemContext();
const formItemInputContext = FormItemInputContext.useInject();
const mergedStatus = computed(() => getMergedStatus(formItemInputContext.status, props.status));
const {
direction,
prefixCls,
size,
autocomplete
} = useConfigInject("input", props);
const {
compactSize,
compactItemClassnames
} = useCompactItemContext(prefixCls, direction);
const mergedSize = computed(() => {
return compactSize.value || size.value;
});
const [wrapSSR, hashId] = useStyle(prefixCls);
const disabled = useInjectDisabled();
const focus = (option) => {
var _a;
(_a = inputRef.value) === null || _a === void 0 ? void 0 : _a.focus(option);
};
const blur = () => {
var _a;
(_a = inputRef.value) === null || _a === void 0 ? void 0 : _a.blur();
};
const setSelectionRange = (start, end, direction2) => {
var _a;
(_a = inputRef.value) === null || _a === void 0 ? void 0 : _a.setSelectionRange(start, end, direction2);
};
const select = () => {
var _a;
(_a = inputRef.value) === null || _a === void 0 ? void 0 : _a.select();
};
expose({
focus,
blur,
input: inputRef,
setSelectionRange,
select
});
const removePasswordTimeoutRef = ref([]);
const removePasswordTimeout = () => {
removePasswordTimeoutRef.value.push(setTimeout(() => {
var _a, _b, _c, _d;
if (((_a = inputRef.value) === null || _a === void 0 ? void 0 : _a.input) && ((_b = inputRef.value) === null || _b === void 0 ? void 0 : _b.input.getAttribute("type")) === "password" && ((_c = inputRef.value) === null || _c === void 0 ? void 0 : _c.input.hasAttribute("value"))) {
(_d = inputRef.value) === null || _d === void 0 ? void 0 : _d.input.removeAttribute("value");
}
}));
};
onMounted(() => {
removePasswordTimeout();
});
onBeforeUpdate(() => {
removePasswordTimeoutRef.value.forEach((item) => clearTimeout(item));
});
onBeforeUnmount(() => {
removePasswordTimeoutRef.value.forEach((item) => clearTimeout(item));
});
const handleBlur = (e) => {
removePasswordTimeout();
emit("blur", e);
formItemContext.onFieldBlur();
};
const handleFocus = (e) => {
removePasswordTimeout();
emit("focus", e);
};
const triggerChange = (e) => {
emit("update:value", e.target.value);
emit("change", e);
emit("input", e);
formItemContext.onFieldChange();
};
return () => {
var _a, _b, _c, _d, _e, _f;
const {
hasFeedback,
feedbackIcon
} = formItemInputContext;
const {
allowClear,
bordered = true,
prefix = (_a = slots.prefix) === null || _a === void 0 ? void 0 : _a.call(slots),
suffix = (_b = slots.suffix) === null || _b === void 0 ? void 0 : _b.call(slots),
addonAfter = (_c = slots.addonAfter) === null || _c === void 0 ? void 0 : _c.call(slots),
addonBefore = (_d = slots.addonBefore) === null || _d === void 0 ? void 0 : _d.call(slots),
id = (_e = formItemContext.id) === null || _e === void 0 ? void 0 : _e.value
} = props, rest = __rest$2(props, ["allowClear", "bordered", "prefix", "suffix", "addonAfter", "addonBefore", "id"]);
const suffixNode = (hasFeedback || suffix) && createVNode(Fragment, null, [suffix, hasFeedback && feedbackIcon]);
const prefixClsValue = prefixCls.value;
const inputHasPrefixSuffix = hasPrefixSuffix({
prefix,
suffix
}) || !!hasFeedback;
const clearIcon = slots.clearIcon || (() => createVNode(CloseCircleFilled, null, null));
return wrapSSR(createVNode(VcInput, _objectSpread2(_objectSpread2(_objectSpread2({}, attrs), omit(rest, ["onUpdate:value", "onChange", "onInput"])), {}, {
"onChange": triggerChange,
"id": id,
"disabled": (_f = props.disabled) !== null && _f !== void 0 ? _f : disabled.value,
"ref": inputRef,
"prefixCls": prefixClsValue,
"autocomplete": autocomplete.value,
"onBlur": handleBlur,
"onFocus": handleFocus,
"prefix": prefix,
"suffix": suffixNode,
"allowClear": allowClear,
"addonAfter": addonAfter && createVNode(NoCompactStyle, null, {
default: () => [createVNode(NoFormStatus, null, {
default: () => [addonAfter]
})]
}),
"addonBefore": addonBefore && createVNode(NoCompactStyle, null, {
default: () => [createVNode(NoFormStatus, null, {
default: () => [addonBefore]
})]
}),
"class": [attrs.class, compactItemClassnames.value],
"inputClassName": classNames({
[`${prefixClsValue}-sm`]: mergedSize.value === "small",
[`${prefixClsValue}-lg`]: mergedSize.value === "large",
[`${prefixClsValue}-rtl`]: direction.value === "rtl",
[`${prefixClsValue}-borderless`]: !bordered
}, !inputHasPrefixSuffix && getStatusClassNames(prefixClsValue, mergedStatus.value), hashId.value),
"affixWrapperClassName": classNames({
[`${prefixClsValue}-affix-wrapper-sm`]: mergedSize.value === "small",
[`${prefixClsValue}-affix-wrapper-lg`]: mergedSize.value === "large",
[`${prefixClsValue}-affix-wrapper-rtl`]: direction.value === "rtl",
[`${prefixClsValue}-affix-wrapper-borderless`]: !bordered
}, getStatusClassNames(`${prefixClsValue}-affix-wrapper`, mergedStatus.value, hasFeedback), hashId.value),
"wrapperClassName": classNames({
[`${prefixClsValue}-group-rtl`]: direction.value === "rtl"
}, hashId.value),
"groupClassName": classNames({
[`${prefixClsValue}-group-wrapper-sm`]: mergedSize.value === "small",
[`${prefixClsValue}-group-wrapper-lg`]: mergedSize.value === "large",
[`${prefixClsValue}-group-wrapper-rtl`]: direction.value === "rtl"
}, getStatusClassNames(`${prefixClsValue}-group-wrapper`, mergedStatus.value, hasFeedback), hashId.value)
}), _extends(_extends({}, slots), {
clearIcon
})));
};
}
});
const Group = defineComponent({
compatConfig: {
MODE: 3
},
name: "AInputGroup",
inheritAttrs: false,
props: {
prefixCls: String,
size: {
type: String
},
compact: {
type: Boolean,
default: void 0
}
},
setup(props, _ref) {
let {
slots,
attrs
} = _ref;
const {
prefixCls,
direction,
getPrefixCls
} = useConfigInject("input-group", props);
const formItemInputContext = FormItemInputContext.useInject();
FormItemInputContext.useProvide(formItemInputContext, {
isFormItemInput: false
});
const inputPrefixCls = computed(() => getPrefixCls("input"));
const [wrapSSR, hashId] = useStyle(inputPrefixCls);
const cls = computed(() => {
const pre = prefixCls.value;
return {
[`${pre}`]: true,
[hashId.value]: true,
[`${pre}-lg`]: props.size === "large",
[`${pre}-sm`]: props.size === "small",
[`${pre}-compact`]: props.compact,
[`${pre}-rtl`]: direction.value === "rtl"
};
});
return () => {
var _a;
return wrapSSR(createVNode("span", _objectSpread2(_objectSpread2({}, attrs), {}, {
"class": classNames(cls.value, attrs.class)
}), [(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]));
};
}
});
var __rest$1 = function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
const Search = defineComponent({
compatConfig: {
MODE: 3
},
name: "AInputSearch",
inheritAttrs: false,
props: _extends(_extends({}, inputProps()), {
inputPrefixCls: String,
// 不能设置默认值 https://github.com/vueComponent/ant-design-vue/issues/1916
enterButton: PropTypes.any,
onSearch: {
type: Function
}
}),
setup(props, _ref) {
let {
slots,
attrs,
expose,
emit
} = _ref;
const inputRef = shallowRef();
const composedRef = shallowRef(false);
const focus = () => {
var _a;
(_a = inputRef.value) === null || _a === void 0 ? void 0 : _a.focus();
};
c