@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.
Files changed (168) hide show
  1. package/README.md +3 -0
  2. package/assets/index.css +207 -0
  3. package/esm/component.d.ts +3 -0
  4. package/esm/component.mjs +12 -0
  5. package/esm/form/index.d.ts +37 -0
  6. package/esm/form/index.mjs +6 -0
  7. package/esm/form/index.vue.d.ts +19 -0
  8. package/esm/form/index.vue.mjs +110 -0
  9. package/esm/form/index.vue2.mjs +4 -0
  10. package/esm/formItem/form.Item.base.vue.d.ts +16 -0
  11. package/esm/formItem/form.Item.base.vue.mjs +114 -0
  12. package/esm/formItem/form.Item.base.vue2.mjs +4 -0
  13. package/esm/formItem/form.hide.item.vue.d.ts +16 -0
  14. package/esm/formItem/form.hide.item.vue.mjs +78 -0
  15. package/esm/formItem/form.hide.item.vue2.mjs +4 -0
  16. package/esm/formItem/formItem.vue.d.ts +18 -0
  17. package/esm/formItem/formItem.vue.mjs +102 -0
  18. package/esm/formItem/formItem.vue2.mjs +4 -0
  19. package/esm/formItem/index.d.ts +71 -0
  20. package/esm/formItem/index.mjs +12 -0
  21. package/esm/hooks/attr/attr.FormItem.d.ts +876 -0
  22. package/esm/hooks/attr/attr.FormItem.mjs +120 -0
  23. package/esm/hooks/index.d.ts +13 -0
  24. package/esm/hooks/register/register.FormHideItem.d.ts +9 -0
  25. package/esm/hooks/register/register.FormHideItem.mjs +38 -0
  26. package/esm/hooks/register/register.FormItem.d.ts +802 -0
  27. package/esm/hooks/register/register.FormItem.mjs +55 -0
  28. package/esm/hooks/register/register.FormList.d.ts +789 -0
  29. package/esm/hooks/register/register.FormList.mjs +43 -0
  30. package/esm/hooks/register/register.form.d.ts +3 -0
  31. package/esm/hooks/register/register.form.mjs +12 -0
  32. package/esm/hooks/useAttrs.d.ts +24 -0
  33. package/esm/hooks/useAttrs.mjs +45 -0
  34. package/esm/hooks/useEffect.d.ts +2 -0
  35. package/esm/hooks/useEffect.mjs +14 -0
  36. package/esm/hooks/useForm.d.ts +8 -0
  37. package/esm/hooks/useForm.mjs +26 -0
  38. package/esm/hooks/useFormItem.d.ts +7 -0
  39. package/esm/hooks/useFormItem.mjs +26 -0
  40. package/esm/hooks/useFormItemParentName.d.ts +18 -0
  41. package/esm/hooks/useFormItemParentName.mjs +37 -0
  42. package/esm/hooks/useFormList.d.ts +7 -0
  43. package/esm/hooks/useFormList.mjs +26 -0
  44. package/esm/hooks/useHtmlFor.d.ts +2 -0
  45. package/esm/hooks/useHtmlFor.mjs +11 -0
  46. package/esm/hooks/useMultipleForm.d.ts +7 -0
  47. package/esm/hooks/useMultipleForm.mjs +27 -0
  48. package/esm/index.d.ts +11 -0
  49. package/esm/index.mjs +59 -0
  50. package/esm/instance/ruleIntsnace.d.ts +49 -0
  51. package/esm/instance/ruleIntsnace.mjs +73 -0
  52. package/esm/interface/index.d.ts +36 -0
  53. package/esm/interface/layout.d.ts +28 -0
  54. package/esm/interface/layout.formItem.d.ts +39 -0
  55. package/esm/layout/index.d.ts +65 -0
  56. package/esm/layout/index.mjs +12 -0
  57. package/esm/layout/layout.form.rows.vue.d.ts +10 -0
  58. package/esm/layout/layout.form.rows.vue.mjs +31 -0
  59. package/esm/layout/layout.form.rows.vue2.mjs +4 -0
  60. package/esm/layout/layout.formItem.vue.d.ts +18 -0
  61. package/esm/layout/layout.formItem.vue.mjs +216 -0
  62. package/esm/layout/layout.formItem.vue2.mjs +4 -0
  63. package/esm/layout/layout.vue.d.ts +16 -0
  64. package/esm/layout/layout.vue.mjs +166 -0
  65. package/esm/layout/layout.vue2.mjs +4 -0
  66. package/esm/utils/index.d.ts +1 -0
  67. package/esm/utils/withInstall.d.ts +3 -0
  68. package/esm/utils/withInstall.mjs +22 -0
  69. package/lib/component.d.ts +3 -0
  70. package/lib/component.js +12 -0
  71. package/lib/form/index.d.ts +37 -0
  72. package/lib/form/index.js +6 -0
  73. package/lib/form/index.vue.d.ts +19 -0
  74. package/lib/form/index.vue.js +110 -0
  75. package/lib/form/index.vue2.js +4 -0
  76. package/lib/formItem/form.Item.base.vue.d.ts +16 -0
  77. package/lib/formItem/form.Item.base.vue.js +114 -0
  78. package/lib/formItem/form.Item.base.vue2.js +4 -0
  79. package/lib/formItem/form.hide.item.vue.d.ts +16 -0
  80. package/lib/formItem/form.hide.item.vue.js +78 -0
  81. package/lib/formItem/form.hide.item.vue2.js +4 -0
  82. package/lib/formItem/formItem.vue.d.ts +18 -0
  83. package/lib/formItem/formItem.vue.js +102 -0
  84. package/lib/formItem/formItem.vue2.js +4 -0
  85. package/lib/formItem/index.d.ts +71 -0
  86. package/lib/formItem/index.js +12 -0
  87. package/lib/hooks/attr/attr.FormItem.d.ts +876 -0
  88. package/lib/hooks/attr/attr.FormItem.js +120 -0
  89. package/lib/hooks/index.d.ts +13 -0
  90. package/lib/hooks/register/register.FormHideItem.d.ts +9 -0
  91. package/lib/hooks/register/register.FormHideItem.js +38 -0
  92. package/lib/hooks/register/register.FormItem.d.ts +802 -0
  93. package/lib/hooks/register/register.FormItem.js +55 -0
  94. package/lib/hooks/register/register.FormList.d.ts +789 -0
  95. package/lib/hooks/register/register.FormList.js +43 -0
  96. package/lib/hooks/register/register.form.d.ts +3 -0
  97. package/lib/hooks/register/register.form.js +12 -0
  98. package/lib/hooks/useAttrs.d.ts +24 -0
  99. package/lib/hooks/useAttrs.js +45 -0
  100. package/lib/hooks/useEffect.d.ts +2 -0
  101. package/lib/hooks/useEffect.js +14 -0
  102. package/lib/hooks/useForm.d.ts +8 -0
  103. package/lib/hooks/useForm.js +26 -0
  104. package/lib/hooks/useFormItem.d.ts +7 -0
  105. package/lib/hooks/useFormItem.js +26 -0
  106. package/lib/hooks/useFormItemParentName.d.ts +18 -0
  107. package/lib/hooks/useFormItemParentName.js +37 -0
  108. package/lib/hooks/useFormList.d.ts +7 -0
  109. package/lib/hooks/useFormList.js +26 -0
  110. package/lib/hooks/useHtmlFor.d.ts +2 -0
  111. package/lib/hooks/useHtmlFor.js +11 -0
  112. package/lib/hooks/useMultipleForm.d.ts +7 -0
  113. package/lib/hooks/useMultipleForm.js +27 -0
  114. package/lib/index.d.ts +11 -0
  115. package/lib/index.js +59 -0
  116. package/lib/instance/ruleIntsnace.d.ts +49 -0
  117. package/lib/instance/ruleIntsnace.js +73 -0
  118. package/lib/interface/index.d.ts +36 -0
  119. package/lib/interface/layout.d.ts +28 -0
  120. package/lib/interface/layout.formItem.d.ts +39 -0
  121. package/lib/layout/index.d.ts +65 -0
  122. package/lib/layout/index.js +12 -0
  123. package/lib/layout/layout.form.rows.vue.d.ts +10 -0
  124. package/lib/layout/layout.form.rows.vue.js +31 -0
  125. package/lib/layout/layout.form.rows.vue2.js +4 -0
  126. package/lib/layout/layout.formItem.vue.d.ts +18 -0
  127. package/lib/layout/layout.formItem.vue.js +216 -0
  128. package/lib/layout/layout.formItem.vue2.js +4 -0
  129. package/lib/layout/layout.vue.d.ts +16 -0
  130. package/lib/layout/layout.vue.js +166 -0
  131. package/lib/layout/layout.vue2.js +4 -0
  132. package/lib/utils/index.d.ts +1 -0
  133. package/lib/utils/withInstall.d.ts +3 -0
  134. package/lib/utils/withInstall.js +22 -0
  135. package/package.json +33 -0
  136. package/src/component.ts +3 -0
  137. package/src/form/index.ts +3 -0
  138. package/src/form/index.vue +66 -0
  139. package/src/formItem/form.Item.base.vue +54 -0
  140. package/src/formItem/form.hide.item.vue +28 -0
  141. package/src/formItem/formItem.vue +38 -0
  142. package/src/formItem/index.ts +7 -0
  143. package/src/hooks/attr/attr.FormItem.tsx +170 -0
  144. package/src/hooks/index.ts +13 -0
  145. package/src/hooks/register/register.FormHideItem.ts +45 -0
  146. package/src/hooks/register/register.FormItem.ts +80 -0
  147. package/src/hooks/register/register.FormList.ts +49 -0
  148. package/src/hooks/register/register.form.ts +12 -0
  149. package/src/hooks/useAttrs.ts +66 -0
  150. package/src/hooks/useEffect.ts +13 -0
  151. package/src/hooks/useForm.ts +28 -0
  152. package/src/hooks/useFormItem.ts +28 -0
  153. package/src/hooks/useFormItemParentName.ts +49 -0
  154. package/src/hooks/useFormList.ts +28 -0
  155. package/src/hooks/useHtmlFor.ts +9 -0
  156. package/src/hooks/useMultipleForm.ts +29 -0
  157. package/src/index.ts +16 -0
  158. package/src/instance/ruleIntsnace.ts +105 -0
  159. package/src/interface/index.ts +40 -0
  160. package/src/interface/layout.formItem.ts +42 -0
  161. package/src/interface/layout.ts +29 -0
  162. package/src/layout/index.ts +8 -0
  163. package/src/layout/layout.form.rows.vue +19 -0
  164. package/src/layout/layout.formItem.vue +119 -0
  165. package/src/layout/layout.vue +97 -0
  166. package/src/utils/index.ts +1 -0
  167. package/src/utils/withInstall.ts +28 -0
  168. package/src/vite-env.d.ts +1 -0
