antdv-next 1.5.0 → 1.5.2
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/useClosable.d.ts +4 -2
- package/dist/_util/hooks/useClosable.js +9 -3
- package/dist/_util/hooks/useMergeSemantic.d.ts +7 -4
- package/dist/_util/hooks/useMergeSemantic.js +8 -3
- package/dist/_util/statusUtils.d.ts +1 -1
- package/dist/_util/vueNode.d.ts +2 -6
- package/dist/alert/style/index.d.ts +5 -0
- package/dist/alert/style/index.js +2 -1
- package/dist/anchor/Anchor.js +12 -6
- package/dist/antd-with-locales.esm.js +12799 -12587
- package/dist/antd-with-locales.js +82 -82
- package/dist/antd.css +1 -1
- package/dist/antd.esm.js +10540 -10546
- package/dist/antd.js +57 -57
- 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 +1 -0
- package/dist/border-beam/BorderBeam.js +30 -11
- package/dist/border-beam/hooks/useBorderSize.d.ts +3 -7
- package/dist/border-beam/hooks/useBorderSize.js +25 -26
- package/dist/border-beam/style/index.js +9 -8
- package/dist/border-beam/util.d.ts +3 -1
- package/dist/border-beam/util.js +4 -1
- 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/buttonHelper.d.ts +1 -1
- 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 +13 -10
- package/dist/collapse/Collapse.js +2 -4
- package/dist/color-picker/ColorPicker.js +4 -7
- package/dist/color-picker/components/ColorTrigger.js +1 -1
- package/dist/color-picker/style/index.js +1 -0
- package/dist/components.d.ts +25 -21
- package/dist/components.js +4 -3
- package/dist/config-provider/context.d.ts +24 -8
- package/dist/config-provider/define.d.ts +2 -1
- package/dist/config-provider/index.js +10 -0
- package/dist/date-picker/generatePicker/generateRangePicker.js +6 -7
- package/dist/date-picker/generatePicker/generateSinglePicker.js +2 -5
- package/dist/date-picker/generatePicker/useComponents.d.ts +2 -2
- 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 -6
- 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 +25 -43
- 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 +23 -0
- package/dist/form/ErrorList.js +2 -2
- package/dist/form/FormItem/ItemHolder.js +1 -1
- package/dist/form/FormItem/index.js +26 -28
- 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/style/index.js +25 -12
- package/dist/form/types.d.ts +11 -3
- package/dist/form/utils/validateUtil.js +4 -0
- package/dist/image/hooks/usePreviewConfig.d.ts +5 -4
- package/dist/image/index.js +8 -9
- package/dist/index.d.ts +25 -21
- package/dist/index.js +2 -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/listy/interface.d.ts +3 -2
- package/dist/listy/style/index.js +5 -1
- package/dist/locale/en_US.js +4 -0
- package/dist/locale/index.d.ts +4 -0
- package/dist/locale/is_IS.js +1 -1
- package/dist/locale/mn_MN.js +1 -1
- package/dist/locale/sq_AL.d.ts +5 -0
- package/dist/locale/sq_AL.js +151 -0
- package/dist/locale/zh_CN.js +4 -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/menu/MenuItem.js +12 -2
- package/dist/menu/SubMenu.d.ts +1 -1
- package/dist/menu/style/vertical.js +2 -6
- package/dist/message/useMessage.js +4 -4
- package/dist/modal/PurePanel.js +4 -7
- package/dist/notification/index.js +2 -1
- package/dist/notification/useNotification.js +12 -9
- package/dist/package.js +1 -1
- package/dist/package.json.d.ts +4 -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/radio/group.js +2 -2
- 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/index.js +1 -1
- package/dist/select/style/dropdown.js +4 -0
- package/dist/select/style/index.js +1 -1
- package/dist/select/style/select-input.js +1 -1
- package/dist/select/style/token.js +4 -2
- package/dist/select/useIcons.d.ts +2 -6
- 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 +5 -2
- 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/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/InternalTable.js +5 -4
- package/dist/table/hooks/useFilter/FilterDropdown.js +2 -2
- package/dist/table/style/radius.js +4 -0
- package/dist/table/style/virtual.js +4 -0
- package/dist/tag/hooks/useColor.d.ts +1 -1
- package/dist/tag/index.js +3 -3
- 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/index.js +10 -13
- package/dist/tour/panelRender.js +2 -8
- package/dist/transfer/ListBody.js +2 -1
- package/dist/transfer/ListItem.d.ts +1 -0
- package/dist/transfer/ListItem.js +6 -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/transfer/search.js +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/tree/utils/dictUtil.js +3 -2
- 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 +6 -13
- package/dist/upload/UploadList/index.js +8 -2
- package/dist/upload/index.d.ts +2 -2
- package/dist/version/token-meta.json +1 -0
- package/dist/version/token.json +1 -0
- package/dist/watermark/index.d.ts +4 -1
- package/dist/watermark/index.js +2 -1
- package/package.json +13 -9
- package/web-tags.json +1980 -1947
- package/web-types.json +5808 -5730
- package/dist/slider/useRafLock.d.ts +0 -5
- package/dist/slider/useRafLock.js +0 -23
|
@@ -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,15 @@ 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) => {
|
|
70
46
|
const prefersReducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)");
|
|
71
47
|
scrollTo(0, {
|
|
72
|
-
getContainer:
|
|
48
|
+
getContainer: getTarget.value,
|
|
73
49
|
duration: prefersReducedMotion?.matches ? 0 : duration.value ?? 450
|
|
74
50
|
});
|
|
75
51
|
emit("click", e);
|
|
@@ -79,11 +55,12 @@ const BackTopWithInstall = /* @__PURE__ */ defineComponent((props, { attrs, slot
|
|
|
79
55
|
return createVNode(Transition, transitionProps.value, { default: () => visible.value ? createVNode(FloatButton, mergeProps(pureAttrs(attrs), omit(props, [
|
|
80
56
|
"visibilityHeight",
|
|
81
57
|
"target",
|
|
82
|
-
"duration"
|
|
58
|
+
"duration",
|
|
59
|
+
"showProgress"
|
|
83
60
|
]), {
|
|
84
61
|
"ref": floatButtonRef,
|
|
85
|
-
"class": className,
|
|
86
|
-
"style": style,
|
|
62
|
+
"class": [className, { [`${prefixCls.value}-progress`]: showProgress.value }],
|
|
63
|
+
"style": [progressStyle.value, style],
|
|
87
64
|
"shape": mergedShape.value,
|
|
88
65
|
"icon": mergedIcon.value,
|
|
89
66
|
"onClick": scrollToTop
|
|
@@ -103,6 +80,11 @@ const BackTopWithInstall = /* @__PURE__ */ defineComponent((props, { attrs, slot
|
|
|
103
80
|
type: Number,
|
|
104
81
|
required: false
|
|
105
82
|
},
|
|
83
|
+
showProgress: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
required: false,
|
|
86
|
+
default: void 0
|
|
87
|
+
},
|
|
106
88
|
icon: {
|
|
107
89
|
type: [
|
|
108
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 [, 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,27 @@ const genFloatButtonStyle = (token) => {
|
|
|
33
35
|
},
|
|
34
36
|
"&:empty": { display: "none" },
|
|
35
37
|
[`${componentCls}-icon`]: { lineHeight: 1 },
|
|
38
|
+
[`&${antCls}-btn${componentCls}-progress`]: {
|
|
39
|
+
borderWidth: unit(token.lineWidthBold),
|
|
40
|
+
borderColor: "transparent",
|
|
41
|
+
backgroundImage: getProgressBackground(buttonVarRef("bg-color")),
|
|
42
|
+
backgroundOrigin: "border-box",
|
|
43
|
+
backgroundClip: "padding-box, border-box",
|
|
44
|
+
[`&:not(:disabled):not(${antCls}-btn-disabled)`]: {
|
|
45
|
+
"&:hover": {
|
|
46
|
+
borderColor: "transparent",
|
|
47
|
+
backgroundImage: getProgressBackground(buttonVarRef("bg-color-hover"))
|
|
48
|
+
},
|
|
49
|
+
"&:active": {
|
|
50
|
+
borderColor: "transparent",
|
|
51
|
+
backgroundImage: getProgressBackground(buttonVarRef("bg-color-active"))
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
[`&:disabled, &${antCls}-btn-disabled`]: {
|
|
55
|
+
borderColor: "transparent",
|
|
56
|
+
backgroundImage: getProgressBackground(buttonVarRef("bg-color-disabled"))
|
|
57
|
+
}
|
|
58
|
+
},
|
|
36
59
|
[`&${componentCls}-icon-only`]: { [iconCls]: { fontSize: floatButtonIconSize } },
|
|
37
60
|
[`${componentCls}-content`]: { fontSize: token.fontSizeSM },
|
|
38
61
|
[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
|
}, {
|
|
@@ -28,7 +28,7 @@ const ItemHolder = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
|
|
|
28
28
|
}
|
|
29
29
|
}, { immediate: true });
|
|
30
30
|
const onErrorVisibleChanged = (visible) => {
|
|
31
|
-
if (!visible) marginBottom.value = null;
|
|
31
|
+
if (!visible && !hasError.value) marginBottom.value = null;
|
|
32
32
|
};
|
|
33
33
|
function getValidateState(isDebounce = false) {
|
|
34
34
|
return getStatus(isDebounce ? props?.errors : props?.meta?.errors, isDebounce ? props?.warnings : props?.meta?.warnings, props?.meta, "", !!props?.hasFeedback, props?.validateStatus);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useComponentBaseConfig } from "../../config-provider/context.js";
|
|
2
2
|
import { getSlotPropsFnRun } from "../../_util/tools.js";
|
|
3
3
|
import useCSSVarCls from "../../config-provider/hooks/useCSSVarCls.js";
|
|
4
|
-
import { checkRenderNode } from "../../_util/vueNode.js";
|
|
5
4
|
import { useFormContext, useFormItemProvider, useNoStyleItemContext } from "../context.js";
|
|
6
5
|
import { getFieldId, initialValueFormat, toArray, toNamePathStr } from "../util.js";
|
|
6
|
+
import { useFormInstance } from "../hooks/useForm.js";
|
|
7
7
|
import style_default from "../style/index.js";
|
|
8
8
|
import { getNamePath, getValue, setValue } from "../utils/valueUtil.js";
|
|
9
9
|
import { validateRules } from "../utils/validateUtil.js";
|
|
@@ -29,6 +29,7 @@ function genEmptyMeta() {
|
|
|
29
29
|
}
|
|
30
30
|
const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs }) => {
|
|
31
31
|
const formContext = useFormContext();
|
|
32
|
+
const formInstance = useFormInstance();
|
|
32
33
|
const mergedValidateTrigger = computed(() => {
|
|
33
34
|
const { trigger, validateTrigger } = props;
|
|
34
35
|
return validateTrigger !== void 0 ? validateTrigger : trigger !== void 0 ? trigger : formContext.value?.validateTrigger;
|
|
@@ -63,29 +64,14 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
63
64
|
const validateDisabled = shallowRef(false);
|
|
64
65
|
const subFieldErrors = shallowRef({});
|
|
65
66
|
const initialValue = shallowRef(initialValueFormat(formContext.value?.getFieldValue?.(namePath.value)));
|
|
66
|
-
const
|
|
67
|
+
const getMergedRules = () => {
|
|
67
68
|
const collectedRules = [];
|
|
68
69
|
const formRules = formContext.value?.rules ? getValue(formContext.value.rules, namePath.value) : void 0;
|
|
69
70
|
if (formRules) collectedRules.push(...Array.isArray(formRules) ? formRules : [formRules]);
|
|
70
71
|
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));
|
|
72
|
+
return collectedRules.map((rule) => typeof rule === "function" ? rule(formInstance) : rule);
|
|
73
|
+
};
|
|
74
|
+
const isRequired = computed(() => getMergedRules().some((rule) => rule?.required && !rule?.warningOnly));
|
|
89
75
|
const messageVariables = computed(() => {
|
|
90
76
|
let variables = {};
|
|
91
77
|
if (typeof props.label === "string") variables.label = props.label;
|
|
@@ -123,7 +109,7 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
123
109
|
};
|
|
124
110
|
const validateRulesInner = (options = {}) => {
|
|
125
111
|
if (!namePath.value.length) return Promise.resolve();
|
|
126
|
-
let filteredRules =
|
|
112
|
+
let filteredRules = getMergedRules();
|
|
127
113
|
const { triggerName, validateOnly = false } = options;
|
|
128
114
|
if (triggerName) if (mergedValidateTrigger.value === false) filteredRules = [];
|
|
129
115
|
else filteredRules = filteredRules.filter((rule) => {
|
|
@@ -179,7 +165,7 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
179
165
|
};
|
|
180
166
|
const triggerValidate = (triggerName) => {
|
|
181
167
|
if (mergedValidateTrigger.value === false) return;
|
|
182
|
-
if (!
|
|
168
|
+
if (!getMergedRules().some((rule) => getRuleTriggerList(rule).includes(triggerName))) return;
|
|
183
169
|
validateRulesInner({ triggerName }).catch((e) => e);
|
|
184
170
|
};
|
|
185
171
|
const clearValidate = () => {
|
|
@@ -275,7 +261,7 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
275
261
|
namePath: () => namePath.value,
|
|
276
262
|
getValue: () => fieldValue.value,
|
|
277
263
|
getMeta: () => meta.value,
|
|
278
|
-
rules: () =>
|
|
264
|
+
rules: () => getMergedRules(),
|
|
279
265
|
isFieldDirty: () => meta.value.touched || meta.value.validated || initialValue.value !== void 0,
|
|
280
266
|
validateRules: (options) => validateRulesInner(options),
|
|
281
267
|
resetField,
|
|
@@ -315,17 +301,17 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
315
301
|
triggerFocus: onFieldFocus
|
|
316
302
|
});
|
|
317
303
|
return () => {
|
|
318
|
-
return renderLayout(
|
|
304
|
+
return renderLayout(filterEmpty(slots.default?.() ?? []), fieldId.value, isRequired.value);
|
|
319
305
|
};
|
|
320
306
|
function renderLayout(baseChildren, currentFieldId, isRequiredMark) {
|
|
321
|
-
if (Array.isArray(baseChildren) && baseChildren.length === 1 && isVNode(baseChildren[0])
|
|
322
|
-
const child =
|
|
307
|
+
if (Array.isArray(baseChildren) && baseChildren.length === 1 && isVNode(baseChildren[0])) {
|
|
308
|
+
const child = baseChildren[0];
|
|
323
309
|
const childProps = child.props || {};
|
|
324
310
|
const _onBlur = childProps.onBlur;
|
|
325
311
|
const _onFocus = childProps.onFocus;
|
|
326
312
|
if (_onBlur) delete child.props.onBlur;
|
|
327
313
|
if (_onFocus) delete child.props.onFocus;
|
|
328
|
-
|
|
314
|
+
const newChildProps = {
|
|
329
315
|
id: childProps.id || currentFieldId,
|
|
330
316
|
onBlur: (...args) => {
|
|
331
317
|
onFieldBlur();
|
|
@@ -342,7 +328,19 @@ const InternalFormItem = /* @__PURE__ */ defineComponent((props, { slots, attrs
|
|
|
342
328
|
else _onFocus?.(...args);
|
|
343
329
|
},
|
|
344
330
|
ref: setItemInstance
|
|
345
|
-
}
|
|
331
|
+
};
|
|
332
|
+
const helpNode = getSlotPropsFnRun(slots, props, "help");
|
|
333
|
+
const extraNode = getSlotPropsFnRun(slots, props, "extra");
|
|
334
|
+
const { errors: itemErrors, warnings: itemWarnings } = mergedErrorList.value;
|
|
335
|
+
if (currentFieldId && (helpNode || itemErrors.length > 0 || itemWarnings.length > 0 || extraNode)) {
|
|
336
|
+
const describedbyArr = [];
|
|
337
|
+
if (helpNode || itemErrors.length > 0) describedbyArr.push(`${currentFieldId}_help`);
|
|
338
|
+
if (extraNode) describedbyArr.push(`${currentFieldId}_extra`);
|
|
339
|
+
newChildProps["aria-describedby"] = describedbyArr.join(" ");
|
|
340
|
+
}
|
|
341
|
+
if (itemErrors.length > 0) newChildProps["aria-invalid"] = "true";
|
|
342
|
+
if (props.required ?? isRequiredMark) newChildProps["aria-required"] = "true";
|
|
343
|
+
baseChildren = [createVNode(child, newChildProps)];
|
|
346
344
|
}
|
|
347
345
|
if (props.noStyle && !props.hidden) return createVNode(StatusProvider, {
|
|
348
346
|
"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" | "borderless" | "filled" | "underlined" | undefined, "outlined" | "borderless" | "filled" | "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" | "borderless" | "filled" | "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 };
|
|
@@ -2,17 +2,27 @@ import { Variants, useConfig } from "../../config-provider/context.js";
|
|
|
2
2
|
import { useVariantContext } from "../context.js";
|
|
3
3
|
import { computed } from "vue";
|
|
4
4
|
//#region src/form/hooks/useVariant.ts
|
|
5
|
-
function useVariant(component, variant, legacyBordered) {
|
|
5
|
+
function useVariant(component, variant, legacyBordered, fallbackComponent) {
|
|
6
6
|
const config = useConfig();
|
|
7
7
|
const formVariant = useVariantContext();
|
|
8
|
+
const configComponentVariant = computed(() => {
|
|
9
|
+
const componentConfigVariant = config.value?.[component]?.variant;
|
|
10
|
+
const fallbackConfigVariant = fallbackComponent ? config.value?.[fallbackComponent]?.variant : void 0;
|
|
11
|
+
return componentConfigVariant ?? fallbackConfigVariant;
|
|
12
|
+
});
|
|
8
13
|
const mergedVariant = computed(() => {
|
|
9
14
|
if (typeof variant?.value !== "undefined") return variant.value;
|
|
10
15
|
if ((typeof legacyBordered === "object" ? legacyBordered.value : legacyBordered) === false) return "borderless";
|
|
11
|
-
|
|
12
|
-
const globalVariant = config.value?.variant;
|
|
13
|
-
return formVariant.value ?? componentConfigVariant ?? globalVariant ?? "outlined";
|
|
16
|
+
return formVariant.value ?? configComponentVariant.value ?? config.value?.variant ?? "outlined";
|
|
14
17
|
});
|
|
15
|
-
return [
|
|
18
|
+
return [
|
|
19
|
+
mergedVariant,
|
|
20
|
+
computed(() => Variants.includes(mergedVariant.value)),
|
|
21
|
+
computed(() => {
|
|
22
|
+
const borderedValue = typeof legacyBordered === "object" ? legacyBordered.value : legacyBordered;
|
|
23
|
+
return typeof variant?.value !== "undefined" || borderedValue === false || typeof formVariant.value !== "undefined" || typeof configComponentVariant.value !== "undefined" || typeof config.value?.variant !== "undefined";
|
|
24
|
+
})
|
|
25
|
+
];
|
|
16
26
|
}
|
|
17
27
|
const useVariants = useVariant;
|
|
18
28
|
//#endregion
|