1922 lines
58 KiB
JavaScript
1922 lines
58 KiB
JavaScript
import _objectSpread$1 from '@babel/runtime/helpers/esm/objectSpread2';
|
|
import { createVNode, defineComponent, mergeProps, ref, watch, computed, withDirectives, vShow, Transition, inject, watchEffect, shallowRef, nextTick, provide, Teleport, Fragment, getCurrentInstance, onActivated } from 'vue';
|
|
import { bb as Icon$1, L as initDefaultProps, E as useConfigInject, F as genComponentStyleHook, H as classNames, bv as getDataAndAriaProps, X as functionType, Z as booleanType, Y as stringType, P as PropTypes, aC as someType, aD as devWarning, $ as useInjectDisabled, J as flattenChildren, a0 as merge, Q as resetComponent, bp as resetIcon, aZ as isEmptyElement, ae as cloneElement, ab as isValidElement, a1 as Keyframe, a2 as genFocusOutline, I as arrayType } from './server.mjs';
|
|
import { f as firstNotUndefined } from './index-B7KbXP6Z.mjs';
|
|
import { g as genCollapseMotion, c as collapseMotion } from './collapseMotion-cQ2SGjCA.mjs';
|
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
import { V as VcCheckbox } from './Checkbox-CndEMz1g.mjs';
|
|
import { u as useInjectFormItemContext, F as FormItemInputContext } from './FormItemContext-CR0UDjwx.mjs';
|
|
import { e as extend, c as createNamespace, w as withInstall, p as pick, t as truthProp, u as unknownProp, n as numericProp, m as makeStringProp, d as makeArrayProp, b as addUnit, s as stdin_default$5, i as isDef, f as isNumeric, k as kebabCase, h as getZIndexStyle, j as isPromise, l as noop } from './index-CMTdA55b.mjs';
|
|
|
|
// This icon file is generated automatically.
|
|
var RightOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z" } }] }, "name": "right", "theme": "outlined" };
|
|
|
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
var RightOutlined = function RightOutlined(props, context) {
|
|
var p = _objectSpread({}, props, context.attrs);
|
|
|
|
return createVNode(Icon$1, _objectSpread({}, p, {
|
|
"icon": RightOutlined$1
|
|
}), null);
|
|
};
|
|
|
|
RightOutlined.displayName = 'RightOutlined';
|
|
RightOutlined.inheritAttrs = false;
|
|
|
|
const collapseProps = () => ({
|
|
prefixCls: String,
|
|
activeKey: someType([Array, Number, String]),
|
|
defaultActiveKey: someType([Array, Number, String]),
|
|
accordion: booleanType(),
|
|
destroyInactivePanel: booleanType(),
|
|
bordered: booleanType(),
|
|
expandIcon: functionType(),
|
|
openAnimation: PropTypes.object,
|
|
expandIconPosition: stringType(),
|
|
collapsible: stringType(),
|
|
ghost: booleanType(),
|
|
onChange: functionType(),
|
|
"onUpdate:activeKey": functionType()
|
|
});
|
|
const collapsePanelProps = () => ({
|
|
openAnimation: PropTypes.object,
|
|
prefixCls: String,
|
|
header: PropTypes.any,
|
|
headerClass: String,
|
|
showArrow: booleanType(),
|
|
isActive: booleanType(),
|
|
destroyInactivePanel: booleanType(),
|
|
/** @deprecated Use `collapsible="disabled"` instead */
|
|
disabled: booleanType(),
|
|
accordion: booleanType(),
|
|
forceRender: booleanType(),
|
|
expandIcon: functionType(),
|
|
extra: PropTypes.any,
|
|
panelKey: someType(),
|
|
collapsible: stringType(),
|
|
role: String,
|
|
onItemClick: functionType()
|
|
});
|
|
const genBaseStyle = (token) => {
|
|
const {
|
|
componentCls,
|
|
collapseContentBg,
|
|
padding,
|
|
collapseContentPaddingHorizontal,
|
|
collapseHeaderBg,
|
|
collapseHeaderPadding,
|
|
collapsePanelBorderRadius,
|
|
lineWidth,
|
|
lineType,
|
|
colorBorder,
|
|
colorText,
|
|
colorTextHeading,
|
|
colorTextDisabled,
|
|
fontSize,
|
|
lineHeight,
|
|
marginSM,
|
|
paddingSM,
|
|
motionDurationSlow,
|
|
fontSizeIcon
|
|
} = token;
|
|
const borderBase = `${lineWidth}px ${lineType} ${colorBorder}`;
|
|
return {
|
|
[componentCls]: _extends(_extends({}, resetComponent(token)), {
|
|
backgroundColor: collapseHeaderBg,
|
|
border: borderBase,
|
|
borderBottom: 0,
|
|
borderRadius: `${collapsePanelBorderRadius}px`,
|
|
[`&-rtl`]: {
|
|
direction: "rtl"
|
|
},
|
|
[`& > ${componentCls}-item`]: {
|
|
borderBottom: borderBase,
|
|
[`&:last-child`]: {
|
|
[`
|
|
&,
|
|
& > ${componentCls}-header`]: {
|
|
borderRadius: `0 0 ${collapsePanelBorderRadius}px ${collapsePanelBorderRadius}px`
|
|
}
|
|
},
|
|
[`> ${componentCls}-header`]: {
|
|
position: "relative",
|
|
display: "flex",
|
|
flexWrap: "nowrap",
|
|
alignItems: "flex-start",
|
|
padding: collapseHeaderPadding,
|
|
color: colorTextHeading,
|
|
lineHeight,
|
|
cursor: "pointer",
|
|
transition: `all ${motionDurationSlow}, visibility 0s`,
|
|
[`> ${componentCls}-header-text`]: {
|
|
flex: "auto"
|
|
},
|
|
"&:focus": {
|
|
outline: "none"
|
|
},
|
|
// >>>>> Arrow
|
|
[`${componentCls}-expand-icon`]: {
|
|
height: fontSize * lineHeight,
|
|
display: "flex",
|
|
alignItems: "center",
|
|
paddingInlineEnd: marginSM
|
|
},
|
|
[`${componentCls}-arrow`]: _extends(_extends({}, resetIcon()), {
|
|
fontSize: fontSizeIcon,
|
|
svg: {
|
|
transition: `transform ${motionDurationSlow}`
|
|
}
|
|
}),
|
|
// >>>>> Text
|
|
[`${componentCls}-header-text`]: {
|
|
marginInlineEnd: "auto"
|
|
}
|
|
},
|
|
[`${componentCls}-header-collapsible-only`]: {
|
|
cursor: "default",
|
|
[`${componentCls}-header-text`]: {
|
|
flex: "none",
|
|
cursor: "pointer"
|
|
},
|
|
[`${componentCls}-expand-icon`]: {
|
|
cursor: "pointer"
|
|
}
|
|
},
|
|
[`${componentCls}-icon-collapsible-only`]: {
|
|
cursor: "default",
|
|
[`${componentCls}-expand-icon`]: {
|
|
cursor: "pointer"
|
|
}
|
|
},
|
|
[`&${componentCls}-no-arrow`]: {
|
|
[`> ${componentCls}-header`]: {
|
|
paddingInlineStart: paddingSM
|
|
}
|
|
}
|
|
},
|
|
[`${componentCls}-content`]: {
|
|
color: colorText,
|
|
backgroundColor: collapseContentBg,
|
|
borderTop: borderBase,
|
|
[`& > ${componentCls}-content-box`]: {
|
|
padding: `${padding}px ${collapseContentPaddingHorizontal}px`
|
|
},
|
|
[`&-hidden`]: {
|
|
display: "none"
|
|
}
|
|
},
|
|
[`${componentCls}-item:last-child`]: {
|
|
[`> ${componentCls}-content`]: {
|
|
borderRadius: `0 0 ${collapsePanelBorderRadius}px ${collapsePanelBorderRadius}px`
|
|
}
|
|
},
|
|
[`& ${componentCls}-item-disabled > ${componentCls}-header`]: {
|
|
[`
|
|
&,
|
|
& > .arrow
|
|
`]: {
|
|
color: colorTextDisabled,
|
|
cursor: "not-allowed"
|
|
}
|
|
},
|
|
// ========================== Icon Position ==========================
|
|
[`&${componentCls}-icon-position-end`]: {
|
|
[`& > ${componentCls}-item`]: {
|
|
[`> ${componentCls}-header`]: {
|
|
[`${componentCls}-expand-icon`]: {
|
|
order: 1,
|
|
paddingInlineEnd: 0,
|
|
paddingInlineStart: marginSM
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
};
|
|
};
|
|
const genArrowStyle = (token) => {
|
|
const {
|
|
componentCls
|
|
} = token;
|
|
const fixedSelector = `> ${componentCls}-item > ${componentCls}-header ${componentCls}-arrow svg`;
|
|
return {
|
|
[`${componentCls}-rtl`]: {
|
|
[fixedSelector]: {
|
|
transform: `rotate(180deg)`
|
|
}
|
|
}
|
|
};
|
|
};
|
|
const genBorderlessStyle = (token) => {
|
|
const {
|
|
componentCls,
|
|
collapseHeaderBg,
|
|
paddingXXS,
|
|
colorBorder
|
|
} = token;
|
|
return {
|
|
[`${componentCls}-borderless`]: {
|
|
backgroundColor: collapseHeaderBg,
|
|
border: 0,
|
|
[`> ${componentCls}-item`]: {
|
|
borderBottom: `1px solid ${colorBorder}`
|
|
},
|
|
[`
|
|
> ${componentCls}-item:last-child,
|
|
> ${componentCls}-item:last-child ${componentCls}-header
|
|
`]: {
|
|
borderRadius: 0
|
|
},
|
|
[`> ${componentCls}-item:last-child`]: {
|
|
borderBottom: 0
|
|
},
|
|
[`> ${componentCls}-item > ${componentCls}-content`]: {
|
|
backgroundColor: "transparent",
|
|
borderTop: 0
|
|
},
|
|
[`> ${componentCls}-item > ${componentCls}-content > ${componentCls}-content-box`]: {
|
|
paddingTop: paddingXXS
|
|
}
|
|
}
|
|
};
|
|
};
|
|
const genGhostStyle = (token) => {
|
|
const {
|
|
componentCls,
|
|
paddingSM
|
|
} = token;
|
|
return {
|
|
[`${componentCls}-ghost`]: {
|
|
backgroundColor: "transparent",
|
|
border: 0,
|
|
[`> ${componentCls}-item`]: {
|
|
borderBottom: 0,
|
|
[`> ${componentCls}-content`]: {
|
|
backgroundColor: "transparent",
|
|
border: 0,
|
|
[`> ${componentCls}-content-box`]: {
|
|
paddingBlock: paddingSM
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
const useStyle$1 = genComponentStyleHook("Collapse", (token) => {
|
|
const collapseToken = merge(token, {
|
|
collapseContentBg: token.colorBgContainer,
|
|
collapseHeaderBg: token.colorFillAlter,
|
|
collapseHeaderPadding: `${token.paddingSM}px ${token.padding}px`,
|
|
collapsePanelBorderRadius: token.borderRadiusLG,
|
|
collapseContentPaddingHorizontal: 16
|
|
// Fixed value
|
|
});
|
|
return [genBaseStyle(collapseToken), genBorderlessStyle(collapseToken), genGhostStyle(collapseToken), genArrowStyle(collapseToken), genCollapseMotion(collapseToken)];
|
|
});
|
|
function getActiveKeysArray(activeKey) {
|
|
let currentActiveKey = activeKey;
|
|
if (!Array.isArray(currentActiveKey)) {
|
|
const activeKeyType = typeof currentActiveKey;
|
|
currentActiveKey = activeKeyType === "number" || activeKeyType === "string" ? [currentActiveKey] : [];
|
|
}
|
|
return currentActiveKey.map((key) => String(key));
|
|
}
|
|
const Collapse = defineComponent({
|
|
compatConfig: {
|
|
MODE: 3
|
|
},
|
|
name: "ACollapse",
|
|
inheritAttrs: false,
|
|
props: initDefaultProps(collapseProps(), {
|
|
accordion: false,
|
|
destroyInactivePanel: false,
|
|
bordered: true,
|
|
expandIconPosition: "start"
|
|
}),
|
|
slots: Object,
|
|
setup(props, _ref) {
|
|
let {
|
|
attrs,
|
|
slots,
|
|
emit
|
|
} = _ref;
|
|
const stateActiveKey = ref(getActiveKeysArray(firstNotUndefined([props.activeKey, props.defaultActiveKey])));
|
|
watch(() => props.activeKey, () => {
|
|
stateActiveKey.value = getActiveKeysArray(props.activeKey);
|
|
}, {
|
|
deep: true
|
|
});
|
|
const {
|
|
prefixCls,
|
|
direction,
|
|
rootPrefixCls
|
|
} = useConfigInject("collapse", props);
|
|
const [wrapSSR, hashId] = useStyle$1(prefixCls);
|
|
const iconPosition = computed(() => {
|
|
const {
|
|
expandIconPosition
|
|
} = props;
|
|
if (expandIconPosition !== void 0) {
|
|
return expandIconPosition;
|
|
}
|
|
return direction.value === "rtl" ? "end" : "start";
|
|
});
|
|
const renderExpandIcon = (panelProps) => {
|
|
const {
|
|
expandIcon = slots.expandIcon
|
|
} = props;
|
|
const icon = expandIcon ? expandIcon(panelProps) : createVNode(RightOutlined, {
|
|
"rotate": panelProps.isActive ? 90 : void 0
|
|
}, null);
|
|
return createVNode("div", {
|
|
"class": [`${prefixCls.value}-expand-icon`, hashId.value],
|
|
"onClick": () => ["header", "icon"].includes(props.collapsible) && onClickItem(panelProps.panelKey)
|
|
}, [isValidElement(Array.isArray(expandIcon) ? icon[0] : icon) ? cloneElement(icon, {
|
|
class: `${prefixCls.value}-arrow`
|
|
}, false) : icon]);
|
|
};
|
|
const setActiveKey = (activeKey) => {
|
|
if (props.activeKey === void 0) {
|
|
stateActiveKey.value = activeKey;
|
|
}
|
|
const newKey = props.accordion ? activeKey[0] : activeKey;
|
|
emit("update:activeKey", newKey);
|
|
emit("change", newKey);
|
|
};
|
|
const onClickItem = (key) => {
|
|
let activeKey = stateActiveKey.value;
|
|
if (props.accordion) {
|
|
activeKey = activeKey[0] === key ? [] : [key];
|
|
} else {
|
|
activeKey = [...activeKey];
|
|
const index = activeKey.indexOf(key);
|
|
const isActive = index > -1;
|
|
if (isActive) {
|
|
activeKey.splice(index, 1);
|
|
} else {
|
|
activeKey.push(key);
|
|
}
|
|
}
|
|
setActiveKey(activeKey);
|
|
};
|
|
const getNewChild = (child, index) => {
|
|
var _a, _b, _c;
|
|
if (isEmptyElement(child)) return;
|
|
const activeKey = stateActiveKey.value;
|
|
const {
|
|
accordion,
|
|
destroyInactivePanel,
|
|
collapsible,
|
|
openAnimation
|
|
} = props;
|
|
const animation = openAnimation || collapseMotion(`${rootPrefixCls.value}-motion-collapse`);
|
|
const key = String((_a = child.key) !== null && _a !== void 0 ? _a : index);
|
|
const {
|
|
header = (_c = (_b = child.children) === null || _b === void 0 ? void 0 : _b.header) === null || _c === void 0 ? void 0 : _c.call(_b),
|
|
headerClass,
|
|
collapsible: childCollapsible,
|
|
disabled
|
|
} = child.props || {};
|
|
let isActive = false;
|
|
if (accordion) {
|
|
isActive = activeKey[0] === key;
|
|
} else {
|
|
isActive = activeKey.indexOf(key) > -1;
|
|
}
|
|
let mergeCollapsible = childCollapsible !== null && childCollapsible !== void 0 ? childCollapsible : collapsible;
|
|
if (disabled || disabled === "") {
|
|
mergeCollapsible = "disabled";
|
|
}
|
|
const newProps = {
|
|
key,
|
|
panelKey: key,
|
|
header,
|
|
headerClass,
|
|
isActive,
|
|
prefixCls: prefixCls.value,
|
|
destroyInactivePanel,
|
|
openAnimation: animation,
|
|
accordion,
|
|
onItemClick: mergeCollapsible === "disabled" ? null : onClickItem,
|
|
expandIcon: renderExpandIcon,
|
|
collapsible: mergeCollapsible
|
|
};
|
|
return cloneElement(child, newProps);
|
|
};
|
|
const getItems = () => {
|
|
var _a;
|
|
return flattenChildren((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)).map(getNewChild);
|
|
};
|
|
return () => {
|
|
const {
|
|
accordion,
|
|
bordered,
|
|
ghost
|
|
} = props;
|
|
const collapseClassName = classNames(prefixCls.value, {
|
|
[`${prefixCls.value}-borderless`]: !bordered,
|
|
[`${prefixCls.value}-icon-position-${iconPosition.value}`]: true,
|
|
[`${prefixCls.value}-rtl`]: direction.value === "rtl",
|
|
[`${prefixCls.value}-ghost`]: !!ghost,
|
|
[attrs.class]: !!attrs.class
|
|
}, hashId.value);
|
|
return wrapSSR(createVNode("div", _objectSpread$1(_objectSpread$1({
|
|
"class": collapseClassName
|
|
}, getDataAndAriaProps(attrs)), {}, {
|
|
"style": attrs.style,
|
|
"role": accordion ? "tablist" : null
|
|
}), [getItems()]));
|
|
};
|
|
}
|
|
});
|
|
const PanelContent = defineComponent({
|
|
compatConfig: {
|
|
MODE: 3
|
|
},
|
|
name: "PanelContent",
|
|
props: collapsePanelProps(),
|
|
setup(props, _ref) {
|
|
let {
|
|
slots
|
|
} = _ref;
|
|
const rendered = shallowRef(false);
|
|
watchEffect(() => {
|
|
if (props.isActive || props.forceRender) {
|
|
rendered.value = true;
|
|
}
|
|
});
|
|
return () => {
|
|
var _a;
|
|
if (!rendered.value) return null;
|
|
const {
|
|
prefixCls,
|
|
isActive,
|
|
role
|
|
} = props;
|
|
return createVNode("div", {
|
|
"class": classNames(`${prefixCls}-content`, {
|
|
[`${prefixCls}-content-active`]: isActive,
|
|
[`${prefixCls}-content-inactive`]: !isActive
|
|
}),
|
|
"role": role
|
|
}, [createVNode("div", {
|
|
"class": `${prefixCls}-content-box`
|
|
}, [(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)])]);
|
|
};
|
|
}
|
|
});
|
|
const __nuxt_component_6 = defineComponent({
|
|
compatConfig: {
|
|
MODE: 3
|
|
},
|
|
name: "ACollapsePanel",
|
|
inheritAttrs: false,
|
|
props: initDefaultProps(collapsePanelProps(), {
|
|
showArrow: true,
|
|
isActive: false,
|
|
onItemClick() {
|
|
},
|
|
headerClass: "",
|
|
forceRender: false
|
|
}),
|
|
slots: Object,
|
|
// emits: ['itemClick'],
|
|
setup(props, _ref) {
|
|
let {
|
|
slots,
|
|
emit,
|
|
attrs
|
|
} = _ref;
|
|
devWarning(props.disabled === void 0, "Collapse.Panel", '`disabled` is deprecated. Please use `collapsible="disabled"` instead.');
|
|
const {
|
|
prefixCls
|
|
} = useConfigInject("collapse", props);
|
|
const handleItemClick = () => {
|
|
emit("itemClick", props.panelKey);
|
|
};
|
|
const handleKeyPress = (e) => {
|
|
if (e.key === "Enter" || e.keyCode === 13 || e.which === 13) {
|
|
handleItemClick();
|
|
}
|
|
};
|
|
return () => {
|
|
var _a, _b;
|
|
const {
|
|
header = (_a = slots.header) === null || _a === void 0 ? void 0 : _a.call(slots),
|
|
headerClass,
|
|
isActive,
|
|
showArrow,
|
|
destroyInactivePanel,
|
|
accordion,
|
|
forceRender,
|
|
openAnimation,
|
|
expandIcon = slots.expandIcon,
|
|
extra = (_b = slots.extra) === null || _b === void 0 ? void 0 : _b.call(slots),
|
|
collapsible
|
|
} = props;
|
|
const disabled = collapsible === "disabled";
|
|
const prefixClsValue = prefixCls.value;
|
|
const headerCls = classNames(`${prefixClsValue}-header`, {
|
|
[headerClass]: headerClass,
|
|
[`${prefixClsValue}-header-collapsible-only`]: collapsible === "header",
|
|
[`${prefixClsValue}-icon-collapsible-only`]: collapsible === "icon"
|
|
});
|
|
const itemCls = classNames({
|
|
[`${prefixClsValue}-item`]: true,
|
|
[`${prefixClsValue}-item-active`]: isActive,
|
|
[`${prefixClsValue}-item-disabled`]: disabled,
|
|
[`${prefixClsValue}-no-arrow`]: !showArrow,
|
|
[`${attrs.class}`]: !!attrs.class
|
|
});
|
|
let icon = createVNode("i", {
|
|
"class": "arrow"
|
|
}, null);
|
|
if (showArrow && typeof expandIcon === "function") {
|
|
icon = expandIcon(props);
|
|
}
|
|
const panelContent = withDirectives(createVNode(PanelContent, {
|
|
"prefixCls": prefixClsValue,
|
|
"isActive": isActive,
|
|
"forceRender": forceRender,
|
|
"role": accordion ? "tabpanel" : null
|
|
}, {
|
|
default: slots.default
|
|
}), [[vShow, isActive]]);
|
|
const transitionProps = _extends({
|
|
appear: false,
|
|
css: false
|
|
}, openAnimation);
|
|
return createVNode("div", _objectSpread$1(_objectSpread$1({}, attrs), {}, {
|
|
"class": itemCls
|
|
}), [createVNode("div", {
|
|
"class": headerCls,
|
|
"onClick": () => !["header", "icon"].includes(collapsible) && handleItemClick(),
|
|
"role": accordion ? "tab" : "button",
|
|
"tabindex": disabled ? -1 : 0,
|
|
"aria-expanded": isActive,
|
|
"onKeypress": handleKeyPress
|
|
}, [showArrow && icon, createVNode("span", {
|
|
"onClick": () => collapsible === "header" && handleItemClick(),
|
|
"class": `${prefixClsValue}-header-text`
|
|
}, [header]), extra && createVNode("div", {
|
|
"class": `${prefixClsValue}-extra`
|
|
}, [extra])]), createVNode(Transition, transitionProps, {
|
|
default: () => [!destroyInactivePanel || isActive ? panelContent : null]
|
|
})]);
|
|
};
|
|
}
|
|
});
|
|
Collapse.Panel = __nuxt_component_6;
|
|
Collapse.install = function(app) {
|
|
app.component(Collapse.name, Collapse);
|
|
app.component(__nuxt_component_6.name, __nuxt_component_6);
|
|
return app;
|
|
};
|
|
const antCheckboxEffect = new Keyframe("antCheckboxEffect", {
|
|
"0%": {
|
|
transform: "scale(1)",
|
|
opacity: 0.5
|
|
},
|
|
"100%": {
|
|
transform: "scale(1.6)",
|
|
opacity: 0
|
|
}
|
|
});
|
|
const genCheckboxStyle = (token) => {
|
|
const {
|
|
checkboxCls
|
|
} = token;
|
|
const wrapperCls = `${checkboxCls}-wrapper`;
|
|
return [
|
|
// ===================== Basic =====================
|
|
{
|
|
// Group
|
|
[`${checkboxCls}-group`]: _extends(_extends({}, resetComponent(token)), {
|
|
display: "inline-flex",
|
|
flexWrap: "wrap",
|
|
columnGap: token.marginXS,
|
|
// Group > Grid
|
|
[`> ${token.antCls}-row`]: {
|
|
flex: 1
|
|
}
|
|
}),
|
|
// Wrapper
|
|
[wrapperCls]: _extends(_extends({}, resetComponent(token)), {
|
|
display: "inline-flex",
|
|
alignItems: "baseline",
|
|
cursor: "pointer",
|
|
// Fix checkbox & radio in flex align #30260
|
|
"&:after": {
|
|
display: "inline-block",
|
|
width: 0,
|
|
overflow: "hidden",
|
|
content: "'\\a0'"
|
|
},
|
|
// Checkbox near checkbox
|
|
[`& + ${wrapperCls}`]: {
|
|
marginInlineStart: 0
|
|
},
|
|
[`&${wrapperCls}-in-form-item`]: {
|
|
'input[type="checkbox"]': {
|
|
width: 14,
|
|
height: 14
|
|
// FIXME: magic
|
|
}
|
|
}
|
|
}),
|
|
// Wrapper > Checkbox
|
|
[checkboxCls]: _extends(_extends({}, resetComponent(token)), {
|
|
position: "relative",
|
|
whiteSpace: "nowrap",
|
|
lineHeight: 1,
|
|
cursor: "pointer",
|
|
// To make alignment right when `controlHeight` is changed
|
|
// Ref: https://github.com/ant-design/ant-design/issues/41564
|
|
alignSelf: "center",
|
|
// Wrapper > Checkbox > input
|
|
[`${checkboxCls}-input`]: {
|
|
position: "absolute",
|
|
// Since baseline align will get additional space offset,
|
|
// we need to move input to top to make it align with text.
|
|
// Ref: https://github.com/ant-design/ant-design/issues/38926#issuecomment-1486137799
|
|
inset: 0,
|
|
zIndex: 1,
|
|
cursor: "pointer",
|
|
opacity: 0,
|
|
margin: 0,
|
|
[`&:focus-visible + ${checkboxCls}-inner`]: _extends({}, genFocusOutline(token))
|
|
},
|
|
// Wrapper > Checkbox > inner
|
|
[`${checkboxCls}-inner`]: {
|
|
boxSizing: "border-box",
|
|
position: "relative",
|
|
top: 0,
|
|
insetInlineStart: 0,
|
|
display: "block",
|
|
width: token.checkboxSize,
|
|
height: token.checkboxSize,
|
|
direction: "ltr",
|
|
backgroundColor: token.colorBgContainer,
|
|
border: `${token.lineWidth}px ${token.lineType} ${token.colorBorder}`,
|
|
borderRadius: token.borderRadiusSM,
|
|
borderCollapse: "separate",
|
|
transition: `all ${token.motionDurationSlow}`,
|
|
"&:after": {
|
|
boxSizing: "border-box",
|
|
position: "absolute",
|
|
top: "50%",
|
|
insetInlineStart: "21.5%",
|
|
display: "table",
|
|
width: token.checkboxSize / 14 * 5,
|
|
height: token.checkboxSize / 14 * 8,
|
|
border: `${token.lineWidthBold}px solid ${token.colorWhite}`,
|
|
borderTop: 0,
|
|
borderInlineStart: 0,
|
|
transform: "rotate(45deg) scale(0) translate(-50%,-50%)",
|
|
opacity: 0,
|
|
content: '""',
|
|
transition: `all ${token.motionDurationFast} ${token.motionEaseInBack}, opacity ${token.motionDurationFast}`
|
|
}
|
|
},
|
|
// Wrapper > Checkbox + Text
|
|
"& + span": {
|
|
paddingInlineStart: token.paddingXS,
|
|
paddingInlineEnd: token.paddingXS
|
|
}
|
|
})
|
|
},
|
|
// ================= Indeterminate =================
|
|
{
|
|
[checkboxCls]: {
|
|
"&-indeterminate": {
|
|
// Wrapper > Checkbox > inner
|
|
[`${checkboxCls}-inner`]: {
|
|
"&:after": {
|
|
top: "50%",
|
|
insetInlineStart: "50%",
|
|
width: token.fontSizeLG / 2,
|
|
height: token.fontSizeLG / 2,
|
|
backgroundColor: token.colorPrimary,
|
|
border: 0,
|
|
transform: "translate(-50%, -50%) scale(1)",
|
|
opacity: 1,
|
|
content: '""'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
// ===================== Hover =====================
|
|
{
|
|
// Wrapper
|
|
[`${wrapperCls}:hover ${checkboxCls}:after`]: {
|
|
visibility: "visible"
|
|
},
|
|
// Wrapper & Wrapper > Checkbox
|
|
[`
|
|
${wrapperCls}:not(${wrapperCls}-disabled),
|
|
${checkboxCls}:not(${checkboxCls}-disabled)
|
|
`]: {
|
|
[`&:hover ${checkboxCls}-inner`]: {
|
|
borderColor: token.colorPrimary
|
|
}
|
|
},
|
|
[`${wrapperCls}:not(${wrapperCls}-disabled)`]: {
|
|
[`&:hover ${checkboxCls}-checked:not(${checkboxCls}-disabled) ${checkboxCls}-inner`]: {
|
|
backgroundColor: token.colorPrimaryHover,
|
|
borderColor: "transparent"
|
|
},
|
|
[`&:hover ${checkboxCls}-checked:not(${checkboxCls}-disabled):after`]: {
|
|
borderColor: token.colorPrimaryHover
|
|
}
|
|
}
|
|
},
|
|
// ==================== Checked ====================
|
|
{
|
|
// Wrapper > Checkbox
|
|
[`${checkboxCls}-checked`]: {
|
|
[`${checkboxCls}-inner`]: {
|
|
backgroundColor: token.colorPrimary,
|
|
borderColor: token.colorPrimary,
|
|
"&:after": {
|
|
opacity: 1,
|
|
transform: "rotate(45deg) scale(1) translate(-50%,-50%)",
|
|
transition: `all ${token.motionDurationMid} ${token.motionEaseOutBack} ${token.motionDurationFast}`
|
|
}
|
|
},
|
|
// Checked Effect
|
|
"&:after": {
|
|
position: "absolute",
|
|
top: 0,
|
|
insetInlineStart: 0,
|
|
width: "100%",
|
|
height: "100%",
|
|
borderRadius: token.borderRadiusSM,
|
|
visibility: "hidden",
|
|
border: `${token.lineWidthBold}px solid ${token.colorPrimary}`,
|
|
animationName: antCheckboxEffect,
|
|
animationDuration: token.motionDurationSlow,
|
|
animationTimingFunction: "ease-in-out",
|
|
animationFillMode: "backwards",
|
|
content: '""',
|
|
transition: `all ${token.motionDurationSlow}`
|
|
}
|
|
},
|
|
[`
|
|
${wrapperCls}-checked:not(${wrapperCls}-disabled),
|
|
${checkboxCls}-checked:not(${checkboxCls}-disabled)
|
|
`]: {
|
|
[`&:hover ${checkboxCls}-inner`]: {
|
|
backgroundColor: token.colorPrimaryHover,
|
|
borderColor: "transparent"
|
|
},
|
|
[`&:hover ${checkboxCls}:after`]: {
|
|
borderColor: token.colorPrimaryHover
|
|
}
|
|
}
|
|
},
|
|
// ==================== Disable ====================
|
|
{
|
|
// Wrapper
|
|
[`${wrapperCls}-disabled`]: {
|
|
cursor: "not-allowed"
|
|
},
|
|
// Wrapper > Checkbox
|
|
[`${checkboxCls}-disabled`]: {
|
|
// Wrapper > Checkbox > input
|
|
[`&, ${checkboxCls}-input`]: {
|
|
cursor: "not-allowed",
|
|
// Disabled for native input to enable Tooltip event handler
|
|
// ref: https://github.com/ant-design/ant-design/issues/39822#issuecomment-1365075901
|
|
pointerEvents: "none"
|
|
},
|
|
// Wrapper > Checkbox > inner
|
|
[`${checkboxCls}-inner`]: {
|
|
background: token.colorBgContainerDisabled,
|
|
borderColor: token.colorBorder,
|
|
"&:after": {
|
|
borderColor: token.colorTextDisabled
|
|
}
|
|
},
|
|
"&:after": {
|
|
display: "none"
|
|
},
|
|
"& + span": {
|
|
color: token.colorTextDisabled
|
|
},
|
|
[`&${checkboxCls}-indeterminate ${checkboxCls}-inner::after`]: {
|
|
background: token.colorTextDisabled
|
|
}
|
|
}
|
|
}
|
|
];
|
|
};
|
|
function getStyle(prefixCls, token) {
|
|
const checkboxToken = merge(token, {
|
|
checkboxCls: `.${prefixCls}`,
|
|
checkboxSize: token.controlInteractiveSize
|
|
});
|
|
return [genCheckboxStyle(checkboxToken)];
|
|
}
|
|
const useStyle = genComponentStyleHook("Checkbox", (token, _ref) => {
|
|
let {
|
|
prefixCls
|
|
} = _ref;
|
|
return [getStyle(prefixCls, token)];
|
|
});
|
|
const abstractCheckboxGroupProps = () => {
|
|
return {
|
|
name: String,
|
|
prefixCls: String,
|
|
options: arrayType([]),
|
|
disabled: Boolean,
|
|
id: String
|
|
};
|
|
};
|
|
const checkboxGroupProps = () => {
|
|
return _extends(_extends({}, abstractCheckboxGroupProps()), {
|
|
defaultValue: arrayType(),
|
|
value: arrayType(),
|
|
onChange: functionType(),
|
|
"onUpdate:value": functionType()
|
|
});
|
|
};
|
|
const abstractCheckboxProps = () => {
|
|
return {
|
|
prefixCls: String,
|
|
defaultChecked: booleanType(),
|
|
checked: booleanType(),
|
|
disabled: booleanType(),
|
|
isGroup: booleanType(),
|
|
value: PropTypes.any,
|
|
name: String,
|
|
id: String,
|
|
indeterminate: booleanType(),
|
|
type: stringType("checkbox"),
|
|
autofocus: booleanType(),
|
|
onChange: functionType(),
|
|
"onUpdate:checked": functionType(),
|
|
onClick: functionType(),
|
|
skipGroup: booleanType(false)
|
|
};
|
|
};
|
|
const checkboxProps = () => {
|
|
return _extends(_extends({}, abstractCheckboxProps()), {
|
|
indeterminate: booleanType(false)
|
|
});
|
|
};
|
|
const CheckboxGroupContextKey = Symbol("CheckboxGroupContext");
|
|
var __rest = 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 Checkbox = defineComponent({
|
|
compatConfig: {
|
|
MODE: 3
|
|
},
|
|
name: "ACheckbox",
|
|
inheritAttrs: false,
|
|
__ANT_CHECKBOX: true,
|
|
props: checkboxProps(),
|
|
// emits: ['change', 'update:checked'],
|
|
setup(props, _ref) {
|
|
let {
|
|
emit,
|
|
attrs,
|
|
slots,
|
|
expose
|
|
} = _ref;
|
|
const formItemContext = useInjectFormItemContext();
|
|
const formItemInputContext = FormItemInputContext.useInject();
|
|
const {
|
|
prefixCls,
|
|
direction,
|
|
disabled
|
|
} = useConfigInject("checkbox", props);
|
|
const contextDisabled = useInjectDisabled();
|
|
const [wrapSSR, hashId] = useStyle(prefixCls);
|
|
const checkboxGroup = inject(CheckboxGroupContextKey, void 0);
|
|
const uniId = Symbol("checkboxUniId");
|
|
const mergedDisabled = computed(() => {
|
|
return (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.disabled.value) || disabled.value;
|
|
});
|
|
watchEffect(() => {
|
|
if (!props.skipGroup && checkboxGroup) {
|
|
checkboxGroup.registerValue(uniId, props.value);
|
|
}
|
|
});
|
|
const handleChange = (event) => {
|
|
const targetChecked = event.target.checked;
|
|
emit("update:checked", targetChecked);
|
|
emit("change", event);
|
|
formItemContext.onFieldChange();
|
|
};
|
|
const checkboxRef = ref();
|
|
const focus = () => {
|
|
var _a;
|
|
(_a = checkboxRef.value) === null || _a === void 0 ? void 0 : _a.focus();
|
|
};
|
|
const blur = () => {
|
|
var _a;
|
|
(_a = checkboxRef.value) === null || _a === void 0 ? void 0 : _a.blur();
|
|
};
|
|
expose({
|
|
focus,
|
|
blur
|
|
});
|
|
return () => {
|
|
var _a;
|
|
const children = flattenChildren((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots));
|
|
const {
|
|
indeterminate,
|
|
skipGroup,
|
|
id = formItemContext.id.value
|
|
} = props, restProps = __rest(props, ["indeterminate", "skipGroup", "id"]);
|
|
const {
|
|
onMouseenter,
|
|
onMouseleave,
|
|
onInput,
|
|
class: className,
|
|
style
|
|
} = attrs, restAttrs = __rest(attrs, ["onMouseenter", "onMouseleave", "onInput", "class", "style"]);
|
|
const checkboxProps2 = _extends(_extends(_extends(_extends({}, restProps), {
|
|
id,
|
|
prefixCls: prefixCls.value
|
|
}), restAttrs), {
|
|
disabled: mergedDisabled.value
|
|
});
|
|
if (checkboxGroup && !skipGroup) {
|
|
checkboxProps2.onChange = function() {
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
args[_key] = arguments[_key];
|
|
}
|
|
emit("change", ...args);
|
|
checkboxGroup.toggleOption({
|
|
label: children,
|
|
value: props.value
|
|
});
|
|
};
|
|
checkboxProps2.name = checkboxGroup.name.value;
|
|
checkboxProps2.checked = checkboxGroup.mergedValue.value.includes(props.value);
|
|
checkboxProps2.disabled = mergedDisabled.value || contextDisabled.value;
|
|
checkboxProps2.indeterminate = indeterminate;
|
|
} else {
|
|
checkboxProps2.onChange = handleChange;
|
|
}
|
|
const classString = classNames({
|
|
[`${prefixCls.value}-wrapper`]: true,
|
|
[`${prefixCls.value}-rtl`]: direction.value === "rtl",
|
|
[`${prefixCls.value}-wrapper-checked`]: checkboxProps2.checked,
|
|
[`${prefixCls.value}-wrapper-disabled`]: checkboxProps2.disabled,
|
|
[`${prefixCls.value}-wrapper-in-form-item`]: formItemInputContext.isFormItemInput
|
|
}, className, hashId.value);
|
|
const checkboxClass = classNames({
|
|
[`${prefixCls.value}-indeterminate`]: indeterminate
|
|
}, hashId.value);
|
|
const ariaChecked = indeterminate ? "mixed" : void 0;
|
|
return wrapSSR(createVNode("label", {
|
|
"class": classString,
|
|
"style": style,
|
|
"onMouseenter": onMouseenter,
|
|
"onMouseleave": onMouseleave
|
|
}, [createVNode(VcCheckbox, _objectSpread$1(_objectSpread$1({
|
|
"aria-checked": ariaChecked
|
|
}, checkboxProps2), {}, {
|
|
"class": checkboxClass,
|
|
"ref": checkboxRef
|
|
}), null), children.length ? createVNode("span", null, [children]) : null]));
|
|
};
|
|
}
|
|
});
|
|
const CheckboxGroup = defineComponent({
|
|
compatConfig: {
|
|
MODE: 3
|
|
},
|
|
name: "ACheckboxGroup",
|
|
inheritAttrs: false,
|
|
props: checkboxGroupProps(),
|
|
// emits: ['change', 'update:value'],
|
|
setup(props, _ref) {
|
|
let {
|
|
slots,
|
|
attrs,
|
|
emit,
|
|
expose
|
|
} = _ref;
|
|
const formItemContext = useInjectFormItemContext();
|
|
const {
|
|
prefixCls,
|
|
direction
|
|
} = useConfigInject("checkbox", props);
|
|
const groupPrefixCls = computed(() => `${prefixCls.value}-group`);
|
|
const [wrapSSR, hashId] = useStyle(groupPrefixCls);
|
|
const mergedValue = ref((props.value === void 0 ? props.defaultValue : props.value) || []);
|
|
watch(() => props.value, () => {
|
|
mergedValue.value = props.value || [];
|
|
});
|
|
const options = computed(() => {
|
|
return props.options.map((option) => {
|
|
if (typeof option === "string" || typeof option === "number") {
|
|
return {
|
|
label: option,
|
|
value: option
|
|
};
|
|
}
|
|
return option;
|
|
});
|
|
});
|
|
const triggerUpdate = ref(Symbol());
|
|
const registeredValuesMap = ref(/* @__PURE__ */ new Map());
|
|
const cancelValue = (id) => {
|
|
registeredValuesMap.value.delete(id);
|
|
triggerUpdate.value = Symbol();
|
|
};
|
|
const registerValue = (id, value) => {
|
|
registeredValuesMap.value.set(id, value);
|
|
triggerUpdate.value = Symbol();
|
|
};
|
|
const registeredValues = ref(/* @__PURE__ */ new Map());
|
|
watch(triggerUpdate, () => {
|
|
const valuseMap = /* @__PURE__ */ new Map();
|
|
for (const value of registeredValuesMap.value.values()) {
|
|
valuseMap.set(value, true);
|
|
}
|
|
registeredValues.value = valuseMap;
|
|
});
|
|
const toggleOption = (option) => {
|
|
const optionIndex = mergedValue.value.indexOf(option.value);
|
|
const value = [...mergedValue.value];
|
|
if (optionIndex === -1) {
|
|
value.push(option.value);
|
|
} else {
|
|
value.splice(optionIndex, 1);
|
|
}
|
|
if (props.value === void 0) {
|
|
mergedValue.value = value;
|
|
}
|
|
const val = value.filter((val2) => registeredValues.value.has(val2)).sort((a, b) => {
|
|
const indexA = options.value.findIndex((opt) => opt.value === a);
|
|
const indexB = options.value.findIndex((opt) => opt.value === b);
|
|
return indexA - indexB;
|
|
});
|
|
emit("update:value", val);
|
|
emit("change", val);
|
|
formItemContext.onFieldChange();
|
|
};
|
|
provide(CheckboxGroupContextKey, {
|
|
cancelValue,
|
|
registerValue,
|
|
toggleOption,
|
|
mergedValue,
|
|
name: computed(() => props.name),
|
|
disabled: computed(() => props.disabled)
|
|
});
|
|
expose({
|
|
mergedValue
|
|
});
|
|
return () => {
|
|
var _a;
|
|
const {
|
|
id = formItemContext.id.value
|
|
} = props;
|
|
let children = null;
|
|
if (options.value && options.value.length > 0) {
|
|
children = options.value.map((option) => {
|
|
var _a2;
|
|
return createVNode(Checkbox, {
|
|
"prefixCls": prefixCls.value,
|
|
"key": option.value.toString(),
|
|
"disabled": "disabled" in option ? option.disabled : props.disabled,
|
|
"indeterminate": option.indeterminate,
|
|
"value": option.value,
|
|
"checked": mergedValue.value.indexOf(option.value) !== -1,
|
|
"onChange": option.onChange,
|
|
"class": `${groupPrefixCls.value}-item`
|
|
}, {
|
|
default: () => [slots.label !== void 0 ? (_a2 = slots.label) === null || _a2 === void 0 ? void 0 : _a2.call(slots, option) : option.label]
|
|
});
|
|
});
|
|
}
|
|
return wrapSSR(createVNode("div", _objectSpread$1(_objectSpread$1({}, attrs), {}, {
|
|
"class": [groupPrefixCls.value, {
|
|
[`${groupPrefixCls.value}-rtl`]: direction.value === "rtl"
|
|
}, attrs.class, hashId.value],
|
|
"id": id
|
|
}), [children || ((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots))]));
|
|
};
|
|
}
|
|
});
|
|
Checkbox.Group = CheckboxGroup;
|
|
Checkbox.install = function(app) {
|
|
app.component(Checkbox.name, Checkbox);
|
|
app.component(CheckboxGroup.name, CheckboxGroup);
|
|
return app;
|
|
};
|
|
function onMountedOrActivated(hook) {
|
|
onActivated(() => {
|
|
});
|
|
}
|
|
var width;
|
|
var height;
|
|
function useWindowSize() {
|
|
if (!width) {
|
|
width = ref(0);
|
|
height = ref(0);
|
|
}
|
|
return { width, height };
|
|
}
|
|
var overflowScrollReg = /scroll|auto|overlay/i;
|
|
var defaultRoot = void 0;
|
|
function isElement(node) {
|
|
const ELEMENT_NODE_TYPE = 1;
|
|
return node.tagName !== "HTML" && node.tagName !== "BODY" && node.nodeType === ELEMENT_NODE_TYPE;
|
|
}
|
|
function getScrollParent(el, root = defaultRoot) {
|
|
let node = el;
|
|
while (node && node !== root && isElement(node)) {
|
|
const { overflowY } = (void 0).getComputedStyle(node);
|
|
if (overflowScrollReg.test(overflowY)) {
|
|
return node;
|
|
}
|
|
node = node.parentNode;
|
|
}
|
|
return root;
|
|
}
|
|
const stopPropagation = (event) => event.stopPropagation();
|
|
function preventDefault(event, isStopPropagation) {
|
|
if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
|
event.preventDefault();
|
|
}
|
|
{
|
|
stopPropagation(event);
|
|
}
|
|
}
|
|
useWindowSize();
|
|
const HAPTICS_FEEDBACK = "van-haptics-feedback";
|
|
const TAP_OFFSET = 5;
|
|
function callInterceptor(interceptor, {
|
|
args = [],
|
|
done,
|
|
canceled,
|
|
error
|
|
}) {
|
|
if (interceptor) {
|
|
const returnVal = interceptor.apply(null, args);
|
|
if (isPromise(returnVal)) {
|
|
returnVal.then((value) => {
|
|
if (value) {
|
|
done();
|
|
} else if (canceled) {
|
|
canceled();
|
|
}
|
|
}).catch(error || noop);
|
|
} else if (returnVal) {
|
|
done();
|
|
} else if (canceled) {
|
|
canceled();
|
|
}
|
|
} else {
|
|
done();
|
|
}
|
|
}
|
|
const [name$5, bem$5] = createNamespace("badge");
|
|
const badgeProps = {
|
|
dot: Boolean,
|
|
max: numericProp,
|
|
tag: makeStringProp("div"),
|
|
color: String,
|
|
offset: Array,
|
|
content: numericProp,
|
|
showZero: truthProp,
|
|
position: makeStringProp("top-right")
|
|
};
|
|
var stdin_default$4 = defineComponent({
|
|
name: name$5,
|
|
props: badgeProps,
|
|
setup(props, {
|
|
slots
|
|
}) {
|
|
const hasContent = () => {
|
|
if (slots.content) {
|
|
return true;
|
|
}
|
|
const {
|
|
content,
|
|
showZero
|
|
} = props;
|
|
return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
|
|
};
|
|
const renderContent = () => {
|
|
const {
|
|
dot,
|
|
max,
|
|
content
|
|
} = props;
|
|
if (!dot && hasContent()) {
|
|
if (slots.content) {
|
|
return slots.content();
|
|
}
|
|
if (isDef(max) && isNumeric(content) && +content > +max) {
|
|
return `${max}+`;
|
|
}
|
|
return content;
|
|
}
|
|
};
|
|
const getOffsetWithMinusString = (val) => val.startsWith("-") ? val.replace("-", "") : `-${val}`;
|
|
const style = computed(() => {
|
|
const style2 = {
|
|
background: props.color
|
|
};
|
|
if (props.offset) {
|
|
const [x, y] = props.offset;
|
|
const {
|
|
position
|
|
} = props;
|
|
const [offsetY, offsetX] = position.split("-");
|
|
if (slots.default) {
|
|
if (typeof y === "number") {
|
|
style2[offsetY] = addUnit(offsetY === "top" ? y : -y);
|
|
} else {
|
|
style2[offsetY] = offsetY === "top" ? addUnit(y) : getOffsetWithMinusString(y);
|
|
}
|
|
if (typeof x === "number") {
|
|
style2[offsetX] = addUnit(offsetX === "left" ? x : -x);
|
|
} else {
|
|
style2[offsetX] = offsetX === "left" ? addUnit(x) : getOffsetWithMinusString(x);
|
|
}
|
|
} else {
|
|
style2.marginTop = addUnit(y);
|
|
style2.marginLeft = addUnit(x);
|
|
}
|
|
}
|
|
return style2;
|
|
});
|
|
const renderBadge = () => {
|
|
if (hasContent() || props.dot) {
|
|
return createVNode("div", {
|
|
"class": bem$5([props.position, {
|
|
dot: props.dot,
|
|
fixed: !!slots.default
|
|
}]),
|
|
"style": style.value
|
|
}, [renderContent()]);
|
|
}
|
|
};
|
|
return () => {
|
|
if (slots.default) {
|
|
const {
|
|
tag
|
|
} = props;
|
|
return createVNode(tag, {
|
|
"class": bem$5("wrapper")
|
|
}, {
|
|
default: () => [slots.default(), renderBadge()]
|
|
});
|
|
}
|
|
return renderBadge();
|
|
};
|
|
}
|
|
});
|
|
const Badge = withInstall(stdin_default$4);
|
|
let globalZIndex = 2e3;
|
|
const useGlobalZIndex = () => ++globalZIndex;
|
|
const setGlobalZIndex = (val) => {
|
|
globalZIndex = val;
|
|
};
|
|
const [name$4, bem$4] = createNamespace("config-provider");
|
|
const CONFIG_PROVIDER_KEY = Symbol(name$4);
|
|
const configProviderProps = {
|
|
tag: makeStringProp("div"),
|
|
theme: makeStringProp("light"),
|
|
zIndex: Number,
|
|
themeVars: Object,
|
|
themeVarsDark: Object,
|
|
themeVarsLight: Object,
|
|
themeVarsScope: makeStringProp("local"),
|
|
iconPrefix: String
|
|
};
|
|
function insertDash(str) {
|
|
return str.replace(/([a-zA-Z])(\d)/g, "$1-$2");
|
|
}
|
|
function mapThemeVarsToCSSVars(themeVars) {
|
|
const cssVars = {};
|
|
Object.keys(themeVars).forEach((key) => {
|
|
const formattedKey = insertDash(kebabCase(key));
|
|
cssVars[`--van-${formattedKey}`] = themeVars[key];
|
|
});
|
|
return cssVars;
|
|
}
|
|
defineComponent({
|
|
name: name$4,
|
|
props: configProviderProps,
|
|
setup(props, {
|
|
slots
|
|
}) {
|
|
const style = computed(() => mapThemeVarsToCSSVars(extend({}, props.themeVars, props.theme === "dark" ? props.themeVarsDark : props.themeVarsLight)));
|
|
provide(CONFIG_PROVIDER_KEY, props);
|
|
watchEffect(() => {
|
|
if (props.zIndex !== void 0) {
|
|
setGlobalZIndex(props.zIndex);
|
|
}
|
|
});
|
|
return () => createVNode(props.tag, {
|
|
"class": bem$4(),
|
|
"style": props.themeVarsScope === "local" ? style.value : void 0
|
|
}, {
|
|
default: () => {
|
|
var _a;
|
|
return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
|
}
|
|
});
|
|
}
|
|
});
|
|
const [name$3, bem$3] = createNamespace("icon");
|
|
const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
|
|
const iconProps = {
|
|
dot: Boolean,
|
|
tag: makeStringProp("i"),
|
|
name: String,
|
|
size: numericProp,
|
|
badge: numericProp,
|
|
color: String,
|
|
badgeProps: Object,
|
|
classPrefix: String
|
|
};
|
|
var stdin_default$3 = defineComponent({
|
|
name: name$3,
|
|
props: iconProps,
|
|
setup(props, {
|
|
slots
|
|
}) {
|
|
const config = inject(CONFIG_PROVIDER_KEY, null);
|
|
const classPrefix = computed(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$3());
|
|
return () => {
|
|
const {
|
|
tag,
|
|
dot,
|
|
name: name2,
|
|
size,
|
|
badge,
|
|
color
|
|
} = props;
|
|
const isImageIcon = isImage(name2);
|
|
return createVNode(Badge, mergeProps({
|
|
"dot": dot,
|
|
"tag": tag,
|
|
"class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
|
|
"style": {
|
|
color,
|
|
fontSize: addUnit(size)
|
|
},
|
|
"content": badge
|
|
}, props.badgeProps), {
|
|
default: () => {
|
|
var _a;
|
|
return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && createVNode("img", {
|
|
"class": bem$3("image"),
|
|
"src": name2
|
|
}, null)];
|
|
}
|
|
});
|
|
};
|
|
}
|
|
});
|
|
const Icon = withInstall(stdin_default$3);
|
|
const popupSharedProps = {
|
|
// whether to show popup
|
|
show: Boolean,
|
|
// z-index
|
|
zIndex: numericProp,
|
|
// whether to show overlay
|
|
overlay: truthProp,
|
|
// transition duration
|
|
duration: numericProp,
|
|
// teleport
|
|
teleport: [String, Object],
|
|
// prevent body scroll
|
|
lockScroll: truthProp,
|
|
// whether to lazy render
|
|
lazyRender: truthProp,
|
|
// callback function before close
|
|
beforeClose: Function,
|
|
// overlay custom style
|
|
overlayStyle: Object,
|
|
// overlay custom class name
|
|
overlayClass: unknownProp,
|
|
// Initial rendering animation
|
|
transitionAppear: Boolean,
|
|
// whether to close popup when overlay is clicked
|
|
closeOnClickOverlay: truthProp
|
|
};
|
|
const popupSharedPropKeys = Object.keys(
|
|
popupSharedProps
|
|
);
|
|
function useExpose(apis) {
|
|
const instance = getCurrentInstance();
|
|
if (instance) {
|
|
extend(instance.proxy, apis);
|
|
}
|
|
}
|
|
function getDirection(x, y) {
|
|
if (x > y) {
|
|
return "horizontal";
|
|
}
|
|
if (y > x) {
|
|
return "vertical";
|
|
}
|
|
return "";
|
|
}
|
|
function useTouch() {
|
|
const startX = ref(0);
|
|
const startY = ref(0);
|
|
const deltaX = ref(0);
|
|
const deltaY = ref(0);
|
|
const offsetX = ref(0);
|
|
const offsetY = ref(0);
|
|
const direction = ref("");
|
|
const isTap = ref(true);
|
|
const isVertical = () => direction.value === "vertical";
|
|
const isHorizontal = () => direction.value === "horizontal";
|
|
const reset = () => {
|
|
deltaX.value = 0;
|
|
deltaY.value = 0;
|
|
offsetX.value = 0;
|
|
offsetY.value = 0;
|
|
direction.value = "";
|
|
isTap.value = true;
|
|
};
|
|
const start = (event) => {
|
|
reset();
|
|
startX.value = event.touches[0].clientX;
|
|
startY.value = event.touches[0].clientY;
|
|
};
|
|
const move = (event) => {
|
|
const touch = event.touches[0];
|
|
deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
|
|
deltaY.value = touch.clientY - startY.value;
|
|
offsetX.value = Math.abs(deltaX.value);
|
|
offsetY.value = Math.abs(deltaY.value);
|
|
const LOCK_DIRECTION_DISTANCE = 10;
|
|
if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
|
|
direction.value = getDirection(offsetX.value, offsetY.value);
|
|
}
|
|
if (isTap.value && (offsetX.value > TAP_OFFSET || offsetY.value > TAP_OFFSET)) {
|
|
isTap.value = false;
|
|
}
|
|
};
|
|
return {
|
|
move,
|
|
start,
|
|
reset,
|
|
startX,
|
|
startY,
|
|
deltaX,
|
|
deltaY,
|
|
offsetX,
|
|
offsetY,
|
|
direction,
|
|
isVertical,
|
|
isHorizontal,
|
|
isTap
|
|
};
|
|
}
|
|
let totalLockCount = 0;
|
|
const BODY_LOCK_CLASS = "van-overflow-hidden";
|
|
function useLockScroll(rootRef, shouldLock) {
|
|
const touch = useTouch();
|
|
const DIRECTION_UP = "01";
|
|
const DIRECTION_DOWN = "10";
|
|
const onTouchMove = (event) => {
|
|
touch.move(event);
|
|
const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
|
|
const el = getScrollParent(
|
|
event.target,
|
|
rootRef.value
|
|
);
|
|
const { scrollHeight, offsetHeight, scrollTop } = el;
|
|
let status = "11";
|
|
if (scrollTop === 0) {
|
|
status = offsetHeight >= scrollHeight ? "00" : "01";
|
|
} else if (scrollTop + offsetHeight >= scrollHeight) {
|
|
status = "10";
|
|
}
|
|
if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
|
|
preventDefault(event);
|
|
}
|
|
};
|
|
const lock = () => {
|
|
(void 0).addEventListener("touchstart", touch.start);
|
|
(void 0).addEventListener("touchmove", onTouchMove, { passive: false });
|
|
if (!totalLockCount) {
|
|
(void 0).body.classList.add(BODY_LOCK_CLASS);
|
|
}
|
|
totalLockCount++;
|
|
};
|
|
const unlock = () => {
|
|
if (totalLockCount) {
|
|
(void 0).removeEventListener("touchstart", touch.start);
|
|
(void 0).removeEventListener("touchmove", onTouchMove);
|
|
totalLockCount--;
|
|
if (!totalLockCount) {
|
|
(void 0).body.classList.remove(BODY_LOCK_CLASS);
|
|
}
|
|
}
|
|
};
|
|
onMountedOrActivated();
|
|
watch(shouldLock, (value) => {
|
|
value ? lock() : unlock();
|
|
});
|
|
}
|
|
function useLazyRender(show) {
|
|
const inited = ref(false);
|
|
watch(
|
|
show,
|
|
(value) => {
|
|
if (value) {
|
|
inited.value = value;
|
|
}
|
|
},
|
|
{ immediate: true }
|
|
);
|
|
return (render) => () => inited.value ? render() : null;
|
|
}
|
|
const POPUP_TOGGLE_KEY = Symbol();
|
|
const useScopeId = () => {
|
|
var _a;
|
|
const { scopeId } = ((_a = getCurrentInstance()) == null ? void 0 : _a.vnode) || {};
|
|
return scopeId ? { [scopeId]: "" } : null;
|
|
};
|
|
const [name$2, bem$2] = createNamespace("overlay");
|
|
const overlayProps = {
|
|
show: Boolean,
|
|
zIndex: numericProp,
|
|
duration: numericProp,
|
|
className: unknownProp,
|
|
lockScroll: truthProp,
|
|
lazyRender: truthProp,
|
|
customStyle: Object,
|
|
teleport: [String, Object]
|
|
};
|
|
var stdin_default$2 = defineComponent({
|
|
name: name$2,
|
|
inheritAttrs: false,
|
|
props: overlayProps,
|
|
setup(props, {
|
|
attrs,
|
|
slots
|
|
}) {
|
|
const root = ref();
|
|
const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
|
|
const renderOverlay = lazyRender(() => {
|
|
var _a;
|
|
const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
|
|
if (isDef(props.duration)) {
|
|
style.animationDuration = `${props.duration}s`;
|
|
}
|
|
return withDirectives(createVNode("div", mergeProps({
|
|
"ref": root,
|
|
"style": style,
|
|
"class": [bem$2(), props.className]
|
|
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vShow, props.show]]);
|
|
});
|
|
return () => {
|
|
const Content = createVNode(Transition, {
|
|
"name": "van-fade",
|
|
"appear": true
|
|
}, {
|
|
default: renderOverlay
|
|
});
|
|
if (props.teleport) {
|
|
return createVNode(Teleport, {
|
|
"to": props.teleport
|
|
}, {
|
|
default: () => [Content]
|
|
});
|
|
}
|
|
return Content;
|
|
};
|
|
}
|
|
});
|
|
const Overlay = withInstall(stdin_default$2);
|
|
const popupProps = extend({}, popupSharedProps, {
|
|
round: Boolean,
|
|
position: makeStringProp("center"),
|
|
closeIcon: makeStringProp("cross"),
|
|
closeable: Boolean,
|
|
transition: String,
|
|
iconPrefix: String,
|
|
closeOnPopstate: Boolean,
|
|
closeIconPosition: makeStringProp("top-right"),
|
|
destroyOnClose: Boolean,
|
|
safeAreaInsetTop: Boolean,
|
|
safeAreaInsetBottom: Boolean
|
|
});
|
|
const [name$1, bem$1] = createNamespace("popup");
|
|
var stdin_default$1 = defineComponent({
|
|
name: name$1,
|
|
inheritAttrs: false,
|
|
props: popupProps,
|
|
emits: ["open", "close", "opened", "closed", "keydown", "update:show", "clickOverlay", "clickCloseIcon"],
|
|
setup(props, {
|
|
emit,
|
|
attrs,
|
|
slots
|
|
}) {
|
|
let opened;
|
|
const zIndex = ref();
|
|
const popupRef = ref();
|
|
const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
|
|
const style = computed(() => {
|
|
const style2 = {
|
|
zIndex: zIndex.value
|
|
};
|
|
if (isDef(props.duration)) {
|
|
const key = props.position === "center" ? "animationDuration" : "transitionDuration";
|
|
style2[key] = `${props.duration}s`;
|
|
}
|
|
return style2;
|
|
});
|
|
const open = () => {
|
|
if (!opened) {
|
|
opened = true;
|
|
zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
|
|
emit("open");
|
|
}
|
|
};
|
|
const close = () => {
|
|
if (opened) {
|
|
callInterceptor(props.beforeClose, {
|
|
done() {
|
|
opened = false;
|
|
emit("close");
|
|
emit("update:show", false);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
const onClickOverlay = (event) => {
|
|
emit("clickOverlay", event);
|
|
if (props.closeOnClickOverlay) {
|
|
close();
|
|
}
|
|
};
|
|
const renderOverlay = () => {
|
|
if (props.overlay) {
|
|
return createVNode(Overlay, mergeProps({
|
|
"show": props.show,
|
|
"class": props.overlayClass,
|
|
"zIndex": zIndex.value,
|
|
"duration": props.duration,
|
|
"customStyle": props.overlayStyle,
|
|
"role": props.closeOnClickOverlay ? "button" : void 0,
|
|
"tabindex": props.closeOnClickOverlay ? 0 : void 0
|
|
}, useScopeId(), {
|
|
"onClick": onClickOverlay
|
|
}), {
|
|
default: slots["overlay-content"]
|
|
});
|
|
}
|
|
};
|
|
const onClickCloseIcon = (event) => {
|
|
emit("clickCloseIcon", event);
|
|
close();
|
|
};
|
|
const renderCloseIcon = () => {
|
|
if (props.closeable) {
|
|
return createVNode(Icon, {
|
|
"role": "button",
|
|
"tabindex": 0,
|
|
"name": props.closeIcon,
|
|
"class": [bem$1("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
|
|
"classPrefix": props.iconPrefix,
|
|
"onClick": onClickCloseIcon
|
|
}, null);
|
|
}
|
|
};
|
|
let timer;
|
|
const onOpened = () => {
|
|
if (timer) clearTimeout(timer);
|
|
timer = setTimeout(() => {
|
|
emit("opened");
|
|
});
|
|
};
|
|
const onClosed = () => emit("closed");
|
|
const onKeydown = (event) => emit("keydown", event);
|
|
const renderPopup = lazyRender(() => {
|
|
var _a;
|
|
const {
|
|
destroyOnClose,
|
|
round,
|
|
position,
|
|
safeAreaInsetTop,
|
|
safeAreaInsetBottom,
|
|
show
|
|
} = props;
|
|
if (!show && destroyOnClose) {
|
|
return;
|
|
}
|
|
return withDirectives(createVNode("div", mergeProps({
|
|
"ref": popupRef,
|
|
"style": style.value,
|
|
"role": "dialog",
|
|
"tabindex": 0,
|
|
"class": [bem$1({
|
|
round,
|
|
[position]: position
|
|
}), {
|
|
"van-safe-area-top": safeAreaInsetTop,
|
|
"van-safe-area-bottom": safeAreaInsetBottom
|
|
}],
|
|
"onKeydown": onKeydown
|
|
}, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vShow, show]]);
|
|
});
|
|
const renderTransition = () => {
|
|
const {
|
|
position,
|
|
transition,
|
|
transitionAppear
|
|
} = props;
|
|
const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
|
|
return createVNode(Transition, {
|
|
"name": transition || name2,
|
|
"appear": transitionAppear,
|
|
"onAfterEnter": onOpened,
|
|
"onAfterLeave": onClosed
|
|
}, {
|
|
default: renderPopup
|
|
});
|
|
};
|
|
watch(() => props.show, (show) => {
|
|
if (show && !opened) {
|
|
open();
|
|
if (attrs.tabindex === 0) {
|
|
nextTick(() => {
|
|
var _a;
|
|
(_a = popupRef.value) == null ? void 0 : _a.focus();
|
|
});
|
|
}
|
|
}
|
|
if (!show && opened) {
|
|
opened = false;
|
|
emit("close");
|
|
}
|
|
});
|
|
useExpose({
|
|
popupRef
|
|
});
|
|
useLockScroll(popupRef, () => props.show && props.lockScroll);
|
|
provide(POPUP_TOGGLE_KEY, () => props.show);
|
|
return () => {
|
|
if (props.teleport) {
|
|
return createVNode(Teleport, {
|
|
"to": props.teleport
|
|
}, {
|
|
default: () => [renderOverlay(), renderTransition()]
|
|
});
|
|
}
|
|
return createVNode(Fragment, null, [renderOverlay(), renderTransition()]);
|
|
};
|
|
}
|
|
});
|
|
const Popup = withInstall(stdin_default$1);
|
|
const Loading = withInstall(stdin_default$5);
|
|
const [name, bem] = createNamespace("action-sheet");
|
|
const actionSheetProps = extend({}, popupSharedProps, {
|
|
title: String,
|
|
round: truthProp,
|
|
actions: makeArrayProp(),
|
|
closeIcon: makeStringProp("cross"),
|
|
closeable: truthProp,
|
|
cancelText: String,
|
|
description: String,
|
|
closeOnPopstate: truthProp,
|
|
closeOnClickAction: Boolean,
|
|
safeAreaInsetBottom: truthProp
|
|
});
|
|
const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
|
|
var stdin_default = defineComponent({
|
|
name,
|
|
props: actionSheetProps,
|
|
emits: ["select", "cancel", "update:show"],
|
|
setup(props, {
|
|
slots,
|
|
emit
|
|
}) {
|
|
const updateShow = (show) => emit("update:show", show);
|
|
const onCancel = () => {
|
|
updateShow(false);
|
|
emit("cancel");
|
|
};
|
|
const renderHeader = () => {
|
|
if (props.title) {
|
|
return createVNode("div", {
|
|
"class": bem("header")
|
|
}, [props.title, props.closeable && createVNode(Icon, {
|
|
"name": props.closeIcon,
|
|
"class": [bem("close"), HAPTICS_FEEDBACK],
|
|
"onClick": onCancel
|
|
}, null)]);
|
|
}
|
|
};
|
|
const renderCancel = () => {
|
|
if (slots.cancel || props.cancelText) {
|
|
return [createVNode("div", {
|
|
"class": bem("gap")
|
|
}, null), createVNode("button", {
|
|
"type": "button",
|
|
"class": bem("cancel"),
|
|
"onClick": onCancel
|
|
}, [slots.cancel ? slots.cancel() : props.cancelText])];
|
|
}
|
|
};
|
|
const renderIcon = (action) => {
|
|
if (action.icon) {
|
|
return createVNode(Icon, {
|
|
"class": bem("item-icon"),
|
|
"name": action.icon
|
|
}, null);
|
|
}
|
|
};
|
|
const renderActionContent = (action, index) => {
|
|
if (action.loading) {
|
|
return createVNode(Loading, {
|
|
"class": bem("loading-icon")
|
|
}, null);
|
|
}
|
|
if (slots.action) {
|
|
return slots.action({
|
|
action,
|
|
index
|
|
});
|
|
}
|
|
return [createVNode("span", {
|
|
"class": bem("name")
|
|
}, [action.name]), action.subname && createVNode("div", {
|
|
"class": bem("subname")
|
|
}, [action.subname])];
|
|
};
|
|
const renderAction = (action, index) => {
|
|
const {
|
|
color,
|
|
loading,
|
|
callback,
|
|
disabled,
|
|
className
|
|
} = action;
|
|
const onClick = () => {
|
|
if (disabled || loading) {
|
|
return;
|
|
}
|
|
if (callback) {
|
|
callback(action);
|
|
}
|
|
if (props.closeOnClickAction) {
|
|
updateShow(false);
|
|
}
|
|
nextTick(() => emit("select", action, index));
|
|
};
|
|
return createVNode("button", {
|
|
"type": "button",
|
|
"style": {
|
|
color
|
|
},
|
|
"class": [bem("item", {
|
|
loading,
|
|
disabled
|
|
}), className],
|
|
"onClick": onClick
|
|
}, [renderIcon(action), renderActionContent(action, index)]);
|
|
};
|
|
const renderDescription = () => {
|
|
if (props.description || slots.description) {
|
|
const content = slots.description ? slots.description() : props.description;
|
|
return createVNode("div", {
|
|
"class": bem("description")
|
|
}, [content]);
|
|
}
|
|
};
|
|
return () => createVNode(Popup, mergeProps({
|
|
"class": bem(),
|
|
"position": "bottom",
|
|
"onUpdate:show": updateShow
|
|
}, pick(props, popupInheritKeys)), {
|
|
default: () => {
|
|
var _a;
|
|
return [renderHeader(), renderDescription(), createVNode("div", {
|
|
"class": bem("content")
|
|
}, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
export { Collapse as C, __nuxt_component_6 as _, CheckboxGroup as a, Checkbox as b, stdin_default as s };
|
|
//# sourceMappingURL=index-Dd1xdhY3.mjs.map
|