@fairys/valtio-form-basic 0.0.8 → 0.0.10
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 +9 -4
- package/esm/form/form.item.d.ts +88 -21
- package/esm/form/form.item.js +124 -32
- package/esm/form/hooks/index.d.ts +34 -0
- package/esm/form/hooks/index.js +57 -0
- package/esm/form/instance/index.d.ts +21 -4
- package/esm/form/instance/index.js +52 -23
- package/esm/form/layout.d.ts +17 -5
- package/esm/form/layout.js +26 -14
- package/esm/form/utils/index.d.ts +24 -0
- package/esm/form/utils/index.js +60 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/styles/index.css +36 -10
- package/lib/index.js +21 -12
- package/package.json +2 -2
- package/src/form/form.item.tsx +236 -52
- package/src/form/form.tsx +3 -18
- package/src/form/hooks/index.tsx +78 -0
- package/src/form/instance/index.ts +69 -33
- package/src/form/layout.tsx +47 -17
- package/src/form/utils/index.ts +108 -0
- package/src/index.tsx +1 -0
- package/src/styles/index.css +18 -4
|
@@ -2,6 +2,7 @@ import { createContext, useContext, useRef } from "react";
|
|
|
2
2
|
import { proxy, ref as external_valtio_ref, snapshot, useSnapshot } from "valtio";
|
|
3
3
|
import async_validator from "async-validator";
|
|
4
4
|
import { copy } from "fast-copy";
|
|
5
|
+
import { formatePath, get, set } from "../utils/index.js";
|
|
5
6
|
class FairysValtioFormInstance {
|
|
6
7
|
state = proxy({});
|
|
7
8
|
errorState = proxy({});
|
|
@@ -21,6 +22,12 @@ class FairysValtioFormInstance {
|
|
|
21
22
|
}
|
|
22
23
|
if (isValidate) this.validate(keys, false);
|
|
23
24
|
};
|
|
25
|
+
updatedValueByPaths = (path, value)=>{
|
|
26
|
+
set(this.state, formatePath(path), value);
|
|
27
|
+
this.validate([
|
|
28
|
+
path
|
|
29
|
+
], false);
|
|
30
|
+
};
|
|
24
31
|
updatedHideInfo = (objectHideInfo)=>{
|
|
25
32
|
const keys = Object.keys(objectHideInfo);
|
|
26
33
|
for(let index = 0; index < keys.length; index++){
|
|
@@ -60,36 +67,49 @@ class FairysValtioFormInstance {
|
|
|
60
67
|
this.errorState = proxy({});
|
|
61
68
|
this.hideState = proxy({});
|
|
62
69
|
};
|
|
70
|
+
mountRules = {};
|
|
71
|
+
removeRules = (name)=>{
|
|
72
|
+
delete this.mountRules[name];
|
|
73
|
+
};
|
|
63
74
|
rules = {};
|
|
75
|
+
nameToPaths = {};
|
|
64
76
|
validate = async (fields, isReturn = true)=>{
|
|
65
|
-
|
|
77
|
+
const rules = {
|
|
78
|
+
...this.rules,
|
|
79
|
+
...this.mountRules
|
|
80
|
+
};
|
|
66
81
|
const _formData = snapshot(this.state);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
...
|
|
86
|
-
}
|
|
82
|
+
const _values = {};
|
|
83
|
+
let _fields = Object.keys(rules);
|
|
84
|
+
let _lastRules = {};
|
|
85
|
+
let isPropsFields = false;
|
|
86
|
+
if (Array.isArray(fields) && fields.length) {
|
|
87
|
+
_fields = [
|
|
88
|
+
...fields
|
|
89
|
+
];
|
|
90
|
+
isPropsFields = true;
|
|
91
|
+
for(let index = 0; index < fields.length; index++){
|
|
92
|
+
const field = fields[index];
|
|
93
|
+
const paths = this.nameToPaths[field];
|
|
94
|
+
_lastRules[field] = rules[field];
|
|
95
|
+
_values[field] = get(_formData, paths ? paths : formatePath(field));
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
isPropsFields = false;
|
|
99
|
+
_lastRules = {
|
|
100
|
+
...rules
|
|
101
|
+
};
|
|
102
|
+
for(let index = 0; index < _fields.length; index++){
|
|
103
|
+
const field = _fields[index];
|
|
104
|
+
const paths = this.nameToPaths[field];
|
|
105
|
+
_values[field] = get(_formData, paths);
|
|
106
|
+
}
|
|
87
107
|
}
|
|
88
108
|
return new Promise((resolve, reject)=>{
|
|
89
109
|
new async_validator({
|
|
90
110
|
...rules
|
|
91
111
|
}).validate({
|
|
92
|
-
...
|
|
112
|
+
..._values
|
|
93
113
|
}, (errors, fields)=>{
|
|
94
114
|
for(let index = 0; index < _fields.length; index++){
|
|
95
115
|
const field = _fields[index];
|
|
@@ -101,10 +121,19 @@ class FairysValtioFormInstance {
|
|
|
101
121
|
errors,
|
|
102
122
|
fields
|
|
103
123
|
});
|
|
104
|
-
else resolve(
|
|
124
|
+
else isPropsFields ? resolve({
|
|
125
|
+
...fields
|
|
126
|
+
}) : resolve({
|
|
127
|
+
..._formData
|
|
128
|
+
});
|
|
105
129
|
});
|
|
106
130
|
});
|
|
107
131
|
};
|
|
132
|
+
validatePrefixFields = async (prefix, isReturn = true)=>{
|
|
133
|
+
const fields = Object.keys(this.rules);
|
|
134
|
+
const _fields = fields.filter((item)=>prefix.some((p)=>item.toString().startsWith(p)));
|
|
135
|
+
return this.validate(_fields, isReturn);
|
|
136
|
+
};
|
|
108
137
|
}
|
|
109
138
|
function useFairysValtioFormInstance(instance) {
|
|
110
139
|
const ref = useRef();
|
package/esm/form/layout.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export interface FairysValtioFormLayoutContextOptions {
|
|
|
2
2
|
/**列数据*/
|
|
3
3
|
colCount?: number;
|
|
4
4
|
/**规则校验失败错误提示位置*/
|
|
5
|
-
errorLayout?: 'left
|
|
5
|
+
errorLayout?: 'bottom-left' | 'bottom-right' | 'top-right' | 'top-left' | 'left-border-top' | 'right-border-top';
|
|
6
6
|
/**
|
|
7
7
|
* label显示模式
|
|
8
8
|
* @platform taro 支持 between
|
|
@@ -23,7 +23,15 @@ export interface FairysValtioFormLayoutContextOptions {
|
|
|
23
23
|
/**
|
|
24
24
|
* 底部边框类型
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
itemBorderType?: 'bottom' | 'body';
|
|
27
|
+
/**边框颜色*/
|
|
28
|
+
itemBorderColor?: React.CSSProperties['borderColor'];
|
|
29
|
+
/**是否校验失败时显示红色边框*/
|
|
30
|
+
isInvalidBorderRed?: boolean;
|
|
31
|
+
/**是否校验失败时显示红色文本*/
|
|
32
|
+
isInvalidTextRed?: boolean;
|
|
33
|
+
/**是否显示冒号*/
|
|
34
|
+
showColon?: boolean;
|
|
27
35
|
}
|
|
28
36
|
export interface FairysValtioFormLayoutAttrsProps extends FairysValtioFormLayoutContextOptions {
|
|
29
37
|
/**
|
|
@@ -63,7 +71,7 @@ export declare const useFairysValtioFormLayoutInstance: (instance?: FairysValtio
|
|
|
63
71
|
export declare const FairysValtioFormLayoutContext: import("react").Context<FairysValtioFormLayoutInstance>;
|
|
64
72
|
export declare const useFairysValtioFormLayoutContext: () => readonly [{
|
|
65
73
|
readonly colCount?: number;
|
|
66
|
-
readonly errorLayout?: "left
|
|
74
|
+
readonly errorLayout?: "bottom-left" | "bottom-right" | "top-right" | "top-left" | "left-border-top" | "right-border-top";
|
|
67
75
|
readonly labelMode?: "left" | "top" | "between";
|
|
68
76
|
readonly formItemClassName?: string;
|
|
69
77
|
readonly formItemStyle?: {
|
|
@@ -2645,7 +2653,11 @@ export declare const useFairysValtioFormLayoutContext: () => readonly [{
|
|
|
2645
2653
|
readonly colorRendering?: import("csstype").Property.ColorRendering | undefined;
|
|
2646
2654
|
readonly glyphOrientationVertical?: import("csstype").Property.GlyphOrientationVertical | undefined;
|
|
2647
2655
|
};
|
|
2648
|
-
readonly
|
|
2656
|
+
readonly itemBorderType?: "bottom" | "body";
|
|
2657
|
+
readonly itemBorderColor?: React.CSSProperties["borderColor"];
|
|
2658
|
+
readonly isInvalidBorderRed?: boolean;
|
|
2659
|
+
readonly isInvalidTextRed?: boolean;
|
|
2660
|
+
readonly showColon?: boolean;
|
|
2649
2661
|
}, FairysValtioFormLayoutInstance];
|
|
2650
2662
|
/**
|
|
2651
2663
|
* 布局属性处理
|
|
@@ -2706,7 +2718,7 @@ export interface FairysValtioFormLayoutAttrsReturn {
|
|
|
2706
2718
|
/**
|
|
2707
2719
|
* 底部边框类型
|
|
2708
2720
|
*/
|
|
2709
|
-
|
|
2721
|
+
itemBorderType: string;
|
|
2710
2722
|
/**表单布局实例*/
|
|
2711
2723
|
formLayoutInstance: FairysValtioFormLayoutInstance;
|
|
2712
2724
|
/**布局ClassName*/
|
package/esm/form/layout.js
CHANGED
|
@@ -4,9 +4,9 @@ import { proxy, useSnapshot } from "valtio";
|
|
|
4
4
|
class FairysValtioFormLayoutInstance {
|
|
5
5
|
state = proxy({
|
|
6
6
|
colCount: 1,
|
|
7
|
-
errorLayout: 'right
|
|
7
|
+
errorLayout: 'bottom-right',
|
|
8
8
|
labelMode: 'between',
|
|
9
|
-
|
|
9
|
+
itemBorderType: 'bottom'
|
|
10
10
|
});
|
|
11
11
|
updated = (options = {})=>{
|
|
12
12
|
const keys = Object.keys(options);
|
|
@@ -35,7 +35,7 @@ function useFairysValtioFormLayoutAttrs(props) {
|
|
|
35
35
|
const formLayoutInstance = useFairysValtioFormLayoutInstance();
|
|
36
36
|
const [state] = useFairysValtioFormLayoutContext();
|
|
37
37
|
const parent_colCount = state.colCount || 1;
|
|
38
|
-
const parent_errorLayout = state.errorLayout || 'right
|
|
38
|
+
const parent_errorLayout = state.errorLayout || 'bottom-right';
|
|
39
39
|
const parent_labelMode = state.labelMode || 'between';
|
|
40
40
|
const parent_formItemClassName = state.formItemClassName;
|
|
41
41
|
const parent_formItemStyle = state.formItemStyle;
|
|
@@ -43,8 +43,12 @@ function useFairysValtioFormLayoutAttrs(props) {
|
|
|
43
43
|
const parent_formItemLabelStyle = state.formItemLabelStyle;
|
|
44
44
|
const parent_formItemBodyClassName = state.formItemBodyClassName;
|
|
45
45
|
const parent_formItemBodyStyle = state.formItemBodyStyle;
|
|
46
|
-
const parent_borderedType = state.
|
|
47
|
-
const
|
|
46
|
+
const parent_borderedType = state.itemBorderType || 'bottom';
|
|
47
|
+
const parent_itemBorderColor = state.itemBorderColor;
|
|
48
|
+
const parent_isInvalidBorderRed = state.isInvalidBorderRed;
|
|
49
|
+
const parent_isInvalidTextRed = state.isInvalidTextRed;
|
|
50
|
+
const parent_showColon = state.showColon;
|
|
51
|
+
const { colCount = parent_colCount, errorLayout = parent_errorLayout, labelMode = parent_labelMode, formItemClassName = parent_formItemClassName, formItemStyle = parent_formItemStyle, formItemLabelClassName = parent_formItemLabelClassName, formItemLabelStyle = parent_formItemLabelStyle, formItemBodyClassName = parent_formItemBodyClassName, formItemBodyStyle = parent_formItemBodyStyle, itemBorderType = parent_borderedType, itemBorderColor = parent_itemBorderColor, lastItemBordered = true, isInvalidBorderRed = parent_isInvalidBorderRed, isInvalidTextRed = parent_isInvalidTextRed, showColon = parent_showColon, gap, isAllColSpan = false, className, style, headerClassName, headerStyle, bodyClassName, bodyStyle, bordered, boxShadow } = props;
|
|
48
52
|
useMemo(()=>formLayoutInstance.updated({
|
|
49
53
|
colCount,
|
|
50
54
|
errorLayout,
|
|
@@ -55,7 +59,11 @@ function useFairysValtioFormLayoutAttrs(props) {
|
|
|
55
59
|
formItemLabelStyle,
|
|
56
60
|
formItemBodyClassName,
|
|
57
61
|
formItemBodyStyle,
|
|
58
|
-
|
|
62
|
+
itemBorderType,
|
|
63
|
+
itemBorderColor,
|
|
64
|
+
isInvalidBorderRed,
|
|
65
|
+
isInvalidTextRed,
|
|
66
|
+
showColon
|
|
59
67
|
}), [
|
|
60
68
|
colCount,
|
|
61
69
|
errorLayout,
|
|
@@ -66,11 +74,15 @@ function useFairysValtioFormLayoutAttrs(props) {
|
|
|
66
74
|
formItemLabelStyle,
|
|
67
75
|
formItemBodyClassName,
|
|
68
76
|
formItemBodyStyle,
|
|
69
|
-
|
|
77
|
+
itemBorderType,
|
|
78
|
+
itemBorderColor,
|
|
79
|
+
isInvalidBorderRed,
|
|
80
|
+
isInvalidTextRed,
|
|
81
|
+
showColon
|
|
70
82
|
]);
|
|
71
|
-
const layoutCls = useMemo(()=>clsx("fairys-valtio-form-layout fairystaroform__text-_zkh1_12px_zhk2_ fairystaroform__w-full fairystaroform__box-border fairystaroform__rounded-
|
|
83
|
+
const layoutCls = useMemo(()=>clsx("fairys-valtio-form-layout fairystaroform__transition-all fairystaroform__duration-300 fairystaroform__text-_zkh1_12px_zhk2_ fairystaroform__w-full fairystaroform__box-border fairystaroform__rounded-_zkh1_8px_zhk2_", {
|
|
72
84
|
'fairys-valtio-form-layout-all-col-span': isAllColSpan,
|
|
73
|
-
'fairys-
|
|
85
|
+
'fairys-valtio-form-layout-box-shadow': boxShadow,
|
|
74
86
|
'fairystaroform__border fairystaroform__border-solid fairystaroform__border-gray-200': bordered,
|
|
75
87
|
'fairys-valtio-form-layout-last-item-no-border': !lastItemBordered
|
|
76
88
|
}, className), [
|
|
@@ -80,7 +92,7 @@ function useFairysValtioFormLayoutAttrs(props) {
|
|
|
80
92
|
boxShadow,
|
|
81
93
|
lastItemBordered
|
|
82
94
|
]);
|
|
83
|
-
const headerCls = useMemo(()=>clsx("fairys-valtio-form-layout-header fairystaroform__flex fairystaroform__justify-between fairystaroform__items-center fairystaroform__flex-row fairystaroform__py-
|
|
95
|
+
const headerCls = useMemo(()=>clsx("fairys-valtio-form-layout-header fairystaroform__transition-all fairystaroform__duration-300 fairystaroform__flex fairystaroform__justify-between fairystaroform__items-center fairystaroform__flex-row fairystaroform__py-_zkh1_10px_zhk2_ fairystaroform__border-b fairystaroform__border-b-solid fairystaroform__border-b-gray-200 fairystaroform__box-border", {
|
|
84
96
|
'fairystaroform__px-_zkh1_8px_zhk2_': bordered || boxShadow,
|
|
85
97
|
'fairystaroform__px-_zkh1_4px_zhk2_': !bordered && !boxShadow
|
|
86
98
|
}, headerClassName), [
|
|
@@ -88,9 +100,9 @@ function useFairysValtioFormLayoutAttrs(props) {
|
|
|
88
100
|
bordered,
|
|
89
101
|
boxShadow
|
|
90
102
|
]);
|
|
91
|
-
const headerTitleCls = useMemo(()=>clsx("fairys-valtio-form-layout-header-title fairystaroform__text-_zkh1_14px_zhk2_ fairystaroform__font-bold fairystaroform__box-border"), []);
|
|
92
|
-
const headerExtraCls = useMemo(()=>clsx("fairys-valtio-form-layout-header-extra fairystaroform__box-border"), []);
|
|
93
|
-
const body_base = useMemo(()=>clsx('fairys-valtio-form-layout-body fairystaroform__px-_zkh1_8px_zhk2_ fairystaroform__w-full fairystaroform__grid fairystaroform__gap-_zkh1_2px_zhk2_ fairystaroform__box-border', bodyClassName), [
|
|
103
|
+
const headerTitleCls = useMemo(()=>clsx("fairys-valtio-form-layout-header-title fairystaroform__transition-all fairystaroform__duration-300 fairystaroform__text-_zkh1_14px_zhk2_ fairystaroform__font-bold fairystaroform__box-border"), []);
|
|
104
|
+
const headerExtraCls = useMemo(()=>clsx("fairys-valtio-form-layout-header-extra fairystaroform__transition-all fairystaroform__duration-300 fairystaroform__box-border"), []);
|
|
105
|
+
const body_base = useMemo(()=>clsx('fairys-valtio-form-layout-body fairystaroform__transition-all fairystaroform__duration-300 fairystaroform__px-_zkh1_8px_zhk2_ fairystaroform__w-full fairystaroform__grid fairystaroform__gap-_zkh1_2px_zhk2_ fairystaroform__box-border', bodyClassName), [
|
|
94
106
|
bodyClassName
|
|
95
107
|
]);
|
|
96
108
|
const styleBase = useMemo(()=>{
|
|
@@ -107,7 +119,7 @@ function useFairysValtioFormLayoutAttrs(props) {
|
|
|
107
119
|
colCount,
|
|
108
120
|
errorLayout,
|
|
109
121
|
labelMode,
|
|
110
|
-
|
|
122
|
+
itemBorderType,
|
|
111
123
|
formLayoutInstance,
|
|
112
124
|
layoutName: layoutCls,
|
|
113
125
|
layoutStyle: style,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* 设置值
|
|
3
|
+
* @param object 任意对象
|
|
4
|
+
* @param paths 值路径
|
|
5
|
+
* @param nextValue 新值
|
|
6
|
+
*
|
|
7
|
+
* @description
|
|
8
|
+
* 值不存在时,当 paths 路径中的值为 number 类型时,会创建一个空数组。当 paths 路径中的值为 string 类型时,会创建一个空对象。
|
|
9
|
+
*/
|
|
10
|
+
export declare function set<T>(state: any, paths: PropertyKey[], nextValue: T): any;
|
|
11
|
+
/***
|
|
12
|
+
* 获取值
|
|
13
|
+
* @param value 任意值
|
|
14
|
+
* @param segments 键路径
|
|
15
|
+
*/
|
|
16
|
+
export declare function get<TDefault = unknown>(value: any, segments: PropertyKey[]): TDefault;
|
|
17
|
+
/***
|
|
18
|
+
* 格式化路径,将路径中的数组索引转换为数字
|
|
19
|
+
* @param path 路径
|
|
20
|
+
* @returns 格式化后的路径
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatePath(path: PropertyKey): (number | symbol)[] | (string | number)[];
|
|
23
|
+
/**格式化属性名*/
|
|
24
|
+
export declare function formateName(name?: string, parentName?: string): string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
function set(state, paths, nextValue) {
|
|
2
|
+
const _keys = [
|
|
3
|
+
...paths
|
|
4
|
+
];
|
|
5
|
+
let current = state;
|
|
6
|
+
const length = _keys.length - 1;
|
|
7
|
+
for(let i = 0; i <= length; i++){
|
|
8
|
+
const key = _keys[i];
|
|
9
|
+
const _current = current[key];
|
|
10
|
+
const nextKey = _keys[i + 1];
|
|
11
|
+
if (void 0 === _current && 'number' == typeof nextKey) current[key] = [];
|
|
12
|
+
else if (void 0 === _current && 'string' == typeof nextKey) current[key] = {};
|
|
13
|
+
if (i === length) current[key] = nextValue;
|
|
14
|
+
else current = current[key];
|
|
15
|
+
}
|
|
16
|
+
return state;
|
|
17
|
+
}
|
|
18
|
+
function get(value, segments) {
|
|
19
|
+
let current = value;
|
|
20
|
+
for (const key of segments)current = current?.[key];
|
|
21
|
+
return current;
|
|
22
|
+
}
|
|
23
|
+
function formatePath(path) {
|
|
24
|
+
if ('string' != typeof path) return [
|
|
25
|
+
path
|
|
26
|
+
];
|
|
27
|
+
return path.split(/[\.]/g).reduce((pre, next)=>{
|
|
28
|
+
if (/\[[0-9]+\]$/.test(next)) {
|
|
29
|
+
const _next = next.split(/\[/);
|
|
30
|
+
let _nextValue = [];
|
|
31
|
+
for(let index = 0; index < _next.length; index++){
|
|
32
|
+
const element = _next[index];
|
|
33
|
+
if (/\]$/.test(element)) {
|
|
34
|
+
const _v = element.replace(/\]$/, '');
|
|
35
|
+
const v = Number.parseInt(_v);
|
|
36
|
+
if (_v.length !== `${v}`.length || Number.isNaN(v)) _nextValue.push(_v);
|
|
37
|
+
else _nextValue.push(v);
|
|
38
|
+
} else _nextValue.push(element);
|
|
39
|
+
}
|
|
40
|
+
return [
|
|
41
|
+
...pre,
|
|
42
|
+
..._nextValue
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
return [
|
|
46
|
+
...pre,
|
|
47
|
+
next
|
|
48
|
+
];
|
|
49
|
+
}, []).map((item)=>{
|
|
50
|
+
if ('string' == typeof item) return item.trim();
|
|
51
|
+
return item;
|
|
52
|
+
}).filter((item)=>'' !== item);
|
|
53
|
+
}
|
|
54
|
+
function formateName(name, parentName) {
|
|
55
|
+
if (parentName && name) return parentName + '.' + name;
|
|
56
|
+
if (parentName) return parentName;
|
|
57
|
+
if (name) return name;
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
export { formateName, formatePath, get, set };
|
package/esm/index.d.ts
CHANGED
package/esm/index.js
CHANGED
package/esm/styles/index.css
CHANGED
|
@@ -63,6 +63,10 @@
|
|
|
63
63
|
bottom: -14px;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
.fairystaroform__bottom-_zkh1_-2px_zhk2_ {
|
|
67
|
+
bottom: -2px;
|
|
68
|
+
}
|
|
69
|
+
|
|
66
70
|
.fairystaroform__left-0 {
|
|
67
71
|
left: 0;
|
|
68
72
|
}
|
|
@@ -71,8 +75,8 @@
|
|
|
71
75
|
right: 0;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
.fairystaroform__top-_zkh1_-
|
|
75
|
-
top: -
|
|
78
|
+
.fairystaroform__top-_zkh1_-4px_zhk2_ {
|
|
79
|
+
top: -4px;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
.fairystaroform__z-10 {
|
|
@@ -91,6 +95,10 @@
|
|
|
91
95
|
height: 100%;
|
|
92
96
|
}
|
|
93
97
|
|
|
98
|
+
.fairystaroform__min-h-_zkh1_32px_zhk2_ {
|
|
99
|
+
min-height: 32px;
|
|
100
|
+
}
|
|
101
|
+
|
|
94
102
|
.fairystaroform__w-full {
|
|
95
103
|
width: 100%;
|
|
96
104
|
}
|
|
@@ -166,8 +174,8 @@
|
|
|
166
174
|
border-bottom-color: rgb(229 231 235 / var(--un-border-bottom-opacity));
|
|
167
175
|
}
|
|
168
176
|
|
|
169
|
-
.fairystaroform__rounded-
|
|
170
|
-
border-radius:
|
|
177
|
+
.fairystaroform__rounded-_zkh1_8px_zhk2_ {
|
|
178
|
+
border-radius: 8px;
|
|
171
179
|
}
|
|
172
180
|
|
|
173
181
|
.fairystaroform__border-solid {
|
|
@@ -192,9 +200,9 @@
|
|
|
192
200
|
padding-right: 8px;
|
|
193
201
|
}
|
|
194
202
|
|
|
195
|
-
.fairystaroform__py-
|
|
196
|
-
padding-top:
|
|
197
|
-
padding-bottom:
|
|
203
|
+
.fairystaroform__py-_zkh1_10px_zhk2_ {
|
|
204
|
+
padding-top: 10px;
|
|
205
|
+
padding-bottom: 10px;
|
|
198
206
|
}
|
|
199
207
|
|
|
200
208
|
.fairystaroform__text-left {
|
|
@@ -231,6 +239,16 @@
|
|
|
231
239
|
font-weight: 700;
|
|
232
240
|
}
|
|
233
241
|
|
|
242
|
+
.fairystaroform__transition-all {
|
|
243
|
+
transition-property: all;
|
|
244
|
+
transition-duration: .15s;
|
|
245
|
+
transition-timing-function: cubic-bezier(.4, 0, .2, 1);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.fairystaroform__duration-300 {
|
|
249
|
+
transition-duration: .3s;
|
|
250
|
+
}
|
|
251
|
+
|
|
234
252
|
.fairys-valtio-form-item-label.show-colon:after {
|
|
235
253
|
content: ":";
|
|
236
254
|
text-align: center;
|
|
@@ -248,11 +266,11 @@
|
|
|
248
266
|
display: inline-block;
|
|
249
267
|
}
|
|
250
268
|
|
|
251
|
-
.fairys-valtio-form-layout.fairys-form-layout-all-col-span {
|
|
269
|
+
.fairys-valtio-form-layout.fairys-valtio-form-layout-all-col-span {
|
|
252
270
|
grid-column: 1 / -1;
|
|
253
271
|
}
|
|
254
272
|
|
|
255
|
-
.fairys-valtio-form-layout.fairys-form-layout-box-shadow {
|
|
273
|
+
.fairys-valtio-form-layout.fairys-valtio-form-layout-box-shadow {
|
|
256
274
|
box-shadow: 0 6px 16px -8px #00000014, 0 9px 28px #0000000d, 0 12px 48px 16px #00000008;
|
|
257
275
|
}
|
|
258
276
|
|
|
@@ -260,7 +278,15 @@
|
|
|
260
278
|
margin-top: 12px;
|
|
261
279
|
}
|
|
262
280
|
|
|
263
|
-
.fairys-valtio-form-layout-last-item-no-border > .fairys-valtio-form-layout-body > .fairys-valtio-form-item:last-child, .fairys-valtio-form-layout-last-item-no-border > .fairys-valtio-form-layout-body > .fairys-valtio-form-item:last-child > .fairys-valtio-form-item-container > .fairys-valtio-form-item-body {
|
|
281
|
+
.fairys-valtio-form-layout-last-item-no-border > .fairys-valtio-form-layout-body > .fairys-valtio-form-item:last-child:not(.fairys-valtio-form-item-invalid-border-red), .fairys-valtio-form-layout-last-item-no-border > .fairys-valtio-form-layout-body > .fairys-valtio-form-item:last-child > .fairys-valtio-form-item-container > .fairys-valtio-form-item-body:not(.fairys-valtio-form-item-invalid-border-red) {
|
|
264
282
|
border-bottom: 0;
|
|
265
283
|
}
|
|
266
284
|
|
|
285
|
+
.fairys-valtio-form-item-invalid-border-red {
|
|
286
|
+
border-bottom-color: red !important;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.fairys-valtio-form-item-invalid-text-red > .fairys-valtio-form-item-container > .fairys-valtio-form-item-label, .fairys-valtio-form-item-invalid-text-red > .fairys-valtio-form-item-container > .fairys-valtio-form-item-body > .fairys-valtio-form-item-body-input {
|
|
290
|
+
color: red !important;
|
|
291
|
+
}
|
|
292
|
+
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,9 @@ var __webpack_modules__ = {
|
|
|
6
6
|
"./form/form": function(module) {
|
|
7
7
|
module.exports = require("./form/form.js");
|
|
8
8
|
},
|
|
9
|
+
"./form/hooks": function(module) {
|
|
10
|
+
module.exports = require("./form/hooks/index.js");
|
|
11
|
+
},
|
|
9
12
|
"./form/instance": function(module) {
|
|
10
13
|
module.exports = require("./form/instance/index.js");
|
|
11
14
|
},
|
|
@@ -56,28 +59,34 @@ function __webpack_require__(moduleId) {
|
|
|
56
59
|
var __webpack_exports__ = {};
|
|
57
60
|
(()=>{
|
|
58
61
|
__webpack_require__.r(__webpack_exports__);
|
|
59
|
-
var
|
|
62
|
+
var _form_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./form/hooks");
|
|
63
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
64
|
+
for(var __WEBPACK_IMPORT_KEY__ in _form_hooks__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
65
|
+
return _form_hooks__WEBPACK_IMPORTED_MODULE_0__[key];
|
|
66
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
67
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
68
|
+
var _form_instance__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./form/instance");
|
|
60
69
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
61
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
62
|
-
return
|
|
70
|
+
for(var __WEBPACK_IMPORT_KEY__ in _form_instance__WEBPACK_IMPORTED_MODULE_1__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
71
|
+
return _form_instance__WEBPACK_IMPORTED_MODULE_1__[key];
|
|
63
72
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
64
73
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
65
|
-
var
|
|
74
|
+
var _form_layout__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./form/layout");
|
|
66
75
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
67
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
68
|
-
return
|
|
76
|
+
for(var __WEBPACK_IMPORT_KEY__ in _form_layout__WEBPACK_IMPORTED_MODULE_2__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
77
|
+
return _form_layout__WEBPACK_IMPORTED_MODULE_2__[key];
|
|
69
78
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
70
79
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
71
|
-
var
|
|
80
|
+
var _form_form__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./form/form");
|
|
72
81
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
73
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
74
|
-
return
|
|
82
|
+
for(var __WEBPACK_IMPORT_KEY__ in _form_form__WEBPACK_IMPORTED_MODULE_3__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
83
|
+
return _form_form__WEBPACK_IMPORTED_MODULE_3__[key];
|
|
75
84
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
76
85
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
77
|
-
var
|
|
86
|
+
var _form_form_item__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./form/form.item");
|
|
78
87
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
79
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
80
|
-
return
|
|
88
|
+
for(var __WEBPACK_IMPORT_KEY__ in _form_form_item__WEBPACK_IMPORTED_MODULE_4__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
89
|
+
return _form_form_item__WEBPACK_IMPORTED_MODULE_4__[key];
|
|
81
90
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
82
91
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
83
92
|
})();
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "SunLxy <1011771396@qq.com>",
|
|
4
4
|
"description": "使用 valtio 实现的表单基础库, 使其更加便捷,同时支持`PC`、`H5`、`Taro`,同时也更加灵活。",
|
|
5
5
|
"homepage": "https://github.com/autumn-fairy-tales/fairys-taro-react",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.10",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"types": "esm/index.d.ts",
|
|
9
9
|
"module": "esm/index.js",
|
|
@@ -35,4 +35,4 @@
|
|
|
35
35
|
"@types/react": "~18.2.21",
|
|
36
36
|
"react": "^18.0.0"
|
|
37
37
|
}
|
|
38
|
-
}
|
|
38
|
+
}
|