@carefrees/form-utils-react-taro 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/formItem/index.d.ts +3 -4
- package/esm/formItem/index.js +4 -5
- package/esm/formList/index.d.ts +1 -1
- package/esm/formList/index.js +5 -8
- package/esm/hooks/attr/attr.FormItem.d.ts +1 -1
- package/esm/hooks/attr/attr.FormItem.js +3 -4
- package/esm/index.d.ts +1 -12
- package/esm/index.js +5 -17
- package/esm/layout/index.d.ts +1 -1
- package/esm/layout/index.js +3 -3
- package/esm/layout/layout.formItem.js +2 -2
- package/lib/formItem/index.d.ts +3 -4
- package/lib/formItem/index.js +4 -5
- package/lib/formList/index.d.ts +1 -1
- package/lib/formList/index.js +5 -8
- package/lib/hooks/attr/attr.FormItem.d.ts +1 -1
- package/lib/hooks/attr/attr.FormItem.js +3 -4
- package/lib/index.d.ts +1 -12
- package/lib/index.js +23 -155
- package/lib/layout/index.d.ts +1 -1
- package/lib/layout/index.js +3 -3
- package/lib/layout/layout.formItem.js +2 -2
- package/package.json +4 -3
- package/src/formItem/index.tsx +3 -4
- package/src/formList/index.tsx +7 -4
- package/src/hooks/attr/attr.FormItem.tsx +1 -2
- package/src/index.tsx +2 -14
- package/src/layout/index.tsx +2 -1
- package/src/layout/layout.formItem.tsx +1 -1
- package/esm/hooks/register/register.FormHideItem.d.ts +0 -9
- package/esm/hooks/register/register.FormHideItem.js +0 -31
- package/esm/hooks/register/register.FormItem.d.ts +0 -23
- package/esm/hooks/register/register.FormItem.js +0 -42
- package/esm/hooks/register/register.FormList.d.ts +0 -9
- package/esm/hooks/register/register.FormList.js +0 -31
- package/esm/hooks/register/register.form.d.ts +0 -3
- package/esm/hooks/register/register.form.js +0 -17
- package/esm/hooks/useAttrs.d.ts +0 -25
- package/esm/hooks/useAttrs.js +0 -10
- package/esm/hooks/useForm.d.ts +0 -7
- package/esm/hooks/useForm.js +0 -13
- package/esm/hooks/useFormItem.d.ts +0 -7
- package/esm/hooks/useFormItem.js +0 -11
- package/esm/hooks/useFormItemParentName.d.ts +0 -30
- package/esm/hooks/useFormItemParentName.js +0 -61
- package/esm/hooks/useFormList.d.ts +0 -7
- package/esm/hooks/useFormList.js +0 -11
- package/esm/hooks/useHtmlFor.d.ts +0 -1
- package/esm/hooks/useHtmlFor.js +0 -10
- package/esm/hooks/useMultipleForm.d.ts +0 -13
- package/esm/hooks/useMultipleForm.js +0 -19
- package/esm/hooks/useUpdate.d.ts +0 -2
- package/esm/hooks/useUpdate.js +0 -10
- package/esm/hooks/useWatch.d.ts +0 -19
- package/esm/hooks/useWatch.js +0 -41
- package/lib/hooks/register/register.FormHideItem.d.ts +0 -9
- package/lib/hooks/register/register.FormHideItem.js +0 -65
- package/lib/hooks/register/register.FormItem.d.ts +0 -23
- package/lib/hooks/register/register.FormItem.js +0 -76
- package/lib/hooks/register/register.FormList.d.ts +0 -9
- package/lib/hooks/register/register.FormList.js +0 -65
- package/lib/hooks/register/register.form.d.ts +0 -3
- package/lib/hooks/register/register.form.js +0 -51
- package/lib/hooks/useAttrs.d.ts +0 -25
- package/lib/hooks/useAttrs.js +0 -47
- package/lib/hooks/useForm.d.ts +0 -7
- package/lib/hooks/useForm.js +0 -53
- package/lib/hooks/useFormItem.d.ts +0 -7
- package/lib/hooks/useFormItem.js +0 -51
- package/lib/hooks/useFormItemParentName.d.ts +0 -30
- package/lib/hooks/useFormItemParentName.js +0 -101
- package/lib/hooks/useFormList.d.ts +0 -7
- package/lib/hooks/useFormList.js +0 -51
- package/lib/hooks/useHtmlFor.d.ts +0 -1
- package/lib/hooks/useHtmlFor.js +0 -44
- package/lib/hooks/useMultipleForm.d.ts +0 -13
- package/lib/hooks/useMultipleForm.js +0 -62
- package/lib/hooks/useUpdate.d.ts +0 -2
- package/lib/hooks/useUpdate.js +0 -44
- package/lib/hooks/useWatch.d.ts +0 -19
- package/lib/hooks/useWatch.js +0 -78
- package/src/hooks/register/register.FormHideItem.ts +0 -29
- package/src/hooks/register/register.FormItem.ts +0 -52
- package/src/hooks/register/register.FormList.ts +0 -31
- package/src/hooks/register/register.form.ts +0 -18
- package/src/hooks/useAttrs.ts +0 -35
- package/src/hooks/useForm.ts +0 -23
- package/src/hooks/useFormItem.ts +0 -21
- package/src/hooks/useFormItemParentName.ts +0 -49
- package/src/hooks/useFormList.ts +0 -21
- package/src/hooks/useHtmlFor.ts +0 -9
- package/src/hooks/useMultipleForm.ts +0 -36
- package/src/hooks/useUpdate.ts +0 -12
- package/src/hooks/useWatch.ts +0 -61
package/esm/formItem/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { LayoutFormItemProps } from '
|
|
1
|
+
import { LayoutFormItemProps } from '../layout/layout.formItem';
|
|
2
2
|
import { FormItemAttrOptions } from '../hooks/attr/attr.FormItem';
|
|
3
|
-
import React from 'react';
|
|
4
3
|
export interface FormItemProps extends FormItemAttrOptions, LayoutFormItemProps {
|
|
5
4
|
/**不进行样式渲染*/
|
|
6
5
|
noStyle?: boolean;
|
|
7
6
|
}
|
|
8
7
|
/**表单项*/
|
|
9
|
-
export declare const FormItem:
|
|
8
|
+
export declare const FormItem: import("react").MemoExoticComponent<(props: Partial<FormItemProps>) => import("react/jsx-runtime").JSX.Element>;
|
|
10
9
|
/**隐藏表单项*/
|
|
11
|
-
export declare const FormHideItem:
|
|
10
|
+
export declare const FormHideItem: import("react").MemoExoticComponent<(props: FormItemProps) => import("react/jsx-runtime").JSX.Element>;
|
package/esm/formItem/index.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__layout_layout_formItem_js_c84059c5__ from "../layout/layout.formItem.js";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__hooks_attr_attr_FormItem_js_9b75aef3__ from "../hooks/attr/attr.FormItem.js";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE__hooks_useFormItemParentName_js_ed96cda3__ from "../hooks/useFormItemParentName.js";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE__hooks_register_register_FormHideItem_js_2b23597a__ from "../hooks/register/register.FormHideItem.js";
|
|
6
4
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__ from "@carefrees/form-utils-react-hooks";
|
|
7
6
|
const FormItemInstance = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
8
7
|
const { labelMode, noStyle, onlyRuleStyle, label, helpText, extra, errorLayout, required, showColon, colSpan, rowSpan, ...rest } = props;
|
|
9
8
|
const { children, ruleInstance, formItemInstance, htmlFor, validateResult } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_attr_attr_FormItem_js_9b75aef3__.useFormItemAttr)({
|
|
10
9
|
...rest
|
|
11
10
|
});
|
|
12
|
-
if (noStyle) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
11
|
+
if (noStyle) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.FormItemParentNameProvider, {
|
|
13
12
|
name: formItemInstance.name,
|
|
14
13
|
sort: formItemInstance.sort,
|
|
15
14
|
children: children
|
|
16
15
|
});
|
|
17
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
16
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.FormItemParentNameProvider, {
|
|
18
17
|
name: formItemInstance.name,
|
|
19
18
|
sort: formItemInstance.sort,
|
|
20
19
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__layout_layout_formItem_js_c84059c5__.LayoutFormItem, {
|
|
@@ -57,7 +56,7 @@ const FormItem = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((prop
|
|
|
57
56
|
});
|
|
58
57
|
const FormHideItem = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
59
58
|
const { name, sort, isJoinParentField } = props;
|
|
60
|
-
const { isHide } = (0,
|
|
59
|
+
const { isHide } = (0, __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.useRegisterFormHideItem)({
|
|
61
60
|
name,
|
|
62
61
|
sort: sort,
|
|
63
62
|
isJoinParentField
|
package/esm/formList/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RegisterFormListOptions } from './../hooks/register/register.FormList';
|
|
2
1
|
import { RuleInstanceBase, FormItemInstanceBase, FormListInstanceBase } from '@carefrees/form-utils';
|
|
3
2
|
import React from 'react';
|
|
3
|
+
import { RegisterFormListOptions } from '@carefrees/form-utils-react-hooks';
|
|
4
4
|
export interface FormListChildrenProps {
|
|
5
5
|
/**数据集合*/
|
|
6
6
|
fields: {
|
package/esm/formList/index.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE__hooks_register_register_FormList_js_6f2f394b__ from "../hooks/register/register.FormList.js";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE__hooks_useFormList_js_058846bf__ from "../hooks/useFormList.js";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE__hooks_useFormItemParentName_js_ed96cda3__ from "../hooks/useFormItemParentName.js";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE__hooks_register_register_FormHideItem_js_2b23597a__ from "../hooks/register/register.FormHideItem.js";
|
|
6
2
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__ from "@carefrees/form-utils-react-hooks";
|
|
7
4
|
const FormList = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
8
5
|
const { children, ...rest } = props;
|
|
9
|
-
const { formListInstance, ruleInstance, formItemInstance } = (0,
|
|
10
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
6
|
+
const { formListInstance, ruleInstance, formItemInstance } = (0, __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.useRegisterFormList)(rest);
|
|
7
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.FormListInstanceContext.Provider, {
|
|
11
8
|
value: formListInstance,
|
|
12
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
9
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.FormItemParentNameProvider, {
|
|
13
10
|
name: formListInstance.name,
|
|
14
11
|
sort: formListInstance.sort,
|
|
15
12
|
children: children({
|
|
@@ -27,7 +24,7 @@ const FormList = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((prop
|
|
|
27
24
|
});
|
|
28
25
|
const FormHideList = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
29
26
|
const { name, sort, isJoinParentField } = props;
|
|
30
|
-
const { isHide } = (0,
|
|
27
|
+
const { isHide } = (0, __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.useRegisterFormHideItem)({
|
|
31
28
|
name,
|
|
32
29
|
sort: sort,
|
|
33
30
|
isJoinParentField
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RuleInstanceBase, FormInstanceBase, FormItemInstanceBase } from '@carefrees/form-utils';
|
|
2
|
-
import { RegisterFormItemOptions } from '
|
|
2
|
+
import { RegisterFormItemOptions } from '@carefrees/form-utils-react-hooks';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
export interface FormItemAttrOptions extends RegisterFormItemOptions {
|
|
5
5
|
/**依赖更新项*/
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__ from "@carefrees/form-utils";
|
|
2
|
-
import * as
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE__useHtmlFor_js_30172224__ from "../useHtmlFor.js";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__ from "@carefrees/form-utils-react-hooks";
|
|
4
3
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
5
4
|
const useFormItemAttr = (options)=>{
|
|
6
5
|
const { trigger = 'onChange', dependencies, noticeOnlyRuleDataField, isNoticeParentField, noticeWatchField, preserve, valuePropName = 'value', getValuePath = valuePropName, getValueFromEvent, formatValue, onAfterUpdate, useAttrs, useRules, attrs, children, ...rest } = options;
|
|
7
|
-
const { formItemInstance, form, ruleInstance, newName } = (0,
|
|
6
|
+
const { formItemInstance, form, ruleInstance, newName } = (0, __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.useRegisterFormItem)({
|
|
8
7
|
...rest
|
|
9
8
|
});
|
|
10
9
|
formItemInstance.dependencies = dependencies;
|
|
@@ -33,7 +32,7 @@ const useFormItemAttr = (options)=>{
|
|
|
33
32
|
}
|
|
34
33
|
};
|
|
35
34
|
formItemInstance.onChange = onValueChange;
|
|
36
|
-
const htmlFor = (0,
|
|
35
|
+
const htmlFor = (0, __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.useHtmlFor)(newName);
|
|
37
36
|
formItemInstance.htmlFor = htmlFor;
|
|
38
37
|
const control = {
|
|
39
38
|
[trigger]: onValueChange,
|
package/esm/index.d.ts
CHANGED
|
@@ -6,19 +6,8 @@ export * from './formItem';
|
|
|
6
6
|
export * from './formList';
|
|
7
7
|
export * from './layout';
|
|
8
8
|
export * from './layout/layout.formItem';
|
|
9
|
-
export * from './hooks/useAttrs';
|
|
10
|
-
export * from './hooks/useForm';
|
|
11
|
-
export * from './hooks/useFormItem';
|
|
12
|
-
export * from './hooks/useFormItemParentName';
|
|
13
|
-
export * from './hooks/useFormList';
|
|
14
|
-
export * from './hooks/useHtmlFor';
|
|
15
|
-
export * from './hooks/useMultipleForm';
|
|
16
|
-
export * from './hooks/useWatch';
|
|
17
9
|
export * from './hooks/attr/attr.FormItem';
|
|
18
|
-
export * from '
|
|
19
|
-
export * from './hooks/register/register.FormItem';
|
|
20
|
-
export * from './hooks/register/register.FormList';
|
|
21
|
-
export * from './hooks/register/register.form';
|
|
10
|
+
export * from '@carefrees/form-utils-react-hooks';
|
|
22
11
|
export interface FormProps<T = any> extends FormLayoutProps {
|
|
23
12
|
children?: React.ReactNode;
|
|
24
13
|
form?: FormInstanceBase;
|
package/esm/index.js
CHANGED
|
@@ -2,31 +2,19 @@ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/j
|
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_classnames__ from "classnames";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE__layout_index_js_0ed29524__ from "./layout/index.js";
|
|
5
|
-
import * as
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE__hooks_register_register_form_js_792e1382__ from "./hooks/register/register.form.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__ from "@carefrees/form-utils-react-hooks";
|
|
7
6
|
import * as __WEBPACK_EXTERNAL_MODULE__tarojs_components_865ae511__ from "@tarojs/components";
|
|
8
7
|
import "./styles/index.css";
|
|
9
8
|
export * from "./formItem/index.js";
|
|
10
9
|
export * from "./formList/index.js";
|
|
11
10
|
export * from "./layout/index.js";
|
|
12
11
|
export * from "./layout/layout.formItem.js";
|
|
13
|
-
export * from "./hooks/useAttrs.js";
|
|
14
|
-
export * from "./hooks/useForm.js";
|
|
15
|
-
export * from "./hooks/useFormItem.js";
|
|
16
|
-
export * from "./hooks/useFormItemParentName.js";
|
|
17
|
-
export * from "./hooks/useFormList.js";
|
|
18
|
-
export * from "./hooks/useHtmlFor.js";
|
|
19
|
-
export * from "./hooks/useMultipleForm.js";
|
|
20
|
-
export * from "./hooks/useWatch.js";
|
|
21
12
|
export * from "./hooks/attr/attr.FormItem.js";
|
|
22
|
-
export * from "
|
|
23
|
-
export * from "./hooks/register/register.FormItem.js";
|
|
24
|
-
export * from "./hooks/register/register.FormList.js";
|
|
25
|
-
export * from "./hooks/register/register.form.js";
|
|
13
|
+
export * from "@carefrees/form-utils-react-hooks";
|
|
26
14
|
function Form(props) {
|
|
27
15
|
const { children, form, style, className, formData, hideData, hideRuleData, isAutoUpdatedFormData = false, name, onFinish, onFinishFailed, onValuesChange, layoutStyle, layoutClassName, ...rest } = props;
|
|
28
|
-
const formInstance = (0,
|
|
29
|
-
(0,
|
|
16
|
+
const formInstance = (0, __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.useForm)(form);
|
|
17
|
+
(0, __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.useRegisterForm)(formInstance, name);
|
|
30
18
|
const cls = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>(0, __WEBPACK_EXTERNAL_MODULE_classnames__["default"])('carefrees-form', className), []);
|
|
31
19
|
(0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>formInstance.ctor(formData, hideData, hideRuleData), []);
|
|
32
20
|
formInstance.onFinish = onFinish;
|
|
@@ -43,7 +31,7 @@ function Form(props) {
|
|
|
43
31
|
event?.stopPropagation?.();
|
|
44
32
|
formInstance.submit();
|
|
45
33
|
};
|
|
46
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
34
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.FormInstanceContext.Provider, {
|
|
47
35
|
value: formInstance,
|
|
48
36
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__tarojs_components_865ae511__.Form, {
|
|
49
37
|
className: cls,
|
package/esm/layout/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ViewProps } from '@tarojs/components';
|
|
3
|
-
import { AttrsOptions } from '
|
|
3
|
+
import { AttrsOptions } from '@carefrees/form-utils-react-hooks';
|
|
4
4
|
export interface FormLayoutProps extends AttrsOptions {
|
|
5
5
|
/**标题*/
|
|
6
6
|
title?: React.ReactNode;
|
package/esm/layout/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/j
|
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__tarojs_components_865ae511__ from "@tarojs/components";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_classnames__ from "classnames";
|
|
5
|
-
import * as
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__ from "@carefrees/form-utils-react-hooks";
|
|
6
6
|
const preCls = 'carefrees-form-layout';
|
|
7
7
|
const FormLayout = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
8
|
-
const { colCount: p_colCount = 4, errorLayout: p_errorLayout = 'left-bottom', labelMode: p_labelMode = 'left', showColon: p_showColon = true, formItemClassName: p_formItemClassName, formItemStyle: p_formItemStyle, formItemLabelClassName: p_formItemLabelClassName, formItemLabelStyle: p_formItemLabelStyle } = (0,
|
|
8
|
+
const { colCount: p_colCount = 4, errorLayout: p_errorLayout = 'left-bottom', labelMode: p_labelMode = 'left', showColon: p_showColon = true, formItemClassName: p_formItemClassName, formItemStyle: p_formItemStyle, formItemLabelClassName: p_formItemLabelClassName, formItemLabelStyle: p_formItemLabelStyle } = (0, __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.useAttrs)();
|
|
9
9
|
const { colCount = p_colCount, title, extra, children, isAllColSpan, className, headerClassName, bodyClassName, style, headerStyle, bodyStyle, errorLayout = p_errorLayout, labelMode = p_labelMode, showColon = p_showColon, formItemClassName = p_formItemClassName, formItemStyle = p_formItemStyle, formItemLabelClassName = p_formItemLabelClassName, formItemLabelStyle = p_formItemLabelStyle, bordered = false, gap } = props;
|
|
10
10
|
const propsRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(props);
|
|
11
11
|
propsRef.current = props;
|
|
@@ -52,7 +52,7 @@ const FormLayout = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((pr
|
|
|
52
52
|
colCount,
|
|
53
53
|
gap
|
|
54
54
|
]);
|
|
55
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
55
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.AttrsContext.Provider, {
|
|
56
56
|
value: value,
|
|
57
57
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__tarojs_components_865ae511__.View, {
|
|
58
58
|
style: style,
|
|
@@ -2,10 +2,10 @@ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/j
|
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__tarojs_components_865ae511__ from "@tarojs/components";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_classnames__ from "classnames";
|
|
5
|
-
import * as
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__ from "@carefrees/form-utils-react-hooks";
|
|
6
6
|
const preCls = 'carefrees-form-item';
|
|
7
7
|
const LayoutFormItem = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
8
|
-
const { formItemClassName, formItemLabelClassName, formItemLabelStyle, formItemStyle, labelMode: p_labelMode = 'top', errorLayout: p_errorLayout = 'left-bottom', showColon: p_showColon = true, colCount = 1, inputBordered: p_inputBordered = true } = (0,
|
|
8
|
+
const { formItemClassName, formItemLabelClassName, formItemLabelStyle, formItemStyle, labelMode: p_labelMode = 'top', errorLayout: p_errorLayout = 'left-bottom', showColon: p_showColon = true, colCount = 1, inputBordered: p_inputBordered = true } = (0, __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_react_hooks_1966d15b__.useAttrs)();
|
|
9
9
|
const { children, labelMode = p_labelMode, onlyRuleStyle, label, helpText, extra, showColon = p_showColon, colSpan = 1, rowSpan = 1, validateResult, htmlFor, required, errorLayout = p_errorLayout, style, className, labelClassName, labelStyle, inputBordered = p_inputBordered } = props;
|
|
10
10
|
const tip = validateResult?.tip;
|
|
11
11
|
const isInvalid = !!validateResult?.isInvalid;
|
package/lib/formItem/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { LayoutFormItemProps } from '
|
|
1
|
+
import { LayoutFormItemProps } from '../layout/layout.formItem';
|
|
2
2
|
import { FormItemAttrOptions } from '../hooks/attr/attr.FormItem';
|
|
3
|
-
import React from 'react';
|
|
4
3
|
export interface FormItemProps extends FormItemAttrOptions, LayoutFormItemProps {
|
|
5
4
|
/**不进行样式渲染*/
|
|
6
5
|
noStyle?: boolean;
|
|
7
6
|
}
|
|
8
7
|
/**表单项*/
|
|
9
|
-
export declare const FormItem:
|
|
8
|
+
export declare const FormItem: import("react").MemoExoticComponent<(props: Partial<FormItemProps>) => import("react/jsx-runtime").JSX.Element>;
|
|
10
9
|
/**隐藏表单项*/
|
|
11
|
-
export declare const FormHideItem:
|
|
10
|
+
export declare const FormHideItem: import("react").MemoExoticComponent<(props: FormItemProps) => import("react/jsx-runtime").JSX.Element>;
|
package/lib/formItem/index.js
CHANGED
|
@@ -30,20 +30,19 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
31
|
const layout_formItem_js_namespaceObject = require("../layout/layout.formItem.js");
|
|
32
32
|
const attr_FormItem_js_namespaceObject = require("../hooks/attr/attr.FormItem.js");
|
|
33
|
-
const useFormItemParentName_js_namespaceObject = require("../hooks/useFormItemParentName.js");
|
|
34
|
-
const register_FormHideItem_js_namespaceObject = require("../hooks/register/register.FormHideItem.js");
|
|
35
33
|
const external_react_namespaceObject = require("react");
|
|
34
|
+
const form_utils_react_hooks_namespaceObject = require("@carefrees/form-utils-react-hooks");
|
|
36
35
|
const FormItemInstance = /*#__PURE__*/ (0, external_react_namespaceObject.memo)((props)=>{
|
|
37
36
|
const { labelMode, noStyle, onlyRuleStyle, label, helpText, extra, errorLayout, required, showColon, colSpan, rowSpan, ...rest } = props;
|
|
38
37
|
const { children, ruleInstance, formItemInstance, htmlFor, validateResult } = (0, attr_FormItem_js_namespaceObject.useFormItemAttr)({
|
|
39
38
|
...rest
|
|
40
39
|
});
|
|
41
|
-
if (noStyle) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
40
|
+
if (noStyle) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_utils_react_hooks_namespaceObject.FormItemParentNameProvider, {
|
|
42
41
|
name: formItemInstance.name,
|
|
43
42
|
sort: formItemInstance.sort,
|
|
44
43
|
children: children
|
|
45
44
|
});
|
|
46
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
45
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_utils_react_hooks_namespaceObject.FormItemParentNameProvider, {
|
|
47
46
|
name: formItemInstance.name,
|
|
48
47
|
sort: formItemInstance.sort,
|
|
49
48
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(layout_formItem_js_namespaceObject.LayoutFormItem, {
|
|
@@ -86,7 +85,7 @@ const FormItem = /*#__PURE__*/ (0, external_react_namespaceObject.memo)((props)=
|
|
|
86
85
|
});
|
|
87
86
|
const FormHideItem = /*#__PURE__*/ (0, external_react_namespaceObject.memo)((props)=>{
|
|
88
87
|
const { name, sort, isJoinParentField } = props;
|
|
89
|
-
const { isHide } = (0,
|
|
88
|
+
const { isHide } = (0, form_utils_react_hooks_namespaceObject.useRegisterFormHideItem)({
|
|
90
89
|
name,
|
|
91
90
|
sort: sort,
|
|
92
91
|
isJoinParentField
|
package/lib/formList/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RegisterFormListOptions } from './../hooks/register/register.FormList';
|
|
2
1
|
import { RuleInstanceBase, FormItemInstanceBase, FormListInstanceBase } from '@carefrees/form-utils';
|
|
3
2
|
import React from 'react';
|
|
3
|
+
import { RegisterFormListOptions } from '@carefrees/form-utils-react-hooks';
|
|
4
4
|
export interface FormListChildrenProps {
|
|
5
5
|
/**数据集合*/
|
|
6
6
|
fields: {
|
package/lib/formList/index.js
CHANGED
|
@@ -28,17 +28,14 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
FormList: ()=>FormList
|
|
29
29
|
});
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
-
const register_FormList_js_namespaceObject = require("../hooks/register/register.FormList.js");
|
|
32
|
-
const useFormList_js_namespaceObject = require("../hooks/useFormList.js");
|
|
33
|
-
const useFormItemParentName_js_namespaceObject = require("../hooks/useFormItemParentName.js");
|
|
34
|
-
const register_FormHideItem_js_namespaceObject = require("../hooks/register/register.FormHideItem.js");
|
|
35
31
|
const external_react_namespaceObject = require("react");
|
|
32
|
+
const form_utils_react_hooks_namespaceObject = require("@carefrees/form-utils-react-hooks");
|
|
36
33
|
const FormList = /*#__PURE__*/ (0, external_react_namespaceObject.memo)((props)=>{
|
|
37
34
|
const { children, ...rest } = props;
|
|
38
|
-
const { formListInstance, ruleInstance, formItemInstance } = (0,
|
|
39
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
35
|
+
const { formListInstance, ruleInstance, formItemInstance } = (0, form_utils_react_hooks_namespaceObject.useRegisterFormList)(rest);
|
|
36
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_utils_react_hooks_namespaceObject.FormListInstanceContext.Provider, {
|
|
40
37
|
value: formListInstance,
|
|
41
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
38
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_utils_react_hooks_namespaceObject.FormItemParentNameProvider, {
|
|
42
39
|
name: formListInstance.name,
|
|
43
40
|
sort: formListInstance.sort,
|
|
44
41
|
children: children({
|
|
@@ -56,7 +53,7 @@ const FormList = /*#__PURE__*/ (0, external_react_namespaceObject.memo)((props)=
|
|
|
56
53
|
});
|
|
57
54
|
const FormHideList = /*#__PURE__*/ (0, external_react_namespaceObject.memo)((props)=>{
|
|
58
55
|
const { name, sort, isJoinParentField } = props;
|
|
59
|
-
const { isHide } = (0,
|
|
56
|
+
const { isHide } = (0, form_utils_react_hooks_namespaceObject.useRegisterFormHideItem)({
|
|
60
57
|
name,
|
|
61
58
|
sort: sort,
|
|
62
59
|
isJoinParentField
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RuleInstanceBase, FormInstanceBase, FormItemInstanceBase } from '@carefrees/form-utils';
|
|
2
|
-
import { RegisterFormItemOptions } from '
|
|
2
|
+
import { RegisterFormItemOptions } from '@carefrees/form-utils-react-hooks';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
export interface FormItemAttrOptions extends RegisterFormItemOptions {
|
|
5
5
|
/**依赖更新项*/
|
|
@@ -27,12 +27,11 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
useFormItemAttr: ()=>useFormItemAttr
|
|
28
28
|
});
|
|
29
29
|
const form_utils_namespaceObject = require("@carefrees/form-utils");
|
|
30
|
-
const
|
|
31
|
-
const external_useHtmlFor_js_namespaceObject = require("../useHtmlFor.js");
|
|
30
|
+
const form_utils_react_hooks_namespaceObject = require("@carefrees/form-utils-react-hooks");
|
|
32
31
|
const external_react_namespaceObject = require("react");
|
|
33
32
|
const useFormItemAttr = (options)=>{
|
|
34
33
|
const { trigger = 'onChange', dependencies, noticeOnlyRuleDataField, isNoticeParentField, noticeWatchField, preserve, valuePropName = 'value', getValuePath = valuePropName, getValueFromEvent, formatValue, onAfterUpdate, useAttrs, useRules, attrs, children, ...rest } = options;
|
|
35
|
-
const { formItemInstance, form, ruleInstance, newName } = (0,
|
|
34
|
+
const { formItemInstance, form, ruleInstance, newName } = (0, form_utils_react_hooks_namespaceObject.useRegisterFormItem)({
|
|
36
35
|
...rest
|
|
37
36
|
});
|
|
38
37
|
formItemInstance.dependencies = dependencies;
|
|
@@ -61,7 +60,7 @@ const useFormItemAttr = (options)=>{
|
|
|
61
60
|
}
|
|
62
61
|
};
|
|
63
62
|
formItemInstance.onChange = onValueChange;
|
|
64
|
-
const htmlFor = (0,
|
|
63
|
+
const htmlFor = (0, form_utils_react_hooks_namespaceObject.useHtmlFor)(newName);
|
|
65
64
|
formItemInstance.htmlFor = htmlFor;
|
|
66
65
|
const control = {
|
|
67
66
|
[trigger]: onValueChange,
|
package/lib/index.d.ts
CHANGED
|
@@ -6,19 +6,8 @@ export * from './formItem';
|
|
|
6
6
|
export * from './formList';
|
|
7
7
|
export * from './layout';
|
|
8
8
|
export * from './layout/layout.formItem';
|
|
9
|
-
export * from './hooks/useAttrs';
|
|
10
|
-
export * from './hooks/useForm';
|
|
11
|
-
export * from './hooks/useFormItem';
|
|
12
|
-
export * from './hooks/useFormItemParentName';
|
|
13
|
-
export * from './hooks/useFormList';
|
|
14
|
-
export * from './hooks/useHtmlFor';
|
|
15
|
-
export * from './hooks/useMultipleForm';
|
|
16
|
-
export * from './hooks/useWatch';
|
|
17
9
|
export * from './hooks/attr/attr.FormItem';
|
|
18
|
-
export * from '
|
|
19
|
-
export * from './hooks/register/register.FormItem';
|
|
20
|
-
export * from './hooks/register/register.FormList';
|
|
21
|
-
export * from './hooks/register/register.form';
|
|
10
|
+
export * from '@carefrees/form-utils-react-hooks';
|
|
22
11
|
export interface FormProps<T = any> extends FormLayoutProps {
|
|
23
12
|
children?: React.ReactNode;
|
|
24
13
|
form?: FormInstanceBase;
|