@carefrees/form-utils-vue 0.0.11 → 0.0.13

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 (176) hide show
  1. package/README.md +104 -2
  2. package/assets/index.css +23 -12
  3. package/esm/component.js +3 -0
  4. package/esm/form/form.js +161 -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 +157 -0
  9. package/esm/formItem/form.Item.base.vue.d.ts +7 -8
  10. package/esm/formItem/form.hide.item.js +122 -0
  11. package/esm/formItem/form.hide.item.vue.d.ts +7 -8
  12. package/esm/formItem/formItem.js +151 -0
  13. package/esm/formItem/formItem.vue.d.ts +6 -9
  14. package/esm/formItem/index.d.ts +26 -37
  15. package/esm/formItem/index.js +8 -0
  16. package/esm/index.d.ts +2 -2
  17. package/esm/index.js +13 -0
  18. package/esm/interface/index.d.ts +6 -11
  19. package/esm/interface/index.js +0 -0
  20. package/esm/interface/layout.d.ts +1 -1
  21. package/esm/interface/layout.formItem.d.ts +1 -1
  22. package/esm/interface/layout.formItem.js +0 -0
  23. package/esm/interface/layout.js +0 -0
  24. package/esm/layout/index.d.ts +24 -33
  25. package/esm/layout/index.js +8 -0
  26. package/esm/layout/layout.form.rows.js +21 -0
  27. package/esm/layout/layout.form.rows.vue.d.ts +8 -5
  28. package/esm/layout/layout.formItem.js +195 -0
  29. package/esm/layout/layout.formItem.vue.d.ts +6 -9
  30. package/esm/layout/layout.js +160 -0
  31. package/esm/layout/layout.vue.d.ts +6 -8
  32. package/esm/utils/index.js +1 -0
  33. package/esm/utils/withInstall.d.ts +2 -2
  34. package/esm/utils/withInstall.js +15 -0
  35. package/package.json +7 -8
  36. package/src/form/form.vue +21 -7
  37. package/src/formItem/form.Item.base.vue +5 -5
  38. package/src/formItem/form.hide.item.vue +3 -1
  39. package/src/formItem/formItem.vue +2 -1
  40. package/src/index.ts +1 -1
  41. package/src/interface/index.ts +6 -13
  42. package/src/interface/layout.formItem.ts +1 -2
  43. package/src/interface/layout.ts +2 -1
  44. package/src/layout/layout.formItem.vue +2 -1
  45. package/src/layout/layout.vue +2 -1
  46. package/esm/component.mjs +0 -12
  47. package/esm/form/form.vue.mjs +0 -110
  48. package/esm/form/form.vue2.mjs +0 -4
  49. package/esm/form/index.mjs +0 -6
  50. package/esm/formItem/form.Item.base.vue.mjs +0 -114
  51. package/esm/formItem/form.Item.base.vue2.mjs +0 -4
  52. package/esm/formItem/form.hide.item.vue.mjs +0 -78
  53. package/esm/formItem/form.hide.item.vue2.mjs +0 -4
  54. package/esm/formItem/formItem.vue.mjs +0 -102
  55. package/esm/formItem/formItem.vue2.mjs +0 -4
  56. package/esm/formItem/index.mjs +0 -12
  57. package/esm/hooks/attr/attr.FormItem.d.ts +0 -97
  58. package/esm/hooks/attr/attr.FormItem.mjs +0 -120
  59. package/esm/hooks/index.d.ts +0 -13
  60. package/esm/hooks/register/register.FormHideItem.d.ts +0 -9
  61. package/esm/hooks/register/register.FormHideItem.mjs +0 -38
  62. package/esm/hooks/register/register.FormItem.d.ts +0 -23
  63. package/esm/hooks/register/register.FormItem.mjs +0 -55
  64. package/esm/hooks/register/register.FormList.d.ts +0 -9
  65. package/esm/hooks/register/register.FormList.mjs +0 -43
  66. package/esm/hooks/register/register.form.d.ts +0 -3
  67. package/esm/hooks/register/register.form.mjs +0 -12
  68. package/esm/hooks/useAttrs.d.ts +0 -24
  69. package/esm/hooks/useAttrs.mjs +0 -43
  70. package/esm/hooks/useEffect.d.ts +0 -2
  71. package/esm/hooks/useEffect.mjs +0 -14
  72. package/esm/hooks/useForm.d.ts +0 -8
  73. package/esm/hooks/useForm.mjs +0 -26
  74. package/esm/hooks/useFormItem.d.ts +0 -7
  75. package/esm/hooks/useFormItem.mjs +0 -26
  76. package/esm/hooks/useFormItemParentName.d.ts +0 -18
  77. package/esm/hooks/useFormItemParentName.mjs +0 -37
  78. package/esm/hooks/useFormList.d.ts +0 -7
  79. package/esm/hooks/useFormList.mjs +0 -26
  80. package/esm/hooks/useHtmlFor.d.ts +0 -2
  81. package/esm/hooks/useHtmlFor.mjs +0 -11
  82. package/esm/hooks/useMultipleForm.d.ts +0 -7
  83. package/esm/hooks/useMultipleForm.mjs +0 -27
  84. package/esm/index.mjs +0 -59
  85. package/esm/instance/ruleIntsnace.d.ts +0 -49
  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/hooks/attr/attr.FormItem.tsx +0 -174
  162. package/src/hooks/index.ts +0 -13
  163. package/src/hooks/register/register.FormHideItem.ts +0 -45
  164. package/src/hooks/register/register.FormItem.ts +0 -80
  165. package/src/hooks/register/register.FormList.ts +0 -49
  166. package/src/hooks/register/register.form.ts +0 -12
  167. package/src/hooks/useAttrs.ts +0 -64
  168. package/src/hooks/useEffect.ts +0 -13
  169. package/src/hooks/useForm.ts +0 -28
  170. package/src/hooks/useFormItem.ts +0 -28
  171. package/src/hooks/useFormItemParentName.ts +0 -49
  172. package/src/hooks/useFormList.ts +0 -28
  173. package/src/hooks/useHtmlFor.ts +0 -9
  174. package/src/hooks/useMultipleForm.ts +0 -29
  175. package/src/instance/ruleIntsnace.ts +0 -105
  176. package/src/vite-env.d.ts +0 -1
