@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/esm/index.mjs DELETED
@@ -1,59 +0,0 @@
1
- import * as component from "./component.mjs";
2
- import { useAttrsInject, useAttrsProvide } from "./hooks/useAttrs.mjs";
3
- import { useForm, useFormInject, useFormProvide } from "./hooks/useForm.mjs";
4
- import { useFormItem, useFormItemInject, useFormItemProvide } from "./hooks/useFormItem.mjs";
5
- import { useFormList, useFormListInject, useFormListProvide } from "./hooks/useFormList.mjs";
6
- import { useHtmlFor } from "./hooks/useHtmlFor.mjs";
7
- import { useMultipleForm, useMultipleFormInject, useMultipleFormProvide } from "./hooks/useMultipleForm.mjs";
8
- import { useFormItemParentNameInject, useFormItemParentNameProvide } from "./hooks/useFormItemParentName.mjs";
9
- import { useEffect } from "./hooks/useEffect.mjs";
10
- import { useRegisterFormHideItem } from "./hooks/register/register.FormHideItem.mjs";
11
- import { useRegisterFormItem } from "./hooks/register/register.FormItem.mjs";
12
- import { useRegisterFormList } from "./hooks/register/register.FormList.mjs";
13
- import { useRegisterForm } from "./hooks/register/register.form.mjs";
14
- import { useFormItemAttr } from "./hooks/attr/attr.FormItem.mjs";
15
- import { withInstall } from "./utils/withInstall.mjs";
16
- import { Form } from "./form/index.mjs";
17
- import { FormHideItem, FormItem, FormItemBase } from "./formItem/index.mjs";
18
- import { FormLayoutRows, Layout, LayoutFormItem } from "./layout/index.mjs";
19
- const index = {
20
- install: (app) => {
21
- for (const c in component) {
22
- app.use(component[c]);
23
- }
24
- }
25
- };
26
- export {
27
- Form,
28
- FormHideItem,
29
- FormItem,
30
- FormItemBase,
31
- FormLayoutRows,
32
- Layout,
33
- LayoutFormItem,
34
- index as default,
35
- useAttrsInject,
36
- useAttrsProvide,
37
- useEffect,
38
- useForm,
39
- useFormInject,
40
- useFormItem,
41
- useFormItemAttr,
42
- useFormItemInject,
43
- useFormItemParentNameInject,
44
- useFormItemParentNameProvide,
45
- useFormItemProvide,
46
- useFormList,
47
- useFormListInject,
48
- useFormListProvide,
49
- useFormProvide,
50
- useHtmlFor,
51
- useMultipleForm,
52
- useMultipleFormInject,
53
- useMultipleFormProvide,
54
- useRegisterForm,
55
- useRegisterFormHideItem,
56
- useRegisterFormItem,
57
- useRegisterFormList,
58
- withInstall
59
- };
@@ -1,49 +0,0 @@
1
- import { RuleItem } from 'async-validator';
2
- import { MessageType, FormInstanceBase } from '@carefrees/form-utils';
3
- import { Ref } from 'vue';
4
- export declare class RuleInstanceBase2 {
5
- /**
6
- * 顺序
7
- * @example
8
- * "0"
9
- * "0-0"
10
- * "0-0-0"
11
- */
12
- sort?: string;
13
- /**表单实例*/
14
- instance?: FormInstanceBase;
15
- /**
16
- * 字段 ,分割方式与lodash的get和set方法值更新或设置路径一致
17
- * @example
18
- * 默认:"name"
19
- * 嵌套字段:"name.a.doc"
20
- * 嵌套字段:"name[1].a.doc"
21
- * 嵌套字段:"name.a[2].doc"
22
- */
23
- name: string;
24
- /**规则*/
25
- rules: Ref<RuleItem[]>;
26
- /**错误提示内容*/
27
- messages: Ref<MessageType[]>;
28
- /**更新当前组件方法*/
29
- updated?: Function;
30
- /**判断是否必填*/
31
- isRequired: () => boolean;
32
- /**初始化*/
33
- ctor: (name: string, rules: RuleItem[]) => this;
34
- /**判断是否需要验证*/
35
- isValidate: () => boolean;
36
- /**更新提示信息*/
37
- updatedMessages: (messages?: MessageType[]) => void;
38
- /**更新规则*/
39
- updatedRules: (rules: RuleItem[]) => void;
40
- /**验证规则
41
- * @param {boolean} isOnly 仅判断是否校验通过
42
- */
43
- validate: (isOnly?: boolean) => Promise<unknown>;
44
- /**获取校验结果*/
45
- getValidateResult: () => {
46
- tip: string | (string | undefined)[];
47
- isInvalid: boolean;
48
- };
49
- }
@@ -1,73 +0,0 @@
1
- import AsyncValidator from "async-validator";
2
- import { ref, toValue } from "vue";
3
- class RuleInstanceBase2 {
4
- constructor() {
5
- this.name = "";
6
- this.rules = ref([]);
7
- this.messages = ref([]);
8
- this.isRequired = () => {
9
- var _a, _b;
10
- if ((_b = (_a = this.instance) == null ? void 0 : _a.getFieldHideRulesValue) == null ? void 0 : _b.call(_a, this.name)) {
11
- return false;
12
- }
13
- const findItem = (toValue(this.rules) || []).find((item) => item == null ? void 0 : item.required);
14
- return !!findItem;
15
- };
16
- this.ctor = (name, rules) => {
17
- this.name = name;
18
- this.rules.value = rules || [];
19
- return this;
20
- };
21
- this.isValidate = () => {
22
- var _a, _b;
23
- if ((_b = (_a = this.instance) == null ? void 0 : _a.getFieldHideRulesValue) == null ? void 0 : _b.call(_a, this.name)) {
24
- return false;
25
- }
26
- const _rules = toValue(this.rules);
27
- return !!(Array.isArray(_rules) && _rules.length);
28
- };
29
- this.updatedMessages = (messages) => {
30
- var _a;
31
- this.messages.value = messages || [];
32
- (_a = this.updated) == null ? void 0 : _a.call(this, {});
33
- };
34
- this.updatedRules = (rules) => {
35
- var _a;
36
- this.rules.value = rules;
37
- (_a = this.updatedMessages) == null ? void 0 : _a.call(this, []);
38
- };
39
- this.validate = (isOnly = false) => {
40
- return new Promise((resolve, reject) => {
41
- var _a, _b, _c, _d;
42
- const value = (_b = (_a = this.instance) == null ? void 0 : _a.getFieldValue) == null ? void 0 : _b.call(_a, this.name);
43
- if ((_d = (_c = this.instance) == null ? void 0 : _c.getFieldHideRulesValue) == null ? void 0 : _d.call(_c, this.name)) {
44
- this.updatedMessages([]);
45
- resolve({ [this.name]: value });
46
- }
47
- new AsyncValidator({ [this.name]: toValue(this.rules) || [] }).validate({ [this.name]: value }).then((values) => {
48
- if (!isOnly) this.updatedMessages([]);
49
- resolve(values);
50
- }).catch(({ errors }) => {
51
- if (Array.isArray(errors)) {
52
- if (!isOnly) this.updatedMessages(errors);
53
- reject(errors);
54
- } else {
55
- reject();
56
- }
57
- });
58
- });
59
- };
60
- this.getValidateResult = () => {
61
- const _messages = toValue(this.messages);
62
- const tip = Array.isArray(_messages) ? _messages.map((it) => it.message) : "";
63
- const isInvalid = Array.isArray(tip) ? !!tip.length : !!tip;
64
- return {
65
- tip,
66
- isInvalid
67
- };
68
- };
69
- }
70
- }
71
- export {
72
- RuleInstanceBase2
73
- };
@@ -1,12 +0,0 @@
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
- };
@@ -1,31 +0,0 @@
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
- };
@@ -1,4 +0,0 @@
1
- import _sfc_main from "./layout.form.rows.vue.mjs";
2
- export {
3
- _sfc_main as default
4
- };
@@ -1,216 +0,0 @@
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
- };
@@ -1,4 +0,0 @@
1
- import _sfc_main from "./layout.formItem.vue.mjs";
2
- export {
3
- _sfc_main as default
4
- };
@@ -1,166 +0,0 @@
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
- };
@@ -1,4 +0,0 @@
1
- import _sfc_main from "./layout.vue.mjs";
2
- export {
3
- _sfc_main as default
4
- };
@@ -1,22 +0,0 @@
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
- };
@@ -1,3 +0,0 @@
1
- export * from './form';
2
- export * from './formItem';
3
- export * from './layout';
package/lib/component.js DELETED
@@ -1,12 +0,0 @@
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;
@@ -1,19 +0,0 @@
1
- import { FormProps } from '../interface/index';
2
- type __VLS_Props = FormProps;
3
- declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
4
- finish: (...args: any[]) => void;
5
- valuesChange: (...args: any[]) => void;
6
- finishFailed: (...args: any[]) => void;
7
- }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
8
- onFinish?: ((...args: any[]) => any) | undefined;
9
- onValuesChange?: ((...args: any[]) => any) | undefined;
10
- onFinishFailed?: ((...args: any[]) => any) | undefined;
11
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, {
12
- default?(_: {}): any;
13
- }>;
14
- export default _default;
15
- type __VLS_WithTemplateSlots<T, S> = T & {
16
- new (): {
17
- $slots: S;
18
- };
19
- };