@antdv-vue/pro-utils 0.0.0-stage → 2.1.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/CHANGELOG.md +123 -0
- package/README.md +80 -2
- package/dist/autoFocusToFirstChild/index.d.ts +9 -0
- package/dist/autoFocusToFirstChild/index.js +36 -0
- package/dist/childrenToArray/index.d.ts +7 -0
- package/dist/childrenToArray/index.js +8 -0
- package/dist/components/CopyToClipboard/copy/index.d.ts +10 -0
- package/dist/components/CopyToClipboard/copy/index.js +84 -0
- package/dist/components/CopyToClipboard/copy/toggle-selection.d.ts +4 -0
- package/dist/components/CopyToClipboard/copy/toggle-selection.js +27 -0
- package/dist/components/CopyToClipboard/index.d.ts +14 -0
- package/dist/components/CopyToClipboard/index.js +13 -0
- package/dist/components/Draggable/Draggable.d.ts +62 -0
- package/dist/components/Draggable/Draggable.js +162 -0
- package/dist/components/Draggable/DraggableCore.d.ts +40 -0
- package/dist/components/Draggable/DraggableCore.js +149 -0
- package/dist/components/Draggable/index.d.ts +4 -0
- package/dist/components/Draggable/index.js +3 -0
- package/dist/components/Draggable/types.d.ts +30 -0
- package/dist/components/Draggable/types.js +1 -0
- package/dist/components/Draggable/utils/domFns.d.ts +36 -0
- package/dist/components/Draggable/utils/domFns.js +165 -0
- package/dist/components/Draggable/utils/getPrefix.d.ts +6 -0
- package/dist/components/Draggable/utils/getPrefix.js +31 -0
- package/dist/components/Draggable/utils/positionFns.d.ts +13 -0
- package/dist/components/Draggable/utils/positionFns.js +96 -0
- package/dist/components/Draggable/utils/shims.d.ts +7 -0
- package/dist/components/Draggable/utils/shims.js +19 -0
- package/dist/components/DropdownFooter/index.d.ts +20 -0
- package/dist/components/DropdownFooter/index.js +80 -0
- package/dist/components/DropdownFooter/style/index.d.ts +8 -0
- package/dist/components/DropdownFooter/style/index.js +18 -0
- package/dist/components/ErrorBoundary/index.d.ts +25 -0
- package/dist/components/ErrorBoundary/index.js +65 -0
- package/dist/components/FieldLabel/index.d.ts +31 -0
- package/dist/components/FieldLabel/index.js +212 -0
- package/dist/components/FieldLabel/style/index.d.ts +8 -0
- package/dist/components/FieldLabel/style/index.js +146 -0
- package/dist/components/FilterDropdown/index.d.ts +38 -0
- package/dist/components/FilterDropdown/index.js +91 -0
- package/dist/components/FilterDropdown/style/index.d.ts +8 -0
- package/dist/components/FilterDropdown/style/index.js +21 -0
- package/dist/components/FormItem/FormItemInput.d.ts +34 -0
- package/dist/components/FormItem/FormItemInput.js +163 -0
- package/dist/components/FormItem/ItemHolder.d.ts +58 -0
- package/dist/components/FormItem/ItemHolder.js +289 -0
- package/dist/components/FormItem/index.d.ts +64 -0
- package/dist/components/FormItem/index.js +591 -0
- package/dist/components/FormList/Field.d.ts +29 -0
- package/dist/components/FormList/Field.js +106 -0
- package/dist/components/FormList/FieldContext.d.ts +15 -0
- package/dist/components/FormList/FieldContext.js +11 -0
- package/dist/components/FormList/InternalField.d.ts +51 -0
- package/dist/components/FormList/InternalField.js +149 -0
- package/dist/components/FormList/ListContext.d.ts +12 -0
- package/dist/components/FormList/ListContext.js +11 -0
- package/dist/components/FormList/index.d.ts +36 -0
- package/dist/components/FormList/index.js +145 -0
- package/dist/components/FormList/interface.d.ts +9 -0
- package/dist/components/FormList/interface.js +1 -0
- package/dist/components/FormList/namePathType.d.ts +9 -0
- package/dist/components/FormList/namePathType.js +1 -0
- package/dist/components/FormList/utils/index.d.ts +15 -0
- package/dist/components/FormList/utils/index.js +37 -0
- package/dist/components/InlineErrorFormItem/InlineErrorFormItemPopover.d.ts +21 -0
- package/dist/components/InlineErrorFormItem/InlineErrorFormItemPopover.js +95 -0
- package/dist/components/InlineErrorFormItem/index.d.ts +14 -0
- package/dist/components/InlineErrorFormItem/index.js +44 -0
- package/dist/components/InlineErrorFormItem/style/index.d.ts +8 -0
- package/dist/components/InlineErrorFormItem/style/index.js +46 -0
- package/dist/components/LabelIconTip/index.d.ts +16 -0
- package/dist/components/LabelIconTip/index.js +79 -0
- package/dist/components/LabelIconTip/style/index.d.ts +8 -0
- package/dist/components/LabelIconTip/style/index.js +38 -0
- package/dist/components/ProFormContext/index.d.ts +51 -0
- package/dist/components/ProFormContext/index.js +11 -0
- package/dist/conversionMomentValue/index.d.ts +48 -0
- package/dist/conversionMomentValue/index.js +103 -0
- package/dist/dateArrayFormatter/index.d.ts +14 -0
- package/dist/dateArrayFormatter/index.js +38 -0
- package/dist/deepMerge/index.d.ts +4 -0
- package/dist/deepMerge/index.js +17 -0
- package/dist/genCopyable/index.d.ts +27 -0
- package/dist/genCopyable/index.js +82 -0
- package/dist/getFieldPropsOrFormItemProps/index.d.ts +18 -0
- package/dist/getFieldPropsOrFormItemProps/index.js +15 -0
- package/dist/getSlot/index.d.ts +8 -0
- package/dist/getSlot/index.js +11 -0
- package/dist/hooks/index.d.ts +9 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/useDebounceFn/index.d.ts +12 -0
- package/dist/hooks/useDebounceFn/index.js +34 -0
- package/dist/hooks/useDebounceValue/index.d.ts +12 -0
- package/dist/hooks/useDebounceValue/index.js +21 -0
- package/dist/hooks/useDocumentTitle/index.d.ts +10 -0
- package/dist/hooks/useDocumentTitle/index.js +12 -0
- package/dist/hooks/useEffect/index.d.ts +6 -0
- package/dist/hooks/useEffect/index.js +17 -0
- package/dist/hooks/useFetchData/index.d.ts +12 -0
- package/dist/hooks/useFetchData/index.js +35 -0
- package/dist/hooks/useLayoutEffect/index.d.ts +6 -0
- package/dist/hooks/useLayoutEffect/index.js +21 -0
- package/dist/hooks/useMemo/index.d.ts +6 -0
- package/dist/hooks/useMemo/index.js +13 -0
- package/dist/hooks/useState/index.d.ts +6 -0
- package/dist/hooks/useState/index.js +11 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +58 -0
- package/dist/isBrowser/index.d.ts +4 -0
- package/dist/isBrowser/index.js +8 -0
- package/dist/isDropdownValueType/index.d.ts +4 -0
- package/dist/isDropdownValueType/index.js +8 -0
- package/dist/isImg/index.d.ts +5 -0
- package/dist/isImg/index.js +7 -0
- package/dist/isNil/index.d.ts +4 -0
- package/dist/isNil/index.js +6 -0
- package/dist/isUrl/index.d.ts +9 -0
- package/dist/isUrl/index.js +17 -0
- package/dist/merge/index.d.ts +9 -0
- package/dist/merge/index.js +20 -0
- package/dist/nanoid/index.d.ts +9 -0
- package/dist/nanoid/index.js +25 -0
- package/dist/normalizeProps/index.d.ts +6 -0
- package/dist/normalizeProps/index.js +6 -0
- package/dist/omitBoolean/index.d.ts +9 -0
- package/dist/omitBoolean/index.js +11 -0
- package/dist/omitUndefined/index.d.ts +5 -0
- package/dist/omitUndefined/index.js +11 -0
- package/dist/omitUndefinedAndEmptyArr/index.d.ts +4 -0
- package/dist/omitUndefinedAndEmptyArr/index.js +12 -0
- package/dist/parseValueToDay/index.d.ts +7 -0
- package/dist/parseValueToDay/index.js +21 -0
- package/dist/pickProFormItemProps/index.d.ts +34 -0
- package/dist/pickProFormItemProps/index.js +42 -0
- package/dist/pickProProps/index.d.ts +4 -0
- package/dist/pickProProps/index.js +14 -0
- package/dist/pro-utils.esm.js +3672 -0
- package/dist/proFieldParsingText/index.d.ts +25 -0
- package/dist/proFieldParsingText/index.js +100 -0
- package/dist/runFunction/index.d.ts +5 -0
- package/dist/runFunction/index.js +8 -0
- package/dist/stringify/index.d.ts +7 -0
- package/dist/stringify/index.js +10 -0
- package/dist/transformBooleanProps/index.d.ts +4 -0
- package/dist/transformBooleanProps/index.js +9 -0
- package/dist/transformKeySubmitValue/index.d.ts +24 -0
- package/dist/transformKeySubmitValue/index.js +200 -0
- package/dist/transformVueNodeType/index.d.ts +14 -0
- package/dist/transformVueNodeType/index.js +14 -0
- package/dist/typing.d.ts +562 -0
- package/dist/typing.js +1 -0
- package/dist/useEditableArray/components/CancelEditableAction.d.ts +47 -0
- package/dist/useEditableArray/components/CancelEditableAction.js +90 -0
- package/dist/useEditableArray/components/DeleteEditableAction.d.ts +33 -0
- package/dist/useEditableArray/components/DeleteEditableAction.js +63 -0
- package/dist/useEditableArray/components/SaveEditableAction.d.ts +33 -0
- package/dist/useEditableArray/components/SaveEditableAction.js +79 -0
- package/dist/useEditableArray/index.d.ts +66 -0
- package/dist/useEditableArray/index.js +584 -0
- package/dist/useEditableArray/typing.d.ts +130 -0
- package/dist/useEditableArray/typing.js +1 -0
- package/dist/useEditableMap/index.d.ts +32 -0
- package/dist/useEditableMap/index.js +147 -0
- package/dist/useMediaQuery/index.d.ts +44 -0
- package/dist/useMediaQuery/index.js +99 -0
- package/dist/useMediaQuery/query.d.ts +6 -0
- package/dist/useMediaQuery/query.js +17 -0
- package/dist/useMountMergeState/index.d.ts +11 -0
- package/dist/useMountMergeState/index.js +26 -0
- package/dist/usePrevious/index.d.ts +6 -0
- package/dist/usePrevious/index.js +11 -0
- package/dist/useRefFunction/index.d.ts +4 -0
- package/dist/useRefFunction/index.js +11 -0
- package/package.json +69 -3
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useMemo } from "../../hooks/useMemo/index.js";
|
|
2
|
+
import DropdownFooter from "../DropdownFooter/index.js";
|
|
3
|
+
import style_default from "./style/index.js";
|
|
4
|
+
import { computed, createVNode, defineComponent, mergeProps, shallowRef } from "vue";
|
|
5
|
+
import { classNames } from "@v-c/util";
|
|
6
|
+
import { ConfigProvider, Popover } from "antdv-next";
|
|
7
|
+
import { useConfig as useConfig$1 } from "antdv-next/config-provider/context";
|
|
8
|
+
//#region src/components/FilterDropdown/index.tsx
|
|
9
|
+
const FilterDropdown = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
10
|
+
const config = useConfig$1();
|
|
11
|
+
const prefixCls = computed(() => config.value.getPrefixCls("pro"));
|
|
12
|
+
const baseClassName = computed(() => `${prefixCls.value}-core-field-dropdown`);
|
|
13
|
+
const [hashId, cssVarCls] = style_default(baseClassName);
|
|
14
|
+
const htmlRef = shallowRef(null);
|
|
15
|
+
const styles = useMemo(() => ({
|
|
16
|
+
container: { ...props.popoverProps?.styles?.container || {} },
|
|
17
|
+
...props.popoverProps?.styles || {}
|
|
18
|
+
}), [() => props.popoverProps?.styles]);
|
|
19
|
+
return () => {
|
|
20
|
+
const { label, footer, open, popoverProps, onOpenChange, disabled, footerRender, placement } = props;
|
|
21
|
+
return createVNode(Popover, mergeProps(popoverProps, {
|
|
22
|
+
"placement": placement,
|
|
23
|
+
"trigger": ["click"],
|
|
24
|
+
"open": open || false,
|
|
25
|
+
"onOpenChange": onOpenChange,
|
|
26
|
+
"styles": styles.value,
|
|
27
|
+
"content": createVNode("div", {
|
|
28
|
+
"ref": htmlRef,
|
|
29
|
+
"class": classNames(`${baseClassName.value}-overlay`, { [`${baseClassName.value}-overlay-${placement}`]: placement }, hashId.value, cssVarCls.value)
|
|
30
|
+
}, [createVNode(ConfigProvider, { "getPopupContainer": () => htmlRef.value || document.body }, { default: () => [createVNode("div", { "class": classNames(`${baseClassName.value}-content`, hashId.value, cssVarCls.value) }, [slots.default?.()])] }), footer && createVNode(DropdownFooter, mergeProps({
|
|
31
|
+
"disabled": disabled,
|
|
32
|
+
"footerRender": footerRender
|
|
33
|
+
}, footer), null)])
|
|
34
|
+
}), { default: () => [createVNode("span", { "class": classNames(`${baseClassName.value}-label`, hashId.value, cssVarCls.value) }, [label])] });
|
|
35
|
+
};
|
|
36
|
+
}, {
|
|
37
|
+
props: {
|
|
38
|
+
label: {
|
|
39
|
+
type: [
|
|
40
|
+
Object,
|
|
41
|
+
Function,
|
|
42
|
+
String,
|
|
43
|
+
Number,
|
|
44
|
+
null,
|
|
45
|
+
Boolean,
|
|
46
|
+
Array
|
|
47
|
+
],
|
|
48
|
+
required: false,
|
|
49
|
+
default: void 0
|
|
50
|
+
},
|
|
51
|
+
footer: {
|
|
52
|
+
type: Object,
|
|
53
|
+
required: false
|
|
54
|
+
},
|
|
55
|
+
footerRender: {
|
|
56
|
+
type: [Function, Boolean],
|
|
57
|
+
required: false,
|
|
58
|
+
default: void 0
|
|
59
|
+
},
|
|
60
|
+
padding: {
|
|
61
|
+
type: Number,
|
|
62
|
+
required: false
|
|
63
|
+
},
|
|
64
|
+
disabled: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
required: false,
|
|
67
|
+
default: void 0
|
|
68
|
+
},
|
|
69
|
+
onOpenChange: {
|
|
70
|
+
type: Function,
|
|
71
|
+
required: false
|
|
72
|
+
},
|
|
73
|
+
open: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
required: false,
|
|
76
|
+
default: void 0
|
|
77
|
+
},
|
|
78
|
+
placement: {
|
|
79
|
+
type: String,
|
|
80
|
+
required: false
|
|
81
|
+
},
|
|
82
|
+
popoverProps: {
|
|
83
|
+
type: Object,
|
|
84
|
+
required: false
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
name: "FilterDropdown",
|
|
88
|
+
inheritAttrs: false
|
|
89
|
+
});
|
|
90
|
+
//#endregion
|
|
91
|
+
export { FilterDropdown as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
import { ProAliasCssVarToken } from "@antdv-vue/pro-provider";
|
|
3
|
+
|
|
4
|
+
//#region src/components/FilterDropdown/style/index.d.ts
|
|
5
|
+
interface ProFilterDropdownToken extends ProAliasCssVarToken {}
|
|
6
|
+
declare const _default: (prefixCls: _$vue.Ref<string>, rootCls?: _$vue.Ref<string | undefined>) => readonly [_$vue.Ref<string, string>, _$vue.ComputedRef<string | undefined>];
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ProFilterDropdownToken, _default as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useStyle } from "@antdv-vue/pro-provider";
|
|
2
|
+
import { mergeToken } from "@antdv-next/cssinjs";
|
|
3
|
+
//#region src/components/FilterDropdown/style/index.ts
|
|
4
|
+
const genProFilterDropdownStyle = (token) => {
|
|
5
|
+
return {
|
|
6
|
+
[`${token.componentCls}-label`]: { cursor: "pointer" },
|
|
7
|
+
[`${token.componentCls}-overlay`]: {
|
|
8
|
+
minWidth: 200,
|
|
9
|
+
marginBlockStart: 4
|
|
10
|
+
},
|
|
11
|
+
[`${token.componentCls}-content`]: {
|
|
12
|
+
paddingBlock: 16,
|
|
13
|
+
paddingInline: 16
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
var style_default = useStyle("FilterDropdown", (token) => {
|
|
18
|
+
return [genProFilterDropdownStyle(mergeToken(token, {}))];
|
|
19
|
+
});
|
|
20
|
+
//#endregion
|
|
21
|
+
export { style_default as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
import { VNode } from "vue";
|
|
3
|
+
import { VueNode } from "@v-c/util";
|
|
4
|
+
import { FormItemInputProps } from "antdv-next/dist/form/FormItemInput";
|
|
5
|
+
|
|
6
|
+
//#region src/components/FormItem/FormItemInput.d.ts
|
|
7
|
+
interface FormItemInputMiscProps {
|
|
8
|
+
prefixCls: string;
|
|
9
|
+
errors: any[];
|
|
10
|
+
warnings: any[];
|
|
11
|
+
marginBottom?: number | null;
|
|
12
|
+
onErrorVisibleChanged?: (visible: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const FormItemInput: _$vue.DefineSetupFnComponent<FormItemInputProps & FormItemInputMiscProps & {
|
|
15
|
+
_internalItemRender?: {
|
|
16
|
+
mark: string;
|
|
17
|
+
render: (props: FormItemInputProps & FormItemInputMiscProps, domList: {
|
|
18
|
+
input: VNode;
|
|
19
|
+
errorList: VNode | null;
|
|
20
|
+
extra: VNode | null;
|
|
21
|
+
}) => VueNode;
|
|
22
|
+
};
|
|
23
|
+
}, {}, {}, FormItemInputProps & FormItemInputMiscProps & {
|
|
24
|
+
_internalItemRender?: {
|
|
25
|
+
mark: string;
|
|
26
|
+
render: (props: FormItemInputProps & FormItemInputMiscProps, domList: {
|
|
27
|
+
input: VNode;
|
|
28
|
+
errorList: VNode | null;
|
|
29
|
+
extra: VNode | null;
|
|
30
|
+
}) => VueNode;
|
|
31
|
+
};
|
|
32
|
+
} & {}, _$vue.PublicProps>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { FormItemInputMiscProps, FormItemInput as default };
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Fragment, computed, createVNode, defineComponent, isVNode, mergeProps, nextTick, shallowRef, watch } from "vue";
|
|
2
|
+
import { clsx, get, omit, set } from "@v-c/util";
|
|
3
|
+
import { Col } from "antdv-next";
|
|
4
|
+
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
5
|
+
import { FormItemPrefixContextProvider, useFormContext, useFormContextProvider } from "antdv-next/dist/form/context";
|
|
6
|
+
import { getSlotPropsFnRun } from "antdv-next/dist/_util/tools";
|
|
7
|
+
import { responsiveArrayReversed } from "antdv-next/dist/_util/responsiveObserver";
|
|
8
|
+
import ErrorList from "antdv-next/dist/form/ErrorList";
|
|
9
|
+
//#region src/components/FormItem/FormItemInput.tsx
|
|
10
|
+
function _isSlot(s) {
|
|
11
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
12
|
+
}
|
|
13
|
+
const GRID_MAX = 24;
|
|
14
|
+
const FormItemInput = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
15
|
+
const baseClassName = computed(() => `${props.prefixCls}-item`);
|
|
16
|
+
const formContext = useFormContext();
|
|
17
|
+
const contextClassNames = computed(() => formContext.value?.classes ?? {});
|
|
18
|
+
const contextStyles = computed(() => formContext.value?.styles ?? {});
|
|
19
|
+
const extraRef = shallowRef();
|
|
20
|
+
const extraHeight = shallowRef(0);
|
|
21
|
+
watch(() => props.extra, async () => {
|
|
22
|
+
await nextTick();
|
|
23
|
+
if (props.extra && extraRef.value) extraHeight.value = extraRef.value.clientHeight;
|
|
24
|
+
else extraHeight.value = 0;
|
|
25
|
+
}, { immediate: true });
|
|
26
|
+
useFormContextProvider(computed(() => omit(formContext.value ?? {}, ["labelCol", "wrapperCol"])));
|
|
27
|
+
return () => {
|
|
28
|
+
const { wrapperCol, labelCol, marginBottom, warnings, errors, prefixCls, _internalItemRender: formItemRender, status, fieldId, onErrorVisibleChanged } = props;
|
|
29
|
+
const label = getSlotPropsFnRun({}, props, "label");
|
|
30
|
+
const extra = getSlotPropsFnRun({}, props, "extra");
|
|
31
|
+
const help = getSlotPropsFnRun({}, props, "help");
|
|
32
|
+
const children = filterEmpty(slots?.default?.() ?? []);
|
|
33
|
+
const mergedWrapperColFn = () => {
|
|
34
|
+
let mergedWrapper = { ...wrapperCol || formContext.value?.wrapperCol || {} };
|
|
35
|
+
if (label === null && !labelCol && !wrapperCol && formContext.value?.labelCol) [void 0, ...responsiveArrayReversed].forEach((size) => {
|
|
36
|
+
const _size = size ? [size] : [];
|
|
37
|
+
const formLabel = get(formContext?.value?.labelCol, _size);
|
|
38
|
+
const formLabelObj = typeof formLabel === "object" ? formLabel : {};
|
|
39
|
+
const wrapper = get(mergedWrapper, _size);
|
|
40
|
+
const wrapperObj = typeof wrapper === "object" ? wrapper : {};
|
|
41
|
+
if ("span" in formLabelObj && !("offset" in wrapperObj) && formLabelObj.span < GRID_MAX) mergedWrapper = set(mergedWrapper, [..._size, "offset"], formLabelObj.span);
|
|
42
|
+
});
|
|
43
|
+
return mergedWrapper;
|
|
44
|
+
};
|
|
45
|
+
const mergedWrapperCol = mergedWrapperColFn();
|
|
46
|
+
const className = clsx(`${baseClassName.value}-control`, mergedWrapperCol?.class);
|
|
47
|
+
const inputDom = createVNode("div", { "class": `${baseClassName.value}-control-input` }, [createVNode("div", {
|
|
48
|
+
"class": clsx(`${baseClassName.value}-control-input-content`, contextClassNames.value?.content),
|
|
49
|
+
"style": contextStyles.value?.content
|
|
50
|
+
}, [children])]);
|
|
51
|
+
const errorListDom = marginBottom || errors.length || warnings.length ? createVNode(FormItemPrefixContextProvider, {
|
|
52
|
+
"prefixCls": prefixCls,
|
|
53
|
+
"status": status
|
|
54
|
+
}, { default: () => [createVNode(ErrorList, {
|
|
55
|
+
"fieldId": fieldId,
|
|
56
|
+
"errors": errors,
|
|
57
|
+
"warnings": warnings,
|
|
58
|
+
"help": help,
|
|
59
|
+
"helpStatus": status,
|
|
60
|
+
"class": `${baseClassName.value}-explain-connected`,
|
|
61
|
+
"onVisibleChanged": onErrorVisibleChanged
|
|
62
|
+
}, null)] }) : null;
|
|
63
|
+
const extraProps = {};
|
|
64
|
+
if (fieldId) extraProps.id = `${fieldId}_extra`;
|
|
65
|
+
const extraDom = extra ? createVNode("div", mergeProps(extraProps, {
|
|
66
|
+
"class": `${baseClassName.value}-extra`,
|
|
67
|
+
"ref": extraRef
|
|
68
|
+
}), [extra]) : null;
|
|
69
|
+
const additionalDom = errorListDom || extraDom ? createVNode("div", {
|
|
70
|
+
"class": `${baseClassName.value}-additional`,
|
|
71
|
+
"style": marginBottom ? { minHeight: `${marginBottom + extraHeight.value}px` } : {}
|
|
72
|
+
}, [errorListDom, extraDom]) : null;
|
|
73
|
+
const dom = formItemRender && formItemRender.mark === "pro_table_render" && formItemRender.render ? formItemRender.render(props, {
|
|
74
|
+
input: inputDom,
|
|
75
|
+
errorList: errorListDom,
|
|
76
|
+
extra: extraDom
|
|
77
|
+
}) : createVNode(Fragment, null, [inputDom, additionalDom]);
|
|
78
|
+
return createVNode(Col, mergeProps(mergedWrapperCol, { "class": className }), _isSlot(dom) ? dom : { default: () => [dom] });
|
|
79
|
+
};
|
|
80
|
+
}, {
|
|
81
|
+
props: {
|
|
82
|
+
labelCol: {
|
|
83
|
+
type: Object,
|
|
84
|
+
required: false
|
|
85
|
+
},
|
|
86
|
+
wrapperCol: {
|
|
87
|
+
type: Object,
|
|
88
|
+
required: false
|
|
89
|
+
},
|
|
90
|
+
extra: {
|
|
91
|
+
type: [
|
|
92
|
+
Function,
|
|
93
|
+
String,
|
|
94
|
+
Number,
|
|
95
|
+
null,
|
|
96
|
+
Object,
|
|
97
|
+
Boolean
|
|
98
|
+
],
|
|
99
|
+
required: false,
|
|
100
|
+
default: void 0
|
|
101
|
+
},
|
|
102
|
+
status: {
|
|
103
|
+
type: String,
|
|
104
|
+
required: false
|
|
105
|
+
},
|
|
106
|
+
help: {
|
|
107
|
+
type: [
|
|
108
|
+
Function,
|
|
109
|
+
String,
|
|
110
|
+
Number,
|
|
111
|
+
null,
|
|
112
|
+
Object,
|
|
113
|
+
Boolean
|
|
114
|
+
],
|
|
115
|
+
required: false,
|
|
116
|
+
default: void 0
|
|
117
|
+
},
|
|
118
|
+
fieldId: {
|
|
119
|
+
type: String,
|
|
120
|
+
required: false
|
|
121
|
+
},
|
|
122
|
+
label: {
|
|
123
|
+
type: [
|
|
124
|
+
Function,
|
|
125
|
+
String,
|
|
126
|
+
Number,
|
|
127
|
+
null,
|
|
128
|
+
Object,
|
|
129
|
+
Boolean
|
|
130
|
+
],
|
|
131
|
+
required: false,
|
|
132
|
+
default: void 0
|
|
133
|
+
},
|
|
134
|
+
prefixCls: {
|
|
135
|
+
type: String,
|
|
136
|
+
required: true
|
|
137
|
+
},
|
|
138
|
+
errors: {
|
|
139
|
+
type: Array,
|
|
140
|
+
required: true
|
|
141
|
+
},
|
|
142
|
+
warnings: {
|
|
143
|
+
type: Array,
|
|
144
|
+
required: true
|
|
145
|
+
},
|
|
146
|
+
marginBottom: {
|
|
147
|
+
type: [Number, null],
|
|
148
|
+
required: false
|
|
149
|
+
},
|
|
150
|
+
onErrorVisibleChanged: {
|
|
151
|
+
type: Function,
|
|
152
|
+
required: false
|
|
153
|
+
},
|
|
154
|
+
_internalItemRender: {
|
|
155
|
+
type: Object,
|
|
156
|
+
required: false
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
name: "FormItemInput",
|
|
160
|
+
inheritAttrs: false
|
|
161
|
+
});
|
|
162
|
+
//#endregion
|
|
163
|
+
export { FormItemInput as default };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { FormItemInputMiscProps } from "./FormItemInput.js";
|
|
2
|
+
import * as _$vue from "vue";
|
|
3
|
+
import { VNode } from "vue";
|
|
4
|
+
import { VueNode } from "@v-c/util";
|
|
5
|
+
import * as _$antdv_next0 from "antdv-next";
|
|
6
|
+
import * as _$antdv_next_dist_form_context0 from "antdv-next/dist/form/context";
|
|
7
|
+
import * as _$antdv_next_dist_form_types0 from "antdv-next/dist/form/types";
|
|
8
|
+
import { NamePath, StoreValue } from "antdv-next/dist/form/types";
|
|
9
|
+
import { FormItemInputProps } from "antdv-next/dist/form/FormItemInput";
|
|
10
|
+
|
|
11
|
+
//#region src/components/FormItem/ItemHolder.d.ts
|
|
12
|
+
declare const ItemHolder: _$vue.DefineSetupFnComponent<Omit<_$antdv_next0.FormItemProps, "preserve"> & {
|
|
13
|
+
errors: any[];
|
|
14
|
+
warnings: any[];
|
|
15
|
+
meta: _$antdv_next_dist_form_types0.Meta;
|
|
16
|
+
fieldId?: string;
|
|
17
|
+
isRequired?: boolean;
|
|
18
|
+
onSubItemMetaChange: _$antdv_next_dist_form_context0.ReportMetaChange;
|
|
19
|
+
} & {
|
|
20
|
+
initialValue?: any;
|
|
21
|
+
valuePropName?: "checked" | "value" | "fileList";
|
|
22
|
+
isListField?: boolean;
|
|
23
|
+
dependencies?: NamePath<string | number | boolean>[];
|
|
24
|
+
getValueFromEvent?: (...args: any[]) => StoreValue;
|
|
25
|
+
getValueProps?: (value: StoreValue) => Record<string, unknown>;
|
|
26
|
+
_internalItemRender?: {
|
|
27
|
+
mark: string;
|
|
28
|
+
render: (props: FormItemInputProps & FormItemInputMiscProps, domList: {
|
|
29
|
+
input: VNode;
|
|
30
|
+
errorList: VNode | null;
|
|
31
|
+
extra: VNode | null;
|
|
32
|
+
}) => VueNode;
|
|
33
|
+
};
|
|
34
|
+
}, {}, {}, Omit<_$antdv_next0.FormItemProps, "preserve"> & {
|
|
35
|
+
errors: any[];
|
|
36
|
+
warnings: any[];
|
|
37
|
+
meta: _$antdv_next_dist_form_types0.Meta;
|
|
38
|
+
fieldId?: string;
|
|
39
|
+
isRequired?: boolean;
|
|
40
|
+
onSubItemMetaChange: _$antdv_next_dist_form_context0.ReportMetaChange;
|
|
41
|
+
} & {
|
|
42
|
+
initialValue?: any;
|
|
43
|
+
valuePropName?: "checked" | "value" | "fileList";
|
|
44
|
+
isListField?: boolean;
|
|
45
|
+
dependencies?: NamePath<string | number | boolean>[];
|
|
46
|
+
getValueFromEvent?: (...args: any[]) => StoreValue;
|
|
47
|
+
getValueProps?: (value: StoreValue) => Record<string, unknown>;
|
|
48
|
+
_internalItemRender?: {
|
|
49
|
+
mark: string;
|
|
50
|
+
render: (props: FormItemInputProps & FormItemInputMiscProps, domList: {
|
|
51
|
+
input: VNode;
|
|
52
|
+
errorList: VNode | null;
|
|
53
|
+
extra: VNode | null;
|
|
54
|
+
}) => VueNode;
|
|
55
|
+
};
|
|
56
|
+
} & {}, _$vue.PublicProps>;
|
|
57
|
+
//#endregion
|
|
58
|
+
export { ItemHolder as default };
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import FormItemInput from "./FormItemInput.js";
|
|
2
|
+
import { computed, createVNode, defineComponent, mergeProps, nextTick, shallowRef, watch } from "vue";
|
|
3
|
+
import { clsx, omit } from "@v-c/util";
|
|
4
|
+
import { Row } from "antdv-next";
|
|
5
|
+
import { NoStyleItemContextProvider, useFormContext } from "antdv-next/dist/form/context";
|
|
6
|
+
import StatusProvider from "antdv-next/dist/form/FormItem/StatusProvider";
|
|
7
|
+
import { getStatus } from "antdv-next/dist/form/util";
|
|
8
|
+
import isVisible from "@v-c/util/dist/Dom/isVisible";
|
|
9
|
+
import { getAttrStyleAndClass } from "antdv-next/dist/_util/hooks/index";
|
|
10
|
+
import isNonNullable from "antdv-next/dist/_util/isNonNullable";
|
|
11
|
+
import FormItemLabel from "antdv-next/dist/form/FormItemLabel";
|
|
12
|
+
//#region src/components/FormItem/ItemHolder.tsx
|
|
13
|
+
const ItemHolder = /* @__PURE__ */ defineComponent((props, { attrs, slots }) => {
|
|
14
|
+
const itemPrefixCls = computed(() => `${props.prefixCls}-item`);
|
|
15
|
+
const formContext = useFormContext();
|
|
16
|
+
const layout = computed(() => props?.layout ?? formContext.value?.layout);
|
|
17
|
+
const vertical = computed(() => layout.value === "vertical");
|
|
18
|
+
const itemRef = shallowRef();
|
|
19
|
+
const hasHelp = computed(() => isNonNullable(props.help));
|
|
20
|
+
const hasError = computed(() => !!(hasHelp.value || props?.errors?.length || props?.warnings?.length));
|
|
21
|
+
const isOnScreen = computed(() => !!itemRef.value && isVisible(itemRef.value));
|
|
22
|
+
const marginBottom = shallowRef();
|
|
23
|
+
watch([hasError, isOnScreen], async () => {
|
|
24
|
+
await nextTick();
|
|
25
|
+
if (hasError.value && itemRef.value) {
|
|
26
|
+
const itemStyle = getComputedStyle(itemRef.value);
|
|
27
|
+
marginBottom.value = Number.parseInt(itemStyle.marginBottom, 10);
|
|
28
|
+
}
|
|
29
|
+
}, { immediate: true });
|
|
30
|
+
const onErrorVisibleChanged = (visible) => {
|
|
31
|
+
if (!visible) marginBottom.value = null;
|
|
32
|
+
};
|
|
33
|
+
function getValidateState(isDebounce = false) {
|
|
34
|
+
return getStatus(isDebounce ? props?.errors : props?.meta?.errors, isDebounce ? props?.warnings : props?.meta?.warnings, props?.meta, "", !!props?.hasFeedback, props?.validateStatus);
|
|
35
|
+
}
|
|
36
|
+
return () => {
|
|
37
|
+
const mergedValidateStatus = getValidateState();
|
|
38
|
+
const { prefixCls, rootClass, hasFeedback, hidden, fieldId, required, isRequired, meta, help, onSubItemMetaChange, name } = props;
|
|
39
|
+
const { className, style, restAttrs } = getAttrStyleAndClass(attrs);
|
|
40
|
+
const debounceErrors = props?.errors;
|
|
41
|
+
const debounceWarnings = props?.warnings;
|
|
42
|
+
return createVNode("div", {
|
|
43
|
+
"class": clsx(itemPrefixCls.value, className, rootClass, {
|
|
44
|
+
[`${itemPrefixCls.value}-with-help`]: hasHelp.value || debounceErrors.length || debounceWarnings.length,
|
|
45
|
+
[`${itemPrefixCls.value}-has-feedback`]: mergedValidateStatus && hasFeedback,
|
|
46
|
+
[`${itemPrefixCls.value}-has-success`]: mergedValidateStatus === "success",
|
|
47
|
+
[`${itemPrefixCls.value}-has-warning`]: mergedValidateStatus === "warning",
|
|
48
|
+
[`${itemPrefixCls.value}-has-error`]: mergedValidateStatus === "error",
|
|
49
|
+
[`${itemPrefixCls.value}-is-validating`]: mergedValidateStatus === "validating",
|
|
50
|
+
[`${itemPrefixCls.value}-hidden`]: hidden,
|
|
51
|
+
[`${itemPrefixCls.value}-${layout.value}`]: layout.value
|
|
52
|
+
}),
|
|
53
|
+
"style": style,
|
|
54
|
+
"ref": itemRef
|
|
55
|
+
}, [createVNode(Row, mergeProps({ "class": `${itemPrefixCls.value}-row` }, restAttrs), { default: () => [createVNode(FormItemLabel, mergeProps(omit(props, ["_internalItemRender"]), {
|
|
56
|
+
"htmlFor": props.htmlFor || fieldId,
|
|
57
|
+
"requiredMark": formContext.value?.requiredMark,
|
|
58
|
+
"required": required ?? isRequired,
|
|
59
|
+
"prefixCls": prefixCls,
|
|
60
|
+
"vertical": vertical.value
|
|
61
|
+
}), null), createVNode(FormItemInput, mergeProps(props, meta, {
|
|
62
|
+
"errors": debounceErrors,
|
|
63
|
+
"warnings": debounceWarnings,
|
|
64
|
+
"prefixCls": prefixCls,
|
|
65
|
+
"status": mergedValidateStatus,
|
|
66
|
+
"help": help,
|
|
67
|
+
"marginBottom": marginBottom.value,
|
|
68
|
+
"onErrorVisibleChanged": onErrorVisibleChanged
|
|
69
|
+
}), { default: () => [createVNode(NoStyleItemContextProvider, { "value": onSubItemMetaChange }, { default: () => [createVNode(StatusProvider, {
|
|
70
|
+
"prefixCls": prefixCls,
|
|
71
|
+
"meta": meta,
|
|
72
|
+
"errors": meta.errors,
|
|
73
|
+
"warnings": meta.warnings,
|
|
74
|
+
"hasFeedback": hasFeedback,
|
|
75
|
+
"validateStatus": mergedValidateStatus,
|
|
76
|
+
"name": name
|
|
77
|
+
}, { default: () => [slots?.default?.()] })] })] })] }), !!marginBottom.value && createVNode("div", {
|
|
78
|
+
"class": `${itemPrefixCls.value}-margin-offset`,
|
|
79
|
+
"style": { marginBottom: `${-marginBottom.value}px` }
|
|
80
|
+
}, null)]);
|
|
81
|
+
};
|
|
82
|
+
}, {
|
|
83
|
+
props: {
|
|
84
|
+
name: { required: false },
|
|
85
|
+
rules: {
|
|
86
|
+
type: Array,
|
|
87
|
+
required: false
|
|
88
|
+
},
|
|
89
|
+
trigger: {
|
|
90
|
+
type: [String, Array],
|
|
91
|
+
required: false
|
|
92
|
+
},
|
|
93
|
+
validateTrigger: {
|
|
94
|
+
type: [
|
|
95
|
+
String,
|
|
96
|
+
Array,
|
|
97
|
+
Boolean
|
|
98
|
+
],
|
|
99
|
+
required: false,
|
|
100
|
+
default: void 0
|
|
101
|
+
},
|
|
102
|
+
validateDebounce: {
|
|
103
|
+
type: Number,
|
|
104
|
+
required: false
|
|
105
|
+
},
|
|
106
|
+
validateFirst: {
|
|
107
|
+
type: [Boolean, String],
|
|
108
|
+
required: false,
|
|
109
|
+
default: void 0
|
|
110
|
+
},
|
|
111
|
+
rootClass: {
|
|
112
|
+
type: String,
|
|
113
|
+
required: false
|
|
114
|
+
},
|
|
115
|
+
prefixCls: {
|
|
116
|
+
type: String,
|
|
117
|
+
required: false
|
|
118
|
+
},
|
|
119
|
+
colon: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
required: false,
|
|
122
|
+
default: void 0
|
|
123
|
+
},
|
|
124
|
+
htmlFor: {
|
|
125
|
+
type: String,
|
|
126
|
+
required: false
|
|
127
|
+
},
|
|
128
|
+
label: {
|
|
129
|
+
type: [
|
|
130
|
+
Function,
|
|
131
|
+
String,
|
|
132
|
+
Number,
|
|
133
|
+
null,
|
|
134
|
+
Object,
|
|
135
|
+
Boolean
|
|
136
|
+
],
|
|
137
|
+
required: false,
|
|
138
|
+
default: void 0
|
|
139
|
+
},
|
|
140
|
+
labelAlign: {
|
|
141
|
+
type: String,
|
|
142
|
+
required: false
|
|
143
|
+
},
|
|
144
|
+
labelCol: {
|
|
145
|
+
type: Object,
|
|
146
|
+
required: false
|
|
147
|
+
},
|
|
148
|
+
tooltip: {
|
|
149
|
+
type: [
|
|
150
|
+
Object,
|
|
151
|
+
Function,
|
|
152
|
+
String,
|
|
153
|
+
Number,
|
|
154
|
+
null,
|
|
155
|
+
Boolean
|
|
156
|
+
],
|
|
157
|
+
required: false,
|
|
158
|
+
default: void 0
|
|
159
|
+
},
|
|
160
|
+
vertical: {
|
|
161
|
+
type: Boolean,
|
|
162
|
+
required: false,
|
|
163
|
+
default: void 0
|
|
164
|
+
},
|
|
165
|
+
wrapperCol: {
|
|
166
|
+
type: Object,
|
|
167
|
+
required: false
|
|
168
|
+
},
|
|
169
|
+
extra: {
|
|
170
|
+
type: [
|
|
171
|
+
Function,
|
|
172
|
+
String,
|
|
173
|
+
Number,
|
|
174
|
+
null,
|
|
175
|
+
Object,
|
|
176
|
+
Boolean
|
|
177
|
+
],
|
|
178
|
+
required: false,
|
|
179
|
+
default: void 0
|
|
180
|
+
},
|
|
181
|
+
status: {
|
|
182
|
+
type: String,
|
|
183
|
+
required: false
|
|
184
|
+
},
|
|
185
|
+
help: {
|
|
186
|
+
type: [
|
|
187
|
+
Function,
|
|
188
|
+
String,
|
|
189
|
+
Number,
|
|
190
|
+
null,
|
|
191
|
+
Object,
|
|
192
|
+
Boolean
|
|
193
|
+
],
|
|
194
|
+
required: false,
|
|
195
|
+
default: void 0
|
|
196
|
+
},
|
|
197
|
+
fieldId: {
|
|
198
|
+
type: String,
|
|
199
|
+
required: false
|
|
200
|
+
},
|
|
201
|
+
noStyle: {
|
|
202
|
+
type: Boolean,
|
|
203
|
+
required: false,
|
|
204
|
+
default: void 0
|
|
205
|
+
},
|
|
206
|
+
id: {
|
|
207
|
+
type: String,
|
|
208
|
+
required: false
|
|
209
|
+
},
|
|
210
|
+
hasFeedback: {
|
|
211
|
+
type: [Boolean, Object],
|
|
212
|
+
required: false,
|
|
213
|
+
default: void 0
|
|
214
|
+
},
|
|
215
|
+
validateStatus: {
|
|
216
|
+
type: String,
|
|
217
|
+
required: false
|
|
218
|
+
},
|
|
219
|
+
required: {
|
|
220
|
+
type: Boolean,
|
|
221
|
+
required: false,
|
|
222
|
+
default: void 0
|
|
223
|
+
},
|
|
224
|
+
hidden: {
|
|
225
|
+
type: Boolean,
|
|
226
|
+
required: false,
|
|
227
|
+
default: void 0
|
|
228
|
+
},
|
|
229
|
+
messageVariables: {
|
|
230
|
+
type: Object,
|
|
231
|
+
required: false
|
|
232
|
+
},
|
|
233
|
+
layout: {
|
|
234
|
+
type: String,
|
|
235
|
+
required: false
|
|
236
|
+
},
|
|
237
|
+
errors: {
|
|
238
|
+
type: Array,
|
|
239
|
+
required: true
|
|
240
|
+
},
|
|
241
|
+
warnings: {
|
|
242
|
+
type: Array,
|
|
243
|
+
required: true
|
|
244
|
+
},
|
|
245
|
+
meta: {
|
|
246
|
+
type: Object,
|
|
247
|
+
required: true
|
|
248
|
+
},
|
|
249
|
+
isRequired: {
|
|
250
|
+
type: Boolean,
|
|
251
|
+
required: false,
|
|
252
|
+
default: void 0
|
|
253
|
+
},
|
|
254
|
+
onSubItemMetaChange: {
|
|
255
|
+
type: Function,
|
|
256
|
+
required: true
|
|
257
|
+
},
|
|
258
|
+
initialValue: { required: false },
|
|
259
|
+
valuePropName: {
|
|
260
|
+
type: String,
|
|
261
|
+
required: false
|
|
262
|
+
},
|
|
263
|
+
isListField: {
|
|
264
|
+
type: Boolean,
|
|
265
|
+
required: false,
|
|
266
|
+
default: void 0
|
|
267
|
+
},
|
|
268
|
+
dependencies: {
|
|
269
|
+
type: Array,
|
|
270
|
+
required: false
|
|
271
|
+
},
|
|
272
|
+
getValueFromEvent: {
|
|
273
|
+
type: Function,
|
|
274
|
+
required: false
|
|
275
|
+
},
|
|
276
|
+
getValueProps: {
|
|
277
|
+
type: Function,
|
|
278
|
+
required: false
|
|
279
|
+
},
|
|
280
|
+
_internalItemRender: {
|
|
281
|
+
type: Object,
|
|
282
|
+
required: false
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
name: "FormItemHolder",
|
|
286
|
+
inheritAttrs: false
|
|
287
|
+
});
|
|
288
|
+
//#endregion
|
|
289
|
+
export { ItemHolder as default };
|