@carefrees/form-utils-vue 0.0.11 → 0.0.12

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.
Files changed (161) hide show
  1. package/README.md +56 -2
  2. package/assets/index.css +23 -12
  3. package/esm/component.js +3 -0
  4. package/esm/form/form.js +156 -0
  5. package/esm/form/form.vue.d.ts +10 -7
  6. package/esm/form/index.d.ts +12 -12
  7. package/esm/form/index.js +4 -0
  8. package/esm/formItem/form.Item.base.js +162 -0
  9. package/esm/formItem/form.Item.base.vue.d.ts +6 -8
  10. package/esm/formItem/form.hide.item.js +126 -0
  11. package/esm/formItem/form.hide.item.vue.d.ts +6 -8
  12. package/esm/formItem/formItem.js +155 -0
  13. package/esm/formItem/formItem.vue.d.ts +6 -9
  14. package/esm/formItem/index.d.ts +24 -37
  15. package/esm/formItem/index.js +8 -0
  16. package/esm/hooks/attr/attr.FormItem.d.ts +5 -5
  17. package/esm/hooks/attr/attr.FormItem.js +97 -0
  18. package/esm/hooks/index.js +13 -0
  19. package/esm/hooks/register/register.FormHideItem.d.ts +2 -2
  20. package/esm/hooks/register/register.FormHideItem.js +42 -0
  21. package/esm/hooks/register/register.FormItem.d.ts +9 -6
  22. package/esm/hooks/register/register.FormItem.js +67 -0
  23. package/esm/hooks/register/register.FormList.d.ts +3 -3
  24. package/esm/hooks/register/register.FormList.js +42 -0
  25. package/esm/hooks/register/register.form.d.ts +1 -1
  26. package/esm/hooks/register/register.form.js +10 -0
  27. package/esm/hooks/useAttrs.d.ts +1 -0
  28. package/esm/hooks/useAttrs.js +26 -0
  29. package/esm/hooks/useEffect.js +12 -0
  30. package/esm/hooks/useForm.d.ts +1 -1
  31. package/esm/hooks/useForm.js +17 -0
  32. package/esm/hooks/useFormItem.js +17 -0
  33. package/esm/hooks/useFormItemParentName.js +47 -0
  34. package/esm/hooks/useFormList.js +17 -0
  35. package/esm/hooks/useHtmlFor.d.ts +1 -1
  36. package/esm/hooks/useHtmlFor.js +7 -0
  37. package/esm/hooks/useMultipleForm.d.ts +1 -1
  38. package/esm/hooks/useMultipleForm.js +18 -0
  39. package/esm/index.d.ts +1 -1
  40. package/esm/index.js +13 -0
  41. package/esm/instance/ruleIntsnace.d.ts +1 -1
  42. package/esm/instance/ruleIntsnace.js +65 -0
  43. package/esm/interface/index.d.ts +2 -0
  44. package/esm/interface/index.js +0 -0
  45. package/esm/interface/layout.formItem.js +0 -0
  46. package/esm/interface/layout.js +0 -0
  47. package/esm/layout/index.d.ts +24 -33
  48. package/esm/layout/index.js +8 -0
  49. package/esm/layout/layout.form.rows.js +21 -0
  50. package/esm/layout/layout.form.rows.vue.d.ts +8 -5
  51. package/esm/layout/layout.formItem.js +195 -0
  52. package/esm/layout/layout.formItem.vue.d.ts +6 -9
  53. package/esm/layout/layout.js +160 -0
  54. package/esm/layout/layout.vue.d.ts +6 -8
  55. package/esm/utils/index.js +1 -0
  56. package/esm/utils/withInstall.d.ts +2 -2
  57. package/esm/utils/withInstall.js +15 -0
  58. package/package.json +6 -8
  59. package/src/form/form.vue +8 -1
  60. package/src/interface/index.ts +2 -0
  61. package/esm/component.mjs +0 -12
  62. package/esm/form/form.vue.mjs +0 -110
  63. package/esm/form/form.vue2.mjs +0 -4
  64. package/esm/form/index.mjs +0 -6
  65. package/esm/formItem/form.Item.base.vue.mjs +0 -114
  66. package/esm/formItem/form.Item.base.vue2.mjs +0 -4
  67. package/esm/formItem/form.hide.item.vue.mjs +0 -78
  68. package/esm/formItem/form.hide.item.vue2.mjs +0 -4
  69. package/esm/formItem/formItem.vue.mjs +0 -102
  70. package/esm/formItem/formItem.vue2.mjs +0 -4
  71. package/esm/formItem/index.mjs +0 -12
  72. package/esm/hooks/attr/attr.FormItem.mjs +0 -120
  73. package/esm/hooks/register/register.FormHideItem.mjs +0 -38
  74. package/esm/hooks/register/register.FormItem.mjs +0 -55
  75. package/esm/hooks/register/register.FormList.mjs +0 -43
  76. package/esm/hooks/register/register.form.mjs +0 -12
  77. package/esm/hooks/useAttrs.mjs +0 -43
  78. package/esm/hooks/useEffect.mjs +0 -14
  79. package/esm/hooks/useForm.mjs +0 -26
  80. package/esm/hooks/useFormItem.mjs +0 -26
  81. package/esm/hooks/useFormItemParentName.mjs +0 -37
  82. package/esm/hooks/useFormList.mjs +0 -26
  83. package/esm/hooks/useHtmlFor.mjs +0 -11
  84. package/esm/hooks/useMultipleForm.mjs +0 -27
  85. package/esm/index.mjs +0 -59
  86. package/esm/instance/ruleIntsnace.mjs +0 -73
  87. package/esm/layout/index.mjs +0 -12
  88. package/esm/layout/layout.form.rows.vue.mjs +0 -31
  89. package/esm/layout/layout.form.rows.vue2.mjs +0 -4
  90. package/esm/layout/layout.formItem.vue.mjs +0 -216
  91. package/esm/layout/layout.formItem.vue2.mjs +0 -4
  92. package/esm/layout/layout.vue.mjs +0 -166
  93. package/esm/layout/layout.vue2.mjs +0 -4
  94. package/esm/utils/withInstall.mjs +0 -22
  95. package/lib/component.d.ts +0 -3
  96. package/lib/component.js +0 -12
  97. package/lib/form/form.vue.d.ts +0 -19
  98. package/lib/form/form.vue.js +0 -110
  99. package/lib/form/form.vue2.js +0 -4
  100. package/lib/form/index.d.ts +0 -37
  101. package/lib/form/index.js +0 -6
  102. package/lib/formItem/form.Item.base.vue.d.ts +0 -16
  103. package/lib/formItem/form.Item.base.vue.js +0 -114
  104. package/lib/formItem/form.Item.base.vue2.js +0 -4
  105. package/lib/formItem/form.hide.item.vue.d.ts +0 -16
  106. package/lib/formItem/form.hide.item.vue.js +0 -78
  107. package/lib/formItem/form.hide.item.vue2.js +0 -4
  108. package/lib/formItem/formItem.vue.d.ts +0 -18
  109. package/lib/formItem/formItem.vue.js +0 -102
  110. package/lib/formItem/formItem.vue2.js +0 -4
  111. package/lib/formItem/index.d.ts +0 -71
  112. package/lib/formItem/index.js +0 -12
  113. package/lib/hooks/attr/attr.FormItem.d.ts +0 -97
  114. package/lib/hooks/attr/attr.FormItem.js +0 -120
  115. package/lib/hooks/index.d.ts +0 -13
  116. package/lib/hooks/register/register.FormHideItem.d.ts +0 -9
  117. package/lib/hooks/register/register.FormHideItem.js +0 -38
  118. package/lib/hooks/register/register.FormItem.d.ts +0 -23
  119. package/lib/hooks/register/register.FormItem.js +0 -55
  120. package/lib/hooks/register/register.FormList.d.ts +0 -9
  121. package/lib/hooks/register/register.FormList.js +0 -43
  122. package/lib/hooks/register/register.form.d.ts +0 -3
  123. package/lib/hooks/register/register.form.js +0 -12
  124. package/lib/hooks/useAttrs.d.ts +0 -24
  125. package/lib/hooks/useAttrs.js +0 -43
  126. package/lib/hooks/useEffect.d.ts +0 -2
  127. package/lib/hooks/useEffect.js +0 -14
  128. package/lib/hooks/useForm.d.ts +0 -8
  129. package/lib/hooks/useForm.js +0 -26
  130. package/lib/hooks/useFormItem.d.ts +0 -7
  131. package/lib/hooks/useFormItem.js +0 -26
  132. package/lib/hooks/useFormItemParentName.d.ts +0 -18
  133. package/lib/hooks/useFormItemParentName.js +0 -37
  134. package/lib/hooks/useFormList.d.ts +0 -7
  135. package/lib/hooks/useFormList.js +0 -26
  136. package/lib/hooks/useHtmlFor.d.ts +0 -2
  137. package/lib/hooks/useHtmlFor.js +0 -11
  138. package/lib/hooks/useMultipleForm.d.ts +0 -7
  139. package/lib/hooks/useMultipleForm.js +0 -27
  140. package/lib/index.d.ts +0 -11
  141. package/lib/index.js +0 -59
  142. package/lib/instance/ruleIntsnace.d.ts +0 -49
  143. package/lib/instance/ruleIntsnace.js +0 -73
  144. package/lib/interface/index.d.ts +0 -36
  145. package/lib/interface/layout.d.ts +0 -28
  146. package/lib/interface/layout.formItem.d.ts +0 -39
  147. package/lib/layout/index.d.ts +0 -65
  148. package/lib/layout/index.js +0 -12
  149. package/lib/layout/layout.form.rows.vue.d.ts +0 -10
  150. package/lib/layout/layout.form.rows.vue.js +0 -31
  151. package/lib/layout/layout.form.rows.vue2.js +0 -4
  152. package/lib/layout/layout.formItem.vue.d.ts +0 -18
  153. package/lib/layout/layout.formItem.vue.js +0 -216
  154. package/lib/layout/layout.formItem.vue2.js +0 -4
  155. package/lib/layout/layout.vue.d.ts +0 -16
  156. package/lib/layout/layout.vue.js +0 -166
  157. package/lib/layout/layout.vue2.js +0 -4
  158. package/lib/utils/index.d.ts +0 -1
  159. package/lib/utils/withInstall.d.ts +0 -3
  160. package/lib/utils/withInstall.js +0 -22
  161. package/src/vite-env.d.ts +0 -1