package/README.md CHANGED
@@ -1,3 +1,105 @@
1
- # 表单工具
1
+ # vue 表单工具
2
2
 
3
- 表单和很多基础组件存在联动关系,暂时处理不了,放弃写vue的表单工具,后面有解决方法才继续
3
+ ## 安装
4
+
5
+ ```bash
6
+ npm install @carefrees/form-utils-vue # yarn add @carefrees/form-utils-vue # pnpm add @carefrees/form-utils-vue
7
+ ```
8
+
9
+ ## 使用
10
+
11
+ ### 基本使用
12
+
13
+ ```vue
14
+ <script lang="ts" setup>
15
+ import { ref } from "vue";
16
+ import { Form, useForm, FormItem } from "@carefrees/form-utils-vue";
17
+ import "@carefrees/form-utils-vue/assets/index.css"
18
+ import Input from './Input.vue';
19
+ const formData = ref<{ a: string, b: string }>({
20
+ a: '',
21
+ b: ''
22
+ })
23
+
24
+ const form = useForm();
25
+ const onSubmit = async () => {
26
+ try {
27
+ console.log(form, formData)
28
+ const result = await form.value.validate()
29
+ if (result) {
30
+ console.log(result)
31
+ }
32
+ } catch (error) {
33
+ console.log(error)
34
+ }
35
+ }
36
+ const onSetValue = () => {
37
+ formData.value.a = '123'
38
+ formData.value.b = '456'
39
+ // form.value.updatedFieldValue('b', '123')
40
+ }
41
+
42
+ const onSetValue2 = () => {
43
+ // formData.value.a = ''
44
+ // formData.value.b = ''
45
+ formData.value = {
46
+ a: "21",
47
+ b: "22"
48
+ }
49
+ // form.value.updatedFieldValue('b', '123')
50
+ }
51
+
52
+ const onSetValue3 = () => {
53
+ form.value.updatedFieldValue('b', '')
54
+ }
55
+
56
+ const rules1 = ref([{ required: true, message: "必填" }])
57
+ const rules2 = ref([{ required: true, message: "必填" }])
58
+
59
+ const onUpdateRules = () => {
60
+ rules1.value = [{ required: true, message: "必填2" }]
61
+ rules2.value = [{ required: false, message: "不必填" }]
62
+ }
63
+
64
+ const onValuesChange = (...rest: any[]) => {
65
+ console.log(rest)
66
+ }
67
+ </script>
68
+ <template>
69
+ <Form @valuesChange='onValuesChange' :formData='formData' :form='form'>
70
+ <FormItem label='内容' input='input' name='a' :rules='rules1' />
71
+ <FormItem :input='Input' name='b' :rules='rules2'>
72
+ <template #label>
73
+ <span>s内容2</span>
74
+ </template>
75
+ <template #helpText>
76
+ <span>helpText</span>
77
+ </template>
78
+ <template #extra>
79
+ <span>extra</span>
80
+ </template>
81
+ </FormItem>
82
+ <FormItem label='Input' input='input' name='c' />
83
+ <FormItem name='d'>
84
+ <template #label>
85
+ <span>d</span>
86
+ </template>
87
+ <template #helpText>
88
+ <span>helpText</span>
89
+ </template>
90
+ <template #default>
91
+ <input placeholder='输入内容' v-model='formData.a' />
92
+ </template>
93
+ <template #extra>
94
+ <span>extra</span>
95
+ </template>
96
+ </FormItem>
97
+ <button type='button' @click='onSubmit'>验证</button>
98
+ <button type='button' @click='onSetValue'>设置值</button>
99
+ <button type='button' @click='onSetValue2'>设置值2</button>
100
+ <button type='button' @click='onSetValue3'>设置值3</button>
101
+ <button type='button' @click='onUpdateRules'>更新规则</button>
102
+ </Form>
103
+ </template>
104
+ <style scoped></style>
105
+ ```
package/assets/index.css CHANGED
@@ -1,8 +1,20 @@
1
1
  /* 表单 */
