@carefrees/form-utils-vue 0.0.8
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/README.md +3 -0
- package/assets/index.css +207 -0
- package/esm/component.d.ts +3 -0
- package/esm/component.mjs +12 -0
- package/esm/form/index.d.ts +37 -0
- package/esm/form/index.mjs +6 -0
- package/esm/form/index.vue.d.ts +19 -0
- package/esm/form/index.vue.mjs +110 -0
- package/esm/form/index.vue2.mjs +4 -0
- package/esm/formItem/form.Item.base.vue.d.ts +16 -0
- package/esm/formItem/form.Item.base.vue.mjs +114 -0
- package/esm/formItem/form.Item.base.vue2.mjs +4 -0
- package/esm/formItem/form.hide.item.vue.d.ts +16 -0
- package/esm/formItem/form.hide.item.vue.mjs +78 -0
- package/esm/formItem/form.hide.item.vue2.mjs +4 -0
- package/esm/formItem/formItem.vue.d.ts +18 -0
- package/esm/formItem/formItem.vue.mjs +102 -0
- package/esm/formItem/formItem.vue2.mjs +4 -0
- package/esm/formItem/index.d.ts +71 -0
- package/esm/formItem/index.mjs +12 -0
- package/esm/hooks/attr/attr.FormItem.d.ts +876 -0
- package/esm/hooks/attr/attr.FormItem.mjs +120 -0
- package/esm/hooks/index.d.ts +13 -0
- package/esm/hooks/register/register.FormHideItem.d.ts +9 -0
- package/esm/hooks/register/register.FormHideItem.mjs +38 -0
- package/esm/hooks/register/register.FormItem.d.ts +802 -0
- package/esm/hooks/register/register.FormItem.mjs +55 -0
- package/esm/hooks/register/register.FormList.d.ts +789 -0
- package/esm/hooks/register/register.FormList.mjs +43 -0
- package/esm/hooks/register/register.form.d.ts +3 -0
- package/esm/hooks/register/register.form.mjs +12 -0
- package/esm/hooks/useAttrs.d.ts +24 -0
- package/esm/hooks/useAttrs.mjs +45 -0
- package/esm/hooks/useEffect.d.ts +2 -0
- package/esm/hooks/useEffect.mjs +14 -0
- package/esm/hooks/useForm.d.ts +8 -0
- package/esm/hooks/useForm.mjs +26 -0
- package/esm/hooks/useFormItem.d.ts +7 -0
- package/esm/hooks/useFormItem.mjs +26 -0
- package/esm/hooks/useFormItemParentName.d.ts +18 -0
- package/esm/hooks/useFormItemParentName.mjs +37 -0
- package/esm/hooks/useFormList.d.ts +7 -0
- package/esm/hooks/useFormList.mjs +26 -0
- package/esm/hooks/useHtmlFor.d.ts +2 -0
- package/esm/hooks/useHtmlFor.mjs +11 -0
- package/esm/hooks/useMultipleForm.d.ts +7 -0
- package/esm/hooks/useMultipleForm.mjs +27 -0
- package/esm/index.d.ts +11 -0
- package/esm/index.mjs +59 -0
- package/esm/instance/ruleIntsnace.d.ts +49 -0
- package/esm/instance/ruleIntsnace.mjs +73 -0
- package/esm/interface/index.d.ts +36 -0
- package/esm/interface/layout.d.ts +28 -0
- package/esm/interface/layout.formItem.d.ts +39 -0
- package/esm/layout/index.d.ts +65 -0
- package/esm/layout/index.mjs +12 -0
- package/esm/layout/layout.form.rows.vue.d.ts +10 -0
- package/esm/layout/layout.form.rows.vue.mjs +31 -0
- package/esm/layout/layout.form.rows.vue2.mjs +4 -0
- package/esm/layout/layout.formItem.vue.d.ts +18 -0
- package/esm/layout/layout.formItem.vue.mjs +216 -0
- package/esm/layout/layout.formItem.vue2.mjs +4 -0
- package/esm/layout/layout.vue.d.ts +16 -0
- package/esm/layout/layout.vue.mjs +166 -0
- package/esm/layout/layout.vue2.mjs +4 -0
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/withInstall.d.ts +3 -0
- package/esm/utils/withInstall.mjs +22 -0
- package/lib/component.d.ts +3 -0
- package/lib/component.js +12 -0
- package/lib/form/index.d.ts +37 -0
- package/lib/form/index.js +6 -0
- package/lib/form/index.vue.d.ts +19 -0
- package/lib/form/index.vue.js +110 -0
- package/lib/form/index.vue2.js +4 -0
- package/lib/formItem/form.Item.base.vue.d.ts +16 -0
- package/lib/formItem/form.Item.base.vue.js +114 -0
- package/lib/formItem/form.Item.base.vue2.js +4 -0
- package/lib/formItem/form.hide.item.vue.d.ts +16 -0
- package/lib/formItem/form.hide.item.vue.js +78 -0
- package/lib/formItem/form.hide.item.vue2.js +4 -0
- package/lib/formItem/formItem.vue.d.ts +18 -0
- package/lib/formItem/formItem.vue.js +102 -0
- package/lib/formItem/formItem.vue2.js +4 -0
- package/lib/formItem/index.d.ts +71 -0
- package/lib/formItem/index.js +12 -0
- package/lib/hooks/attr/attr.FormItem.d.ts +876 -0
- package/lib/hooks/attr/attr.FormItem.js +120 -0
- package/lib/hooks/index.d.ts +13 -0
- package/lib/hooks/register/register.FormHideItem.d.ts +9 -0
- package/lib/hooks/register/register.FormHideItem.js +38 -0
- package/lib/hooks/register/register.FormItem.d.ts +802 -0
- package/lib/hooks/register/register.FormItem.js +55 -0
- package/lib/hooks/register/register.FormList.d.ts +789 -0
- package/lib/hooks/register/register.FormList.js +43 -0
- package/lib/hooks/register/register.form.d.ts +3 -0
- package/lib/hooks/register/register.form.js +12 -0
- package/lib/hooks/useAttrs.d.ts +24 -0
- package/lib/hooks/useAttrs.js +45 -0
- package/lib/hooks/useEffect.d.ts +2 -0
- package/lib/hooks/useEffect.js +14 -0
- package/lib/hooks/useForm.d.ts +8 -0
- package/lib/hooks/useForm.js +26 -0
- package/lib/hooks/useFormItem.d.ts +7 -0
- package/lib/hooks/useFormItem.js +26 -0
- package/lib/hooks/useFormItemParentName.d.ts +18 -0
- package/lib/hooks/useFormItemParentName.js +37 -0
- package/lib/hooks/useFormList.d.ts +7 -0
- package/lib/hooks/useFormList.js +26 -0
- package/lib/hooks/useHtmlFor.d.ts +2 -0
- package/lib/hooks/useHtmlFor.js +11 -0
- package/lib/hooks/useMultipleForm.d.ts +7 -0
- package/lib/hooks/useMultipleForm.js +27 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +59 -0
- package/lib/instance/ruleIntsnace.d.ts +49 -0
- package/lib/instance/ruleIntsnace.js +73 -0
- package/lib/interface/index.d.ts +36 -0
- package/lib/interface/layout.d.ts +28 -0
- package/lib/interface/layout.formItem.d.ts +39 -0
- package/lib/layout/index.d.ts +65 -0
- package/lib/layout/index.js +12 -0
- package/lib/layout/layout.form.rows.vue.d.ts +10 -0
- package/lib/layout/layout.form.rows.vue.js +31 -0
- package/lib/layout/layout.form.rows.vue2.js +4 -0
- package/lib/layout/layout.formItem.vue.d.ts +18 -0
- package/lib/layout/layout.formItem.vue.js +216 -0
- package/lib/layout/layout.formItem.vue2.js +4 -0
- package/lib/layout/layout.vue.d.ts +16 -0
- package/lib/layout/layout.vue.js +166 -0
- package/lib/layout/layout.vue2.js +4 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/withInstall.d.ts +3 -0
- package/lib/utils/withInstall.js +22 -0
- package/package.json +33 -0
- package/src/component.ts +3 -0
- package/src/form/index.ts +3 -0
- package/src/form/index.vue +66 -0
- package/src/formItem/form.Item.base.vue +54 -0
- package/src/formItem/form.hide.item.vue +28 -0
- package/src/formItem/formItem.vue +38 -0
- package/src/formItem/index.ts +7 -0
- package/src/hooks/attr/attr.FormItem.tsx +170 -0
- package/src/hooks/index.ts +13 -0
- package/src/hooks/register/register.FormHideItem.ts +45 -0
- package/src/hooks/register/register.FormItem.ts +80 -0
- package/src/hooks/register/register.FormList.ts +49 -0
- package/src/hooks/register/register.form.ts +12 -0
- package/src/hooks/useAttrs.ts +66 -0
- package/src/hooks/useEffect.ts +13 -0
- package/src/hooks/useForm.ts +28 -0
- package/src/hooks/useFormItem.ts +28 -0
- package/src/hooks/useFormItemParentName.ts +49 -0
- package/src/hooks/useFormList.ts +28 -0
- package/src/hooks/useHtmlFor.ts +9 -0
- package/src/hooks/useMultipleForm.ts +29 -0
- package/src/index.ts +16 -0
- package/src/instance/ruleIntsnace.ts +105 -0
- package/src/interface/index.ts +40 -0
- package/src/interface/layout.formItem.ts +42 -0
- package/src/interface/layout.ts +29 -0
- package/src/layout/index.ts +8 -0
- package/src/layout/layout.form.rows.vue +19 -0
- package/src/layout/layout.formItem.vue +119 -0
- package/src/layout/layout.vue +97 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/withInstall.ts +28 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export declare const Layout: import('../utils').SFCWithInstall<{
|
|
2
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('..').FormLayoutProps> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
|
3
|
+
P: {};
|
|
4
|
+
B: {};
|
|
5
|
+
D: {};
|
|
6
|
+
C: {};
|
|
7
|
+
M: {};
|
|
8
|
+
Defaults: {};
|
|
9
|
+
}, Readonly<import('..').FormLayoutProps> & Readonly<{}>, {}, {}, {}, {}, {}>;
|
|
10
|
+
__isFragment?: undefined;
|
|
11
|
+
__isTeleport?: undefined;
|
|
12
|
+
__isSuspense?: undefined;
|
|
13
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('..').FormLayoutProps> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
14
|
+
$slots: Readonly<{
|
|
15
|
+
default: any;
|
|
16
|
+
title: any;
|
|
17
|
+
extra: any;
|
|
18
|
+
}> & {
|
|
19
|
+
default: any;
|
|
20
|
+
title: any;
|
|
21
|
+
extra: any;
|
|
22
|
+
};
|
|
23
|
+
})> & Record<string, any>;
|
|
24
|
+
export declare const LayoutFormItem: import('../utils').SFCWithInstall<{
|
|
25
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('..').LayoutFormItemProps> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
|
26
|
+
P: {};
|
|
27
|
+
B: {};
|
|
28
|
+
D: {};
|
|
29
|
+
C: {};
|
|
30
|
+
M: {};
|
|
31
|
+
Defaults: {};
|
|
32
|
+
}, Readonly<import('..').LayoutFormItemProps> & Readonly<{}>, {}, {}, {}, {}, {}>;
|
|
33
|
+
__isFragment?: undefined;
|
|
34
|
+
__isTeleport?: undefined;
|
|
35
|
+
__isSuspense?: undefined;
|
|
36
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('..').LayoutFormItemProps> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
37
|
+
$slots: Readonly<{
|
|
38
|
+
default: any;
|
|
39
|
+
label: any;
|
|
40
|
+
helpText: any;
|
|
41
|
+
extra: any;
|
|
42
|
+
}> & {
|
|
43
|
+
default: any;
|
|
44
|
+
label: any;
|
|
45
|
+
helpText: any;
|
|
46
|
+
extra: any;
|
|
47
|
+
};
|
|
48
|
+
})> & Record<string, any>;
|
|
49
|
+
export declare const FormLayoutRows: import('../utils').SFCWithInstall<{
|
|
50
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('vue').HTMLAttributes> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
|
51
|
+
P: {};
|
|
52
|
+
B: {};
|
|
53
|
+
D: {};
|
|
54
|
+
C: {};
|
|
55
|
+
M: {};
|
|
56
|
+
Defaults: {};
|
|
57
|
+
}, Readonly<import('vue').HTMLAttributes> & Readonly<{}>, {}, {}, {}, {}, {}>;
|
|
58
|
+
__isFragment?: undefined;
|
|
59
|
+
__isTeleport?: undefined;
|
|
60
|
+
__isSuspense?: undefined;
|
|
61
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('vue').HTMLAttributes> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
62
|
+
$slots: {
|
|
63
|
+
default?(_: {}): any;
|
|
64
|
+
};
|
|
65
|
+
})> & Record<string, any>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _sfc_main from "./layout.vue.mjs";
|
|
2
|
+
import _sfc_main$1 from "./layout.formItem.vue.mjs";
|
|
3
|
+
import _sfc_main$2 from "./layout.form.rows.vue.mjs";
|
|
4
|
+
import { withInstall } from "../utils/withInstall.mjs";
|
|
5
|
+
const Layout = withInstall(_sfc_main);
|
|
6
|
+
const LayoutFormItem = withInstall(_sfc_main$1);
|
|
7
|
+
const FormLayoutRows = withInstall(_sfc_main$2);
|
|
8
|
+
export {
|
|
9
|
+
FormLayoutRows,
|
|
10
|
+
Layout,
|
|
11
|
+
LayoutFormItem
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'vue';
|
|
2
|
+
declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<HTMLAttributes, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<HTMLAttributes> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, {
|
|
3
|
+
default?(_: {}): any;
|
|
4
|
+
}>;
|
|
5
|
+
export default _default;
|
|
6
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
7
|
+
new (): {
|
|
8
|
+
$slots: S;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineComponent, computed, createElementBlock, openBlock, mergeProps, renderSlot } from "vue";
|
|
2
|
+
import clx from "classnames";
|
|
3
|
+
const __default__ = defineComponent({
|
|
4
|
+
name: "FormLayoutRows",
|
|
5
|
+
inheritAttrs: false
|
|
6
|
+
// 可选,防止属性自动应用到根元素
|
|
7
|
+
});
|
|
8
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
9
|
+
...__default__,
|
|
10
|
+
setup(__props) {
|
|
11
|
+
const preCls = "carefrees-form-layout";
|
|
12
|
+
const props = __props;
|
|
13
|
+
const cls = computed(() => clx(preCls, props.class, {
|
|
14
|
+
"all-colspan": true
|
|
15
|
+
}));
|
|
16
|
+
return (_ctx, _cache) => {
|
|
17
|
+
return openBlock(), createElementBlock(
|
|
18
|
+
"div",
|
|
19
|
+
mergeProps(props, { class: cls.value }),
|
|
20
|
+
[
|
|
21
|
+
renderSlot(_ctx.$slots, "default")
|
|
22
|
+
],
|
|
23
|
+
16
|
|
24
|
+
/* FULL_PROPS */
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
_sfc_main as default
|
|
31
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LayoutFormItemProps } from '../interface/layout.formItem';
|
|
2
|
+
declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<LayoutFormItemProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<LayoutFormItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, Readonly<{
|
|
3
|
+
default: any;
|
|
4
|
+
label: any;
|
|
5
|
+
helpText: any;
|
|
6
|
+
extra: any;
|
|
7
|
+
}> & {
|
|
8
|
+
default: any;
|
|
9
|
+
label: any;
|
|
10
|
+
helpText: any;
|
|
11
|
+
extra: any;
|
|
12
|
+
}>;
|
|
13
|
+
export default _default;
|
|
14
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
15
|
+
new (): {
|
|
16
|
+
$slots: S;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { defineComponent, useSlots, computed, toValue, createElementBlock, openBlock, normalizeStyle, normalizeClass, createElementVNode, createCommentVNode, renderSlot, Fragment, createTextVNode, toDisplayString } from "vue";
|
|
2
|
+
import clx from "classnames";
|
|
3
|
+
import { useAttrsInject } from "../hooks/useAttrs.mjs";
|
|
4
|
+
const _hoisted_1 = ["for"];
|
|
5
|
+
const __default__ = defineComponent({
|
|
6
|
+
name: "LayoutFormItem",
|
|
7
|
+
inheritAttrs: false
|
|
8
|
+
// 可选,防止属性自动应用到根元素
|
|
9
|
+
});
|
|
10
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
11
|
+
...__default__,
|
|
12
|
+
props: {
|
|
13
|
+
errorLayout: {},
|
|
14
|
+
required: { type: Boolean },
|
|
15
|
+
labelMode: {},
|
|
16
|
+
onlyRuleStyle: { type: Boolean },
|
|
17
|
+
label: { type: [Object, String, Number, Boolean, null, Array] },
|
|
18
|
+
helpText: { type: [Object, String, Number, Boolean, null, Array] },
|
|
19
|
+
extra: { type: [Object, String, Number, Boolean, null, Array] },
|
|
20
|
+
showColon: { type: Boolean },
|
|
21
|
+
colSpan: {},
|
|
22
|
+
rowSpan: {},
|
|
23
|
+
htmlFor: {},
|
|
24
|
+
validateResult: {},
|
|
25
|
+
style: { type: [Boolean, null, String, Object, Array] },
|
|
26
|
+
class: {},
|
|
27
|
+
labelStyle: { type: [Boolean, null, String, Object, Array] },
|
|
28
|
+
labelClass: {}
|
|
29
|
+
},
|
|
30
|
+
setup(__props) {
|
|
31
|
+
const preCls = "carefrees-form-item";
|
|
32
|
+
const attrs = useAttrsInject();
|
|
33
|
+
const props = __props;
|
|
34
|
+
const solts = useSlots();
|
|
35
|
+
const labelMode = computed(() => props.labelMode ?? toValue(attrs.value.labelMode) ?? "top");
|
|
36
|
+
const showColon = computed(() => props.showColon ?? toValue(attrs.value.showColon));
|
|
37
|
+
const errorLayout = computed(() => props.errorLayout ?? toValue(attrs.value.errorLayout) ?? "left-bottom");
|
|
38
|
+
const tips = computed(() => {
|
|
39
|
+
var _a;
|
|
40
|
+
const v = (_a = toValue(props.validateResult)) == null ? void 0 : _a.tip;
|
|
41
|
+
if (Array.isArray(v)) {
|
|
42
|
+
return v.join(",");
|
|
43
|
+
}
|
|
44
|
+
return v;
|
|
45
|
+
});
|
|
46
|
+
const cls = computed(() => {
|
|
47
|
+
var _a;
|
|
48
|
+
return clx(preCls, props.class, toValue(attrs.value.formItemClass), { "dx-invalid": !!((_a = toValue(props.validateResult)) == null ? void 0 : _a.isInvalid) });
|
|
49
|
+
});
|
|
50
|
+
const containerCls = computed(() => clx(`${preCls}-container`, { [`${labelMode.value}`]: !!labelMode.value }));
|
|
51
|
+
const labelCls = computed(() => clx(`${preCls}-label`, { required: !!props.required, "show-colon": showColon && (labelMode.value === "left" || labelMode.value === "between") }));
|
|
52
|
+
const labelWarpCls = computed(() => clx(`${preCls}-label-warp`, toValue(props.labelClass), toValue(attrs.value.formItemLabelClass)));
|
|
53
|
+
const inputCls = computed(() => clx(`${preCls}-body-input`));
|
|
54
|
+
const errorCls = computed(() => clx(`${preCls}-body-error`, { [errorLayout.value]: !!errorLayout.value }));
|
|
55
|
+
const _isLabel = computed(() => (props.label || solts.label) && labelMode.value !== "hide");
|
|
56
|
+
const style = computed(() => {
|
|
57
|
+
const css = {};
|
|
58
|
+
if (props.onlyRuleStyle) {
|
|
59
|
+
css.padding = "0px";
|
|
60
|
+
}
|
|
61
|
+
if (props.colSpan) {
|
|
62
|
+
const colCount = toValue(attrs.value.colCount) || 4;
|
|
63
|
+
const end = colCount > props.colSpan ? props.colSpan : colCount;
|
|
64
|
+
css.gridColumnEnd = `span ${end}`;
|
|
65
|
+
}
|
|
66
|
+
if (props.rowSpan) {
|
|
67
|
+
css.gridRowEnd = `span ${props.rowSpan}`;
|
|
68
|
+
}
|
|
69
|
+
return [toValue(attrs.value.formItemStyle), props.style, css];
|
|
70
|
+
});
|
|
71
|
+
const labelStyle = computed(() => {
|
|
72
|
+
return [toValue(attrs.value.formItemLabelStyle), props.labelStyle];
|
|
73
|
+
});
|
|
74
|
+
const isHelpText = computed(() => {
|
|
75
|
+
return !!props.helpText || solts.helpText;
|
|
76
|
+
});
|
|
77
|
+
const isExtra = computed(() => {
|
|
78
|
+
return !!props.extra || solts.extra;
|
|
79
|
+
});
|
|
80
|
+
return (_ctx, _cache) => {
|
|
81
|
+
return openBlock(), createElementBlock(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
class: normalizeClass(cls.value),
|
|
85
|
+
style: normalizeStyle(style.value)
|
|
86
|
+
},
|
|
87
|
+
[
|
|
88
|
+
createElementVNode(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
class: normalizeClass(containerCls.value)
|
|
92
|
+
},
|
|
93
|
+
[
|
|
94
|
+
_isLabel.value ? (openBlock(), createElementBlock(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
key: 0,
|
|
98
|
+
class: normalizeClass(labelWarpCls.value)
|
|
99
|
+
},
|
|
100
|
+
[
|
|
101
|
+
createElementVNode("label", {
|
|
102
|
+
style: normalizeStyle(labelStyle.value),
|
|
103
|
+
class: normalizeClass(labelCls.value),
|
|
104
|
+
for: toValue(props.htmlFor)
|
|
105
|
+
}, [
|
|
106
|
+
props.label ? (openBlock(), createElementBlock(
|
|
107
|
+
Fragment,
|
|
108
|
+
{ key: 0 },
|
|
109
|
+
[
|
|
110
|
+
createTextVNode(
|
|
111
|
+
toDisplayString(props.label),
|
|
112
|
+
1
|
|
113
|
+
/* TEXT */
|
|
114
|
+
)
|
|
115
|
+
],
|
|
116
|
+
64
|
|
117
|
+
/* STABLE_FRAGMENT */
|
|
118
|
+
)) : renderSlot(_ctx.$slots, "label", { key: 1 })
|
|
119
|
+
], 14, _hoisted_1)
|
|
120
|
+
],
|
|
121
|
+
2
|
|
122
|
+
/* CLASS */
|
|
123
|
+
)) : createCommentVNode("v-if", true),
|
|
124
|
+
createElementVNode(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
class: normalizeClass(preCls + "-body")
|
|
128
|
+
},
|
|
129
|
+
[
|
|
130
|
+
createElementVNode(
|
|
131
|
+
"div",
|
|
132
|
+
{
|
|
133
|
+
class: normalizeClass(inputCls.value)
|
|
134
|
+
},
|
|
135
|
+
[
|
|
136
|
+
renderSlot(_ctx.$slots, "default")
|
|
137
|
+
],
|
|
138
|
+
2
|
|
139
|
+
/* CLASS */
|
|
140
|
+
),
|
|
141
|
+
isHelpText.value ? (openBlock(), createElementBlock(
|
|
142
|
+
"div",
|
|
143
|
+
{
|
|
144
|
+
key: 0,
|
|
145
|
+
class: normalizeClass(preCls + "-body-help")
|
|
146
|
+
},
|
|
147
|
+
[
|
|
148
|
+
props.helpText ? (openBlock(), createElementBlock(
|
|
149
|
+
Fragment,
|
|
150
|
+
{ key: 0 },
|
|
151
|
+
[
|
|
152
|
+
createTextVNode(
|
|
153
|
+
toDisplayString(props.helpText),
|
|
154
|
+
1
|
|
155
|
+
/* TEXT */
|
|
156
|
+
)
|
|
157
|
+
],
|
|
158
|
+
64
|
|
159
|
+
/* STABLE_FRAGMENT */
|
|
160
|
+
)) : renderSlot(_ctx.$slots, "helpText", { key: 1 })
|
|
161
|
+
],
|
|
162
|
+
2
|
|
163
|
+
/* CLASS */
|
|
164
|
+
)) : createCommentVNode("v-if", true),
|
|
165
|
+
!!tips.value ? (openBlock(), createElementBlock(
|
|
166
|
+
"div",
|
|
167
|
+
{
|
|
168
|
+
key: 1,
|
|
169
|
+
class: normalizeClass(errorCls.value)
|
|
170
|
+
},
|
|
171
|
+
toDisplayString(tips.value),
|
|
172
|
+
3
|
|
173
|
+
/* TEXT, CLASS */
|
|
174
|
+
)) : createCommentVNode("v-if", true)
|
|
175
|
+
],
|
|
176
|
+
2
|
|
177
|
+
/* CLASS */
|
|
178
|
+
)
|
|
179
|
+
],
|
|
180
|
+
2
|
|
181
|
+
/* CLASS */
|
|
182
|
+
),
|
|
183
|
+
isExtra.value ? (openBlock(), createElementBlock(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
key: 0,
|
|
187
|
+
class: normalizeClass(preCls + "-extra")
|
|
188
|
+
},
|
|
189
|
+
[
|
|
190
|
+
props.extra ? (openBlock(), createElementBlock(
|
|
191
|
+
Fragment,
|
|
192
|
+
{ key: 0 },
|
|
193
|
+
[
|
|
194
|
+
createTextVNode(
|
|
195
|
+
toDisplayString(props.extra),
|
|
196
|
+
1
|
|
197
|
+
/* TEXT */
|
|
198
|
+
)
|
|
199
|
+
],
|
|
200
|
+
64
|
|
201
|
+
/* STABLE_FRAGMENT */
|
|
202
|
+
)) : renderSlot(_ctx.$slots, "extra", { key: 1 })
|
|
203
|
+
],
|
|
204
|
+
2
|
|
205
|
+
/* CLASS */
|
|
206
|
+
)) : createCommentVNode("v-if", true)
|
|
207
|
+
],
|
|
208
|
+
6
|
|
209
|
+
/* CLASS, STYLE */
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
export {
|
|
215
|
+
_sfc_main as default
|
|
216
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FormLayoutProps } from '../interface/layout';
|
|
2
|
+
declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<FormLayoutProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FormLayoutProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, Readonly<{
|
|
3
|
+
default: any;
|
|
4
|
+
title: any;
|
|
5
|
+
extra: any;
|
|
6
|
+
}> & {
|
|
7
|
+
default: any;
|
|
8
|
+
title: any;
|
|
9
|
+
extra: any;
|
|
10
|
+
}>;
|
|
11
|
+
export default _default;
|
|
12
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
13
|
+
new (): {
|
|
14
|
+
$slots: S;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { defineComponent, useSlots, computed, toValue, createElementBlock, openBlock, normalizeClass, normalizeStyle, createCommentVNode, createElementVNode, renderSlot, Fragment, createTextVNode, toDisplayString } from "vue";
|
|
2
|
+
import clx from "classnames";
|
|
3
|
+
import { useAttrsInject, useAttrsProvide } from "../hooks/useAttrs.mjs";
|
|
4
|
+
const __default__ = defineComponent({
|
|
5
|
+
name: "Layout",
|
|
6
|
+
inheritAttrs: false
|
|
7
|
+
// 可选,防止属性自动应用到根元素
|
|
8
|
+
});
|
|
9
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
10
|
+
...__default__,
|
|
11
|
+
props: {
|
|
12
|
+
title: { type: [Object, String, Number, Boolean, null, Array] },
|
|
13
|
+
extra: { type: [Object, String, Number, Boolean, null, Array] },
|
|
14
|
+
isAllColSpan: { type: Boolean },
|
|
15
|
+
class: {},
|
|
16
|
+
headerClass: {},
|
|
17
|
+
bodyClass: {},
|
|
18
|
+
style: { type: [Boolean, null, String, Object, Array] },
|
|
19
|
+
headerStyle: { type: [Boolean, null, String, Object, Array] },
|
|
20
|
+
bodyStyle: { type: [Boolean, null, String, Object, Array] },
|
|
21
|
+
bordered: { type: Boolean },
|
|
22
|
+
colCount: {},
|
|
23
|
+
gap: {},
|
|
24
|
+
errorLayout: {},
|
|
25
|
+
labelMode: {},
|
|
26
|
+
showColon: {},
|
|
27
|
+
formItemClass: {},
|
|
28
|
+
formItemStyle: {},
|
|
29
|
+
formItemLabelClass: {},
|
|
30
|
+
formItemLabelStyle: {}
|
|
31
|
+
},
|
|
32
|
+
setup(__props) {
|
|
33
|
+
const preCls = "carefrees-form-layout";
|
|
34
|
+
const attrs = useAttrsInject();
|
|
35
|
+
const props = __props;
|
|
36
|
+
const solts = useSlots();
|
|
37
|
+
const colCount = computed(() => toValue(props.colCount) ?? toValue(attrs.value.colCount));
|
|
38
|
+
const errorLayout = computed(() => toValue(props.errorLayout) ?? toValue(attrs.value.errorLayout));
|
|
39
|
+
const labelMode = computed(() => toValue(props.labelMode) ?? toValue(attrs.value.labelMode));
|
|
40
|
+
const showColon = computed(() => toValue(props.showColon) ?? toValue(attrs.value.showColon));
|
|
41
|
+
const formItemClass = computed(() => toValue(props.formItemClass) ?? toValue(attrs.value.formItemClass));
|
|
42
|
+
const formItemStyle = computed(() => toValue(props.formItemStyle) ?? toValue(attrs.value.formItemStyle));
|
|
43
|
+
const formItemLabelClass = computed(() => toValue(props.formItemLabelClass) ?? toValue(attrs.value.formItemLabelClass));
|
|
44
|
+
const formItemLabelStyle = computed(() => toValue(props.formItemLabelStyle) ?? toValue(attrs.value.formItemLabelStyle));
|
|
45
|
+
useAttrsProvide({
|
|
46
|
+
colCount,
|
|
47
|
+
errorLayout,
|
|
48
|
+
labelMode,
|
|
49
|
+
showColon,
|
|
50
|
+
formItemClass,
|
|
51
|
+
formItemStyle,
|
|
52
|
+
formItemLabelClass,
|
|
53
|
+
formItemLabelStyle
|
|
54
|
+
});
|
|
55
|
+
const cls = computed(() => clx(preCls, props.class, { "all-colspan": props.isAllColSpan, bordered: props.bordered }));
|
|
56
|
+
const bodyCls = computed(() => clx(`${preCls}-body`, props.bodyClass));
|
|
57
|
+
const headerCls = computed(() => clx(`${preCls}-header`, props.headerClass));
|
|
58
|
+
const headerTitleCls = computed(() => clx(`${preCls}-header-title`));
|
|
59
|
+
const headerExtraCls = computed(() => clx(`${preCls}-header-extra`));
|
|
60
|
+
const bodyStyle = computed(() => {
|
|
61
|
+
const css = {};
|
|
62
|
+
if (typeof props.gap === "string") {
|
|
63
|
+
css.gap = props.gap;
|
|
64
|
+
}
|
|
65
|
+
if (typeof props.gap === "number") {
|
|
66
|
+
css.gap = `${props.gap}px`;
|
|
67
|
+
}
|
|
68
|
+
if (colCount.value) {
|
|
69
|
+
css.gridTemplateColumns = `repeat(${colCount.value}, auto)`;
|
|
70
|
+
}
|
|
71
|
+
return [css, props.bodyStyle];
|
|
72
|
+
});
|
|
73
|
+
const isTitle = computed(() => {
|
|
74
|
+
return !!props.title || solts.title;
|
|
75
|
+
});
|
|
76
|
+
const isExtra = computed(() => {
|
|
77
|
+
return !!props.extra || solts.extra;
|
|
78
|
+
});
|
|
79
|
+
return (_ctx, _cache) => {
|
|
80
|
+
return openBlock(), createElementBlock(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
style: normalizeStyle(props.style),
|
|
84
|
+
class: normalizeClass(cls.value)
|
|
85
|
+
},
|
|
86
|
+
[
|
|
87
|
+
isExtra.value || isTitle.value ? (openBlock(), createElementBlock(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
key: 0,
|
|
91
|
+
style: normalizeStyle(_ctx.headerStyle),
|
|
92
|
+
class: normalizeClass(headerCls.value)
|
|
93
|
+
},
|
|
94
|
+
[
|
|
95
|
+
createElementVNode(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
class: normalizeClass(headerTitleCls.value)
|
|
99
|
+
},
|
|
100
|
+
[
|
|
101
|
+
props.title ? (openBlock(), createElementBlock(
|
|
102
|
+
Fragment,
|
|
103
|
+
{ key: 0 },
|
|
104
|
+
[
|
|
105
|
+
createTextVNode(
|
|
106
|
+
toDisplayString(props.title),
|
|
107
|
+
1
|
|
108
|
+
/* TEXT */
|
|
109
|
+
)
|
|
110
|
+
],
|
|
111
|
+
64
|
|
112
|
+
/* STABLE_FRAGMENT */
|
|
113
|
+
)) : renderSlot(_ctx.$slots, "title", { key: 1 })
|
|
114
|
+
],
|
|
115
|
+
2
|
|
116
|
+
/* CLASS */
|
|
117
|
+
),
|
|
118
|
+
createElementVNode(
|
|
119
|
+
"div",
|
|
120
|
+
{
|
|
121
|
+
class: normalizeClass(headerExtraCls.value)
|
|
122
|
+
},
|
|
123
|
+
[
|
|
124
|
+
props.extra ? (openBlock(), createElementBlock(
|
|
125
|
+
Fragment,
|
|
126
|
+
{ key: 0 },
|
|
127
|
+
[
|
|
128
|
+
createTextVNode(
|
|
129
|
+
toDisplayString(props.extra),
|
|
130
|
+
1
|
|
131
|
+
/* TEXT */
|
|
132
|
+
)
|
|
133
|
+
],
|
|
134
|
+
64
|
|
135
|
+
/* STABLE_FRAGMENT */
|
|
136
|
+
)) : renderSlot(_ctx.$slots, "extra", { key: 1 })
|
|
137
|
+
],
|
|
138
|
+
2
|
|
139
|
+
/* CLASS */
|
|
140
|
+
)
|
|
141
|
+
],
|
|
142
|
+
6
|
|
143
|
+
/* CLASS, STYLE */
|
|
144
|
+
)) : createCommentVNode("v-if", true),
|
|
145
|
+
createElementVNode(
|
|
146
|
+
"div",
|
|
147
|
+
{
|
|
148
|
+
style: normalizeStyle(bodyStyle.value),
|
|
149
|
+
class: normalizeClass(bodyCls.value)
|
|
150
|
+
},
|
|
151
|
+
[
|
|
152
|
+
renderSlot(_ctx.$slots, "default")
|
|
153
|
+
],
|
|
154
|
+
6
|
|
155
|
+
/* CLASS, STYLE */
|
|
156
|
+
)
|
|
157
|
+
],
|
|
158
|
+
6
|
|
159
|
+
/* CLASS, STYLE */
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
export {
|
|
165
|
+
_sfc_main as default
|
|
166
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './withInstall';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Plugin } from 'vue';
|
|
2
|
+
export type SFCWithInstall<T> = T & Plugin;
|
|
3
|
+
export declare const withInstall: <T, E extends Record<string, any> = Record<string, any>, K extends Record<string, any> = Record<string, any>>(main: T, extra?: E | undefined, childComponents?: K | undefined) => SFCWithInstall<T> & E & K;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const withInstall = (main, extra, childComponents) => {
|
|
2
|
+
main.install = (app) => {
|
|
3
|
+
for (const comp of [main, ...Object.values(childComponents ?? {})]) {
|
|
4
|
+
const name = comp.name || comp.__name;
|
|
5
|
+
app.component(name, comp);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
if (childComponents) {
|
|
9
|
+
for (const [key, comp] of Object.entries(childComponents)) {
|
|
10
|
+
main[key] = comp;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (extra) {
|
|
14
|
+
for (const [key, comp] of Object.entries(extra)) {
|
|
15
|
+
main[key] = comp;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return main;
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
withInstall
|
|
22
|
+
};
|
package/lib/component.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const index = require("./form/index.js");
|
|
4
|
+
const index$1 = require("./formItem/index.js");
|
|
5
|
+
const index$2 = require("./layout/index.js");
|
|
6
|
+
exports.Form = index.Form;
|
|
7
|
+
exports.FormHideItem = index$1.FormHideItem;
|
|
8
|
+
exports.FormItem = index$1.FormItem;
|
|
9
|
+
exports.FormItemBase = index$1.FormItemBase;
|
|
10
|
+
exports.FormLayoutRows = index$2.FormLayoutRows;
|
|
11
|
+
exports.Layout = index$2.Layout;
|
|
12
|
+
exports.LayoutFormItem = index$2.LayoutFormItem;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const Form: import('../utils').SFCWithInstall<{
|
|
2
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('..').FormProps<any>> & Readonly<{
|
|
3
|
+
onFinish?: ((...args: any[]) => any) | undefined;
|
|
4
|
+
onValuesChange?: ((...args: any[]) => any) | undefined;
|
|
5
|
+
onFinishFailed?: ((...args: any[]) => any) | undefined;
|
|
6
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
7
|
+
finish: (...args: any[]) => void;
|
|
8
|
+
valuesChange: (...args: any[]) => void;
|
|
9
|
+
finishFailed: (...args: any[]) => void;
|
|
10
|
+
}, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
|
11
|
+
P: {};
|
|
12
|
+
B: {};
|
|
13
|
+
D: {};
|
|
14
|
+
C: {};
|
|
15
|
+
M: {};
|
|
16
|
+
Defaults: {};
|
|
17
|
+
}, Readonly<import('..').FormProps<any>> & Readonly<{
|
|
18
|
+
onFinish?: ((...args: any[]) => any) | undefined;
|
|
19
|
+
onValuesChange?: ((...args: any[]) => any) | undefined;
|
|
20
|
+
onFinishFailed?: ((...args: any[]) => any) | undefined;
|
|
21
|
+
}>, {}, {}, {}, {}, {}>;
|
|
22
|
+
__isFragment?: undefined;
|
|
23
|
+
__isTeleport?: undefined;
|
|
24
|
+
__isSuspense?: undefined;
|
|
25
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('..').FormProps<any>> & Readonly<{
|
|
26
|
+
onFinish?: ((...args: any[]) => any) | undefined;
|
|
27
|
+
onValuesChange?: ((...args: any[]) => any) | undefined;
|
|
28
|
+
onFinishFailed?: ((...args: any[]) => any) | undefined;
|
|
29
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
30
|
+
finish: (...args: any[]) => void;
|
|
31
|
+
valuesChange: (...args: any[]) => void;
|
|
32
|
+
finishFailed: (...args: any[]) => void;
|
|
33
|
+
}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
34
|
+
$slots: {
|
|
35
|
+
default?(_: {}): any;
|
|
36
|
+
};
|
|
37
|
+
})> & Record<string, any>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const index_vue_vue_type_script_setup_true_lang = require("./index.vue.js");
|
|
4
|
+
const withInstall = require("../utils/withInstall.js");
|
|
5
|
+
const Form = withInstall.withInstall(index_vue_vue_type_script_setup_true_lang.default);
|
|
6
|
+
exports.Form = Form;
|