@@ -1,114 +0,0 @@
1
- import { defineComponent, useSlots, computed, toValue, createBlock, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, unref, normalizeClass, normalizeStyle, createSlots, withCtx, guardReactiveProps, renderList, renderSlot } from "vue";
2
- import { useFormItemAttr } from "../hooks/attr/attr.FormItem.mjs";
3
- import _sfc_main$1 from "../layout/layout.formItem.vue.mjs";
4
- import { useFormItemParentNameProvide } from "../hooks/useFormItemParentName.mjs";
5
- const __default__ = defineComponent({
6
- name: "FormItemBase",
7
- inheritAttrs: false
8
- // 可选,防止属性自动应用到根元素
9
- });
10
- const _sfc_main = /* @__PURE__ */ defineComponent({
11
- ...__default__,
12
- props: {
13
- noStyle: { type: Boolean },
14
- input: {},
15
- dependencies: {},
16
- noticeOnlyRuleDataField: {},
17
- isNoticeParentField: { type: Boolean },
18
- noticeWatchField: {},
19
- preserve: { type: Boolean },
20
- useRules: {},
21
- useAttrs: {},
22
- inputAttrs: {},
23
- valuePropName: {},
24
- getValuePath: {},
25
- getValueFromEvent: {},
26
- formatValue: {},
27
- onAfterUpdate: {},
28
- trigger: {},
29
- name: {},
30
- rules: {},
31
- sort: {},
32
- isJoinParentField: { type: Boolean },
33
- errorLayout: {},
34
- required: { type: Boolean },
35
- labelMode: {},
36
- onlyRuleStyle: { type: Boolean },
37
- label: { type: [Object, String, Number, Boolean, null, Array] },
38
- helpText: { type: [Object, String, Number, Boolean, null, Array] },
39
- extra: { type: [Object, String, Number, Boolean, null, Array] },
40
- showColon: { type: Boolean },
41
- colSpan: {},
42
- rowSpan: {},
43
- htmlFor: {},
44
- validateResult: {},
45
- style: { type: [Boolean, null, String, Object, Array] },
46
- class: {},
47
- labelStyle: { type: [Boolean, null, String, Object, Array] },
48
- labelClass: {}
49
- },
50
- setup(__props) {
51
- const props = __props;
52
- const formAttrs = useFormItemAttr(props);
53
- useFormItemParentNameProvide({
54
- name: formAttrs.newName,
55
- sort: formAttrs.newSort
56
- });
57
- const slots = useSlots();
58
- const isRequired = computed(() => {
59
- var _a, _b, _c;
60
- return !!props.required || !!((_c = toValue((_b = (_a = formAttrs.ruleInstance) == null ? void 0 : _a.value) == null ? void 0 : _b.rules) || []) == null ? void 0 : _c.find((item) => {
61
- return item.required;
62
- }));
63
- });
64
- return (_ctx, _cache) => {
65
- return props.noStyle ? (openBlock(), createBlock(
66
- resolveDynamicComponent(props.input),
67
- normalizeProps(mergeProps({ key: 0 }, toValue(unref(formAttrs).attrsLastData))),
68
- null,
69
- 16
70
- /* FULL_PROPS */
71
- )) : (openBlock(), createBlock(_sfc_main$1, {
72
- key: 1,
73
- label: props.label,
74
- required: isRequired.value,
75
- "error-layout": props.errorLayout,
76
- "label-mode": props.labelMode,
77
- "only-rule-style": props.onlyRuleStyle,
78
- "show-colon": props.showColon,
79
- "col-span": props.colSpan,
80
- "row-span": props.rowSpan,
81
- "html-for": unref(formAttrs).htmlFor,
82
- style: normalizeStyle(props.style),
83
- class: normalizeClass(props.class),
84
- "label-style": props.labelStyle,
85
- "label-class": props.labelClass,
86
- "validate-result": unref(formAttrs).validateResult
87
- }, createSlots({
88
- default: withCtx(() => [
89
- (openBlock(), createBlock(
90
- resolveDynamicComponent(props.input),
91
- normalizeProps(guardReactiveProps(toValue(unref(formAttrs).attrsLastData))),
92
- null,
93
- 16
94
- /* FULL_PROPS */
95
- ))
96
- ]),
97
- _: 2
98
- /* DYNAMIC */
99
- }, [
100
- renderList(slots, (item, name) => {
101
- return {
102
- name,
103
- fn: withCtx((slotProps) => [
104
- renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(slotProps)))
105
- ])
106
- };
107
- })
108
- ]), 1032, ["label", "required", "error-layout", "label-mode", "only-rule-style", "show-colon", "col-span", "row-span", "html-for", "style", "class", "label-style", "label-class", "validate-result"]));
109
- };
110
- }
111
- });
112
- export {
113
- _sfc_main as default
114
- };
@@ -1,4 +0,0 @@
1
- import _sfc_main from "./form.Item.base.vue.mjs";
2
- export {
3
- _sfc_main as default
4
- };
@@ -1,78 +0,0 @@
1
- import { defineComponent, useSlots, createBlock, createCommentVNode, unref, openBlock, normalizeProps, mergeProps, createSlots, renderList, withCtx, renderSlot, guardReactiveProps } from "vue";
2
- import _sfc_main$1 from "./form.Item.base.vue.mjs";
3
- import { useRegisterFormHideItem } from "../hooks/register/register.FormHideItem.mjs";
4
- const __default__ = defineComponent({
5
- name: "FormHideItem",
6
- inheritAttrs: false
7
- // 可选,防止属性自动应用到根元素
8
- });
9
- const _sfc_main = /* @__PURE__ */ defineComponent({
10
- ...__default__,
11
- props: {
12
- noStyle: { type: Boolean },
13
- input: {},
14
- dependencies: {},
15
- noticeOnlyRuleDataField: {},
16
- isNoticeParentField: { type: Boolean },
17
- noticeWatchField: {},
18
- preserve: { type: Boolean },
19
- useRules: {},
20
- useAttrs: {},
21
- inputAttrs: {},
22
- valuePropName: {},
23
- getValuePath: {},
24
- getValueFromEvent: {},
25
- formatValue: {},
26
- onAfterUpdate: {},
27
- trigger: {},
28
- name: {},
29
- rules: {},
30
- sort: {},
31
- isJoinParentField: { type: Boolean },
32
- errorLayout: {},
33
- required: { type: Boolean },
34
- labelMode: {},
35
- onlyRuleStyle: { type: Boolean },
36
- label: { type: [Object, String, Number, Boolean, null, Array] },
37
- helpText: { type: [Object, String, Number, Boolean, null, Array] },
38
- extra: { type: [Object, String, Number, Boolean, null, Array] },
39
- showColon: { type: Boolean },
40
- colSpan: {},
41
- rowSpan: {},
42
- htmlFor: {},
43
- validateResult: {},
44
- style: { type: [Boolean, null, String, Object, Array] },
45
- class: {},
46
- labelStyle: { type: [Boolean, null, String, Object, Array] },
47
- labelClass: {}
48
- },
49
- setup(__props) {
50
- const props = __props;
51
- const slots = useSlots();
52
- const { isHide } = useRegisterFormHideItem({ name: props.name, sort: props.sort, isJoinParentField: props.isJoinParentField });
53
- return (_ctx, _cache) => {
54
- return !unref(isHide) ? (openBlock(), createBlock(
55
- _sfc_main$1,
56
- normalizeProps(mergeProps({ key: 0 }, props)),
57
- createSlots({
58
- _: 2
59
- /* DYNAMIC */
60
- }, [
61
- renderList(slots, (item, name) => {
62
- return {
63
- name,
64
- fn: withCtx((slotProps) => [
65
- renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(slotProps)))
66
- ])
67
- };
68
- })
69
- ]),
70
- 1040
71
- /* FULL_PROPS, DYNAMIC_SLOTS */
72
- )) : createCommentVNode("v-if", true);
73
- };
74
- }
75
- });
76
- export {
77
- _sfc_main as default
78
- };
@@ -1,4 +0,0 @@
1
- import _sfc_main from "./form.hide.item.vue.mjs";
2
- export {
3
- _sfc_main as default
4
- };
@@ -1,102 +0,0 @@
1
- import { defineComponent, useSlots, createBlock, openBlock, normalizeProps, mergeProps, createSlots, renderList, withCtx, renderSlot, guardReactiveProps, normalizeClass, normalizeStyle } from "vue";
2
- import _sfc_main$2 from "../layout/layout.formItem.vue.mjs";
3
- import _sfc_main$1 from "./form.Item.base.vue.mjs";
4
- const __default__ = defineComponent({
5
- name: "FormItem",
6
- inheritAttrs: false
7
- // 可选,防止属性自动应用到根元素
8
- });
9
- const _sfc_main = /* @__PURE__ */ defineComponent({
10
- ...__default__,
11
- props: {
12
- noStyle: { type: Boolean },
13
- input: {},
14
- dependencies: {},
15
- noticeOnlyRuleDataField: {},
16
- isNoticeParentField: { type: Boolean },
17
- noticeWatchField: {},
18
- preserve: { type: Boolean },
19
- useRules: {},
20
- useAttrs: {},
21
- inputAttrs: {},
22
- valuePropName: {},
23
- getValuePath: {},
24
- getValueFromEvent: {},
25
- formatValue: {},
26
- onAfterUpdate: {},
27
- trigger: {},
28
- name: {},
29
- rules: {},
30
- sort: {},
31
- isJoinParentField: { type: Boolean },
32
- errorLayout: {},
33
- required: { type: Boolean },
34
- labelMode: {},
35
- onlyRuleStyle: { type: Boolean },
36
- label: { type: [Object, String, Number, Boolean, null, Array] },
37
- helpText: { type: [Object, String, Number, Boolean, null, Array] },
38
- extra: { type: [Object, String, Number, Boolean, null, Array] },
39
- showColon: { type: Boolean },
40
- colSpan: {},
41
- rowSpan: {},
42
- htmlFor: {},
43
- validateResult: {},
44
- style: { type: [Boolean, null, String, Object, Array] },
45
- class: {},
46
- labelStyle: { type: [Boolean, null, String, Object, Array] },
47
- labelClass: {}
48
- },
49
- setup(__props) {
50
- const props = __props;
51
- const slots = useSlots();
52
- return (_ctx, _cache) => {
53
- return props.name ? (openBlock(), createBlock(
54
- _sfc_main$1,
55
- normalizeProps(mergeProps({ key: 0 }, props)),
56
- createSlots({
57
- _: 2
58
- /* DYNAMIC */
59
- }, [
60
- renderList(slots, (_, name) => {
61
- return {
62
- name,
63
- fn: withCtx((slotProps) => [
64
- renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(slotProps)))
65
- ])
66
- };
67
- })
68
- ]),
69
- 1040
70
- /* FULL_PROPS, DYNAMIC_SLOTS */
71
- )) : (openBlock(), createBlock(_sfc_main$2, {
72
- key: 1,
73
- label: props.label,
74
- errorLayout: props.errorLayout,
75
- labelMode: props.labelMode,
76
- onlyRuleStyle: props.onlyRuleStyle,
77
- showColon: props.showColon,
78
- colSpan: props.colSpan,
79
- rowSpan: props.rowSpan,
80
- style: normalizeStyle(props.style),
81
- class: normalizeClass(props.class),
82
- labelStyle: props.labelStyle,
83
- labelClass: props.labelClass
84
- }, createSlots({
85
- _: 2
86
- /* DYNAMIC */
87
- }, [
88
- renderList(slots, (_, name) => {
89
- return {
90
- name,
91
- fn: withCtx((slotProps) => [
92
- renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(slotProps)))
93
- ])
94
- };
95
- })
96
- ]), 1032, ["label", "errorLayout", "labelMode", "onlyRuleStyle", "showColon", "colSpan", "rowSpan", "style", "class", "labelStyle", "labelClass"]));
97
- };
98
- }
99
- });
100
- export {
101
- _sfc_main as default
102
- };
@@ -1,4 +0,0 @@
1
- import _sfc_main from "./formItem.vue.mjs";
2
- export {
3
- _sfc_main as default
4
- };
@@ -1,12 +0,0 @@
1
- import _sfc_main from "./form.Item.base.vue.mjs";
2
- import _sfc_main$1 from "./formItem.vue.mjs";
3
- import _sfc_main$2 from "./form.hide.item.vue.mjs";
4
- import { withInstall } from "../utils/withInstall.mjs";
5
- const FormItemBase = withInstall(_sfc_main);
6
- const FormItem = withInstall(_sfc_main$1);
7
- const FormHideItem = withInstall(_sfc_main$2);
8
- export {
9
- FormHideItem,
10
- FormItem,
11
- FormItemBase
12
- };
@@ -1,120 +0,0 @@
1
- import { get } from "@carefrees/form-utils";
2
- import { useHtmlFor } from "../useHtmlFor.mjs";
3
- import { useRegisterFormItem } from "../register/register.FormItem.mjs";
4
- import { ref, toValue, watch, computed } from "vue";
5
- const useFormItemAttr = (options) => {
6
- const {
7
- trigger = "onChange",
8
- dependencies,
9
- noticeOnlyRuleDataField,
10
- isNoticeParentField,
11
- noticeWatchField,
12
- preserve,
13
- valuePropName = "value",
14
- getValuePath = valuePropName,
15
- getValueFromEvent,
16
- formatValue,
17
- onAfterUpdate,
18
- useAttrs,
19
- useRules,
20
- inputAttrs,
21
- ...rest
22
- } = options;
23
- const {
24
- formItemInstance,
25
- form,
26
- ruleInstance,
27
- newName,
28
- newSort,
29
- deepRefData
30
- } = useRegisterFormItem({
31
- ...rest
32
- });
33
- formItemInstance.dependencies = dependencies;
34
- formItemInstance.noticeOnlyRuleDataField = noticeOnlyRuleDataField;
35
- formItemInstance.isNoticeParentField = isNoticeParentField;
36
- formItemInstance.onAfterUpdate = onAfterUpdate;
37
- formItemInstance.noticeWatchField = noticeWatchField;
38
- formItemInstance.preserve = preserve;
39
- const oldValue = ref(get(form.formData, toValue(newName)));
40
- watch(() => [get(form.formData, toValue(newName)), toValue(newName)], () => {
41
- oldValue.value = form.getFieldValue(toValue(newName));
42
- }, {
43
- immediate: true
44
- });
45
- const onValueChange = (event) => {
46
- var _a;
47
- try {
48
- let value = event;
49
- if (typeof getValueFromEvent === "function") {
50
- value = getValueFromEvent(event, form, formItemInstance);
51
- } else if (event && event.target && typeof event.target === "object" && getValuePath in event.target) {
52
- value = get(event.target, getValuePath);
53
- }
54
- if (typeof formatValue === "function") {
55
- value = formatValue(value, form, formItemInstance, event);
56
- }
57
- if (oldValue.value !== value) {
58
- form.updatedFieldValue(toValue(newName), value, "validate");
59
- (_a = formItemInstance.onAfterUpdate) == null ? void 0 : _a.call(formItemInstance, value, form, formItemInstance, event);
60
- if (Array.isArray(formItemInstance.noticeWatchField) && formItemInstance.noticeWatchField.length) {
61
- form.noticeWatch(formItemInstance.noticeWatchField);
62
- }
63
- if (Array.isArray(formItemInstance.noticeOnlyRuleDataField) && formItemInstance.noticeOnlyRuleDataField.length) {
64
- form.onlyValidate(formItemInstance.noticeOnlyRuleDataField);
65
- }
66
- if (formItemInstance.isNoticeParentField && formItemInstance.parentDataField) {
67
- form.notice(formItemInstance.parentDataField);
68
- }
69
- }
70
- } catch (error) {
71
- console.log(error);
72
- }
73
- };
74
- formItemInstance.onChange = onValueChange;
75
- const htmlFor = useHtmlFor(newName);
76
- watch(() => htmlFor, () => {
77
- formItemInstance.htmlFor = htmlFor.value;
78
- }, {
79
- immediate: true
80
- });
81
- const newAttrs = computed(() => {
82
- const _attr = inputAttrs || {};
83
- return {
84
- ..._attr,
85
- [trigger]: onValueChange,
86
- name: toValue(newName),
87
- id: toValue(htmlFor),
88
- [valuePropName]: toValue(oldValue)
89
- };
90
- });
91
- const attrsLastData = ref(toValue(newAttrs));
92
- watch(() => [toValue(newAttrs), toValue(deepRefData), toValue(oldValue)], () => {
93
- attrsLastData.value = (useAttrs == null ? void 0 : useAttrs(toValue(newAttrs), form, formItemInstance)) || toValue(newAttrs);
94
- }, {
95
- immediate: true
96
- });
97
- const validateResult = ref(toValue(ruleInstance).getValidateResult());
98
- watch(() => [toValue(deepRefData), toValue(oldValue)], () => {
99
- useRules == null ? void 0 : useRules(ruleInstance, form, formItemInstance);
100
- });
101
- watch(() => [toValue(ruleInstance).messages, toValue(ruleInstance).rules, toValue(oldValue)], () => {
102
- validateResult.value = toValue(ruleInstance).getValidateResult();
103
- });
104
- return {
105
- valuePropName,
106
- htmlFor,
107
- onChange: onValueChange,
108
- formItemInstance,
109
- form,
110
- ruleInstance,
111
- newAttrs,
112
- attrsLastData,
113
- validateResult,
114
- newSort,
115
- newName
116
- };
117
- };
118
- export {
119
- useFormItemAttr
120
- };
@@ -1,38 +0,0 @@
1
- import { ref, watch, toValue } from "vue";
2
- import { FormHideItemInstanceBase } from "@carefrees/form-utils";
3
- import { useFormItemParentNameInject } from "../useFormItemParentName.mjs";
4
- import { useFormInject } from "../useForm.mjs";
5
- import { useEffect } from "../useEffect.mjs";
6
- const useRegisterFormHideItem = (options) => {
7
- const { name, sort, isJoinParentField = true } = options;
8
- const form = useFormInject();
9
- const { newName, newSort } = useFormItemParentNameInject({ name, sort, isJoinParentField });
10
- const hideItemInstance = ref(new FormHideItemInstanceBase().ctor(newName.value));
11
- const isHide = ref(form.getFieldHideValue(newName.value));
12
- watch(
13
- () => [toValue(isHide)],
14
- () => {
15
- hideItemInstance.value.preHideValue = isHide.value;
16
- },
17
- { immediate: true }
18
- );
19
- const setValue = () => {
20
- isHide.value = form.getFieldHideValue(newName.value);
21
- };
22
- hideItemInstance.value.updatedItem = setValue;
23
- watch(
24
- () => [form, toValue(newSort)],
25
- () => {
26
- hideItemInstance.value.instance = form;
27
- hideItemInstance.value.sort = toValue(newSort);
28
- },
29
- { immediate: true }
30
- );
31
- useEffect(() => {
32
- return form.registerFormHideItem(toValue(hideItemInstance));
33
- });
34
- return { form, isHide };
35
- };
36
- export {
37
- useRegisterFormHideItem
38
- };
@@ -1,55 +0,0 @@
1
- import { ref, watch, toValue } from "vue";
2
- import { useFormInject } from "../useForm.mjs";
3
- import { useFormItem } from "../useFormItem.mjs";
4
- import { useFormItemParentNameInject } from "../useFormItemParentName.mjs";
5
- import { useEffect } from "../useEffect.mjs";
6
- import { RuleInstanceBase2 } from "../../instance/ruleIntsnace.mjs";
7
- const useRegisterFormItem = (options) => {
8
- const { name, rules, sort, isJoinParentField = true } = options;
9
- const form = useFormInject();
10
- const deepRefData = ref({});
11
- const { newName, newSort, parentItem } = useFormItemParentNameInject({ name, sort, isJoinParentField });
12
- const ruleInstance = ref(new RuleInstanceBase2());
13
- const formItemInstance = useFormItem();
14
- watch(
15
- () => [form],
16
- () => {
17
- ruleInstance.value.instance = form;
18
- formItemInstance.instance = form;
19
- },
20
- { immediate: true }
21
- );
22
- watch(
23
- () => [toValue(newName)],
24
- () => {
25
- ruleInstance.value.ctor(toValue(newName), rules || []);
26
- formItemInstance.ctor(toValue(newName), toValue(ruleInstance));
27
- },
28
- { immediate: true }
29
- );
30
- watch(
31
- () => [toValue(newSort)],
32
- () => {
33
- ruleInstance.value.sort = toValue(newSort);
34
- formItemInstance.sort = toValue(newSort);
35
- },
36
- { immediate: true }
37
- );
38
- watch(
39
- () => [toValue(parentItem)],
40
- () => {
41
- formItemInstance.parentDataField = toValue(toValue(parentItem).name);
42
- },
43
- { immediate: true }
44
- );
45
- const updated = () => {
46
- deepRefData.value = { __temp: (/* @__PURE__ */ new Date()).valueOf() };
47
- };
48
- formItemInstance.updated = updated;
49
- ruleInstance.value.updated = updated;
50
- useEffect(() => form.registerFormItem(formItemInstance));
51
- return { ruleInstance, formItemInstance, form, newName, newSort, parentItem, deepRefData };
52
- };
53
- export {
54
- useRegisterFormItem
55
- };
@@ -1,43 +0,0 @@
1
- import { watch, toValue } from "vue";
2
- import { useRegisterFormItem } from "./register.FormItem.mjs";
3
- import { useFormList } from "../useFormList.mjs";
4
- import { useEffect } from "../useEffect.mjs";
5
- const useRegisterFormList = (options) => {
6
- const { ruleInstance, formItemInstance, form, newName, parentItem } = useRegisterFormItem(options);
7
- const formListInstance = useFormList();
8
- watch(
9
- () => [toValue(newName)],
10
- () => {
11
- formListInstance.ctor(toValue(newName));
12
- },
13
- { immediate: true }
14
- );
15
- watch(
16
- () => [form, formItemInstance, toValue(ruleInstance)],
17
- () => {
18
- formListInstance.instance = form;
19
- formListInstance.formItemInstance = formItemInstance;
20
- formListInstance.rule = toValue(ruleInstance);
21
- },
22
- { immediate: true }
23
- );
24
- watch(
25
- () => [options.sort, toValue(parentItem)],
26
- () => {
27
- formListInstance.sort = toValue(parentItem.value.sort);
28
- formListInstance.parentDataField = toValue(parentItem.value.name);
29
- },
30
- { immediate: true }
31
- );
32
- useEffect(() => {
33
- return form.registerFormList(newName.value, formListInstance);
34
- });
35
- return {
36
- ruleInstance,
37
- formItemInstance,
38
- formListInstance
39
- };
40
- };
41
- export {
42
- useRegisterFormList
43
- };
@@ -1,12 +0,0 @@
1
- import { useMultipleFormInject } from "../useMultipleForm.mjs";
2
- import { useEffect } from "../useEffect.mjs";
3
- const useRegisterForm = (form, name) => {
4
- const multipleForm = useMultipleFormInject();
5
- useEffect(() => {
6
- if (name) return multipleForm.ctor(name, form);
7
- });
8
- return multipleForm;
9
- };
10
- export {
11
- useRegisterForm
12
- };
@@ -1,43 +0,0 @@
1
- import { inject, computed, ref, provide, reactive } from "vue";
2
- const attrsProvideSymbol = Symbol("carefrees-attrs");
3
- function useAttrsProvide(options) {
4
- const {
5
- colCount = ref(4),
6
- errorLayout = ref("left-bottom"),
7
- labelMode = ref("top"),
8
- showColon = ref(true),
9
- formItemClass,
10
- formItemStyle,
11
- formItemLabelClass,
12
- formItemLabelStyle
13
- } = options;
14
- const data = computed(() => {
15
- return {
16
- colCount,
17
- errorLayout,
18
- labelMode,
19
- showColon,
20
- formItemClass,
21
- formItemStyle,
22
- formItemLabelClass,
23
- formItemLabelStyle
24
- };
25
- });
26
- provide(attrsProvideSymbol, reactive(data));
27
- }
28
- function useAttrsInject() {
29
- const attrs = inject(
30
- attrsProvideSymbol,
31
- computed(() => ({
32
- colCount: ref(4),
33
- errorLayout: ref("left-bottom"),
34
- labelMode: ref("top"),
35
- showColon: ref(true)
36
- }))
37
- );
38
- return attrs;
39
- }
40
- export {
41
- useAttrsInject,
42
- useAttrsProvide
43
- };
@@ -1,14 +0,0 @@
1
- import { ref, onMounted, onUnmounted } from "vue";
2
- const useEffect = (fun) => {
3
- const unRegisterRef = ref();
4
- onMounted(() => {
5
- unRegisterRef.value = fun();
6
- });
7
- onUnmounted(() => {
8
- typeof unRegisterRef.value === "function" && unRegisterRef.value();
9
- unRegisterRef.value = void 0;
10
- });
11
- };
12
- export {
13
- useEffect
14
- };
@@ -1,26 +0,0 @@
1
- import { FormInstanceBase } from "@carefrees/form-utils";
2
- import { ref, provide, inject } from "vue";
3
- const formProvideSymbol = Symbol("carefrees-form");
4
- function useFormProvide(form) {
5
- provide(formProvideSymbol, form);
6
- }
7
- function useFormInject() {
8
- const form = inject(formProvideSymbol, new FormInstanceBase());
9
- return form;
10
- }
11
- function useForm(form) {
12
- const refForm = ref();
13
- if (!refForm.value) {
14
- if (form) {
15
- refForm.value = form;
16
- } else {
17
- refForm.value = new FormInstanceBase();
18
- }
19
- }
20
- return refForm;
21
- }
22
- export {
23
- useForm,
24
- useFormInject,
25
- useFormProvide
26
- };