2
+ html.dark .carefrees-form {
3
+ --form-color: #e3e3e3;
4
+ --form-header-color: #e3e3e3;
5
+ --form-font-size: 14px;
6
+ --form-border-color: #e0e0e0;
7
+ }
8
+ /* 表单 */
2
9
  .carefrees-form {
10
+ --form-color: rgba(0, 0, 0, 0.88);
11
+ --form-header-color: #1d2129;
12
+ --form-font-size: 14px;
13
+ --form-border-color: #e0e0e0;
14
+
3
15
  box-sizing: border-box;
4
- background-color: #fff;
5
- font-size: 14px;
16
+ font-size: var(--form-font-size);
17
+ color: var(--form-color, rgba(0, 0, 0, 0.88));
6
18
  }
7
19
 
8
20
  /* 布局 */
@@ -19,7 +31,7 @@
19
31
  }
20
32
 
21
33
  .carefrees-form-layout.bordered {
22
- border: 1px solid #e0e0e0;
34
+ border: 1px solid var(--form-border-color, #e0e0e0);
23
35
  }
24
36
  .carefrees-form-layout.bordered .carefrees-form-layout-header {
25
37
  padding-inline-start: 8px;
@@ -31,7 +43,7 @@
31
43
  justify-content: space-between;
32
44
  align-items: center;
33
45
  flex-direction: row;
34
- border-bottom: 1px solid #e0e0e0;
46
+ border-bottom: 1px solid var(--form-border-color, #e0e0e0);
35
47
  padding-top: 5px;
36
48
  padding-bottom: 5px;
37
49
  margin-block-end: 4px;
@@ -43,13 +55,13 @@
43
55
  .carefrees-form-layout-header-title {
44
56
  font-size: 14px;
45
57
  font-weight: 600;
46
- color: #1d2129;
58
+ color: var(--form-header-color, #1d2129);
47
59
  box-sizing: border-box;
48
60
  }
49
61
  .carefrees-form-layout-header-extra {
50
62
  font-size: 14px;
51
63
  font-weight: 500;
52
- color: #1d2129;
64
+ color: var(--form-header-color, #1d2129);
53
65
  box-sizing: border-box;
54
66
  }
55
67
 
@@ -70,7 +82,7 @@
70
82
  flex-direction: row;
71
83
  padding: 8px;
72
84
  box-sizing: border-box;
73
- color: rgba(0, 0, 0, 0.88);
85
+ color: var(--form-color, rgba(0, 0, 0, 0.88));
74
86
  }
75
87
 
76
88
  .carefrees-form-item-container {
@@ -84,10 +96,9 @@
84
96
  .carefrees-form-item-container.left {
85
97
  flex-direction: row;
86
98
  gap: 8px;
87
- text-align: left;
88
99
  }
89
- .carefrees-form-item-container.left .carefrees-form-item-label {
90
- justify-content: flex-end;
100
+ .carefrees-form-item-container.left .carefrees-form-item-label-warp {
101
+ text-align: right;
91
102
  }
92
103
  .carefrees-form-item-container.between {
93
104
  gap: 8px;
@@ -113,7 +124,7 @@
113
124
  justify-content: flex-start;
114
125
  position: relative;
115
126
  font-size: 14px;
116
- color: rgba(0, 0, 0, 0.88);
127
+ color: var(--form-color, rgba(0, 0, 0, 0.88));
117
128
  min-height: 1.4rem;
118
129
  }
119
130
 
@@ -156,7 +167,7 @@
156
167
  }
157
168
 
158
169
  .carefrees-form-item-body-input.input-bordered {
159
- border-bottom: 1px solid #e0e0e0;
170
+ border-bottom: 1px solid var(--form-border-color, #e0e0e0);
160
171
  }
161
172
 
162
173
  .carefrees-form-item-body-help {
@@ -0,0 +1,3 @@
1
+ export * from "./form/index.js";
2
+ export * from "./formItem/index.js";
3
+ export * from "./layout/index.js";
@@ -0,0 +1,161 @@
1
+ import { computed, createElementBlock, createVNode, defineComponent, mergeProps, normalizeClass, normalizeStyle, openBlock, ref, renderSlot, unref, watch, withCtx } from "vue";
2
+ import layout from "../layout/layout.js";
3
+ import classnames from "classnames";
4
+ import { useForm, useFormProvide, useRegisterForm } from "@carefrees/form-utils-vue-hooks";
5
+ const _sfc_main = /* @__PURE__ */ defineComponent({
6
+ name: "Form",
7
+ inheritAttrs: false,
8
+ __name: "form",
9
+ props: {
10
+ form: {},
11
+ style: {
12
+ type: [
13
+ Boolean,
14
+ null,
15
+ String,
16
+ Object,
17
+ Array
18
+ ]
19
+ },
20
+ class: {},
21
+ layoutClass: {},
22
+ layoutStyle: {
23
+ type: [
24
+ Boolean,
25
+ null,
26
+ String,
27
+ Object,
28
+ Array
29
+ ]
30
+ },
31
+ formData: {},
32
+ onValuesChange: {},
33
+ onFinish: {},
34
+ onFinishFailed: {},
35
+ hideData: {},
36
+ name: {},
37
+ bgcolor: {},
38
+ title: {
39
+ type: [
40
+ Object,
41
+ String,
42
+ Number,
43
+ Boolean,
44
+ null,
45
+ Array
46
+ ]
47
+ },
48
+ extra: {
49
+ type: [
50
+ Object,
51
+ String,
52
+ Number,
53
+ Boolean,
54
+ null,
55
+ Array
56
+ ]
57
+ },
58
+ isAllColSpan: {
59
+ type: Boolean
60
+ },
61
+ headerClass: {},
62
+ bodyClass: {},
63
+ headerStyle: {
64
+ type: [
65
+ Boolean,
66
+ null,
67
+ String,
68
+ Object,
69
+ Array
70
+ ]
71
+ },
72
+ bodyStyle: {
73
+ type: [
74
+ Boolean,
75
+ null,
76
+ String,
77
+ Object,
78
+ Array
79
+ ]
80
+ },
81
+ bordered: {
82
+ type: Boolean
83
+ },
84
+ colCount: {},
85
+ gap: {},
86
+ errorLayout: {},
87
+ labelMode: {},
88
+ showColon: {},
89
+ formItemClass: {},
90
+ formItemStyle: {},
91
+ formItemLabelClass: {},
92
+ formItemLabelStyle: {}
93
+ },
94
+ emits: [
95
+ "finish",
96
+ "valuesChange",
97
+ "finishFailed"
98
+ ],
99
+ setup (__props, { emit: __emit }) {
100
+ const props = __props;
101
+ const { form, style, formData, hideData, name, onFinish, onFinishFailed, onValuesChange, layoutStyle, layoutClass, bgcolor, ...rest } = props;
102
+ const cls = computed(()=>classnames("carefrees-form", props.class));
103
+ const formStyle = computed(()=>{
104
+ if (bgcolor) return [
105
+ {
106
+ backgroundColor: bgcolor
107
+ },
108
+ props.style
109
+ ];
110
+ return [
111
+ props.style
112
+ ];
113
+ });
114
+ const formInstance = useForm(props.form);
115
+ formInstance.value.formData = ref(props.formData || {});
116
+ formInstance.value.hideState = ref(props.hideData || {});
117
+ watch(()=>props.formData, (newVal)=>{
118
+ formInstance.value.formData = ref(newVal || {});
119
+ });
120
+ watch(()=>props.hideData, (newVal)=>{
121
+ formInstance.value.hideState = ref(newVal || {});
122
+ });
123
+ const emits = __emit;
124
+ formInstance.value.onFinish = (...rest2)=>{
125
+ emits("finish", ...rest2);
126
+ };
127
+ formInstance.value.onValuesChange = (...rest2)=>{
128
+ emits("valuesChange", ...rest2);
129
+ };
130
+ formInstance.value.onFinishFailed = (...rest2)=>{
131
+ emits("finishFailed", ...rest2);
132
+ };
133
+ useRegisterForm(formInstance, props.name);
134
+ const onSubmit = (event)=>{
135
+ event?.preventDefault?.();
136
+ event?.stopPropagation?.();
137
+ formInstance.value.submit?.();
138
+ };
139
+ useFormProvide(formInstance.value);
140
+ return (_ctx, _cache)=>(openBlock(), createElementBlock("form", {
141
+ class: normalizeClass(cls.value),
142
+ style: normalizeStyle(formStyle.value),
143
+ onSubmit
144
+ }, [
145
+ createVNode(layout, mergeProps(rest, {
146
+ class: unref(layoutClass),
147
+ style: unref(layoutStyle)
148
+ }), {
149
+ default: withCtx(()=>[
150
+ renderSlot(_ctx.$slots, "default")
151
+ ]),
152
+ _: 3
153
+ }, 16, [
154
+ "class",
155
+ "style"
156
+ ])
157
+ ], 38));
158
+ }
159
+ });
160
+ const form_form = _sfc_main;
161
+ export { form_form as default };
@@ -1,18 +1,21 @@
1
- import { FormProps } from '../interface/index';
1
+ import type { FormProps } from "../interface/index";
2
2
  type __VLS_Props = FormProps;
3
- declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
3
+ declare var __VLS_4: {};
4
+ type __VLS_Slots = {} & {
5
+ default?: (props: typeof __VLS_4) => any;
6
+ };
7
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
4
8
  finish: (...args: any[]) => void;
5
9
  valuesChange: (...args: any[]) => void;
6
10
  finishFailed: (...args: any[]) => void;
7
- }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
12
  onFinish?: ((...args: any[]) => any) | undefined;
9
13
  onValuesChange?: ((...args: any[]) => any) | undefined;
10
14
  onFinishFailed?: ((...args: any[]) => any) | undefined;
11
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, {
12
- default?(_: {}): any;
13
- }>;
15
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
14
17
  export default _default;
15
- type __VLS_WithTemplateSlots<T, S> = T & {
18
+ type __VLS_WithSlots<T, S> = T & {
16
19
  new (): {
17
20
  $slots: S;
18
21
  };
@@ -1,37 +1,37 @@
1
- export declare const Form: import('../utils').SFCWithInstall<{
2
- new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('..').FormProps<any>> & Readonly<{
1
+ export declare const Form: import("../utils").SFCWithInstall<{
2
+ new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("../index.js").FormProps<any>> & Readonly<{
3
3
  onFinish?: ((...args: any[]) => any) | undefined;
4
4
  onValuesChange?: ((...args: any[]) => any) | undefined;
5
5
  onFinishFailed?: ((...args: any[]) => any) | undefined;
6
- }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
6
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
7
  finish: (...args: any[]) => void;
8
8
  valuesChange: (...args: any[]) => void;
9
9
  finishFailed: (...args: any[]) => void;
10
- }, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
10
+ }, import("vue").PublicProps, {}, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
11
11
  P: {};
12
12
  B: {};
13
13
  D: {};
14
14
  C: {};
15
15
  M: {};
16
16
  Defaults: {};
17
- }, Readonly<import('..').FormProps<any>> & Readonly<{
17
+ }, Readonly<import("../index.js").FormProps<any>> & Readonly<{
18
18
  onFinish?: ((...args: any[]) => any) | undefined;
19
19
  onValuesChange?: ((...args: any[]) => any) | undefined;
20
20
  onFinishFailed?: ((...args: any[]) => any) | undefined;
21
21
  }>, {}, {}, {}, {}, {}>;
22
- __isFragment?: undefined;
23
- __isTeleport?: undefined;
24
- __isSuspense?: undefined;
25
- } & import('vue').ComponentOptionsBase<Readonly<import('..').FormProps<any>> & Readonly<{
22
+ __isFragment?: never;
23
+ __isTeleport?: never;
24
+ __isSuspense?: never;
25
+ } & import("vue").ComponentOptionsBase<Readonly<import("../index.js").FormProps<any>> & Readonly<{
26
26
  onFinish?: ((...args: any[]) => any) | undefined;
27
27
  onValuesChange?: ((...args: any[]) => any) | undefined;
28
28
  onFinishFailed?: ((...args: any[]) => any) | undefined;
29
- }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
29
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
30
30
  finish: (...args: any[]) => void;
31
31
  valuesChange: (...args: any[]) => void;
32
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 () => {
33
+ }, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
34
34
  $slots: {
35
- default?(_: {}): any;
35
+ default?: (props: {}) => any;
36
36
  };
37
37
  })> & Record<string, any>;
@@ -0,0 +1,4 @@
1
+ import form_0 from "./form.js";
2
+ import { withInstall } from "../utils/index.js";
3
+ const Form = withInstall(form_0);
4
+ export { Form };
@@ -0,0 +1,157 @@
1
+ import { computed, createBlock, createSlots, defineComponent, guardReactiveProps, mergeProps, normalizeClass, normalizeProps, normalizeStyle, openBlock, renderList, renderSlot, resolveDynamicComponent, toValue, unref, useSlots, withCtx } from "vue";
2
+ import layout_formItem from "../layout/layout.formItem.js";
3
+ import { useFormItemAttr, useFormItemParentNameProvide } from "@carefrees/form-utils-vue-hooks";
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ name: "FormItemBase",
6
+ inheritAttrs: false,
7
+ __name: "form.Item.base",
8
+ props: {
9
+ noStyle: {
10
+ type: Boolean
11
+ },
12
+ input: {},
13
+ dependencies: {},
14
+ noticeOnlyRuleDataField: {},
15
+ preserve: {
16
+ type: Boolean
17
+ },
18
+ useRules: {},
19
+ useAttrs: {},
20
+ inputAttrs: {},
21
+ valuePropName: {},
22
+ getValuePath: {},
23
+ getValueFromEvent: {},
24
+ formatValue: {},
25
+ onAfterUpdate: {},
26
+ trigger: {},
27
+ name: {},
28
+ rules: {},
29
+ sort: {},
30
+ isJoinParentField: {
31
+ type: Boolean
32
+ },
33
+ errorLayout: {},
34
+ required: {
35
+ type: Boolean
36
+ },
37
+ labelMode: {},
38
+ onlyRuleStyle: {
39
+ type: Boolean
40
+ },
41
+ label: {
42
+ type: [
43
+ Object,
44
+ String,
45
+ Number,
46
+ Boolean,
47
+ null,
48
+ Array
49
+ ]
50
+ },
51
+ helpText: {
52
+ type: [
53
+ Object,
54
+ String,
55
+ Number,
56
+ Boolean,
57
+ null,
58
+ Array
59
+ ]
60
+ },
61
+ extra: {
62
+ type: [
63
+ Object,
64
+ String,
65
+ Number,
66
+ Boolean,
67
+ null,
68
+ Array
69
+ ]
70
+ },
71
+ showColon: {
72
+ type: Boolean
73
+ },
74
+ colSpan: {},
75
+ rowSpan: {},
76
+ htmlFor: {},
77
+ validateResult: {},
78
+ style: {
79
+ type: [
80
+ Boolean,
81
+ null,
82
+ String,
83
+ Object,
84
+ Array
85
+ ]
86
+ },
87
+ class: {},
88
+ labelStyle: {
89
+ type: [
90
+ Boolean,
91
+ null,
92
+ String,
93
+ Object,
94
+ Array
95
+ ]
96
+ },
97
+ labelClass: {}
98
+ },
99
+ setup (__props) {
100
+ const props = __props;
101
+ const formAttrs = useFormItemAttr(props);
102
+ useFormItemParentNameProvide({
103
+ name: formAttrs.newName,
104
+ sort: formAttrs.newSort
105
+ });
106
+ const slots = useSlots();
107
+ const isRequired = computed(()=>!!props.required || !!(toValue(formAttrs.ruleInstance?.value?.rules) || [])?.find((item)=>item.required));
108
+ return (_ctx, _cache)=>props.noStyle ? (openBlock(), createBlock(resolveDynamicComponent(props.input), normalizeProps(mergeProps({
109
+ key: 0
110
+ }, toValue(unref(formAttrs).attrsLastData))), null, 16)) : (openBlock(), createBlock(layout_formItem, {
111
+ key: 1,
112
+ label: props.label,
113
+ required: isRequired.value,
114
+ "error-layout": props.errorLayout,
115
+ "label-mode": props.labelMode,
116
+ "only-rule-style": props.onlyRuleStyle,
117
+ "show-colon": props.showColon,
118
+ "col-span": props.colSpan,
119
+ "row-span": props.rowSpan,
120
+ "html-for": unref(formAttrs).htmlFor,
121
+ style: normalizeStyle(props.style),
122
+ class: normalizeClass(props.class),
123
+ "label-style": props.labelStyle,
124
+ "label-class": props.labelClass,
125
+ "validate-result": unref(formAttrs).validateResult
126
+ }, createSlots({
127
+ default: withCtx(()=>[
128
+ (openBlock(), createBlock(resolveDynamicComponent(props.input), normalizeProps(guardReactiveProps(toValue(unref(formAttrs).attrsLastData))), null, 16))
129
+ ]),
130
+ _: 2
131
+ }, [
132
+ renderList(slots, (item, name)=>({
133
+ name,
134
+ fn: withCtx((slotProps)=>[
135
+ renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(slotProps)))
136
+ ])
137
+ }))
138
+ ]), 1032, [
139
+ "label",
140
+ "required",
141
+ "error-layout",
142
+ "label-mode",
143
+ "only-rule-style",
144
+ "show-colon",
145
+ "col-span",
146
+ "row-span",
147
+ "html-for",
148
+ "style",
149
+ "class",
150
+ "label-style",
151
+ "label-class",
152
+ "validate-result"
153
+ ]));
154
+ }
155
+ });
156
+ const form_Item_base = _sfc_main;
157
+ export { form_Item_base as default };
@@ -1,15 +1,14 @@
1
- import { FormItemProps } from '../interface/index';
2
- declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<FormItemProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FormItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, Readonly<{
1
+ import type { FormItemProps } from "../interface/index";
2
+ type __VLS_Slots = {
3
3
  label: (params: any) => any;
4
+ default: (params: any) => any;
4
5
  helpText: (params: any) => any;
5
6
  extra: (params: any) => any;
6
- }> & {
7
- label: (params: any) => any;
8
- helpText: (params: any) => any;
9
- extra: (params: any) => any;
10
- }>;
7
+ };
8
+ declare const __VLS_component: import("vue").DefineComponent<FormItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
11
10
  export default _default;
12
- type __VLS_WithTemplateSlots<T, S> = T & {
11
+ type __VLS_WithSlots<T, S> = T & {
13
12
  new (): {
14
13
  $slots: S;
15
14
  };