antdv-next 1.4.6 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_util/hooks/useMergeSemantic.d.ts +7 -4
- package/dist/_util/hooks/useMergeSemantic.js +8 -3
- package/dist/_util/is.d.ts +9 -1
- package/dist/_util/is.js +25 -2
- package/dist/_util/scrollTo.d.ts +1 -1
- package/dist/_util/scrollTo.js +17 -5
- package/dist/_util/vueNode.d.ts +6 -2
- package/dist/alert/Alert.js +1 -1
- package/dist/alert/style/index.d.ts +5 -0
- package/dist/alert/style/index.js +2 -1
- package/dist/antd-with-locales.esm.js +12939 -12342
- package/dist/antd-with-locales.js +80 -80
- package/dist/antd.css +1 -1
- package/dist/antd.esm.js +10123 -9740
- package/dist/antd.js +55 -55
- package/dist/app/App.js +2 -1
- package/dist/avatar/AvatarGroup.d.ts +4 -1
- package/dist/avatar/AvatarGroup.js +6 -4
- package/dist/avatar/index.d.ts +2 -2
- package/dist/badge/Ribbon.d.ts +4 -1
- package/dist/badge/Ribbon.js +11 -11
- package/dist/badge/index.d.ts +3 -2
- package/dist/badge/index.js +26 -24
- package/dist/border-beam/BorderBeam.d.ts +4 -0
- package/dist/border-beam/BorderBeam.js +48 -12
- package/dist/border-beam/hooks/useBorderSize.d.ts +3 -7
- package/dist/border-beam/hooks/useBorderSize.js +31 -25
- package/dist/border-beam/style/index.js +13 -12
- package/dist/border-beam/util.d.ts +4 -1
- package/dist/border-beam/util.js +7 -2
- package/dist/breadcrumb/Breadcrumb.d.ts +4 -1
- package/dist/breadcrumb/Breadcrumb.js +12 -7
- package/dist/breadcrumb/index.d.ts +2 -2
- package/dist/button/Button.js +5 -14
- package/dist/button/style/index.js +0 -1
- package/dist/calendar/generateCalendar.d.ts +4 -1
- package/dist/calendar/generateCalendar.js +8 -5
- package/dist/calendar/index.d.ts +2 -2
- package/dist/calendar/locale/sq_AL.d.ts +2 -0
- package/dist/calendar/locale/sq_AL.js +5 -0
- package/dist/card/CardGrid.d.ts +4 -1
- package/dist/card/CardGrid.js +7 -4
- package/dist/card/CardMeta.d.ts +4 -1
- package/dist/card/CardMeta.js +5 -3
- package/dist/card/index.d.ts +3 -3
- package/dist/carousel/index.d.ts +1 -0
- package/dist/carousel/index.js +8 -8
- package/dist/checkbox/Group.js +3 -3
- package/dist/color-picker/ColorPicker.js +4 -7
- package/dist/components.d.ts +27 -21
- package/dist/components.js +6 -3
- package/dist/config-provider/context.d.ts +28 -8
- package/dist/config-provider/define.d.ts +4 -1
- package/dist/config-provider/index.js +29 -0
- package/dist/date-picker/generatePicker/generateRangePicker.js +2 -5
- package/dist/date-picker/generatePicker/generateSinglePicker.js +2 -5
- package/dist/date-picker/generatePicker/useComponents.d.ts +1 -1
- package/dist/date-picker/hooks/useMergedPickerSemantic.d.ts +1 -1
- package/dist/date-picker/hooks/useMergedPickerSemantic.js +7 -3
- package/dist/date-picker/locale/sq_AL.d.ts +6 -0
- package/dist/date-picker/locale/sq_AL.js +72 -0
- package/dist/date-picker/locale/zh_TW.js +2 -2
- package/dist/date-picker/util.d.ts +2 -2
- package/dist/descriptions/hooks/useItems.d.ts +4 -4
- package/dist/descriptions/index.d.ts +4 -1
- package/dist/descriptions/index.js +5 -2
- package/dist/divider/index.d.ts +4 -1
- package/dist/divider/index.js +9 -6
- package/dist/drawer/DrawerPanel.js +5 -3
- package/dist/drawer/index.js +9 -13
- package/dist/drawer/style/index.js +1 -0
- package/dist/dropdown/dropdown.js +4 -6
- package/dist/empty/index.d.ts +4 -1
- package/dist/empty/index.js +5 -2
- package/dist/float-button/BackTop.d.ts +2 -0
- package/dist/float-button/BackTop.js +27 -44
- package/dist/float-button/FloatButtonGroup.d.ts +4 -1
- package/dist/float-button/FloatButtonGroup.js +5 -4
- package/dist/float-button/hooks/useScroll.d.ts +16 -0
- package/dist/float-button/hooks/useScroll.js +80 -0
- package/dist/float-button/index.d.ts +2 -2
- package/dist/float-button/style/button.js +17 -0
- package/dist/form/ErrorList.js +2 -2
- package/dist/form/FormItem/index.js +23 -24
- package/dist/form/context.d.ts +1 -1
- package/dist/form/hooks/useVariant.d.ts +2 -2
- package/dist/form/hooks/useVariant.js +15 -5
- package/dist/form/types.d.ts +11 -3
- package/dist/form/utils/validateUtil.js +4 -0
- package/dist/image/hooks/usePreviewConfig.d.ts +6 -5
- package/dist/image/index.js +8 -9
- package/dist/index.d.ts +27 -21
- package/dist/index.js +3 -2
- package/dist/input/OTP/index.js +6 -3
- package/dist/input/Password.js +4 -1
- package/dist/input/Search.js +11 -6
- package/dist/input/index.d.ts +1 -1
- package/dist/input/style/token.js +2 -1
- package/dist/input/style/variants.js +1 -1
- package/dist/layout/Sider.d.ts +2 -0
- package/dist/layout/Sider.js +14 -2
- package/dist/listy/index.d.ts +12 -0
- package/dist/listy/index.js +119 -0
- package/dist/listy/interface.d.ts +21 -0
- package/dist/listy/interface.js +1 -0
- package/dist/listy/style/index.d.ts +23 -0
- package/dist/listy/style/index.js +57 -0
- package/dist/locale/sq_AL.d.ts +5 -0
- package/dist/locale/sq_AL.js +151 -0
- package/dist/locale/zh_TW.js +41 -41
- package/dist/masonry/Masonry.js +4 -4
- package/dist/mentions/index.d.ts +1 -0
- package/dist/mentions/index.js +4 -0
- package/dist/message/useMessage.js +4 -4
- package/dist/modal/PurePanel.js +4 -7
- package/dist/notification/useNotification.js +4 -5
- package/dist/package.js +1 -1
- package/dist/package.json.d.ts +1 -0
- package/dist/pagination/Pagination.js +14 -6
- package/dist/pagination/index.d.ts +2 -2
- package/dist/pagination/interface.d.ts +20 -3
- package/dist/popconfirm/index.js +17 -8
- package/dist/popover/PurePanel.js +10 -0
- package/dist/popover/index.js +24 -16
- package/dist/qrcode/index.d.ts +4 -1
- package/dist/qrcode/index.js +16 -13
- package/dist/rate/style/index.js +12 -9
- package/dist/result/index.d.ts +4 -1
- package/dist/result/index.js +7 -4
- package/dist/select/style/dropdown.js +4 -0
- package/dist/select/style/select-input.js +1 -1
- package/dist/select/style/token.js +4 -2
- package/dist/skeleton/Skeleton.d.ts +4 -1
- package/dist/skeleton/Skeleton.js +10 -4
- package/dist/skeleton/index.d.ts +2 -2
- package/dist/slider/SliderTooltip.js +5 -0
- package/dist/slider/index.d.ts +5 -1
- package/dist/slider/index.js +9 -9
- package/dist/space/Compact.d.ts +4 -1
- package/dist/space/Compact.js +8 -3
- package/dist/space/index.d.ts +2 -2
- package/dist/space/index.js +3 -3
- package/dist/spin/index.d.ts +4 -1
- package/dist/spin/index.js +7 -5
- package/dist/splitter/SplitBar.js +1 -12
- package/dist/splitter/Splitter.d.ts +4 -1
- package/dist/splitter/Splitter.js +4 -2
- package/dist/splitter/index.d.ts +2 -2
- package/dist/splitter/style/index.js +2 -1
- package/dist/statistic/Statistic.d.ts +4 -1
- package/dist/statistic/index.d.ts +2 -2
- package/dist/steps/index.js +6 -8
- package/dist/steps/style/index.js +2 -1
- package/dist/table/style/virtual.js +4 -0
- package/dist/table/util.d.ts +1 -1
- package/dist/tag/hooks/useColor.d.ts +1 -1
- package/dist/tag/index.js +3 -3
- package/dist/theme/interface/components.d.ts +70 -68
- package/dist/theme/interface/seeds.d.ts +8 -0
- package/dist/theme/themes/seed.js +1 -0
- package/dist/theme/util/alias.js +1 -1
- package/dist/time-picker/locale/sq_AL.d.ts +5 -0
- package/dist/time-picker/locale/sq_AL.js +7 -0
- package/dist/timeline/Timeline.js +5 -7
- package/dist/tooltip/PurePanel.js +5 -0
- package/dist/tooltip/index.d.ts +1 -0
- package/dist/tooltip/index.js +27 -13
- package/dist/tour/PurePanel.js +0 -8
- package/dist/tour/index.js +10 -13
- package/dist/tour/interface.d.ts +4 -6
- package/dist/tour/panelRender.js +8 -2
- package/dist/transfer/Transfer.d.ts +4 -1
- package/dist/transfer/Transfer.js +5 -2
- package/dist/transfer/index.d.ts +2 -2
- package/dist/tree/index.d.ts +3 -2
- package/dist/tree/index.js +3 -2
- package/dist/tree/style/index.js +4 -0
- package/dist/typography/Base/EllipsisTooltip.d.ts +6 -1
- package/dist/typography/Base/EllipsisTooltip.js +2 -2
- package/dist/typography/Base/index.js +9 -26
- package/dist/typography/hooks/useCopyClick.d.ts +1 -1
- package/dist/typography/hooks/useCopyClick.js +5 -15
- package/dist/upload/Upload.js +7 -9
- package/dist/upload/UploadList/ListItem.js +4 -12
- package/dist/upload/index.d.ts +2 -2
- package/dist/watermark/index.d.ts +4 -1
- package/dist/watermark/index.js +2 -1
- package/global.d.ts +1 -0
- package/package.json +10 -9
- package/web-tags.json +1384 -1338
- package/web-types.json +4584 -4467
- package/dist/slider/useRafLock.d.ts +0 -5
- package/dist/slider/useRafLock.js +0 -23
package/dist/drawer/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { devUseWarning, isDev } from "../_util/warning.js";
|
|
|
2
2
|
import { useComponentBaseConfig } from "../config-provider/context.js";
|
|
3
3
|
import { ContextIsolator } from "../_util/ContextIsolator.js";
|
|
4
4
|
import { useMergedMask } from "../_util/hooks/useMergedMask.js";
|
|
5
|
-
import { getAttrStyleAndClass, useMergeSemantic, useToArr, useToProps } from "../_util/hooks/useMergeSemantic.js";
|
|
5
|
+
import { getAttrStyleAndClass, useMergeSemantic, useSemanticRootStyle, useToArr, useToProps } from "../_util/hooks/useMergeSemantic.js";
|
|
6
6
|
import { ZIndexProvider } from "../_util/zindexContext.js";
|
|
7
7
|
import { useZIndex } from "../_util/hooks/useZIndex.js";
|
|
8
8
|
import { toPropsRefs } from "../_util/tools.js";
|
|
@@ -69,10 +69,13 @@ const Drawer = /* @__PURE__ */ defineComponent((props, { slots, emit, attrs }) =
|
|
|
69
69
|
maskClosable: mergedMaskClosable.value
|
|
70
70
|
};
|
|
71
71
|
});
|
|
72
|
-
const
|
|
72
|
+
const contextSectionStyle = useSemanticRootStyle(contextStyle, "section");
|
|
73
|
+
const drawerSectionStyle = useSemanticRootStyle(computed(() => props.drawerStyle), "section");
|
|
74
|
+
const sectionStyle = useSemanticRootStyle(computed(() => attrs.style), "section");
|
|
75
|
+
const [mergedClassNames, mergedStyles] = useMergeSemantic(useToArr(contextClassNames, classes), useToArr(contextStyles, contextSectionStyle, styles, drawerSectionStyle, sectionStyle), useToProps(mergedProps));
|
|
73
76
|
return () => {
|
|
74
77
|
const { rootClass, maskStyle, drawerStyle, contentWrapperStyle, open, push, defaultSize, rootStyle, getContainer: customizeGetContainer, resizable, afterOpenChange, destroyOnClose, destroyOnHidden, size, ...rest } = props;
|
|
75
|
-
const { className, restAttrs
|
|
78
|
+
const { className, restAttrs } = getAttrStyleAndClass(attrs);
|
|
76
79
|
const maskMotion = {
|
|
77
80
|
name: getTransitionName(prefixCls.value, "mask-motion"),
|
|
78
81
|
appear: true
|
|
@@ -128,10 +131,7 @@ const Drawer = /* @__PURE__ */ defineComponent((props, { slots, emit, attrs }) =
|
|
|
128
131
|
...mergedStyles.value.mask,
|
|
129
132
|
...maskStyle
|
|
130
133
|
},
|
|
131
|
-
section:
|
|
132
|
-
...mergedStyles.value.section,
|
|
133
|
-
...drawerStyle
|
|
134
|
-
},
|
|
134
|
+
section: mergedStyles.value.section,
|
|
135
135
|
wrapper: {
|
|
136
136
|
...mergedStyles.value.wrapper,
|
|
137
137
|
...contentWrapperStyle
|
|
@@ -149,13 +149,9 @@ const Drawer = /* @__PURE__ */ defineComponent((props, { slots, emit, attrs }) =
|
|
|
149
149
|
panelRef.value = panel;
|
|
150
150
|
innerPanelRef(panel);
|
|
151
151
|
},
|
|
152
|
-
"style": {
|
|
153
|
-
...contextStyle.value,
|
|
154
|
-
...style
|
|
155
|
-
},
|
|
156
152
|
"rootStyle": {
|
|
157
|
-
...
|
|
158
|
-
...
|
|
153
|
+
...mergedStyles.value.root,
|
|
154
|
+
...rootStyle
|
|
159
155
|
},
|
|
160
156
|
"class": clsx(contextClassName.value, className),
|
|
161
157
|
"rootClassName": drawerClassName,
|
|
@@ -117,6 +117,7 @@ const genDrawerStyle = (token) => {
|
|
|
117
117
|
textRendering: "auto",
|
|
118
118
|
[`&${componentCls}-close-end`]: { marginInlineStart: marginXS },
|
|
119
119
|
[`&:not(${componentCls}-close-end)`]: { marginInlineEnd: marginXS },
|
|
120
|
+
"&:disabled": { pointerEvents: "none" },
|
|
120
121
|
"&:hover": {
|
|
121
122
|
color: colorIconHover,
|
|
122
123
|
backgroundColor: colorBgTextHover,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { devUseWarning } from "../_util/warning.js";
|
|
2
2
|
import { useComponentBaseConfig } from "../config-provider/context.js";
|
|
3
3
|
import useToken from "../theme/useToken.js";
|
|
4
|
-
import { useMergeSemantic, useToArr, useToProps } from "../_util/hooks/useMergeSemantic.js";
|
|
4
|
+
import { useMergeSemantic, useSemanticRootStyle, useToArr, useToProps } from "../_util/hooks/useMergeSemantic.js";
|
|
5
5
|
import { ZIndexProvider } from "../_util/zindexContext.js";
|
|
6
6
|
import { useZIndex } from "../_util/hooks/useZIndex.js";
|
|
7
7
|
import getPlacements from "../_util/placements.js";
|
|
@@ -27,7 +27,8 @@ const Dropdown = /* @__PURE__ */ defineComponent((props, { slots, emit, attrs })
|
|
|
27
27
|
const mergedProps = computed(() => {
|
|
28
28
|
return props;
|
|
29
29
|
});
|
|
30
|
-
const
|
|
30
|
+
const contextStyleRoot = useSemanticRootStyle(contextStyle);
|
|
31
|
+
const [mergedClassNames, mergedStyles] = useMergeSemantic(useToArr(contextClassNames, classes), useToArr(contextStyles, contextStyleRoot, styles), useToProps(mergedProps));
|
|
31
32
|
const memoPlacement = computed(() => {
|
|
32
33
|
const { placement } = props;
|
|
33
34
|
if (!placement) return direction.value === "rtl" ? "bottomRight" : "bottomLeft";
|
|
@@ -71,10 +72,7 @@ const Dropdown = /* @__PURE__ */ defineComponent((props, { slots, emit, attrs })
|
|
|
71
72
|
emit("openChange", false, { source: "menu" });
|
|
72
73
|
};
|
|
73
74
|
const mergedRootStyles = computed(() => {
|
|
74
|
-
return {
|
|
75
|
-
...contextStyle.value,
|
|
76
|
-
...mergedStyles.value.root
|
|
77
|
-
};
|
|
75
|
+
return { ...mergedStyles.value.root };
|
|
78
76
|
});
|
|
79
77
|
const [zIndex, contextZIndex] = useZIndex("Dropdown", computed(() => mergedRootStyles.value.zIndex));
|
|
80
78
|
const memoTransitionName = computed(() => {
|
package/dist/empty/index.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ interface EmptyProps extends ComponentBaseProps {
|
|
|
31
31
|
image?: VueNode;
|
|
32
32
|
description?: VueNode;
|
|
33
33
|
}
|
|
34
|
+
interface EmptyRef {
|
|
35
|
+
nativeElement: HTMLDivElement;
|
|
36
|
+
}
|
|
34
37
|
interface EmptySlots {
|
|
35
38
|
image: () => any;
|
|
36
39
|
description: () => any;
|
|
@@ -42,4 +45,4 @@ declare const _default: typeof Empty & {
|
|
|
42
45
|
PRESENTED_IMAGE_SIMPLE: typeof simpleEmptyImg;
|
|
43
46
|
};
|
|
44
47
|
//#endregion
|
|
45
|
-
export { EmptyClassNamesType, EmptyProps, EmptySemanticClassNames, EmptySemanticName, EmptySemanticStyles, EmptySlots, EmptyStylesType, SemanticName, TransferLocale, _default as default };
|
|
48
|
+
export { EmptyClassNamesType, EmptyProps, EmptyRef, EmptySemanticClassNames, EmptySemanticName, EmptySemanticStyles, EmptySlots, EmptyStylesType, SemanticName, TransferLocale, _default as default };
|
package/dist/empty/index.js
CHANGED
|
@@ -5,13 +5,13 @@ import useLocale from "../locale/useLocale.js";
|
|
|
5
5
|
import Empty$1 from "./empty.js";
|
|
6
6
|
import Simple from "./simple.js";
|
|
7
7
|
import style_default from "./style/index.js";
|
|
8
|
-
import { computed, createVNode, defineComponent, mergeDefaults, mergeProps } from "vue";
|
|
8
|
+
import { computed, createVNode, defineComponent, mergeDefaults, mergeProps, shallowRef } from "vue";
|
|
9
9
|
import { classNames } from "@v-c/util";
|
|
10
10
|
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
11
11
|
//#region src/empty/index.tsx
|
|
12
12
|
const defaultEmptyImg = createVNode(Empty$1, null, null);
|
|
13
13
|
const simpleEmptyImg = createVNode(Simple, null, null);
|
|
14
|
-
const Empty = /* @__PURE__ */ defineComponent((props, { slots, attrs }) => {
|
|
14
|
+
const Empty = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) => {
|
|
15
15
|
const componentConfig = useComponentConfig("empty");
|
|
16
16
|
const { prefixCls, direction, class: contextClassName, style: contextStyle, classes: contextClassNames, styles: contextStyles } = useComponentBaseConfig("empty", props);
|
|
17
17
|
const { classes, styles } = toPropsRefs$1(props, "classes", "styles");
|
|
@@ -19,6 +19,8 @@ const Empty = /* @__PURE__ */ defineComponent((props, { slots, attrs }) => {
|
|
|
19
19
|
const contextStyleRoot = useSemanticRootStyle(contextStyle);
|
|
20
20
|
const [mergedClassNames, mergedStyles] = useMergeSemantic(useToArr(contextClassNames, classes), useToArr(contextStyles, contextStyleRoot, styles), useToProps(computed(() => props)));
|
|
21
21
|
const [locale] = useLocale("Empty");
|
|
22
|
+
const nativeElementRef = shallowRef();
|
|
23
|
+
expose({ nativeElement: nativeElementRef });
|
|
22
24
|
return () => {
|
|
23
25
|
const des = getSlotPropsFnRun(slots, props, "description") ?? locale?.value?.description;
|
|
24
26
|
const alt = typeof des === "string" ? des : "empty";
|
|
@@ -32,6 +34,7 @@ const Empty = /* @__PURE__ */ defineComponent((props, { slots, attrs }) => {
|
|
|
32
34
|
else imageNode = mergedImage;
|
|
33
35
|
const children = filterEmpty(slots?.default?.() ?? []);
|
|
34
36
|
return createVNode("div", mergeProps({
|
|
37
|
+
"ref": nativeElementRef,
|
|
35
38
|
"class": classNames(hashId.value, cssVarCls.value, prefixCls.value, contextClassName.value, {
|
|
36
39
|
[`${prefixCls.value}-normal`]: mergedImage === simpleEmptyImg,
|
|
37
40
|
[`${prefixCls.value}-rtl`]: direction.value === "rtl"
|
|
@@ -6,6 +6,8 @@ interface BackTopProps extends Omit<FloatButtonProps, 'target'>, ComponentBasePr
|
|
|
6
6
|
visibilityHeight?: number;
|
|
7
7
|
target?: () => HTMLElement | Window | Document;
|
|
8
8
|
duration?: number;
|
|
9
|
+
/** @default false */
|
|
10
|
+
showProgress?: boolean;
|
|
9
11
|
}
|
|
10
12
|
interface BackTopEmits {
|
|
11
13
|
click: (e: MouseEvent) => void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import throttleByAnimationFrame from "../_util/throttleByAnimationFrame.js";
|
|
2
1
|
import { useComponentBaseConfig, useConfig } from "../config-provider/context.js";
|
|
2
|
+
import { genCssVar } from "../theme/util/genStyleUtils.js";
|
|
3
3
|
import { getAttrStyleAndClass as getAttrStyleAndClass$1, pureAttrs } from "../_util/hooks/useMergeSemantic.js";
|
|
4
4
|
import { toPropsRefs as toPropsRefs$1 } from "../_util/tools.js";
|
|
5
|
-
import getScroll from "../_util/getScroll.js";
|
|
6
5
|
import scrollTo from "../_util/scrollTo.js";
|
|
7
6
|
import { useGroupContext } from "./context.js";
|
|
8
7
|
import FloatButton, { floatButtonPrefixCls } from "./FloatButton.js";
|
|
9
|
-
import
|
|
8
|
+
import useScroll from "./hooks/useScroll.js";
|
|
9
|
+
import { Transition, computed, createVNode, defineComponent, mergeProps, shallowRef } from "vue";
|
|
10
10
|
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
11
11
|
import { VerticalAlignTopOutlined } from "@antdv-next/icons";
|
|
12
12
|
import { getTransitionProps } from "@v-c/util/dist/utils/transition";
|
|
@@ -14,49 +14,20 @@ import { omit } from "es-toolkit";
|
|
|
14
14
|
//#region src/float-button/BackTop.tsx
|
|
15
15
|
const defaultIcon = createVNode(VerticalAlignTopOutlined, null, null);
|
|
16
16
|
const BackTopWithInstall = /* @__PURE__ */ defineComponent((props, { attrs, slots, emit, expose }) => {
|
|
17
|
-
const { backTopIcon } = useComponentBaseConfig("floatButton", props, ["backTopIcon"], floatButtonPrefixCls);
|
|
17
|
+
const { prefixCls, backTopIcon } = useComponentBaseConfig("floatButton", props, ["backTopIcon"], floatButtonPrefixCls);
|
|
18
18
|
const globalConfig = useConfig();
|
|
19
19
|
const groupContext = useGroupContext();
|
|
20
20
|
const { target, visibilityHeight, duration } = toPropsRefs$1(props, "target", "visibilityHeight", "duration");
|
|
21
|
-
const visible = shallowRef((visibilityHeight.value ?? 400) === 0);
|
|
22
21
|
const floatButtonRef = shallowRef(null);
|
|
23
22
|
expose({ nativeElement: computed(() => floatButtonRef.value?.nativeElement ?? null) });
|
|
24
23
|
const getDefaultTarget = () => floatButtonRef.value?.nativeElement?.ownerDocument ?? (typeof window !== "undefined" ? window : void 0);
|
|
25
|
-
const container = shallowRef(null);
|
|
26
24
|
const mergedVisibility = computed(() => visibilityHeight.value ?? 400);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (targetNode) {
|
|
34
|
-
container.value = targetNode;
|
|
35
|
-
targetNode.addEventListener?.("scroll", handleScroll);
|
|
36
|
-
handleScroll({ target: targetNode });
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const removeScroll = () => {
|
|
40
|
-
container.value?.removeEventListener?.("scroll", handleScroll);
|
|
41
|
-
container.value = null;
|
|
42
|
-
};
|
|
43
|
-
onMounted(() => {
|
|
44
|
-
bindScroll();
|
|
45
|
-
});
|
|
46
|
-
onBeforeUnmount(() => {
|
|
47
|
-
handleScroll.cancel();
|
|
48
|
-
removeScroll();
|
|
49
|
-
});
|
|
50
|
-
watch(target, () => {
|
|
51
|
-
removeScroll();
|
|
52
|
-
bindScroll();
|
|
53
|
-
});
|
|
54
|
-
const triggerCheck = () => {
|
|
55
|
-
const node = container.value ?? getDefaultTarget();
|
|
56
|
-
if (node) handleScroll({ target: node });
|
|
57
|
-
};
|
|
58
|
-
watch(mergedVisibility, () => {
|
|
59
|
-
triggerCheck();
|
|
25
|
+
const showProgress = computed(() => props.showProgress ?? false);
|
|
26
|
+
const getTarget = computed(() => target.value || getDefaultTarget);
|
|
27
|
+
const { scrollProgress, visible } = useScroll({
|
|
28
|
+
getTarget,
|
|
29
|
+
showProgress,
|
|
30
|
+
visibilityHeight: mergedVisibility
|
|
60
31
|
});
|
|
61
32
|
const mergedShape = computed(() => groupContext?.value?.shape ?? props.shape ?? "circle");
|
|
62
33
|
const mergedIcon = computed(() => {
|
|
@@ -66,10 +37,16 @@ const BackTopWithInstall = /* @__PURE__ */ defineComponent((props, { attrs, slot
|
|
|
66
37
|
});
|
|
67
38
|
const rootPrefixCls = computed(() => globalConfig.value?.getPrefixCls?.());
|
|
68
39
|
const transitionProps = computed(() => getTransitionProps(`${rootPrefixCls.value}-fade`));
|
|
40
|
+
const progressStyle = computed(() => {
|
|
41
|
+
if (!showProgress.value) return;
|
|
42
|
+
const [varName] = genCssVar(rootPrefixCls.value ?? "ant", floatButtonPrefixCls);
|
|
43
|
+
return { [varName("progress")]: `${scrollProgress.value}turn` };
|
|
44
|
+
});
|
|
69
45
|
const scrollToTop = (e) => {
|
|
46
|
+
const prefersReducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)");
|
|
70
47
|
scrollTo(0, {
|
|
71
|
-
getContainer:
|
|
72
|
-
duration: duration.value ?? 450
|
|
48
|
+
getContainer: getTarget.value,
|
|
49
|
+
duration: prefersReducedMotion?.matches ? 0 : duration.value ?? 450
|
|
73
50
|
});
|
|
74
51
|
emit("click", e);
|
|
75
52
|
};
|
|
@@ -78,11 +55,12 @@ const BackTopWithInstall = /* @__PURE__ */ defineComponent((props, { attrs, slot
|
|
|
78
55
|
return createVNode(Transition, transitionProps.value, { default: () => visible.value ? createVNode(FloatButton, mergeProps(pureAttrs(attrs), omit(props, [
|
|
79
56
|
"visibilityHeight",
|
|
80
57
|
"target",
|
|
81
|
-
"duration"
|
|
58
|
+
"duration",
|
|
59
|
+
"showProgress"
|
|
82
60
|
]), {
|
|
83
61
|
"ref": floatButtonRef,
|
|
84
|
-
"class": className,
|
|
85
|
-
"style": style,
|
|
62
|
+
"class": [className, { [`${prefixCls.value}-progress`]: showProgress.value }],
|
|
63
|
+
"style": [progressStyle.value, style],
|
|
86
64
|
"shape": mergedShape.value,
|
|
87
65
|
"icon": mergedIcon.value,
|
|
88
66
|
"onClick": scrollToTop
|
|
@@ -102,6 +80,11 @@ const BackTopWithInstall = /* @__PURE__ */ defineComponent((props, { attrs, slot
|
|
|
102
80
|
type: Number,
|
|
103
81
|
required: false
|
|
104
82
|
},
|
|
83
|
+
showProgress: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
required: false,
|
|
86
|
+
default: void 0
|
|
87
|
+
},
|
|
105
88
|
icon: {
|
|
106
89
|
type: [
|
|
107
90
|
Function,
|
|
@@ -38,6 +38,9 @@ interface FloatButtonGroupProps extends Omit<FloatButtonProps, 'classes' | 'styl
|
|
|
38
38
|
placement?: 'top' | 'left' | 'right' | 'bottom';
|
|
39
39
|
style?: CSSProperties;
|
|
40
40
|
}
|
|
41
|
+
interface FloatButtonGroupRef {
|
|
42
|
+
nativeElement: HTMLDivElement;
|
|
43
|
+
}
|
|
41
44
|
interface FloatButtonGroupSlots {
|
|
42
45
|
default?: () => any;
|
|
43
46
|
closeIcon?: () => any;
|
|
@@ -56,4 +59,4 @@ interface FloatButtonGroupEmitsProps {
|
|
|
56
59
|
declare const InternalFloatButtonGroup: import("vue").DefineSetupFnComponent<FloatButtonGroupProps, FloatButtonGroupEmits, SlotsType<FloatButtonGroupSlots>, FloatButtonGroupProps, import("vue").PublicProps>;
|
|
57
60
|
declare const FloatButtonGroup: typeof InternalFloatButtonGroup;
|
|
58
61
|
//#endregion
|
|
59
|
-
export { FloatButtonGroupClassNamesType, FloatButtonGroupEmits, FloatButtonGroupEmitsProps, FloatButtonGroupProps, FloatButtonGroupSemanticClassNames, FloatButtonGroupSemanticName, FloatButtonGroupSemanticStyles, FloatButtonGroupSlots, FloatButtonGroupStylesType, FloatButtonGroup as default };
|
|
62
|
+
export { FloatButtonGroupClassNamesType, FloatButtonGroupEmits, FloatButtonGroupEmitsProps, FloatButtonGroupProps, FloatButtonGroupRef, FloatButtonGroupSemanticClassNames, FloatButtonGroupSemanticName, FloatButtonGroupSemanticStyles, FloatButtonGroupSlots, FloatButtonGroupStylesType, FloatButtonGroup as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useComponentBaseConfig } from "../config-provider/context.js";
|
|
2
|
-
import { pureAttrs, useMergeSemantic, useToArr, useToProps } from "../_util/hooks/useMergeSemantic.js";
|
|
2
|
+
import { pureAttrs, useMergeSemantic, useSemanticRootStyle, useToArr, useToProps } from "../_util/hooks/useMergeSemantic.js";
|
|
3
3
|
import { useZIndex } from "../_util/hooks/useZIndex.js";
|
|
4
4
|
import { getSlotPropsFnRun, toPropsRefs as toPropsRefs$1 } from "../_util/tools.js";
|
|
5
5
|
import useCSSVarCls from "../config-provider/hooks/useCSSVarCls.js";
|
|
@@ -36,7 +36,7 @@ const groupOmittedProps = [
|
|
|
36
36
|
"style",
|
|
37
37
|
"rootClass"
|
|
38
38
|
];
|
|
39
|
-
const FloatButtonGroup = /* @__PURE__ */ defineComponent((props, { slots, attrs, emit }) => {
|
|
39
|
+
const FloatButtonGroup = /* @__PURE__ */ defineComponent((props, { slots, attrs, emit, expose }) => {
|
|
40
40
|
const { class: contextClassName, style: contextStyle, classes: contextClasses, styles: contextStyles, direction, closeIcon: contextCloseIcon, prefixCls } = useComponentBaseConfig("floatButtonGroup", props, ["closeIcon"], floatButtonPrefixCls);
|
|
41
41
|
const groupPrefixCls = computed(() => `${prefixCls.value}-group`);
|
|
42
42
|
const listCls = computed(() => `${groupPrefixCls.value}-list`);
|
|
@@ -69,6 +69,7 @@ const FloatButtonGroup = /* @__PURE__ */ defineComponent((props, { slots, attrs,
|
|
|
69
69
|
emit("openChange", nextOpen);
|
|
70
70
|
};
|
|
71
71
|
const groupRef = shallowRef();
|
|
72
|
+
expose({ nativeElement: groupRef });
|
|
72
73
|
const handleDocClick = (event) => {
|
|
73
74
|
if (!clickTrigger.value) return;
|
|
74
75
|
if (groupRef.value?.contains(event.target)) return;
|
|
@@ -106,7 +107,8 @@ const FloatButtonGroup = /* @__PURE__ */ defineComponent((props, { slots, attrs,
|
|
|
106
107
|
shape: mergedShape.value,
|
|
107
108
|
placement: mergedPlacement.value
|
|
108
109
|
}));
|
|
109
|
-
const
|
|
110
|
+
const contextStyleRoot = useSemanticRootStyle(contextStyle);
|
|
111
|
+
const [mergedClassNames, mergedStyles] = useMergeSemantic(useToArr(contextClasses, classes), useToArr(contextStyles, contextStyleRoot, styles), useToProps(mergedProps));
|
|
110
112
|
const listContext = computed(() => ({
|
|
111
113
|
shape: mergedShape.value,
|
|
112
114
|
individual: individual.value,
|
|
@@ -187,7 +189,6 @@ const FloatButtonGroup = /* @__PURE__ */ defineComponent((props, { slots, attrs,
|
|
|
187
189
|
[`${groupPrefixCls.value}-menu-mode`]: !!triggerMode.value
|
|
188
190
|
}),
|
|
189
191
|
"style": [
|
|
190
|
-
contextStyle.value,
|
|
191
192
|
mergedStyles.value.root,
|
|
192
193
|
props.style,
|
|
193
194
|
attrs.style,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Ref } from "vue";
|
|
2
|
+
//#region src/float-button/hooks/useScroll.d.ts
|
|
3
|
+
type ScrollTarget = HTMLElement | Window | Document;
|
|
4
|
+
interface UseScrollOptions {
|
|
5
|
+
/** Reactive getter of the scroll container */
|
|
6
|
+
getTarget: Ref<() => ScrollTarget | null | undefined>;
|
|
7
|
+
showProgress: Ref<boolean>;
|
|
8
|
+
visibilityHeight: Ref<number>;
|
|
9
|
+
}
|
|
10
|
+
declare function getScrollProgress(target?: ScrollTarget | null): number;
|
|
11
|
+
declare function useScroll(options: UseScrollOptions): {
|
|
12
|
+
scrollProgress: import("vue").ShallowRef<number, number>;
|
|
13
|
+
visible: import("vue").ShallowRef<boolean, boolean>;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ScrollTarget, UseScrollOptions, useScroll as default, getScrollProgress };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import throttleByAnimationFrame from "../../_util/throttleByAnimationFrame.js";
|
|
2
|
+
import getScroll, { isDocument, isWindow } from "../../_util/getScroll.js";
|
|
3
|
+
import { onBeforeUnmount, onMounted, shallowRef, watch } from "vue";
|
|
4
|
+
//#region src/float-button/hooks/useScroll.ts
|
|
5
|
+
function getScrollElement(target) {
|
|
6
|
+
if (!target) return null;
|
|
7
|
+
if (isWindow(target)) return target.document.documentElement;
|
|
8
|
+
if (isDocument(target)) return target.documentElement;
|
|
9
|
+
if (target instanceof HTMLElement) return target;
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
function getScrollProgress(target) {
|
|
13
|
+
const scrollElement = getScrollElement(target);
|
|
14
|
+
if (!scrollElement) return 0;
|
|
15
|
+
const scrollTop = getScroll(target ?? null);
|
|
16
|
+
const maxScroll = Math.max(scrollElement.scrollHeight - scrollElement.clientHeight, 0);
|
|
17
|
+
return maxScroll > 0 ? Math.min(Math.max(scrollTop / maxScroll, 0), 1) : 0;
|
|
18
|
+
}
|
|
19
|
+
function useScroll(options) {
|
|
20
|
+
const { getTarget, showProgress, visibilityHeight } = options;
|
|
21
|
+
const visible = shallowRef(visibilityHeight.value === 0);
|
|
22
|
+
const scrollProgress = shallowRef(0);
|
|
23
|
+
let container = null;
|
|
24
|
+
let handleScroll = null;
|
|
25
|
+
const syncScrollState = () => {
|
|
26
|
+
visible.value = getScroll(container) >= visibilityHeight.value;
|
|
27
|
+
if (showProgress.value) scrollProgress.value = getScrollProgress(container);
|
|
28
|
+
};
|
|
29
|
+
const unbindScroll = () => {
|
|
30
|
+
handleScroll?.cancel();
|
|
31
|
+
if (container && handleScroll) container.removeEventListener("scroll", handleScroll);
|
|
32
|
+
container = null;
|
|
33
|
+
handleScroll = null;
|
|
34
|
+
};
|
|
35
|
+
const bindScroll = () => {
|
|
36
|
+
unbindScroll();
|
|
37
|
+
container = getTarget.value?.() ?? null;
|
|
38
|
+
handleScroll = throttleByAnimationFrame(syncScrollState);
|
|
39
|
+
syncScrollState();
|
|
40
|
+
container?.addEventListener("scroll", handleScroll);
|
|
41
|
+
};
|
|
42
|
+
let handleResize = null;
|
|
43
|
+
const unbindResize = () => {
|
|
44
|
+
if (handleResize) {
|
|
45
|
+
window.removeEventListener("resize", handleResize);
|
|
46
|
+
handleResize.cancel();
|
|
47
|
+
handleResize = null;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const bindResize = () => {
|
|
51
|
+
unbindResize();
|
|
52
|
+
if (!showProgress.value || typeof window === "undefined") return;
|
|
53
|
+
handleResize = throttleByAnimationFrame(() => {
|
|
54
|
+
scrollProgress.value = getScrollProgress(getTarget.value?.());
|
|
55
|
+
});
|
|
56
|
+
window.addEventListener("resize", handleResize);
|
|
57
|
+
};
|
|
58
|
+
onMounted(() => {
|
|
59
|
+
bindScroll();
|
|
60
|
+
bindResize();
|
|
61
|
+
});
|
|
62
|
+
onBeforeUnmount(() => {
|
|
63
|
+
unbindScroll();
|
|
64
|
+
unbindResize();
|
|
65
|
+
});
|
|
66
|
+
watch([
|
|
67
|
+
getTarget,
|
|
68
|
+
showProgress,
|
|
69
|
+
visibilityHeight
|
|
70
|
+
], () => {
|
|
71
|
+
bindScroll();
|
|
72
|
+
bindResize();
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
scrollProgress,
|
|
76
|
+
visible
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { useScroll as default, getScrollProgress };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import FloatButton, { FloatButtonProps, FloatButtonRef } from "./FloatButton.js";
|
|
2
|
-
import FloatButtonGroup, { FloatButtonGroupProps } from "./FloatButtonGroup.js";
|
|
2
|
+
import FloatButtonGroup, { FloatButtonGroupProps, FloatButtonGroupRef } from "./FloatButtonGroup.js";
|
|
3
3
|
import BackTopWithInstall from "./BackTop.js";
|
|
4
|
-
export { BackTopWithInstall as BackTop, FloatButtonGroup, type FloatButtonGroupProps, type FloatButtonProps, type FloatButtonRef, FloatButton as default };
|
|
4
|
+
export { BackTopWithInstall as BackTop, FloatButtonGroup, type FloatButtonGroupProps, type FloatButtonGroupRef, type FloatButtonProps, type FloatButtonRef, FloatButton as default };
|
|
@@ -4,6 +4,8 @@ import { unit } from "@antdv-next/cssinjs";
|
|
|
4
4
|
const genFloatButtonStyle = (token) => {
|
|
5
5
|
const { componentCls, floatButtonSize, iconCls, antCls, floatButtonIconSize } = token;
|
|
6
6
|
const [varName, varRef] = genCssVar(antCls, "float-btn");
|
|
7
|
+
const [buttonVarName, buttonVarRef] = genCssVar(antCls, "btn");
|
|
8
|
+
const getProgressBackground = (backgroundColor) => [`linear-gradient(${backgroundColor}, ${backgroundColor})`, `conic-gradient(${token.colorPrimary} ${varRef("progress", "0turn")}, ${token.colorBorderSecondary} 0)`].join(", ");
|
|
7
9
|
const badgeCls = `${componentCls}-badge`;
|
|
8
10
|
const R = Math.SQRT2;
|
|
9
11
|
const offsetR = (R - 1) / R;
|
|
@@ -33,6 +35,21 @@ const genFloatButtonStyle = (token) => {
|
|
|
33
35
|
},
|
|
34
36
|
"&:empty": { display: "none" },
|
|
35
37
|
[`${componentCls}-icon`]: { lineHeight: 1 },
|
|
38
|
+
[`&${componentCls}-progress`]: {
|
|
39
|
+
[buttonVarName("border-width")]: unit(token.lineWidthBold),
|
|
40
|
+
[buttonVarName("border-color")]: "transparent",
|
|
41
|
+
[buttonVarName("border-color-hover")]: "transparent",
|
|
42
|
+
[buttonVarName("border-color-active")]: "transparent",
|
|
43
|
+
[buttonVarName("border-color-disabled")]: "transparent",
|
|
44
|
+
backgroundImage: getProgressBackground(buttonVarRef("bg-color")),
|
|
45
|
+
backgroundOrigin: "border-box",
|
|
46
|
+
backgroundClip: "padding-box, border-box",
|
|
47
|
+
[`&:not(:disabled):not(${antCls}-btn-disabled)`]: {
|
|
48
|
+
"&:hover": { backgroundImage: getProgressBackground(buttonVarRef("bg-color-hover")) },
|
|
49
|
+
"&:active": { backgroundImage: getProgressBackground(buttonVarRef("bg-color-active")) }
|
|
50
|
+
},
|
|
51
|
+
[`&:disabled, &${antCls}-btn-disabled`]: { backgroundImage: getProgressBackground(buttonVarRef("bg-color-disabled")) }
|
|
52
|
+
},
|
|
36
53
|
[`&${componentCls}-icon-only`]: { [iconCls]: { fontSize: floatButtonIconSize } },
|
|
37
54
|
[`${componentCls}-content`]: { fontSize: token.fontSizeSM },
|
|
38
55
|
[badgeCls]: {
|
package/dist/form/ErrorList.js
CHANGED
|
@@ -71,7 +71,7 @@ const ErrorList = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
71
71
|
...collapseMotion,
|
|
72
72
|
name: `${prefixCls.value}-show-help-item`
|
|
73
73
|
};
|
|
74
|
-
return createVNode(Transition, transitionProps, { default: () => [!!filledKeyFullKeyList.length && createVNode("div", { "class": clsx(baseClassName.value, cssVarCls.value, rootCls.value, rootClassName, hashId.value) }, [createVNode(TransitionGroup, mergeProps(transitionGroupProps, { "appear": true }), _isSlot(_slot = filledKeyFullKeyList.map((itemProps) => {
|
|
74
|
+
return createVNode(Transition, transitionProps, { default: () => [!!filledKeyFullKeyList.length && createVNode("div", mergeProps(helpProps, { "class": clsx(baseClassName.value, cssVarCls.value, rootCls.value, rootClassName, hashId.value) }), [createVNode(TransitionGroup, mergeProps(transitionGroupProps, { "appear": true }), _isSlot(_slot = filledKeyFullKeyList.map((itemProps) => {
|
|
75
75
|
const { key, error, errorStatus, class: itemClassName, style: itemStyle } = itemProps;
|
|
76
76
|
return createVNode("div", {
|
|
77
77
|
"key": key,
|
|
@@ -80,7 +80,7 @@ const ErrorList = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
80
80
|
...props.helpItemStyle,
|
|
81
81
|
...itemStyle
|
|
82
82
|
}
|
|
83
|
-
}, [error]);
|
|
83
|
+
}, [typeof error === "function" ? error() : error]);
|
|
84
84
|
})) ? _slot : { default: () => [_slot] })])] });
|
|
85
85
|
};
|
|
86
86
|
}, {
|
|
@@ -4,6 +4,7 @@ import useCSSVarCls from "../../config-provider/hooks/useCSSVarCls.js";
|
|
|
4
4
|
import { checkRenderNode } from "../../_util/vueNode.js";
|
|
5
5
|
import { useFormContext, useFormItemProvider, useNoStyleItemContext } from "../context.js";
|
|
6
6
|
import { getFieldId, initialValueFormat, toArray, toNamePathStr } from "../util.js";
|
|
7
|
+
import { useFormInstance } from "../hooks/useForm.js";
|
|
7
8
|
import style_default from "../style/index.js";
|
|
8
9
|
import { getNamePath, getValue, setValue } from "../utils/valueUtil.js";
|
|
9
10
|
import { validateRules } from "../utils/validateUtil.js";
|
|
@@ -29,6 +30,7 @@ function genEmptyMeta() {
|
|
|
29
30
|
}
|
|
30
31
|
const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs }) => {
|
|
31
32
|
const formContext = useFormContext();
|
|
33
|
+
const formInstance = useFormInstance();
|
|
32
34
|
const mergedValidateTrigger = computed(() => {
|
|
33
35
|
const { trigger, validateTrigger } = props;
|
|
34
36
|
return validateTrigger !== void 0 ? validateTrigger : trigger !== void 0 ? trigger : formContext.value?.validateTrigger;
|
|
@@ -63,29 +65,14 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
63
65
|
const validateDisabled = shallowRef(false);
|
|
64
66
|
const subFieldErrors = shallowRef({});
|
|
65
67
|
const initialValue = shallowRef(initialValueFormat(formContext.value?.getFieldValue?.(namePath.value)));
|
|
66
|
-
const
|
|
68
|
+
const getMergedRules = () => {
|
|
67
69
|
const collectedRules = [];
|
|
68
70
|
const formRules = formContext.value?.rules ? getValue(formContext.value.rules, namePath.value) : void 0;
|
|
69
71
|
if (formRules) collectedRules.push(...Array.isArray(formRules) ? formRules : [formRules]);
|
|
70
72
|
if (props.rules) collectedRules.push(...props.rules);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const currentValue = hasName.value ? formContext.value?.getFieldValue?.(namePath.value) ?? getValue(formContext.value?.model ?? {}, namePath.value) : void 0;
|
|
75
|
-
if (typeof currentValue === "number") ruleType = "number";
|
|
76
|
-
else if (typeof currentValue === "boolean") ruleType = "boolean";
|
|
77
|
-
else if (Array.isArray(currentValue)) ruleType = "array";
|
|
78
|
-
}
|
|
79
|
-
const requiredRule = {
|
|
80
|
-
required: !!props.required,
|
|
81
|
-
...ruleType ? { type: ruleType } : {}
|
|
82
|
-
};
|
|
83
|
-
if (mergedValidateTrigger.value !== void 0) requiredRule.validateTrigger = mergedValidateTrigger.value || [];
|
|
84
|
-
collectedRules.push(requiredRule);
|
|
85
|
-
}
|
|
86
|
-
return collectedRules;
|
|
87
|
-
});
|
|
88
|
-
const isRequired = computed(() => mergedRules.value.some((rule) => rule?.required && !rule?.warningOnly));
|
|
73
|
+
return collectedRules.map((rule) => typeof rule === "function" ? rule(formInstance) : rule);
|
|
74
|
+
};
|
|
75
|
+
const isRequired = computed(() => getMergedRules().some((rule) => rule?.required && !rule?.warningOnly));
|
|
89
76
|
const messageVariables = computed(() => {
|
|
90
77
|
let variables = {};
|
|
91
78
|
if (typeof props.label === "string") variables.label = props.label;
|
|
@@ -123,7 +110,7 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
123
110
|
};
|
|
124
111
|
const validateRulesInner = (options = {}) => {
|
|
125
112
|
if (!namePath.value.length) return Promise.resolve();
|
|
126
|
-
let filteredRules =
|
|
113
|
+
let filteredRules = getMergedRules();
|
|
127
114
|
const { triggerName, validateOnly = false } = options;
|
|
128
115
|
if (triggerName) if (mergedValidateTrigger.value === false) filteredRules = [];
|
|
129
116
|
else filteredRules = filteredRules.filter((rule) => {
|
|
@@ -179,7 +166,7 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
179
166
|
};
|
|
180
167
|
const triggerValidate = (triggerName) => {
|
|
181
168
|
if (mergedValidateTrigger.value === false) return;
|
|
182
|
-
if (!
|
|
169
|
+
if (!getMergedRules().some((rule) => getRuleTriggerList(rule).includes(triggerName))) return;
|
|
183
170
|
validateRulesInner({ triggerName }).catch((e) => e);
|
|
184
171
|
};
|
|
185
172
|
const clearValidate = () => {
|
|
@@ -275,7 +262,7 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
275
262
|
namePath: () => namePath.value,
|
|
276
263
|
getValue: () => fieldValue.value,
|
|
277
264
|
getMeta: () => meta.value,
|
|
278
|
-
rules: () =>
|
|
265
|
+
rules: () => getMergedRules(),
|
|
279
266
|
isFieldDirty: () => meta.value.touched || meta.value.validated || initialValue.value !== void 0,
|
|
280
267
|
validateRules: (options) => validateRulesInner(options),
|
|
281
268
|
resetField,
|
|
@@ -325,7 +312,7 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
325
312
|
const _onFocus = childProps.onFocus;
|
|
326
313
|
if (_onBlur) delete child.props.onBlur;
|
|
327
314
|
if (_onFocus) delete child.props.onFocus;
|
|
328
|
-
|
|
315
|
+
const newChildProps = {
|
|
329
316
|
id: childProps.id || currentFieldId,
|
|
330
317
|
onBlur: (...args) => {
|
|
331
318
|
onFieldBlur();
|
|
@@ -342,7 +329,19 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
342
329
|
else _onFocus?.(...args);
|
|
343
330
|
},
|
|
344
331
|
ref: setItemInstance
|
|
345
|
-
}
|
|
332
|
+
};
|
|
333
|
+
const helpNode = getSlotPropsFnRun(slots, props, "help");
|
|
334
|
+
const extraNode = getSlotPropsFnRun(slots, props, "extra");
|
|
335
|
+
const { errors: itemErrors, warnings: itemWarnings } = mergedErrorList.value;
|
|
336
|
+
if (currentFieldId && (helpNode || itemErrors.length > 0 || itemWarnings.length > 0 || extraNode)) {
|
|
337
|
+
const describedbyArr = [];
|
|
338
|
+
if (helpNode || itemErrors.length > 0) describedbyArr.push(`${currentFieldId}_help`);
|
|
339
|
+
if (extraNode) describedbyArr.push(`${currentFieldId}_extra`);
|
|
340
|
+
newChildProps["aria-describedby"] = describedbyArr.join(" ");
|
|
341
|
+
}
|
|
342
|
+
if (itemErrors.length > 0) newChildProps["aria-invalid"] = "true";
|
|
343
|
+
if (props.required ?? isRequiredMark) newChildProps["aria-required"] = "true";
|
|
344
|
+
baseChildren = createVNode(child, newChildProps);
|
|
346
345
|
}
|
|
347
346
|
if (props.noStyle && !props.hidden) return createVNode(StatusProvider, {
|
|
348
347
|
"prefixCls": prefixCls.value,
|
package/dist/form/context.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ declare function useFormItemPrefixContext(): Ref<{
|
|
|
71
71
|
prefixCls: string;
|
|
72
72
|
}>;
|
|
73
73
|
declare function useVariantContextProvider(variant: Ref<Variant | undefined>): void;
|
|
74
|
-
declare function useVariantContext(): Ref<"outlined" | "
|
|
74
|
+
declare function useVariantContext(): Ref<"outlined" | "filled" | "borderless" | "underlined" | undefined, "outlined" | "filled" | "borderless" | "underlined" | undefined>;
|
|
75
75
|
interface FormItemStatusContextProps {
|
|
76
76
|
isFormItemInput?: boolean;
|
|
77
77
|
status?: ValidateStatus;
|
|
@@ -2,8 +2,8 @@ import { ConfigProviderProps } from "../../config-provider/define.js";
|
|
|
2
2
|
import { Variant } from "../../config-provider/context.js";
|
|
3
3
|
import { Ref } from "vue";
|
|
4
4
|
//#region src/form/hooks/useVariant.d.ts
|
|
5
|
-
type VariantComponents = keyof Pick<ConfigProviderProps, 'input' | 'inputNumber' | 'textArea' | 'mentions' | 'select' | 'cascader' | 'treeSelect' | 'datePicker' | 'timePicker' | 'rangePicker' | 'card'>;
|
|
6
|
-
declare function useVariant(component: VariantComponents, variant?: Ref<Variant | undefined>, legacyBordered?: Ref<boolean | undefined> | boolean): readonly [import("vue").ComputedRef<"outlined" | "
|
|
5
|
+
type VariantComponents = keyof Pick<ConfigProviderProps, 'input' | 'inputPassword' | 'inputSearch' | 'otp' | 'inputNumber' | 'textArea' | 'mentions' | 'select' | 'cascader' | 'treeSelect' | 'datePicker' | 'timePicker' | 'rangePicker' | 'card'>;
|
|
6
|
+
declare function useVariant(component: VariantComponents, variant?: Ref<Variant | undefined>, legacyBordered?: Ref<boolean | undefined> | boolean, fallbackComponent?: VariantComponents): readonly [import("vue").ComputedRef<"outlined" | "filled" | "borderless" | "underlined">, import("vue").ComputedRef<boolean>, import("vue").ComputedRef<boolean>];
|
|
7
7
|
declare const useVariants: typeof useVariant;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { useVariant as default, useVariants };
|