@@ -0,0 +1,39 @@
1
+ import { VNodeChild, StyleValue } from 'vue';
2
+ import { ComputedRefBase } from '.';
3
+ export interface LayoutFormItemProps {
4
+ /**规则校验失败错误提示位置*/
5
+ errorLayout?: 'left-bottom' | 'right-bottom' | 'top-right' | 'top-left';
6
+ /**必填样式*/
7
+ required?: boolean;
8
+ /**label显示模式*/
9
+ labelMode?: 'left' | 'top' | 'between' | 'hide';
10
+ /**只进行规则样式*/
11
+ onlyRuleStyle?: boolean;
12
+ label?: VNodeChild;
13
+ /**底部提示内容*/
14
+ helpText?: VNodeChild;
15
+ /**额外内容*/
16
+ extra?: VNodeChild;
17
+ /**是否显示label后的冒号*/
18
+ showColon?: boolean;
19
+ /**
20
+ * 表单项占据列数
21
+ * @default 1
22
+ */
23
+ colSpan?: number;
24
+ /**
25
+ * 表单项占据行数
26
+ * @default 1
27
+ */
28
+ rowSpan?: number;
29
+ htmlFor?: ComputedRefBase<string>;
30
+ /**规则验证结果*/
31
+ validateResult?: ComputedRefBase<{
32
+ tip: string | (string | undefined)[];
33
+ isInvalid: boolean;
34
+ }>;
35
+ style?: StyleValue;
36
+ class?: string;
37
+ labelStyle?: StyleValue;
38
+ labelClass?: string;
39
+ }
@@ -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
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const layout_vue_vue_type_script_setup_true_lang = require("./layout.vue.js");
4
+ const layout_formItem_vue_vue_type_script_setup_true_lang = require("./layout.formItem.vue.js");
5
+ const layout_form_rows_vue_vue_type_script_setup_true_lang = require("./layout.form.rows.vue.js");
6
+ const withInstall = require("../utils/withInstall.js");
7
+ const Layout = withInstall.withInstall(layout_vue_vue_type_script_setup_true_lang.default);
8
+ const LayoutFormItem = withInstall.withInstall(layout_formItem_vue_vue_type_script_setup_true_lang.default);
9
+ const FormLayoutRows = withInstall.withInstall(layout_form_rows_vue_vue_type_script_setup_true_lang.default);
10
+ exports.FormLayoutRows = FormLayoutRows;
11
+ exports.Layout = Layout;
12
+ exports.LayoutFormItem = LayoutFormItem;
@@ -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
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const vue = require("vue");
4
+ const clx = require("classnames");
5
+ const __default__ = vue.defineComponent({
6
+ name: "FormLayoutRows",
7
+ inheritAttrs: false
8
+ // 可选,防止属性自动应用到根元素
9
+ });
10
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
11
+ ...__default__,
12
+ setup(__props) {
13
+ const preCls = "carefrees-form-layout";
14
+ const props = __props;
15
+ const cls = vue.computed(() => clx(preCls, props.class, {
16
+ "all-colspan": true
17
+ }));
18
+ return (_ctx, _cache) => {
19
+ return vue.openBlock(), vue.createElementBlock(
20
+ "div",
21
+ vue.mergeProps(props, { class: cls.value }),
22
+ [
23
+ vue.renderSlot(_ctx.$slots, "default")
24
+ ],
25
+ 16
26
+ /* FULL_PROPS */
27
+ );
28
+ };
29
+ }
30
+ });
31
+ exports.default = _sfc_main;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const layout_form_rows_vue_vue_type_script_setup_true_lang = require("./layout.form.rows.vue.js");
4
+ exports.default = layout_form_rows_vue_vue_type_script_setup_true_lang.default;
@@ -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
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const vue = require("vue");
4
+ const clx = require("classnames");
5
+ const useAttrs = require("../hooks/useAttrs.js");
6
+ const _hoisted_1 = ["for"];
7
+ const __default__ = vue.defineComponent({
8
+ name: "LayoutFormItem",
9
+ inheritAttrs: false
10
+ // 可选,防止属性自动应用到根元素
11
+ });
12
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
13
+ ...__default__,
14
+ props: {
15
+ errorLayout: {},
16
+ required: { type: Boolean },
17
+ labelMode: {},
18
+ onlyRuleStyle: { type: Boolean },
19
+ label: { type: [Object, String, Number, Boolean, null, Array] },
20
+ helpText: { type: [Object, String, Number, Boolean, null, Array] },
21
+ extra: { type: [Object, String, Number, Boolean, null, Array] },
22
+ showColon: { type: Boolean },
23
+ colSpan: {},
24
+ rowSpan: {},
25
+ htmlFor: {},
26
+ validateResult: {},
27
+ style: { type: [Boolean, null, String, Object, Array] },
28
+ class: {},
29
+ labelStyle: { type: [Boolean, null, String, Object, Array] },
30
+ labelClass: {}
31
+ },
32
+ setup(__props) {
33
+ const preCls = "carefrees-form-item";
34
+ const attrs = useAttrs.useAttrsInject();
35
+ const props = __props;
36
+ const solts = vue.useSlots();
37
+ const labelMode = vue.computed(() => props.labelMode ?? vue.toValue(attrs.value.labelMode) ?? "top");
38
+ const showColon = vue.computed(() => props.showColon ?? vue.toValue(attrs.value.showColon));
39
+ const errorLayout = vue.computed(() => props.errorLayout ?? vue.toValue(attrs.value.errorLayout) ?? "left-bottom");
40
+ const tips = vue.computed(() => {
41
+ var _a;
42
+ const v = (_a = vue.toValue(props.validateResult)) == null ? void 0 : _a.tip;
43
+ if (Array.isArray(v)) {
44
+ return v.join(",");
45
+ }
46
+ return v;
47
+ });
48
+ const cls = vue.computed(() => {
49
+ var _a;
50
+ return clx(preCls, props.class, vue.toValue(attrs.value.formItemClass), { "dx-invalid": !!((_a = vue.toValue(props.validateResult)) == null ? void 0 : _a.isInvalid) });
51
+ });
52
+ const containerCls = vue.computed(() => clx(`${preCls}-container`, { [`${labelMode.value}`]: !!labelMode.value }));
53
+ const labelCls = vue.computed(() => clx(`${preCls}-label`, { required: !!props.required, "show-colon": showColon && (labelMode.value === "left" || labelMode.value === "between") }));
54
+ const labelWarpCls = vue.computed(() => clx(`${preCls}-label-warp`, vue.toValue(props.labelClass), vue.toValue(attrs.value.formItemLabelClass)));
55
+ const inputCls = vue.computed(() => clx(`${preCls}-body-input`));
56
+ const errorCls = vue.computed(() => clx(`${preCls}-body-error`, { [errorLayout.value]: !!errorLayout.value }));
57
+ const _isLabel = vue.computed(() => (props.label || solts.label) && labelMode.value !== "hide");
58
+ const style = vue.computed(() => {
59
+ const css = {};
60
+ if (props.onlyRuleStyle) {
61
+ css.padding = "0px";
62
+ }
63
+ if (props.colSpan) {
64
+ const colCount = vue.toValue(attrs.value.colCount) || 4;
65
+ const end = colCount > props.colSpan ? props.colSpan : colCount;
66
+ css.gridColumnEnd = `span ${end}`;
67
+ }
68
+ if (props.rowSpan) {
69
+ css.gridRowEnd = `span ${props.rowSpan}`;
70
+ }
71
+ return [vue.toValue(attrs.value.formItemStyle), props.style, css];
72
+ });
73
+ const labelStyle = vue.computed(() => {
74
+ return [vue.toValue(attrs.value.formItemLabelStyle), props.labelStyle];
75
+ });
76
+ const isHelpText = vue.computed(() => {
77
+ return !!props.helpText || solts.helpText;
78
+ });
79
+ const isExtra = vue.computed(() => {
80
+ return !!props.extra || solts.extra;
81
+ });
82
+ return (_ctx, _cache) => {
83
+ return vue.openBlock(), vue.createElementBlock(
84
+ "div",
85
+ {
86
+ class: vue.normalizeClass(cls.value),
87
+ style: vue.normalizeStyle(style.value)
88
+ },
89
+ [
90
+ vue.createElementVNode(
91
+ "div",
92
+ {
93
+ class: vue.normalizeClass(containerCls.value)
94
+ },
95
+ [
96
+ _isLabel.value ? (vue.openBlock(), vue.createElementBlock(
97
+ "div",
98
+ {
99
+ key: 0,
100
+ class: vue.normalizeClass(labelWarpCls.value)
101
+ },
102
+ [
103
+ vue.createElementVNode("label", {
104
+ style: vue.normalizeStyle(labelStyle.value),
105
+ class: vue.normalizeClass(labelCls.value),
106
+ for: vue.toValue(props.htmlFor)
107
+ }, [
108
+ props.label ? (vue.openBlock(), vue.createElementBlock(
109
+ vue.Fragment,
110
+ { key: 0 },
111
+ [
112
+ vue.createTextVNode(
113
+ vue.toDisplayString(props.label),
114
+ 1
115
+ /* TEXT */
116
+ )
117
+ ],
118
+ 64
119
+ /* STABLE_FRAGMENT */
120
+ )) : vue.renderSlot(_ctx.$slots, "label", { key: 1 })
121
+ ], 14, _hoisted_1)
122
+ ],
123
+ 2
124
+ /* CLASS */
125
+ )) : vue.createCommentVNode("v-if", true),
126
+ vue.createElementVNode(
127
+ "div",
128
+ {
129
+ class: vue.normalizeClass(preCls + "-body")
130
+ },
131
+ [
132
+ vue.createElementVNode(
133
+ "div",
134
+ {
135
+ class: vue.normalizeClass(inputCls.value)
136
+ },
137
+ [
138
+ vue.renderSlot(_ctx.$slots, "default")
139
+ ],
140
+ 2
141
+ /* CLASS */
142
+ ),
143
+ isHelpText.value ? (vue.openBlock(), vue.createElementBlock(
144
+ "div",
145
+ {
146
+ key: 0,
147
+ class: vue.normalizeClass(preCls + "-body-help")
148
+ },
149
+ [
150
+ props.helpText ? (vue.openBlock(), vue.createElementBlock(
151
+ vue.Fragment,
152
+ { key: 0 },
153
+ [
154
+ vue.createTextVNode(
155
+ vue.toDisplayString(props.helpText),
156
+ 1
157
+ /* TEXT */
158
+ )
159
+ ],
160
+ 64
161
+ /* STABLE_FRAGMENT */
162
+ )) : vue.renderSlot(_ctx.$slots, "helpText", { key: 1 })
163
+ ],
164
+ 2
165
+ /* CLASS */
166
+ )) : vue.createCommentVNode("v-if", true),
167
+ !!tips.value ? (vue.openBlock(), vue.createElementBlock(
168
+ "div",
169
+ {
170
+ key: 1,
171
+ class: vue.normalizeClass(errorCls.value)
172
+ },
173
+ vue.toDisplayString(tips.value),
174
+ 3
175
+ /* TEXT, CLASS */
176
+ )) : vue.createCommentVNode("v-if", true)
177
+ ],
178
+ 2
179
+ /* CLASS */
180
+ )
181
+ ],
182
+ 2
183
+ /* CLASS */
184
+ ),
185
+ isExtra.value ? (vue.openBlock(), vue.createElementBlock(
186
+ "div",
187
+ {
188
+ key: 0,
189
+ class: vue.normalizeClass(preCls + "-extra")
190
+ },
191
+ [
192
+ props.extra ? (vue.openBlock(), vue.createElementBlock(
193
+ vue.Fragment,
194
+ { key: 0 },
195
+ [
196
+ vue.createTextVNode(
197
+ vue.toDisplayString(props.extra),
198
+ 1
199
+ /* TEXT */
200
+ )
201
+ ],
202
+ 64
203
+ /* STABLE_FRAGMENT */
204
+ )) : vue.renderSlot(_ctx.$slots, "extra", { key: 1 })
205
+ ],
206
+ 2
207
+ /* CLASS */
208
+ )) : vue.createCommentVNode("v-if", true)
209
+ ],
210
+ 6
211
+ /* CLASS, STYLE */
212
+ );
213
+ };
214
+ }
215
+ });
216
+ exports.default = _sfc_main;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const layout_formItem_vue_vue_type_script_setup_true_lang = require("./layout.formItem.vue.js");
4
+ exports.default = layout_formItem_vue_vue_type_script_setup_true_lang.default;
@@ -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
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const vue = require("vue");
4
+ const clx = require("classnames");
5
+ const useAttrs = require("../hooks/useAttrs.js");
6
+ const __default__ = vue.defineComponent({
7
+ name: "Layout",
8
+ inheritAttrs: false
9
+ // 可选,防止属性自动应用到根元素
10
+ });
11
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
12
+ ...__default__,
13
+ props: {
14
+ title: { type: [Object, String, Number, Boolean, null, Array] },
15
+ extra: { type: [Object, String, Number, Boolean, null, Array] },
16
+ isAllColSpan: { type: Boolean },
17
+ class: {},
18
+ headerClass: {},
19
+ bodyClass: {},
20
+ style: { type: [Boolean, null, String, Object, Array] },
21
+ headerStyle: { type: [Boolean, null, String, Object, Array] },
22
+ bodyStyle: { type: [Boolean, null, String, Object, Array] },
23
+ bordered: { type: Boolean },
24
+ colCount: {},
25
+ gap: {},
26
+ errorLayout: {},
27
+ labelMode: {},
28
+ showColon: {},
29
+ formItemClass: {},
30
+ formItemStyle: {},
31
+ formItemLabelClass: {},
32
+ formItemLabelStyle: {}
33
+ },
34
+ setup(__props) {
35
+ const preCls = "carefrees-form-layout";
36
+ const attrs = useAttrs.useAttrsInject();
37
+ const props = __props;
38
+ const solts = vue.useSlots();
39
+ const colCount = vue.computed(() => vue.toValue(props.colCount) ?? vue.toValue(attrs.value.colCount));
40
+ const errorLayout = vue.computed(() => vue.toValue(props.errorLayout) ?? vue.toValue(attrs.value.errorLayout));
41
+ const labelMode = vue.computed(() => vue.toValue(props.labelMode) ?? vue.toValue(attrs.value.labelMode));
42
+ const showColon = vue.computed(() => vue.toValue(props.showColon) ?? vue.toValue(attrs.value.showColon));
43
+ const formItemClass = vue.computed(() => vue.toValue(props.formItemClass) ?? vue.toValue(attrs.value.formItemClass));
44
+ const formItemStyle = vue.computed(() => vue.toValue(props.formItemStyle) ?? vue.toValue(attrs.value.formItemStyle));
45
+ const formItemLabelClass = vue.computed(() => vue.toValue(props.formItemLabelClass) ?? vue.toValue(attrs.value.formItemLabelClass));
46
+ const formItemLabelStyle = vue.computed(() => vue.toValue(props.formItemLabelStyle) ?? vue.toValue(attrs.value.formItemLabelStyle));
47
+ useAttrs.useAttrsProvide({
48
+ colCount,
49
+ errorLayout,
50
+ labelMode,
51
+ showColon,
52
+ formItemClass,
53
+ formItemStyle,
54
+ formItemLabelClass,
55
+ formItemLabelStyle
56
+ });
57
+ const cls = vue.computed(() => clx(preCls, props.class, { "all-colspan": props.isAllColSpan, bordered: props.bordered }));
58
+ const bodyCls = vue.computed(() => clx(`${preCls}-body`, props.bodyClass));
59
+ const headerCls = vue.computed(() => clx(`${preCls}-header`, props.headerClass));
60
+ const headerTitleCls = vue.computed(() => clx(`${preCls}-header-title`));
61
+ const headerExtraCls = vue.computed(() => clx(`${preCls}-header-extra`));
62
+ const bodyStyle = vue.computed(() => {
63
+ const css = {};
64
+ if (typeof props.gap === "string") {
65
+ css.gap = props.gap;
66
+ }
67
+ if (typeof props.gap === "number") {
68
+ css.gap = `${props.gap}px`;
69
+ }
70
+ if (colCount.value) {
71
+ css.gridTemplateColumns = `repeat(${colCount.value}, auto)`;
72
+ }
73
+ return [css, props.bodyStyle];
74
+ });
75
+ const isTitle = vue.computed(() => {
76
+ return !!props.title || solts.title;
77
+ });
78
+ const isExtra = vue.computed(() => {
79
+ return !!props.extra || solts.extra;
80
+ });
81
+ return (_ctx, _cache) => {
82
+ return vue.openBlock(), vue.createElementBlock(
83
+ "div",
84
+ {
85
+ style: vue.normalizeStyle(props.style),
86
+ class: vue.normalizeClass(cls.value)
87
+ },
88
+ [
89
+ isExtra.value || isTitle.value ? (vue.openBlock(), vue.createElementBlock(
90
+ "div",
91
+ {
92
+ key: 0,
93
+ style: vue.normalizeStyle(_ctx.headerStyle),
94
+ class: vue.normalizeClass(headerCls.value)
95
+ },
96
+ [
97
+ vue.createElementVNode(
98
+ "div",
99
+ {
100
+ class: vue.normalizeClass(headerTitleCls.value)
101
+ },
102
+ [
103
+ props.title ? (vue.openBlock(), vue.createElementBlock(
104
+ vue.Fragment,
105
+ { key: 0 },
106
+ [
107
+ vue.createTextVNode(
108
+ vue.toDisplayString(props.title),
109
+ 1
110
+ /* TEXT */
111
+ )
112
+ ],
113
+ 64
114
+ /* STABLE_FRAGMENT */
115
+ )) : vue.renderSlot(_ctx.$slots, "title", { key: 1 })
116
+ ],
117
+ 2
118
+ /* CLASS */
119
+ ),
120
+ vue.createElementVNode(
121
+ "div",
122
+ {
123
+ class: vue.normalizeClass(headerExtraCls.value)
124
+ },
125
+ [
126
+ props.extra ? (vue.openBlock(), vue.createElementBlock(
127
+ vue.Fragment,
128
+ { key: 0 },
129
+ [
130
+ vue.createTextVNode(
131
+ vue.toDisplayString(props.extra),
132
+ 1
133
+ /* TEXT */
134
+ )
135
+ ],
136
+ 64
137
+ /* STABLE_FRAGMENT */
138
+ )) : vue.renderSlot(_ctx.$slots, "extra", { key: 1 })
139
+ ],
140
+ 2
141
+ /* CLASS */
142
+ )
143
+ ],
144
+ 6
145
+ /* CLASS, STYLE */
146
+ )) : vue.createCommentVNode("v-if", true),
147
+ vue.createElementVNode(
148
+ "div",
149
+ {
150
+ style: vue.normalizeStyle(bodyStyle.value),
151
+ class: vue.normalizeClass(bodyCls.value)
152
+ },
153
+ [
154
+ vue.renderSlot(_ctx.$slots, "default")
155
+ ],
156
+ 6
157
+ /* CLASS, STYLE */
158
+ )
159
+ ],
160
+ 6
161
+ /* CLASS, STYLE */
162
+ );
163
+ };
164
+ }
165
+ });
166
+ exports.default = _sfc_main;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const layout_vue_vue_type_script_setup_true_lang = require("./layout.vue.js");
4
+ exports.default = layout_vue_vue_type_script_setup_true_lang.default;
@@ -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
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const withInstall = (main, extra, childComponents) => {
4
+ main.install = (app) => {
5
+ for (const comp of [main, ...Object.values(childComponents ?? {})]) {
6
+ const name = comp.name || comp.__name;
7
+ app.component(name, comp);
8
+ }
9
+ };
10
+ if (childComponents) {
11
+ for (const [key, comp] of Object.entries(childComponents)) {
12
+ main[key] = comp;
13
+ }
14
+ }
15
+ if (extra) {
16
+ for (const [key, comp] of Object.entries(extra)) {
17
+ main[key] = comp;
18
+ }
19
+ }
20
+ return main;
21
+ };
22
+ exports.withInstall = withInstall;
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@carefrees/form-utils-vue",
3
+ "author": "SunLxy <1011771396@qq.com>",
4
+ "version": "0.0.8",
5
+ "description": "",
6
+ "main": "lib/index.js",
7
+ "module": "esm/index.mjs",
8
+ "types": "esm/index.d.ts",
9
+ "scripts": {
10
+ "build": "saqu-vue build",
11
+ "watch": "saqu-vue build --watch"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "files": [
17
+ "assets",
18
+ "src",
19
+ "lib",
20
+ "esm"
21
+ ],
22
+ "keywords": [],
23
+ "license": "ISC",
24
+ "devDependencies": {
25
+ "@saqu-vue/core": "^1.0.1",
26
+ "vue": "^3.5.13"
27
+ },
28
+ "dependencies": {
29
+ "async-validator": "~4.2.5",
30
+ "@carefrees/form-utils": "^0.0.8",
31
+ "classnames": "2.5.1"
32
+ }
33
+ }
@@ -0,0 +1,3 @@
1
+ export * from './form';
2
+ export * from './formItem';
3
+ export * from './layout';
@@ -0,0 +1,3 @@
1
+ import _Form from './index.vue';
2
+ import { withInstall } from '../utils';
3
+ export const Form = withInstall(_Form);