@fairys/taro-tools-simple-form-ui 0.0.12 → 1.0.1
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/form/form.d.ts +7 -23
- package/esm/form/form.js +6 -27
- package/esm/form/item.config.d.ts +2 -5
- package/esm/form/item.config.js +1 -1
- package/esm/styles/index.css +0 -2
- package/package.json +2 -4
- package/src/form/form.tsx +6 -41
- package/src/form/item.config.tsx +3 -5
- package/src/styles/index.css +0 -2
- package/esm/form/form.item.d.ts +0 -18
- package/esm/form/form.item.js +0 -81
- package/esm/form/layout.d.ts +0 -4
- package/esm/form/layout.js +0 -37
- package/esm/interface.d.ts +0 -4
- package/esm/interface.js +0 -0
- package/src/form/form.item.tsx +0 -105
- package/src/form/layout.tsx +0 -39
- package/src/interface.ts +0 -4
package/esm/form/form.d.ts
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import type { FairysValtioFormAttrsProps } from '@fairys/valtio-form-basic';
|
|
5
|
-
export * from '@fairys/valtio-form-basic';
|
|
6
|
-
export * from './form.item';
|
|
7
|
-
export * from './layout';
|
|
1
|
+
import { FairysTaroValtioForm as FairysTaroValtioFormBase } from '@fairys/taro-valtio-form-basic';
|
|
2
|
+
import { FairysTaroValtioFormConfigListItem, FairysTaroValtioFormConfigItem } from './item.config';
|
|
3
|
+
export * from '@fairys/taro-valtio-form-basic';
|
|
8
4
|
export * from './item.config';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var useForm: typeof useFairysValtioFormInstance;
|
|
14
|
-
var useFormState: typeof useFairysValtioFormInstanceContextState;
|
|
15
|
-
var useFormHideState: typeof useFairysValtioFormInstanceContextHideState;
|
|
16
|
-
var useFormInstance: typeof useFairysValtioFormInstanceContext;
|
|
17
|
-
var FormItemListItem: (props: {
|
|
18
|
-
items: import("./item.config").FairysTaroValtioInputConfigType[];
|
|
19
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
var FormItemConfig: (config: import("./item.config").FairysTaroValtioInputConfigType) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
var FormItemBase: typeof FairysTaroValtioFormItemBase;
|
|
22
|
-
var FormItem: typeof FairysTaroValtioFormItem;
|
|
23
|
-
var FormHideItem: typeof FairysTaroValtioFormHideItem;
|
|
24
|
-
}
|
|
5
|
+
export declare const FairysTaroValtioForm: typeof FairysTaroValtioFormBase & {
|
|
6
|
+
FormItemListItem: typeof FairysTaroValtioFormConfigListItem;
|
|
7
|
+
FormItemConfig: typeof FairysTaroValtioFormConfigItem;
|
|
8
|
+
};
|
package/esm/form/form.js
CHANGED
|
@@ -1,29 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FairysTaroValtioFormLayout } from "./layout.js";
|
|
3
|
-
import { FairysTaroValtioFormHideItem, FairysTaroValtioFormItem, FairysTaroValtioFormItemBase } from "./form.item.js";
|
|
1
|
+
import { FairysTaroValtioForm } from "@fairys/taro-valtio-form-basic";
|
|
4
2
|
import { FairysTaroValtioFormConfigItem, FairysTaroValtioFormConfigListItem } from "./item.config.js";
|
|
5
|
-
|
|
6
|
-
export * from "@fairys/valtio-form-basic";
|
|
7
|
-
export * from "./form.item.js";
|
|
8
|
-
export * from "./layout.js";
|
|
3
|
+
export * from "@fairys/taro-valtio-form-basic";
|
|
9
4
|
export * from "./item.config.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
children: /*#__PURE__*/ jsx(FairysTaroValtioFormLayout, {
|
|
15
|
-
...rest,
|
|
16
|
-
children: children
|
|
17
|
-
})
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
FairysTaroValtioForm.useForm = useFairysValtioFormInstance;
|
|
21
|
-
FairysTaroValtioForm.useFormState = useFairysValtioFormInstanceContextState;
|
|
22
|
-
FairysTaroValtioForm.useFormHideState = useFairysValtioFormInstanceContextHideState;
|
|
23
|
-
FairysTaroValtioForm.useFormInstance = useFairysValtioFormInstanceContext;
|
|
24
|
-
FairysTaroValtioForm.FormItemListItem = FairysTaroValtioFormConfigListItem;
|
|
25
|
-
FairysTaroValtioForm.FormItemConfig = FairysTaroValtioFormConfigItem;
|
|
26
|
-
FairysTaroValtioForm.FormItemBase = FairysTaroValtioFormItemBase;
|
|
27
|
-
FairysTaroValtioForm.FormItem = FairysTaroValtioFormItem;
|
|
28
|
-
FairysTaroValtioForm.FormHideItem = FairysTaroValtioFormHideItem;
|
|
29
|
-
export { FairysTaroValtioForm };
|
|
5
|
+
const form_FairysTaroValtioForm = FairysTaroValtioForm;
|
|
6
|
+
form_FairysTaroValtioForm.FormItemListItem = FairysTaroValtioFormConfigListItem;
|
|
7
|
+
form_FairysTaroValtioForm.FormItemConfig = FairysTaroValtioFormConfigItem;
|
|
8
|
+
export { form_FairysTaroValtioForm as FairysTaroValtioForm };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FairysTaroValtioFormItemProps } from '
|
|
1
|
+
import type { FairysTaroValtioFormItemProps } from '@fairys/taro-valtio-form-basic';
|
|
2
2
|
import { FairysTaroRadioGroupProps } from '../components/radio.group';
|
|
3
3
|
import { FairysTaroCalendarProps } from '../components/calendar';
|
|
4
4
|
import { FairysTaroCascaderProps } from '../components/cascader';
|
|
@@ -7,10 +7,7 @@ import { FairysTaroDatePickerProps } from '../components/date.picker';
|
|
|
7
7
|
import { FairysTaroPickerProps } from '../components/picker';
|
|
8
8
|
import { FairysTaroPopupSearchProps } from '../components/popup.search';
|
|
9
9
|
import { TaroInputProps, TaroInputNumberProps, RadioGroupProps, RadioProps, RangeProps, RateProps, SignatureProps, SwitchProps, TextAreaProps, UploaderProps } from '@nutui/nutui-react-taro';
|
|
10
|
-
|
|
11
|
-
[K in keyof T]: T[K];
|
|
12
|
-
};
|
|
13
|
-
export type MakeFieldRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
10
|
+
import type { MObject } from '@fairys/taro-valtio-form-basic';
|
|
14
11
|
/**
|
|
15
12
|
* 表单项配置基础类型
|
|
16
13
|
*/
|
package/esm/form/item.config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { View } from "@tarojs/components";
|
|
3
3
|
import { Fragment } from "react";
|
|
4
|
-
import { FairysTaroValtioFormHideItem, FairysTaroValtioFormItemBase, FairysTaroValtioFormItemNoStyle } from "
|
|
4
|
+
import { FairysTaroValtioFormHideItem, FairysTaroValtioFormItemBase, FairysTaroValtioFormItemNoStyle } from "@fairys/taro-valtio-form-basic";
|
|
5
5
|
import { FairysTaroRadioGroupBase } from "../components/radio.group/index.js";
|
|
6
6
|
import { FairysTaroCalendarBase } from "../components/calendar/index.js";
|
|
7
7
|
import { FairysTaroCascaderBase } from "../components/cascader/index.js";
|
package/esm/styles/index.css
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "SunLxy <1011771396@qq.com>",
|
|
4
4
|
"description": "框架组件库",
|
|
5
5
|
"homepage": "https://github.com/autumn-fairy-tales/fairys-taro-react",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "1.0.1",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"types": "esm/index.d.ts",
|
|
9
9
|
"module": "esm/index.js",
|
|
@@ -25,11 +25,9 @@
|
|
|
25
25
|
"esm"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@fairys/valtio-form-basic": "^0.0.
|
|
28
|
+
"@fairys/taro-valtio-form-basic": "^0.0.13",
|
|
29
29
|
"@nutui/nutui-react-taro": "^3.0.18",
|
|
30
|
-
"async-validator": "~4.2.5",
|
|
31
30
|
"clsx": "2.1.1",
|
|
32
|
-
"fast-copy": "~4.0.2",
|
|
33
31
|
"valtio": "~2.1.5"
|
|
34
32
|
},
|
|
35
33
|
"devDependencies": {
|
package/src/form/form.tsx
CHANGED
|
@@ -1,45 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FairysTaroValtioFormLayout } from './layout';
|
|
3
|
-
import { FairysTaroValtioFormItem, FairysTaroValtioFormHideItem, FairysTaroValtioFormItemBase } from './form.item';
|
|
1
|
+
import { FairysTaroValtioForm as FairysTaroValtioFormBase } from '@fairys/taro-valtio-form-basic';
|
|
4
2
|
import { FairysTaroValtioFormConfigListItem, FairysTaroValtioFormConfigItem } from './item.config';
|
|
5
|
-
|
|
6
|
-
useFairysValtioForm,
|
|
7
|
-
FairysValtioFormInstanceContext,
|
|
8
|
-
useFairysValtioFormInstance,
|
|
9
|
-
useFairysValtioFormInstanceContext,
|
|
10
|
-
useFairysValtioFormInstanceContextState,
|
|
11
|
-
useFairysValtioFormInstanceContextHideState,
|
|
12
|
-
} from '@fairys/valtio-form-basic';
|
|
13
|
-
import type { FairysValtioFormAttrsProps } from '@fairys/valtio-form-basic';
|
|
14
|
-
export * from '@fairys/valtio-form-basic';
|
|
15
|
-
export * from './form.item';
|
|
16
|
-
export * from './layout';
|
|
3
|
+
export * from '@fairys/taro-valtio-form-basic';
|
|
17
4
|
export * from './item.config';
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<FairysValtioFormInstanceContext.Provider value={formInstance}>
|
|
24
|
-
<FairysTaroValtioFormLayout {...rest}>{children}</FairysTaroValtioFormLayout>
|
|
25
|
-
</FairysValtioFormInstanceContext.Provider>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
/**初始化实例*/
|
|
29
|
-
FairysTaroValtioForm.useForm = useFairysValtioFormInstance;
|
|
30
|
-
/**获取状态*/
|
|
31
|
-
FairysTaroValtioForm.useFormState = useFairysValtioFormInstanceContextState;
|
|
32
|
-
/**获取隐藏状态*/
|
|
33
|
-
FairysTaroValtioForm.useFormHideState = useFairysValtioFormInstanceContextHideState;
|
|
34
|
-
/**获取上下文实例*/
|
|
35
|
-
FairysTaroValtioForm.useFormInstance = useFairysValtioFormInstanceContext;
|
|
36
|
-
/**多个配置项*/
|
|
5
|
+
export const FairysTaroValtioForm = FairysTaroValtioFormBase as typeof FairysTaroValtioFormBase & {
|
|
6
|
+
FormItemListItem: typeof FairysTaroValtioFormConfigListItem;
|
|
7
|
+
FormItemConfig: typeof FairysTaroValtioFormConfigItem;
|
|
8
|
+
};
|
|
37
9
|
FairysTaroValtioForm.FormItemListItem = FairysTaroValtioFormConfigListItem;
|
|
38
|
-
/**单个配置项*/
|
|
39
10
|
FairysTaroValtioForm.FormItemConfig = FairysTaroValtioFormConfigItem;
|
|
40
|
-
/**表单项基础组件*/
|
|
41
|
-
FairysTaroValtioForm.FormItemBase = FairysTaroValtioFormItemBase;
|
|
42
|
-
/**表单项*/
|
|
43
|
-
FairysTaroValtioForm.FormItem = FairysTaroValtioFormItem;
|
|
44
|
-
/**隐藏表单想*/
|
|
45
|
-
FairysTaroValtioForm.FormHideItem = FairysTaroValtioFormHideItem;
|
package/src/form/item.config.tsx
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
FairysTaroValtioFormItemBase,
|
|
9
9
|
FairysTaroValtioFormHideItem,
|
|
10
10
|
FairysTaroValtioFormItemNoStyle,
|
|
11
|
-
} from '
|
|
12
|
-
import type { FairysTaroValtioFormItemProps } from '
|
|
11
|
+
} from '@fairys/taro-valtio-form-basic';
|
|
12
|
+
import type { FairysTaroValtioFormItemProps } from '@fairys/taro-valtio-form-basic';
|
|
13
13
|
import { FairysTaroRadioGroupBase, FairysTaroRadioGroupProps } from 'components/radio.group';
|
|
14
14
|
import { FairysTaroCalendarBase, FairysTaroCalendarProps } from 'components/calendar';
|
|
15
15
|
import { FairysTaroCascaderBase, FairysTaroCascaderProps } from 'components/cascader';
|
|
@@ -39,9 +39,7 @@ import {
|
|
|
39
39
|
Uploader,
|
|
40
40
|
UploaderProps,
|
|
41
41
|
} from '@nutui/nutui-react-taro';
|
|
42
|
-
|
|
43
|
-
export type MObject<T> = { [K in keyof T]: T[K] };
|
|
44
|
-
export type MakeFieldRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
42
|
+
import type { MObject } from '@fairys/taro-valtio-form-basic';
|
|
45
43
|
|
|
46
44
|
/**
|
|
47
45
|
* 表单项配置基础类型
|
package/src/styles/index.css
CHANGED
package/esm/form/form.item.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**表单项*/
|
|
2
|
-
import { MObject } from '../interface';
|
|
3
|
-
import type { ViewProps } from '@tarojs/components';
|
|
4
|
-
import type { FairysValtioFormItemAttrsProps } from '@fairys/valtio-form-basic';
|
|
5
|
-
export interface FairysTaroValtioFormItemProps<T extends MObject<T> = object> extends Omit<ViewProps, 'style'>, FairysValtioFormItemAttrsProps {
|
|
6
|
-
/**是否使用控制隐藏的表单项*/
|
|
7
|
-
isHide?: boolean;
|
|
8
|
-
/**是否使用无样式表单项*/
|
|
9
|
-
noStyle?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**普通表单项*/
|
|
12
|
-
export declare function FairysTaroValtioFormItemBase<T extends MObject<T> = object>(props: Omit<FairysTaroValtioFormItemProps<T>, 'isHide' | 'noStyle'>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
/**控制隐藏的表单项*/
|
|
14
|
-
export declare function FairysTaroValtioFormHideItem<T extends MObject<T> = object>(props: Omit<FairysTaroValtioFormItemProps<T>, 'isHide' | 'noStyle'>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
/**无样式表单项*/
|
|
16
|
-
export declare function FairysTaroValtioFormItemNoStyle<T extends MObject<T> = object>(props: Omit<FairysTaroValtioFormItemProps<T>, 'isHide' | 'noStyle'>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
/**表单项基础组件(根据isHide和noStyle判断是否使用控制隐藏的表单项和无样式表单项)*/
|
|
18
|
-
export declare function FairysTaroValtioFormItem<T extends MObject<T> = object>(props: FairysTaroValtioFormItemProps<T>): import("react/jsx-runtime").JSX.Element;
|
package/esm/form/form.item.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { View } from "@tarojs/components";
|
|
3
|
-
import { Fragment } from "react";
|
|
4
|
-
import { FairysValtioFormParentAttrsContext, useFairysValtioFormInstanceContextHideState, useFairysValtioFormItemAttrs, useFairysValtioFormItemNoStyleAttrs } from "@fairys/valtio-form-basic";
|
|
5
|
-
function FairysTaroValtioFormItemBase(props) {
|
|
6
|
-
const { label, extra, helpText } = props;
|
|
7
|
-
const { itemClassName, itemStyle, containerClassName, itemLabelClassName, itemLabelStyle, itemBodyClassName, itemBodyStyle, itemInputClassName, itemExtraClassName, errorClassName, helpClassName, isInvalid, itemBorderType, children, error, formAttrsNameInstance } = useFairysValtioFormItemAttrs(props);
|
|
8
|
-
return /*#__PURE__*/ jsxs(View, {
|
|
9
|
-
className: itemClassName,
|
|
10
|
-
style: itemStyle,
|
|
11
|
-
children: [
|
|
12
|
-
/*#__PURE__*/ jsxs(View, {
|
|
13
|
-
className: containerClassName,
|
|
14
|
-
children: [
|
|
15
|
-
label ? /*#__PURE__*/ jsx(View, {
|
|
16
|
-
className: itemLabelClassName,
|
|
17
|
-
style: itemLabelStyle,
|
|
18
|
-
children: label
|
|
19
|
-
}) : /*#__PURE__*/ jsx(Fragment, {}),
|
|
20
|
-
/*#__PURE__*/ jsxs(View, {
|
|
21
|
-
className: itemBodyClassName,
|
|
22
|
-
style: itemBodyStyle,
|
|
23
|
-
children: [
|
|
24
|
-
/*#__PURE__*/ jsx(FairysValtioFormParentAttrsContext.Provider, {
|
|
25
|
-
value: formAttrsNameInstance,
|
|
26
|
-
children: /*#__PURE__*/ jsx(View, {
|
|
27
|
-
className: itemInputClassName,
|
|
28
|
-
children: children
|
|
29
|
-
})
|
|
30
|
-
}),
|
|
31
|
-
extra ? /*#__PURE__*/ jsx(View, {
|
|
32
|
-
className: itemExtraClassName,
|
|
33
|
-
children: extra
|
|
34
|
-
}) : /*#__PURE__*/ jsx(Fragment, {}),
|
|
35
|
-
'body' === itemBorderType && isInvalid ? /*#__PURE__*/ jsx(View, {
|
|
36
|
-
className: errorClassName,
|
|
37
|
-
children: error
|
|
38
|
-
}) : /*#__PURE__*/ jsx(Fragment, {})
|
|
39
|
-
]
|
|
40
|
-
})
|
|
41
|
-
]
|
|
42
|
-
}),
|
|
43
|
-
helpText ? /*#__PURE__*/ jsx(View, {
|
|
44
|
-
className: helpClassName,
|
|
45
|
-
children: helpText
|
|
46
|
-
}) : /*#__PURE__*/ jsx(Fragment, {}),
|
|
47
|
-
isInvalid && 'body' !== itemBorderType ? /*#__PURE__*/ jsx(View, {
|
|
48
|
-
className: errorClassName,
|
|
49
|
-
children: error
|
|
50
|
-
}) : /*#__PURE__*/ jsx(Fragment, {})
|
|
51
|
-
]
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function FairysTaroValtioFormHideItem(props) {
|
|
55
|
-
const [state] = useFairysValtioFormInstanceContextHideState();
|
|
56
|
-
const isHide = state[props.name];
|
|
57
|
-
if (isHide) return /*#__PURE__*/ jsx(Fragment, {});
|
|
58
|
-
return /*#__PURE__*/ jsx(FairysTaroValtioFormItemBase, {
|
|
59
|
-
...props
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function FairysTaroValtioFormItemNoStyle(props) {
|
|
63
|
-
const { children, formAttrsNameInstance } = useFairysValtioFormItemNoStyleAttrs(props);
|
|
64
|
-
return /*#__PURE__*/ jsx(FairysValtioFormParentAttrsContext.Provider, {
|
|
65
|
-
value: formAttrsNameInstance,
|
|
66
|
-
children: children
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
function FairysTaroValtioFormItem(props) {
|
|
70
|
-
const { isHide, noStyle, ...rest } = props;
|
|
71
|
-
if (isHide) return /*#__PURE__*/ jsx(FairysTaroValtioFormHideItem, {
|
|
72
|
-
...rest
|
|
73
|
-
});
|
|
74
|
-
if (noStyle) return /*#__PURE__*/ jsx(FairysTaroValtioFormItemNoStyle, {
|
|
75
|
-
...rest
|
|
76
|
-
});
|
|
77
|
-
return /*#__PURE__*/ jsx(FairysTaroValtioFormItemBase, {
|
|
78
|
-
...rest
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
export { FairysTaroValtioFormHideItem, FairysTaroValtioFormItem, FairysTaroValtioFormItemBase, FairysTaroValtioFormItemNoStyle };
|
package/esm/form/layout.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { FairysValtioFormLayoutAttrsProps } from '@fairys/valtio-form-basic';
|
|
2
|
-
export interface FairysTaroValtioFormLayoutProps extends FairysValtioFormLayoutAttrsProps {
|
|
3
|
-
}
|
|
4
|
-
export declare function FairysTaroValtioFormLayout(props: FairysTaroValtioFormLayoutProps): import("react/jsx-runtime").JSX.Element;
|
package/esm/form/layout.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment } from "react";
|
|
3
|
-
import { View } from "@tarojs/components";
|
|
4
|
-
import { FairysValtioFormLayoutContext, useFairysValtioFormLayoutAttrs } from "@fairys/valtio-form-basic";
|
|
5
|
-
function FairysTaroValtioFormLayout(props) {
|
|
6
|
-
const { children, title, extra } = props;
|
|
7
|
-
const { formLayoutInstance, layoutName, layoutStyle, headerName, headerStyle, headerTitleName, headerExtraName, bodyName, bodyStyle } = useFairysValtioFormLayoutAttrs(props);
|
|
8
|
-
return /*#__PURE__*/ jsx(FairysValtioFormLayoutContext.Provider, {
|
|
9
|
-
value: formLayoutInstance,
|
|
10
|
-
children: /*#__PURE__*/ jsxs(View, {
|
|
11
|
-
className: layoutName,
|
|
12
|
-
style: layoutStyle,
|
|
13
|
-
children: [
|
|
14
|
-
title || extra ? /*#__PURE__*/ jsxs(View, {
|
|
15
|
-
style: headerStyle,
|
|
16
|
-
className: headerName,
|
|
17
|
-
children: [
|
|
18
|
-
/*#__PURE__*/ jsx(View, {
|
|
19
|
-
className: headerTitleName,
|
|
20
|
-
children: title
|
|
21
|
-
}),
|
|
22
|
-
/*#__PURE__*/ jsx(View, {
|
|
23
|
-
className: headerExtraName,
|
|
24
|
-
children: extra
|
|
25
|
-
})
|
|
26
|
-
]
|
|
27
|
-
}) : /*#__PURE__*/ jsx(Fragment, {}),
|
|
28
|
-
/*#__PURE__*/ jsx(View, {
|
|
29
|
-
className: bodyName,
|
|
30
|
-
style: bodyStyle,
|
|
31
|
-
children: children
|
|
32
|
-
})
|
|
33
|
-
]
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
export { FairysTaroValtioFormLayout };
|
package/esm/interface.d.ts
DELETED
package/esm/interface.js
DELETED
|
File without changes
|
package/src/form/form.item.tsx
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**表单项*/
|
|
2
|
-
|
|
3
|
-
import { MObject } from 'interface';
|
|
4
|
-
import { View } from '@tarojs/components';
|
|
5
|
-
import type { ViewProps } from '@tarojs/components';
|
|
6
|
-
import { Fragment } from 'react';
|
|
7
|
-
import type { FairysValtioFormItemAttrsProps } from '@fairys/valtio-form-basic';
|
|
8
|
-
import {
|
|
9
|
-
useFairysValtioFormItemAttrs,
|
|
10
|
-
useFairysValtioFormInstanceContextHideState,
|
|
11
|
-
useFairysValtioFormItemNoStyleAttrs,
|
|
12
|
-
FairysValtioFormParentAttrsContext,
|
|
13
|
-
} from '@fairys/valtio-form-basic';
|
|
14
|
-
|
|
15
|
-
export interface FairysTaroValtioFormItemProps<T extends MObject<T> = object>
|
|
16
|
-
extends Omit<ViewProps, 'style'>,
|
|
17
|
-
FairysValtioFormItemAttrsProps {
|
|
18
|
-
/**是否使用控制隐藏的表单项*/
|
|
19
|
-
isHide?: boolean;
|
|
20
|
-
/**是否使用无样式表单项*/
|
|
21
|
-
noStyle?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**普通表单项*/
|
|
25
|
-
export function FairysTaroValtioFormItemBase<T extends MObject<T> = object>(
|
|
26
|
-
props: Omit<FairysTaroValtioFormItemProps<T>, 'isHide' | 'noStyle'>,
|
|
27
|
-
) {
|
|
28
|
-
const { label, extra, helpText } = props;
|
|
29
|
-
const {
|
|
30
|
-
itemClassName,
|
|
31
|
-
itemStyle,
|
|
32
|
-
containerClassName,
|
|
33
|
-
itemLabelClassName,
|
|
34
|
-
itemLabelStyle,
|
|
35
|
-
itemBodyClassName,
|
|
36
|
-
itemBodyStyle,
|
|
37
|
-
itemInputClassName,
|
|
38
|
-
itemExtraClassName,
|
|
39
|
-
errorClassName,
|
|
40
|
-
helpClassName,
|
|
41
|
-
isInvalid,
|
|
42
|
-
itemBorderType,
|
|
43
|
-
children,
|
|
44
|
-
error,
|
|
45
|
-
formAttrsNameInstance,
|
|
46
|
-
} = useFairysValtioFormItemAttrs(props);
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<View className={itemClassName} style={itemStyle}>
|
|
50
|
-
<View className={containerClassName}>
|
|
51
|
-
{label ? (
|
|
52
|
-
<View className={itemLabelClassName} style={itemLabelStyle}>
|
|
53
|
-
{label}
|
|
54
|
-
</View>
|
|
55
|
-
) : (
|
|
56
|
-
<Fragment />
|
|
57
|
-
)}
|
|
58
|
-
<View className={itemBodyClassName} style={itemBodyStyle}>
|
|
59
|
-
<FairysValtioFormParentAttrsContext.Provider value={formAttrsNameInstance}>
|
|
60
|
-
<View className={itemInputClassName}>{children}</View>
|
|
61
|
-
</FairysValtioFormParentAttrsContext.Provider>
|
|
62
|
-
{extra ? <View className={itemExtraClassName}>{extra}</View> : <Fragment />}
|
|
63
|
-
{itemBorderType === 'body' && isInvalid ? <View className={errorClassName}>{error}</View> : <Fragment />}
|
|
64
|
-
</View>
|
|
65
|
-
</View>
|
|
66
|
-
{helpText ? <View className={helpClassName}>{helpText}</View> : <Fragment />}
|
|
67
|
-
{isInvalid && itemBorderType !== 'body' ? <View className={errorClassName}>{error}</View> : <Fragment />}
|
|
68
|
-
</View>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
/**控制隐藏的表单项*/
|
|
72
|
-
export function FairysTaroValtioFormHideItem<T extends MObject<T> = object>(
|
|
73
|
-
props: Omit<FairysTaroValtioFormItemProps<T>, 'isHide' | 'noStyle'>,
|
|
74
|
-
) {
|
|
75
|
-
const [state] = useFairysValtioFormInstanceContextHideState();
|
|
76
|
-
const isHide = state[props.name];
|
|
77
|
-
if (isHide) {
|
|
78
|
-
return <Fragment />;
|
|
79
|
-
}
|
|
80
|
-
return <FairysTaroValtioFormItemBase<T> {...props} />;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**无样式表单项*/
|
|
84
|
-
export function FairysTaroValtioFormItemNoStyle<T extends MObject<T> = object>(
|
|
85
|
-
props: Omit<FairysTaroValtioFormItemProps<T>, 'isHide' | 'noStyle'>,
|
|
86
|
-
) {
|
|
87
|
-
const { children, formAttrsNameInstance } = useFairysValtioFormItemNoStyleAttrs(props);
|
|
88
|
-
return (
|
|
89
|
-
<FairysValtioFormParentAttrsContext.Provider value={formAttrsNameInstance}>
|
|
90
|
-
{children}
|
|
91
|
-
</FairysValtioFormParentAttrsContext.Provider>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**表单项基础组件(根据isHide和noStyle判断是否使用控制隐藏的表单项和无样式表单项)*/
|
|
96
|
-
export function FairysTaroValtioFormItem<T extends MObject<T> = object>(props: FairysTaroValtioFormItemProps<T>) {
|
|
97
|
-
const { isHide, noStyle, ...rest } = props;
|
|
98
|
-
if (isHide) {
|
|
99
|
-
return <FairysTaroValtioFormHideItem<T> {...rest} />;
|
|
100
|
-
}
|
|
101
|
-
if (noStyle) {
|
|
102
|
-
return <FairysTaroValtioFormItemNoStyle<T> {...rest} />;
|
|
103
|
-
}
|
|
104
|
-
return <FairysTaroValtioFormItemBase<T> {...rest} />;
|
|
105
|
-
}
|
package/src/form/layout.tsx
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Fragment } from 'react';
|
|
2
|
-
import { View } from '@tarojs/components';
|
|
3
|
-
import type { FairysValtioFormLayoutAttrsProps } from '@fairys/valtio-form-basic';
|
|
4
|
-
import { FairysValtioFormLayoutContext, useFairysValtioFormLayoutAttrs } from '@fairys/valtio-form-basic';
|
|
5
|
-
export interface FairysTaroValtioFormLayoutProps extends FairysValtioFormLayoutAttrsProps {}
|
|
6
|
-
|
|
7
|
-
export function FairysTaroValtioFormLayout(props: FairysTaroValtioFormLayoutProps) {
|
|
8
|
-
const { children, title, extra } = props;
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
formLayoutInstance,
|
|
12
|
-
layoutName,
|
|
13
|
-
layoutStyle,
|
|
14
|
-
headerName,
|
|
15
|
-
headerStyle,
|
|
16
|
-
headerTitleName,
|
|
17
|
-
headerExtraName,
|
|
18
|
-
bodyName,
|
|
19
|
-
bodyStyle,
|
|
20
|
-
} = useFairysValtioFormLayoutAttrs(props);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<FairysValtioFormLayoutContext.Provider value={formLayoutInstance}>
|
|
24
|
-
<View className={layoutName} style={layoutStyle}>
|
|
25
|
-
{title || extra ? (
|
|
26
|
-
<View style={headerStyle} className={headerName}>
|
|
27
|
-
<View className={headerTitleName}>{title}</View>
|
|
28
|
-
<View className={headerExtraName}>{extra}</View>
|
|
29
|
-
</View>
|
|
30
|
-
) : (
|
|
31
|
-
<Fragment />
|
|
32
|
-
)}
|
|
33
|
-
<View className={bodyName} style={bodyStyle}>
|
|
34
|
-
{children}
|
|
35
|
-
</View>
|
|
36
|
-
</View>
|
|
37
|
-
</FairysValtioFormLayoutContext.Provider>
|
|
38
|
-
);
|
|
39
|
-
}
|
package/src/interface.ts
DELETED