@fairys/valtio-form-basic 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/{form → common}/hooks/index.d.ts +1 -0
- package/esm/{form → common}/hooks/index.js +9 -1
- package/esm/common/index.d.ts +4 -0
- package/esm/common/index.js +4 -0
- package/esm/{form → common}/instance/index.d.ts +9 -2
- package/esm/{form → common}/instance/index.js +19 -5
- package/esm/{form → common}/utils/index.d.ts +1 -0
- package/esm/{form → common}/utils/index.js +2 -1
- package/esm/form/form.d.ts +7 -7
- package/esm/form/form.item.d.ts +10 -3
- package/esm/form/form.item.js +50 -32
- package/esm/form/form.js +5 -3
- package/esm/form/layout.d.ts +4 -2591
- package/esm/form/layout.js +7 -4
- package/esm/index.d.ts +1 -2
- package/esm/index.js +1 -2
- package/esm/styles/index.css +20 -4
- package/lib/common/hooks/index.d.ts +35 -0
- package/lib/common/hooks/index.js +117 -0
- package/lib/common/index.d.ts +4 -0
- package/lib/common/index.js +87 -0
- package/lib/common/instance/index.d.ts +88 -0
- package/lib/common/instance/index.js +243 -0
- package/lib/common/interface.d.ts +4 -0
- package/lib/common/interface.js +18 -0
- package/lib/common/utils/index.d.ts +25 -0
- package/lib/common/utils/index.js +107 -0
- package/lib/form/form.d.ts +76 -0
- package/lib/form/form.item.d.ts +224 -0
- package/lib/form/form.item.js +321 -0
- package/lib/form/form.js +53 -0
- package/lib/form/layout.d.ts +153 -0
- package/lib/form/layout.js +196 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +18 -27
- package/lib/styles/index.css +308 -0
- package/package.json +5 -5
- package/src/{form → common}/hooks/index.tsx +9 -1
- package/src/common/index.ts +4 -0
- package/src/{form → common}/instance/index.ts +51 -13
- package/src/{form → common}/utils/index.ts +2 -0
- package/src/form/form.item.tsx +59 -36
- package/src/form/form.tsx +12 -7
- package/src/form/layout.tsx +9 -3
- package/src/index.tsx +4 -5
- /package/esm/{interface.d.ts → common/interface.d.ts} +0 -0
- /package/esm/{interface.js → common/interface.js} +0 -0
- /package/src/{interface.ts → common/interface.ts} +0 -0
package/esm/form/layout.js
CHANGED
|
@@ -48,7 +48,8 @@ function useFairysValtioFormLayoutAttrs(props) {
|
|
|
48
48
|
const parent_isInvalidBorderRed = state.isInvalidBorderRed;
|
|
49
49
|
const parent_isInvalidTextRed = state.isInvalidTextRed;
|
|
50
50
|
const parent_showColon = state.showColon;
|
|
51
|
-
const
|
|
51
|
+
const parent_platform = state.platform;
|
|
52
|
+
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, platform = parent_platform, gap, isAllColSpan = false, className, style, headerClassName, headerStyle, bodyClassName, bodyStyle, bordered, boxShadow } = props;
|
|
52
53
|
useMemo(()=>formLayoutInstance.updated({
|
|
53
54
|
colCount,
|
|
54
55
|
errorLayout,
|
|
@@ -63,7 +64,8 @@ function useFairysValtioFormLayoutAttrs(props) {
|
|
|
63
64
|
itemBorderColor,
|
|
64
65
|
isInvalidBorderRed,
|
|
65
66
|
isInvalidTextRed,
|
|
66
|
-
showColon
|
|
67
|
+
showColon,
|
|
68
|
+
platform
|
|
67
69
|
}), [
|
|
68
70
|
colCount,
|
|
69
71
|
errorLayout,
|
|
@@ -78,7 +80,8 @@ function useFairysValtioFormLayoutAttrs(props) {
|
|
|
78
80
|
itemBorderColor,
|
|
79
81
|
isInvalidBorderRed,
|
|
80
82
|
isInvalidTextRed,
|
|
81
|
-
showColon
|
|
83
|
+
showColon,
|
|
84
|
+
platform
|
|
82
85
|
]);
|
|
83
86
|
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_", {
|
|
84
87
|
'fairys-valtio-form-layout-all-col-span': isAllColSpan,
|
|
@@ -102,7 +105,7 @@ function useFairysValtioFormLayoutAttrs(props) {
|
|
|
102
105
|
]);
|
|
103
106
|
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
107
|
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
|
|
108
|
+
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__box-border fairystaroform__pt-_zkh1_8px_zhk2_ fairystaroform__pb-_zkh1_12px_zhk2_ fairystaroform__gap-_zkh1_6px_zhk2_', bodyClassName), [
|
|
106
109
|
bodyClassName
|
|
107
110
|
]);
|
|
108
111
|
const styleBase = useMemo(()=>{
|
package/esm/index.d.ts
CHANGED
package/esm/index.js
CHANGED
package/esm/styles/index.css
CHANGED
|
@@ -59,6 +59,10 @@
|
|
|
59
59
|
position: relative;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
.fairystaroform__bottom-_zkh1_-10px_zhk2_ {
|
|
63
|
+
bottom: -10px;
|
|
64
|
+
}
|
|
65
|
+
|
|
62
66
|
.fairystaroform__bottom-_zkh1_-14px_zhk2_ {
|
|
63
67
|
bottom: -14px;
|
|
64
68
|
}
|
|
@@ -119,6 +123,10 @@
|
|
|
119
123
|
flex-direction: column;
|
|
120
124
|
}
|
|
121
125
|
|
|
126
|
+
.fairystaroform__items-start {
|
|
127
|
+
align-items: flex-start;
|
|
128
|
+
}
|
|
129
|
+
|
|
122
130
|
.fairystaroform__items-center {
|
|
123
131
|
align-items: center;
|
|
124
132
|
}
|
|
@@ -139,14 +147,14 @@
|
|
|
139
147
|
justify-content: space-between;
|
|
140
148
|
}
|
|
141
149
|
|
|
142
|
-
.fairystaroform__gap-_zkh1_2px_zhk2_ {
|
|
143
|
-
gap: 2px;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
150
|
.fairystaroform__gap-_zkh1_4px_zhk2_ {
|
|
147
151
|
gap: 4px;
|
|
148
152
|
}
|
|
149
153
|
|
|
154
|
+
.fairystaroform__gap-_zkh1_6px_zhk2_ {
|
|
155
|
+
gap: 6px;
|
|
156
|
+
}
|
|
157
|
+
|
|
150
158
|
.fairystaroform__gap-_zkh1_8px_zhk2_ {
|
|
151
159
|
gap: 8px;
|
|
152
160
|
}
|
|
@@ -205,6 +213,14 @@
|
|
|
205
213
|
padding-bottom: 10px;
|
|
206
214
|
}
|
|
207
215
|
|
|
216
|
+
.fairystaroform__pb-_zkh1_12px_zhk2_ {
|
|
217
|
+
padding-bottom: 12px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.fairystaroform__pt-_zkh1_8px_zhk2_ {
|
|
221
|
+
padding-top: 8px;
|
|
222
|
+
}
|
|
223
|
+
|
|
208
224
|
.fairystaroform__text-left {
|
|
209
225
|
text-align: left;
|
|
210
226
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface FairysValtioFormParentAttrsState {
|
|
2
|
+
name?: string;
|
|
3
|
+
}
|
|
4
|
+
/***
|
|
5
|
+
* 父级属性
|
|
6
|
+
*/
|
|
7
|
+
export declare class FairysValtioFormParentAttrs {
|
|
8
|
+
state: FairysValtioFormParentAttrsState;
|
|
9
|
+
updated: (attrs: Record<string, any>) => void;
|
|
10
|
+
/***更新父级字段值*/
|
|
11
|
+
updatedName: (name?: string, parentName?: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/**初始化父级属性*/
|
|
14
|
+
export declare const useFairysValtioFormParentAttrs: (instance?: FairysValtioFormParentAttrs) => FairysValtioFormParentAttrs;
|
|
15
|
+
/***父级属性上下文*/
|
|
16
|
+
export declare const FairysValtioFormParentAttrsContext: import("react").Context<FairysValtioFormParentAttrs>;
|
|
17
|
+
/***获取父级属性实例*/
|
|
18
|
+
export declare const useFairysValtioFormParentAttrsContext: () => FairysValtioFormParentAttrs;
|
|
19
|
+
/***获取父级属性状态*/
|
|
20
|
+
export declare const useFairysValtioFormParentAttrsState: () => readonly [{
|
|
21
|
+
readonly name?: string;
|
|
22
|
+
}, FairysValtioFormParentAttrs];
|
|
23
|
+
export interface FairysValtioFormAttrsNameOptions {
|
|
24
|
+
name?: string;
|
|
25
|
+
/**是否拼接父级字段名*/
|
|
26
|
+
isJoinParentField?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/***获取属性名和路径*/
|
|
29
|
+
export declare const useFairysValtioFormAttrsName: (options?: FairysValtioFormAttrsNameOptions) => {
|
|
30
|
+
formAttrsNameInstance: FairysValtioFormParentAttrs;
|
|
31
|
+
parentName: string;
|
|
32
|
+
name: string;
|
|
33
|
+
paths: (number | symbol)[] | (string | number)[];
|
|
34
|
+
};
|
|
35
|
+
export declare const useId: (suffix?: string) => string;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
useId: ()=>useId,
|
|
28
|
+
FairysValtioFormParentAttrsContext: ()=>FairysValtioFormParentAttrsContext,
|
|
29
|
+
useFairysValtioFormAttrsName: ()=>useFairysValtioFormAttrsName,
|
|
30
|
+
useFairysValtioFormParentAttrs: ()=>useFairysValtioFormParentAttrs,
|
|
31
|
+
useFairysValtioFormParentAttrsContext: ()=>useFairysValtioFormParentAttrsContext,
|
|
32
|
+
FairysValtioFormParentAttrs: ()=>FairysValtioFormParentAttrs,
|
|
33
|
+
useFairysValtioFormParentAttrsState: ()=>useFairysValtioFormParentAttrsState
|
|
34
|
+
});
|
|
35
|
+
const external_react_namespaceObject = require("react");
|
|
36
|
+
const external_valtio_namespaceObject = require("valtio");
|
|
37
|
+
const index_js_namespaceObject = require("../utils/index.js");
|
|
38
|
+
class FairysValtioFormParentAttrs {
|
|
39
|
+
state = (0, external_valtio_namespaceObject.proxy)({
|
|
40
|
+
name: ''
|
|
41
|
+
});
|
|
42
|
+
updated = (attrs)=>{
|
|
43
|
+
this.state = {
|
|
44
|
+
...this.state,
|
|
45
|
+
...attrs
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
updatedName = (name, parentName)=>{
|
|
49
|
+
this.state.name = (0, index_js_namespaceObject.formateName)(name, parentName);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const useFairysValtioFormParentAttrs = (instance)=>{
|
|
53
|
+
const parentAttrs = (0, external_react_namespaceObject.useRef)();
|
|
54
|
+
if (!parentAttrs.current) if (instance) parentAttrs.current = instance;
|
|
55
|
+
else parentAttrs.current = new FairysValtioFormParentAttrs();
|
|
56
|
+
return parentAttrs.current;
|
|
57
|
+
};
|
|
58
|
+
const FairysValtioFormParentAttrsContext = /*#__PURE__*/ (0, external_react_namespaceObject.createContext)(new FairysValtioFormParentAttrs());
|
|
59
|
+
const useFairysValtioFormParentAttrsContext = ()=>(0, external_react_namespaceObject.useContext)(FairysValtioFormParentAttrsContext);
|
|
60
|
+
const useFairysValtioFormParentAttrsState = ()=>{
|
|
61
|
+
const instance = useFairysValtioFormParentAttrsContext();
|
|
62
|
+
const state = (0, external_valtio_namespaceObject.useSnapshot)(instance.state);
|
|
63
|
+
return [
|
|
64
|
+
state,
|
|
65
|
+
instance
|
|
66
|
+
];
|
|
67
|
+
};
|
|
68
|
+
const useFairysValtioFormAttrsName = (options = {})=>{
|
|
69
|
+
const { name, isJoinParentField = true } = options;
|
|
70
|
+
const formAttrsNameInstance = useFairysValtioFormParentAttrs();
|
|
71
|
+
const [state] = useFairysValtioFormParentAttrsState();
|
|
72
|
+
const parentName = state.name;
|
|
73
|
+
const _name = (0, external_react_namespaceObject.useMemo)(()=>isJoinParentField ? (0, index_js_namespaceObject.formateName)(name, parentName) : name, [
|
|
74
|
+
name,
|
|
75
|
+
parentName,
|
|
76
|
+
isJoinParentField
|
|
77
|
+
]);
|
|
78
|
+
const _paths = (0, external_react_namespaceObject.useMemo)(()=>(0, index_js_namespaceObject.formatePath)(_name), [
|
|
79
|
+
_name
|
|
80
|
+
]);
|
|
81
|
+
(0, external_react_namespaceObject.useMemo)(()=>formAttrsNameInstance.updatedName(_name), [
|
|
82
|
+
_name
|
|
83
|
+
]);
|
|
84
|
+
return {
|
|
85
|
+
formAttrsNameInstance,
|
|
86
|
+
parentName,
|
|
87
|
+
name: _name,
|
|
88
|
+
paths: _paths
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
let localId = 0;
|
|
92
|
+
const useId = (suffix = 'form-item-input')=>{
|
|
93
|
+
const count = (0, external_react_namespaceObject.useRef)(localId++);
|
|
94
|
+
return (0, external_react_namespaceObject.useMemo)(()=>`fairys-valtio-form_${count.current.toString(32)}_${suffix}`, [
|
|
95
|
+
count.current,
|
|
96
|
+
suffix
|
|
97
|
+
]);
|
|
98
|
+
};
|
|
99
|
+
exports.FairysValtioFormParentAttrs = __webpack_exports__.FairysValtioFormParentAttrs;
|
|
100
|
+
exports.FairysValtioFormParentAttrsContext = __webpack_exports__.FairysValtioFormParentAttrsContext;
|
|
101
|
+
exports.useFairysValtioFormAttrsName = __webpack_exports__.useFairysValtioFormAttrsName;
|
|
102
|
+
exports.useFairysValtioFormParentAttrs = __webpack_exports__.useFairysValtioFormParentAttrs;
|
|
103
|
+
exports.useFairysValtioFormParentAttrsContext = __webpack_exports__.useFairysValtioFormParentAttrsContext;
|
|
104
|
+
exports.useFairysValtioFormParentAttrsState = __webpack_exports__.useFairysValtioFormParentAttrsState;
|
|
105
|
+
exports.useId = __webpack_exports__.useId;
|
|
106
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
107
|
+
"FairysValtioFormParentAttrs",
|
|
108
|
+
"FairysValtioFormParentAttrsContext",
|
|
109
|
+
"useFairysValtioFormAttrsName",
|
|
110
|
+
"useFairysValtioFormParentAttrs",
|
|
111
|
+
"useFairysValtioFormParentAttrsContext",
|
|
112
|
+
"useFairysValtioFormParentAttrsState",
|
|
113
|
+
"useId"
|
|
114
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
115
|
+
Object.defineProperty(exports, '__esModule', {
|
|
116
|
+
value: true
|
|
117
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./hooks": function(module) {
|
|
4
|
+
module.exports = require("./hooks/index.js");
|
|
5
|
+
},
|
|
6
|
+
"./instance": function(module) {
|
|
7
|
+
module.exports = require("./instance/index.js");
|
|
8
|
+
},
|
|
9
|
+
"./interface": function(module) {
|
|
10
|
+
module.exports = require("./interface.js");
|
|
11
|
+
},
|
|
12
|
+
"./utils": function(module) {
|
|
13
|
+
module.exports = require("./utils/index.js");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __webpack_module_cache__ = {};
|
|
17
|
+
function __webpack_require__(moduleId) {
|
|
18
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
19
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
20
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
21
|
+
exports: {}
|
|
22
|
+
};
|
|
23
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
|
+
return module.exports;
|
|
25
|
+
}
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.n = (module)=>{
|
|
28
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
29
|
+
__webpack_require__.d(getter, {
|
|
30
|
+
a: getter
|
|
31
|
+
});
|
|
32
|
+
return getter;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
(()=>{
|
|
36
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
37
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: definition[key]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
(()=>{
|
|
44
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
45
|
+
})();
|
|
46
|
+
(()=>{
|
|
47
|
+
__webpack_require__.r = (exports1)=>{
|
|
48
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
49
|
+
value: 'Module'
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
52
|
+
value: true
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
var __webpack_exports__ = {};
|
|
57
|
+
(()=>{
|
|
58
|
+
__webpack_require__.r(__webpack_exports__);
|
|
59
|
+
var _hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./hooks");
|
|
60
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
61
|
+
for(var __WEBPACK_IMPORT_KEY__ in _hooks__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
62
|
+
return _hooks__WEBPACK_IMPORTED_MODULE_0__[key];
|
|
63
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
64
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
65
|
+
var _instance__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./instance");
|
|
66
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
67
|
+
for(var __WEBPACK_IMPORT_KEY__ in _instance__WEBPACK_IMPORTED_MODULE_1__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
68
|
+
return _instance__WEBPACK_IMPORTED_MODULE_1__[key];
|
|
69
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
70
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
71
|
+
var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./utils");
|
|
72
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
73
|
+
for(var __WEBPACK_IMPORT_KEY__ in _utils__WEBPACK_IMPORTED_MODULE_2__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
74
|
+
return _utils__WEBPACK_IMPORTED_MODULE_2__[key];
|
|
75
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
76
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
77
|
+
var _interface__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./interface");
|
|
78
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
79
|
+
for(var __WEBPACK_IMPORT_KEY__ in _interface__WEBPACK_IMPORTED_MODULE_3__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
80
|
+
return _interface__WEBPACK_IMPORTED_MODULE_3__[key];
|
|
81
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
82
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
83
|
+
})();
|
|
84
|
+
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
85
|
+
Object.defineProperty(exports, '__esModule', {
|
|
86
|
+
value: true
|
|
87
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { MObject } from '../interface';
|
|
2
|
+
import { RuleItem, ValidateFieldsError, Values } from 'async-validator';
|
|
3
|
+
import { FairysValtioFormAttrsProps } from '../../form/form';
|
|
4
|
+
/**表单实例*/
|
|
5
|
+
export declare class FairysValtioFormInstance<T extends MObject<T> = Record<string, any>> {
|
|
6
|
+
/***
|
|
7
|
+
* 判断值是否为代理对象
|
|
8
|
+
* @param value 值
|
|
9
|
+
* @returns 是否为代理对象
|
|
10
|
+
*/
|
|
11
|
+
isValtioProxy: (value: any) => boolean;
|
|
12
|
+
/**状态*/
|
|
13
|
+
state: T;
|
|
14
|
+
/**
|
|
15
|
+
* 错误信息
|
|
16
|
+
*/
|
|
17
|
+
errorState: Record<PropertyKey, string[]>;
|
|
18
|
+
/**隐藏状态*/
|
|
19
|
+
hideState: Record<PropertyKey, boolean>;
|
|
20
|
+
/**初始化表单值*/
|
|
21
|
+
ctor: (options?: {
|
|
22
|
+
formData?: Partial<T>;
|
|
23
|
+
hideState?: Record<PropertyKey, boolean>;
|
|
24
|
+
initFormDataType?: FairysValtioFormAttrsProps["initFormDataType"];
|
|
25
|
+
}) => void;
|
|
26
|
+
/**
|
|
27
|
+
* 更新数据
|
|
28
|
+
* @param state 更新数据对象
|
|
29
|
+
* @param isValidate 是否验证(可选)
|
|
30
|
+
*/
|
|
31
|
+
updated: <M = T>(state: Partial<M>, isValidate?: boolean) => void;
|
|
32
|
+
/**根据路径设置值
|
|
33
|
+
* @param path 值路径
|
|
34
|
+
* @param value 值
|
|
35
|
+
*/
|
|
36
|
+
updatedValueByPaths: (path: PropertyKey, value: any) => void;
|
|
37
|
+
/**
|
|
38
|
+
* 更新行数据的隐藏信息
|
|
39
|
+
* @param objectHideInfo 行数据隐藏信息对象
|
|
40
|
+
*/
|
|
41
|
+
updatedHideInfo: (objectHideInfo: Record<PropertyKey, boolean>) => this;
|
|
42
|
+
/**
|
|
43
|
+
* 清理隐藏信息
|
|
44
|
+
*/
|
|
45
|
+
clearHideInfo: (fields?: PropertyKey[]) => this;
|
|
46
|
+
/**
|
|
47
|
+
* 更新行数据的错误信息
|
|
48
|
+
* @param objectErrorInfo 行数据错误信息对象
|
|
49
|
+
*/
|
|
50
|
+
updatedErrorInfo: (objectErrorInfo: Record<PropertyKey, string[]>) => this;
|
|
51
|
+
/**
|
|
52
|
+
* 清理错误信息
|
|
53
|
+
*/
|
|
54
|
+
clearErrorInfo: (fields?: PropertyKey[]) => this;
|
|
55
|
+
/**
|
|
56
|
+
* 清理所有数据
|
|
57
|
+
*/
|
|
58
|
+
clear: () => void;
|
|
59
|
+
/**由表单项挂载规则,(根据表单项的字段存储路径对应校验规则)*/
|
|
60
|
+
mountRules: Record<PropertyKey, RuleItem[]>;
|
|
61
|
+
/**移除表单项挂载规则*/
|
|
62
|
+
removeRules: (name: PropertyKey) => void;
|
|
63
|
+
/**表单项规则*/
|
|
64
|
+
rules: Record<PropertyKey, RuleItem[]>;
|
|
65
|
+
/**表单项名称到路径映射*/
|
|
66
|
+
nameToPaths: Record<PropertyKey, PropertyKey[]>;
|
|
67
|
+
/**验证表单项规则
|
|
68
|
+
* @param fields 要验证的字段(可选)
|
|
69
|
+
* @param isReturn 是否返回验证结果(可选)
|
|
70
|
+
*/
|
|
71
|
+
validate: (fields?: PropertyKey[], isReturn?: boolean) => Promise<ValidateFieldsError | Values>;
|
|
72
|
+
/**
|
|
73
|
+
* 验证某些前缀的字段
|
|
74
|
+
* @param prefix 前缀字段数组
|
|
75
|
+
* @param isReturn 是否返回验证结果(可选)
|
|
76
|
+
*/
|
|
77
|
+
validatePrefixFields: (prefix: string[], isReturn?: boolean) => Promise<ValidateFieldsError | Values>;
|
|
78
|
+
}
|
|
79
|
+
/**声明实例*/
|
|
80
|
+
export declare function useFairysValtioFormInstance<T extends MObject<T> = object>(instance?: FairysValtioFormInstance<T>): FairysValtioFormInstance<T>;
|
|
81
|
+
/**表单实例上下文*/
|
|
82
|
+
export declare const FairysValtioFormInstanceContext: import("react").Context<FairysValtioFormInstance<any>>;
|
|
83
|
+
/**表单实例上下文*/
|
|
84
|
+
export declare function useFairysValtioFormInstanceContext<T extends MObject<T> = object>(): FairysValtioFormInstance<T>;
|
|
85
|
+
/**状态取值*/
|
|
86
|
+
export declare function useFairysValtioFormInstanceContextState<T extends MObject<T> = object>(): [T, Record<PropertyKey, string[]>, FairysValtioFormInstance<T>, any, any];
|
|
87
|
+
/**隐藏组件状态取值*/
|
|
88
|
+
export declare function useFairysValtioFormInstanceContextHideState<T extends MObject<T> = object>(): [Record<PropertyKey, boolean>, FairysValtioFormInstance<T>, any];
|