@sheinx/hooks 3.8.0-beta.20 → 3.8.0-beta.21
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/cjs/components/use-form/Provider.d.ts.map +1 -1
- package/cjs/components/use-form/Provider.js +7 -2
- package/cjs/components/use-form/form-schema-context.d.ts +6 -0
- package/cjs/components/use-form/form-schema-context.d.ts.map +1 -0
- package/cjs/components/use-form/form-schema-context.js +16 -0
- package/cjs/components/use-form/index.d.ts +2 -0
- package/cjs/components/use-form/index.d.ts.map +1 -1
- package/cjs/components/use-form/index.js +21 -1
- package/cjs/components/use-form/use-form-context.type.d.ts +6 -0
- package/cjs/components/use-form/use-form-context.type.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-item/form-item-context.d.ts +1 -0
- package/cjs/components/use-form/use-form-item/form-item-context.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-item/form-item-context.js +2 -1
- package/cjs/components/use-form/use-form-item/index.d.ts +1 -0
- package/cjs/components/use-form/use-form-item/index.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-item/index.js +7 -0
- package/cjs/components/use-form/use-form-schema/form-schema-builder.d.ts +49 -0
- package/cjs/components/use-form/use-form-schema/form-schema-builder.d.ts.map +1 -0
- package/cjs/components/use-form/use-form-schema/form-schema-builder.js +311 -0
- package/cjs/components/use-form/use-form-schema/index.d.ts +3 -0
- package/cjs/components/use-form/use-form-schema/index.d.ts.map +1 -0
- package/cjs/components/use-form/use-form-schema/index.js +13 -0
- package/cjs/components/use-form/use-form.d.ts +4 -0
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +10 -3
- package/cjs/components/use-form/use-form.type.d.ts +3 -0
- package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
- package/cjs/utils/dom/element.d.ts +1 -0
- package/cjs/utils/dom/element.d.ts.map +1 -1
- package/cjs/utils/dom/element.js +5 -1
- package/esm/components/use-form/Provider.d.ts.map +1 -1
- package/esm/components/use-form/Provider.js +7 -2
- package/esm/components/use-form/form-schema-context.d.ts +6 -0
- package/esm/components/use-form/form-schema-context.d.ts.map +1 -0
- package/esm/components/use-form/form-schema-context.js +8 -0
- package/esm/components/use-form/index.d.ts +2 -0
- package/esm/components/use-form/index.d.ts.map +1 -1
- package/esm/components/use-form/index.js +3 -1
- package/esm/components/use-form/use-form-context.type.d.ts +6 -0
- package/esm/components/use-form/use-form-context.type.d.ts.map +1 -1
- package/esm/components/use-form/use-form-item/form-item-context.d.ts +1 -0
- package/esm/components/use-form/use-form-item/form-item-context.d.ts.map +1 -1
- package/esm/components/use-form/use-form-item/form-item-context.js +2 -1
- package/esm/components/use-form/use-form-item/index.d.ts +1 -0
- package/esm/components/use-form/use-form-item/index.d.ts.map +1 -1
- package/esm/components/use-form/use-form-item/index.js +2 -1
- package/esm/components/use-form/use-form-schema/form-schema-builder.d.ts +49 -0
- package/esm/components/use-form/use-form-schema/form-schema-builder.d.ts.map +1 -0
- package/esm/components/use-form/use-form-schema/form-schema-builder.js +305 -0
- package/esm/components/use-form/use-form-schema/index.d.ts +3 -0
- package/esm/components/use-form/use-form-schema/index.d.ts.map +1 -0
- package/esm/components/use-form/use-form-schema/index.js +2 -0
- package/esm/components/use-form/use-form.d.ts +4 -0
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +10 -3
- package/esm/components/use-form/use-form.type.d.ts +3 -0
- package/esm/components/use-form/use-form.type.d.ts.map +1 -1
- package/esm/utils/dom/element.d.ts +1 -0
- package/esm/utils/dom/element.d.ts.map +1 -1
- package/esm/utils/dom/element.js +4 -0
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["Provider.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["Provider.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,eAAO,MAAM,QAAQ,UAAW,aAAa,4CAa5C,CAAC"}
|
@@ -9,6 +9,7 @@ var _formBindContext = require("./form-bind-context");
|
|
9
9
|
var _formFuncContext = require("./form-func-context");
|
10
10
|
var _formConfigContext = require("./form-config-context");
|
11
11
|
var _fieldsetContext = _interopRequireDefault(require("./use-form-fieldset/fieldset-context"));
|
12
|
+
var _formSchemaContext = require("./form-schema-context");
|
12
13
|
var React = _interopRequireWildcard(require("react"));
|
13
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
14
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
@@ -22,7 +23,8 @@ var Provider = exports.Provider = function Provider(props) {
|
|
22
23
|
var children = props.children,
|
23
24
|
formConfig = props.formConfig,
|
24
25
|
formValue = props.formValue,
|
25
|
-
formFunc = props.formFunc
|
26
|
+
formFunc = props.formFunc,
|
27
|
+
formSchema = props.formSchema;
|
26
28
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_formFuncContext.FormFuncContext.Provider, {
|
27
29
|
value: formFunc,
|
28
30
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_formBindContext.FormBindContext.Provider, {
|
@@ -31,7 +33,10 @@ var Provider = exports.Provider = function Provider(props) {
|
|
31
33
|
value: topPath,
|
32
34
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_formConfigContext.FormConfigContext.Provider, {
|
33
35
|
value: formConfig,
|
34
|
-
children:
|
36
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_formSchemaContext.FormSchemaContext.Provider, {
|
37
|
+
value: formSchema,
|
38
|
+
children: children
|
39
|
+
})
|
35
40
|
})
|
36
41
|
})
|
37
42
|
})
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { SchemaBuilder } from './use-form-schema/form-schema-builder';
|
3
|
+
export type FormSchemaContextValueType = SchemaBuilder;
|
4
|
+
export declare const FormSchemaContext: React.Context<SchemaBuilder | null>;
|
5
|
+
export declare const useFormSchema: () => SchemaBuilder | null;
|
6
|
+
//# sourceMappingURL=form-schema-context.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"form-schema-context.d.ts","sourceRoot":"","sources":["form-schema-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAEtE,MAAM,MAAM,0BAA0B,GAAG,aAAa,CAAA;AAEtD,eAAO,MAAM,iBAAiB,qCAA+D,CAAC;AAC9F,eAAO,MAAM,aAAa,4BAA4C,CAAC"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
"use client";
|
3
|
+
|
4
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.useFormSchema = exports.FormSchemaContext = void 0;
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
12
|
+
var FormSchemaContext = exports.FormSchemaContext = /*#__PURE__*/React.createContext(null);
|
13
|
+
var useFormSchema = exports.useFormSchema = function useFormSchema() {
|
14
|
+
return React.useContext(FormSchemaContext);
|
15
|
+
};
|
16
|
+
FormSchemaContext.displayName = 'FormSchemaContext';
|
@@ -3,8 +3,10 @@ export * from './use-form-item';
|
|
3
3
|
export * from './use-form-fieldset';
|
4
4
|
export * from './use-form-flow';
|
5
5
|
export * from './use-form-context';
|
6
|
+
export * from './use-form-schema';
|
6
7
|
export { default, default as useForm } from './use-form';
|
7
8
|
export { useFormConfig } from './form-config-context';
|
8
9
|
export { useFormFunc } from './form-func-context';
|
10
|
+
export { useFormSchema } from './form-schema-context';
|
9
11
|
export type { BaseFormProps, FormCommonConfig, FormLabelConfig } from './use-form.type';
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
@@ -7,7 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
var _exportNames = {
|
8
8
|
useForm: true,
|
9
9
|
useFormConfig: true,
|
10
|
-
useFormFunc: true
|
10
|
+
useFormFunc: true,
|
11
|
+
useFormSchema: true
|
11
12
|
};
|
12
13
|
Object.defineProperty(exports, "default", {
|
13
14
|
enumerable: true,
|
@@ -33,6 +34,12 @@ Object.defineProperty(exports, "useFormFunc", {
|
|
33
34
|
return _formFuncContext.useFormFunc;
|
34
35
|
}
|
35
36
|
});
|
37
|
+
Object.defineProperty(exports, "useFormSchema", {
|
38
|
+
enumerable: true,
|
39
|
+
get: function get() {
|
40
|
+
return _formSchemaContext.useFormSchema;
|
41
|
+
}
|
42
|
+
});
|
36
43
|
var _useFormControl = require("./use-form-control");
|
37
44
|
Object.keys(_useFormControl).forEach(function (key) {
|
38
45
|
if (key === "default" || key === "__esModule") return;
|
@@ -93,7 +100,20 @@ Object.keys(_useFormContext).forEach(function (key) {
|
|
93
100
|
}
|
94
101
|
});
|
95
102
|
});
|
103
|
+
var _useFormSchema = require("./use-form-schema");
|
104
|
+
Object.keys(_useFormSchema).forEach(function (key) {
|
105
|
+
if (key === "default" || key === "__esModule") return;
|
106
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
107
|
+
if (key in exports && exports[key] === _useFormSchema[key]) return;
|
108
|
+
Object.defineProperty(exports, key, {
|
109
|
+
enumerable: true,
|
110
|
+
get: function get() {
|
111
|
+
return _useFormSchema[key];
|
112
|
+
}
|
113
|
+
});
|
114
|
+
});
|
96
115
|
var _useForm = _interopRequireDefault(require("./use-form"));
|
97
116
|
var _formConfigContext = require("./form-config-context");
|
98
117
|
var _formFuncContext = require("./form-func-context");
|
118
|
+
var _formSchemaContext = require("./form-schema-context");
|
99
119
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { SchemaProperty } from './use-form-schema/form-schema-builder';
|
1
2
|
export interface FormRef<Value = any> {
|
2
3
|
/**
|
3
4
|
* @en return form value
|
@@ -51,5 +52,10 @@ export interface FormRef<Value = any> {
|
|
51
52
|
* @cn 滚动到指定字段
|
52
53
|
*/
|
53
54
|
scrollToField: (name: string, scrollIntoViewOptions?: ScrollIntoViewOptions) => void;
|
55
|
+
/**
|
56
|
+
* @en get form schema
|
57
|
+
* @cn 获取表单的 schema
|
58
|
+
*/
|
59
|
+
getFormSchema: () => SchemaProperty | undefined;
|
54
60
|
}
|
55
61
|
//# sourceMappingURL=use-form-context.type.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-context.type.d.ts","sourceRoot":"","sources":["use-form-context.type.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,OAAO,CAAC,KAAK,GAAG,GAAG;IAClC;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,GAAG,KAAK,CAAC;IACzC;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IACzD;;;OAGG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5D;;;OAGG;IACH,uBAAuB,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACtE;;;OAGG;IACH,uBAAuB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACrE;;;OAGG;IACH,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;OAGG;IACH,GAAG,EAAE,CAAC,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7C;;;OAGG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,qBAAqB,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;
|
1
|
+
{"version":3,"file":"use-form-context.type.d.ts","sourceRoot":"","sources":["use-form-context.type.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,MAAM,WAAW,OAAO,CAAC,KAAK,GAAG,GAAG;IAClC;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,GAAG,KAAK,CAAC;IACzC;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IACzD;;;OAGG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5D;;;OAGG;IACH,uBAAuB,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACtE;;;OAGG;IACH,uBAAuB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACrE;;;OAGG;IACH,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;OAGG;IACH,GAAG,EAAE,CAAC,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7C;;;OAGG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,qBAAqB,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAErF;;;OAGG;IACH,aAAa,EAAE,MAAM,cAAc,GAAG,SAAS,CAAC;CACjD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"form-item-context.d.ts","sourceRoot":"","sources":["form-item-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,eAAe,yCAE1B,CAAC"}
|
1
|
+
{"version":3,"file":"form-item-context.d.ts","sourceRoot":"","sources":["form-item-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,eAAe,yCAE1B,CAAC"}
|
@@ -11,4 +11,5 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
11
11
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
12
12
|
var FormItemContext = exports.FormItemContext = /*#__PURE__*/React.createContext({
|
13
13
|
updateError: function updateError() {}
|
14
|
-
});
|
14
|
+
});
|
15
|
+
FormItemContext.displayName = 'FormItemContext';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
@@ -4,6 +4,12 @@
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
5
5
|
value: true
|
6
6
|
});
|
7
|
+
Object.defineProperty(exports, "FormItemContext", {
|
8
|
+
enumerable: true,
|
9
|
+
get: function get() {
|
10
|
+
return _formItemContext.FormItemContext;
|
11
|
+
}
|
12
|
+
});
|
7
13
|
Object.defineProperty(exports, "default", {
|
8
14
|
enumerable: true,
|
9
15
|
get: function get() {
|
@@ -17,4 +23,5 @@ Object.defineProperty(exports, "useFormItem", {
|
|
17
23
|
}
|
18
24
|
});
|
19
25
|
var _useFormItem = _interopRequireDefault(require("./use-form-item"));
|
26
|
+
var _formItemContext = require("./form-item-context");
|
20
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -0,0 +1,49 @@
|
|
1
|
+
interface SchemaMeta {
|
2
|
+
type?: string;
|
3
|
+
required?: boolean;
|
4
|
+
title?: string;
|
5
|
+
format?: string;
|
6
|
+
items?: any;
|
7
|
+
enum?: any[] | {
|
8
|
+
anyOf: any[];
|
9
|
+
};
|
10
|
+
description?: string;
|
11
|
+
[key: string]: any;
|
12
|
+
}
|
13
|
+
export interface SchemaProperty {
|
14
|
+
type?: string;
|
15
|
+
properties?: Record<string, SchemaProperty>;
|
16
|
+
items?: SchemaProperty;
|
17
|
+
required?: string[];
|
18
|
+
title?: string;
|
19
|
+
description?: string;
|
20
|
+
format?: string;
|
21
|
+
enum?: any;
|
22
|
+
[key: string]: any;
|
23
|
+
}
|
24
|
+
export declare class SchemaBuilder {
|
25
|
+
private schema;
|
26
|
+
constructor(formName: string);
|
27
|
+
updateSchema({ path, meta }: {
|
28
|
+
path: string;
|
29
|
+
meta: SchemaMeta;
|
30
|
+
}): void;
|
31
|
+
/**
|
32
|
+
* 根据组件信息构建 schema meta
|
33
|
+
*/
|
34
|
+
buildSchemaFromComponent(params: {
|
35
|
+
componentElement: any;
|
36
|
+
rules?: any[];
|
37
|
+
label?: string;
|
38
|
+
finalFieldId?: string;
|
39
|
+
separator?: string;
|
40
|
+
}): SchemaMeta;
|
41
|
+
parsePath(path?: string): string[] | null;
|
42
|
+
mergeSchema(currentSchema: SchemaProperty, pathSegments: string[], meta: SchemaMeta): void;
|
43
|
+
handleArraySegment(currentSchema: SchemaProperty, remainingSegments: string[], meta: SchemaMeta): void;
|
44
|
+
handleObjectProperty(currentSchema: SchemaProperty, propertyName: string, remainingSegments: string[], meta: SchemaMeta): void;
|
45
|
+
handleRequired(parentSchema: SchemaProperty, propertyName: string, isRequired: boolean): void;
|
46
|
+
getFormSchema(): SchemaProperty;
|
47
|
+
}
|
48
|
+
export {};
|
49
|
+
//# sourceMappingURL=form-schema-builder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"form-schema-builder.d.ts","sourceRoot":"","sources":["form-schema-builder.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG;QAAE,KAAK,EAAE,GAAG,EAAE,CAAA;KAAE,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAiB;gBACnB,QAAQ,EAAE,MAAM;IAQ5B,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,GAAG,IAAI;IAMtE;;OAEG;IACH,wBAAwB,CAAC,MAAM,EAAE;QAC/B,gBAAgB,EAAE,GAAG,CAAC;QACtB,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,UAAU;IAmId,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAuCzC,WAAW,CAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IAkB1F,kBAAkB,CAAC,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IAatG,oBAAoB,CAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IA0B9H,cAAc,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI;IAwB7F,aAAa,IAAI,cAAc;CAGhC"}
|
@@ -0,0 +1,311 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.SchemaBuilder = void 0;
|
7
|
+
var _excluded = ["required"];
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
10
|
+
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
14
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
16
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
18
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
19
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
20
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
22
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
23
|
+
var SchemaBuilder = exports.SchemaBuilder = /*#__PURE__*/function () {
|
24
|
+
function SchemaBuilder(formName) {
|
25
|
+
_classCallCheck(this, SchemaBuilder);
|
26
|
+
_defineProperty(this, "schema", void 0);
|
27
|
+
this.schema = {
|
28
|
+
type: 'object',
|
29
|
+
title: formName,
|
30
|
+
properties: {}
|
31
|
+
};
|
32
|
+
}
|
33
|
+
_createClass(SchemaBuilder, [{
|
34
|
+
key: "updateSchema",
|
35
|
+
value: function updateSchema(_ref) {
|
36
|
+
var path = _ref.path,
|
37
|
+
meta = _ref.meta;
|
38
|
+
var pathSegments = this.parsePath(path);
|
39
|
+
if (!pathSegments) return;
|
40
|
+
this.mergeSchema(this.schema, pathSegments, meta);
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* 根据组件信息构建 schema meta
|
45
|
+
*/
|
46
|
+
}, {
|
47
|
+
key: "buildSchemaFromComponent",
|
48
|
+
value: function buildSchemaFromComponent(params) {
|
49
|
+
var _componentElement$pro;
|
50
|
+
var componentElement = params.componentElement,
|
51
|
+
rules = params.rules,
|
52
|
+
label = params.label,
|
53
|
+
finalFieldId = params.finalFieldId,
|
54
|
+
separator = params.separator;
|
55
|
+
var fieldSchemaInfo = {
|
56
|
+
title: label
|
57
|
+
};
|
58
|
+
var data = componentElement.props.data;
|
59
|
+
var isRequired = rules === null || rules === void 0 ? void 0 : rules.some(function (rule) {
|
60
|
+
return rule.required;
|
61
|
+
});
|
62
|
+
fieldSchemaInfo.required = isRequired;
|
63
|
+
fieldSchemaInfo.description = '';
|
64
|
+
if (rules !== null && rules !== void 0 && rules.length) {
|
65
|
+
var messageRules = rules.filter(function (rule) {
|
66
|
+
return typeof rule.message === 'string';
|
67
|
+
});
|
68
|
+
if (messageRules.length) {
|
69
|
+
fieldSchemaInfo.description += "rules: ".concat(messageRules.map(function (rule) {
|
70
|
+
return rule.message;
|
71
|
+
}).join(', '), ";");
|
72
|
+
}
|
73
|
+
}
|
74
|
+
var itemType;
|
75
|
+
if (typeof componentElement.type === 'function') {
|
76
|
+
switch (componentElement.type.name) {
|
77
|
+
case 'Input':
|
78
|
+
fieldSchemaInfo.type = 'string';
|
79
|
+
break;
|
80
|
+
case 'InputNumber':
|
81
|
+
fieldSchemaInfo.type = 'number';
|
82
|
+
break;
|
83
|
+
case 'InputPassword':
|
84
|
+
fieldSchemaInfo.type = 'string';
|
85
|
+
break;
|
86
|
+
case 'Textarea':
|
87
|
+
fieldSchemaInfo.type = 'string';
|
88
|
+
break;
|
89
|
+
case 'Select':
|
90
|
+
case 'TreeSelect':
|
91
|
+
{
|
92
|
+
var format = componentElement.props.format || componentElement.props.keygen;
|
93
|
+
if (typeof componentElement.props.keygen !== 'boolean') {
|
94
|
+
if (typeof format === 'string') {
|
95
|
+
var _data$;
|
96
|
+
itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]) === 'object' ? _typeof(data === null || data === void 0 || (_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$[format]) : _typeof(data === null || data === void 0 ? void 0 : data[0]);
|
97
|
+
} else if (typeof format === 'function') {
|
98
|
+
itemType = _typeof(format(data === null || data === void 0 ? void 0 : data[0]));
|
99
|
+
} else {
|
100
|
+
itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]);
|
101
|
+
}
|
102
|
+
} else {
|
103
|
+
itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]);
|
104
|
+
}
|
105
|
+
if (componentElement.props.multiple) {
|
106
|
+
fieldSchemaInfo.type = 'array';
|
107
|
+
fieldSchemaInfo.items = {
|
108
|
+
type: itemType
|
109
|
+
};
|
110
|
+
} else {
|
111
|
+
fieldSchemaInfo.type = itemType;
|
112
|
+
}
|
113
|
+
// props.data格式: [
|
114
|
+
// { "value": 1, "title": "年假" },
|
115
|
+
// { "value": 2, "title": "调休" },
|
116
|
+
// { "value": 3, "title": "事假" },
|
117
|
+
// { "value": 4, "title": "病假" },
|
118
|
+
// { "value": 5, "title": "其他" }
|
119
|
+
// ]
|
120
|
+
// 转换为jsonschema中的enum格式:
|
121
|
+
// "enum": {
|
122
|
+
// "anyOf": [
|
123
|
+
// { "const": 1, "title": "年假" },
|
124
|
+
// { "const": 2, "title": "调休" },
|
125
|
+
// { "const": 3, "title": "事假" },
|
126
|
+
// { "const": 4, "title": "病假" },
|
127
|
+
// { "const": 5, "title": "其他" }
|
128
|
+
// ]
|
129
|
+
// }
|
130
|
+
fieldSchemaInfo.enum = {
|
131
|
+
anyOf: componentElement.props.data.map(function (item) {
|
132
|
+
return {
|
133
|
+
const: (item === null || item === void 0 ? void 0 : item[format]) || item,
|
134
|
+
title: (item === null || item === void 0 ? void 0 : item.title) || item
|
135
|
+
};
|
136
|
+
})
|
137
|
+
};
|
138
|
+
break;
|
139
|
+
}
|
140
|
+
case 'DatePicker':
|
141
|
+
if (componentElement.props.range) {
|
142
|
+
if (finalFieldId !== null && finalFieldId !== void 0 && finalFieldId.includes(separator || '')) {
|
143
|
+
fieldSchemaInfo.type = 'string';
|
144
|
+
fieldSchemaInfo.format = 'date';
|
145
|
+
} else {
|
146
|
+
fieldSchemaInfo.type = 'array';
|
147
|
+
fieldSchemaInfo.items = {
|
148
|
+
type: 'string',
|
149
|
+
format: 'date'
|
150
|
+
};
|
151
|
+
}
|
152
|
+
} else {
|
153
|
+
fieldSchemaInfo.type = 'string';
|
154
|
+
fieldSchemaInfo.format = 'date';
|
155
|
+
}
|
156
|
+
fieldSchemaInfo.description += "\u9ED8\u8BA4\u65F6\u95F4\uFF1A".concat(((_componentElement$pro = componentElement.props.defaultTime) === null || _componentElement$pro === void 0 ? void 0 : _componentElement$pro.toString()) || '', "; \u683C\u5F0F\uFF1A").concat(componentElement.props.format || '', " ");
|
157
|
+
break;
|
158
|
+
case 'Checkbox':
|
159
|
+
fieldSchemaInfo.type = 'array';
|
160
|
+
fieldSchemaInfo.items = {
|
161
|
+
type: 'string'
|
162
|
+
};
|
163
|
+
break;
|
164
|
+
case 'Radio':
|
165
|
+
fieldSchemaInfo.type = 'string';
|
166
|
+
break;
|
167
|
+
case 'Rate':
|
168
|
+
fieldSchemaInfo.type = 'number';
|
169
|
+
break;
|
170
|
+
default:
|
171
|
+
if (Array.isArray(componentElement.props.value) && componentElement.props.value.length === 0) {
|
172
|
+
fieldSchemaInfo.type = 'array';
|
173
|
+
fieldSchemaInfo.items = {
|
174
|
+
type: 'string'
|
175
|
+
};
|
176
|
+
} else {
|
177
|
+
fieldSchemaInfo.type = _typeof(componentElement.props.value);
|
178
|
+
}
|
179
|
+
break;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
return fieldSchemaInfo;
|
183
|
+
}
|
184
|
+
|
185
|
+
// 解析路径字符串,如 'a[0].b1' -> ['a', '[0]', 'b1']
|
186
|
+
}, {
|
187
|
+
key: "parsePath",
|
188
|
+
value: function parsePath(path) {
|
189
|
+
if (!path) return null;
|
190
|
+
var segments = [];
|
191
|
+
var current = '';
|
192
|
+
var inBracket = false;
|
193
|
+
for (var i = 0; i < path.length; i++) {
|
194
|
+
var char = path[i];
|
195
|
+
if (char === '[') {
|
196
|
+
if (current) {
|
197
|
+
segments.push(current);
|
198
|
+
current = '';
|
199
|
+
}
|
200
|
+
current = '[';
|
201
|
+
inBracket = true;
|
202
|
+
} else if (char === ']') {
|
203
|
+
current += ']';
|
204
|
+
segments.push(current);
|
205
|
+
current = '';
|
206
|
+
inBracket = false;
|
207
|
+
} else if (char === '.' && !inBracket) {
|
208
|
+
if (current) {
|
209
|
+
segments.push(current);
|
210
|
+
current = '';
|
211
|
+
}
|
212
|
+
} else {
|
213
|
+
current += char;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
if (current) {
|
217
|
+
segments.push(current);
|
218
|
+
}
|
219
|
+
return segments;
|
220
|
+
}
|
221
|
+
|
222
|
+
// 递归合并 schema
|
223
|
+
}, {
|
224
|
+
key: "mergeSchema",
|
225
|
+
value: function mergeSchema(currentSchema, pathSegments, meta) {
|
226
|
+
if (pathSegments.length === 0) {
|
227
|
+
// 到达叶子节点,应用元数据
|
228
|
+
Object.assign(currentSchema, meta);
|
229
|
+
return;
|
230
|
+
}
|
231
|
+
var _pathSegments = _toArray(pathSegments),
|
232
|
+
currentSegment = _pathSegments[0],
|
233
|
+
remainingSegments = _pathSegments.slice(1);
|
234
|
+
if (currentSegment.startsWith('[') && currentSegment.endsWith(']')) {
|
235
|
+
// 处理数组索引,如 [0]
|
236
|
+
this.handleArraySegment(currentSchema, remainingSegments, meta);
|
237
|
+
} else {
|
238
|
+
// 处理对象属性
|
239
|
+
this.handleObjectProperty(currentSchema, currentSegment, remainingSegments, meta);
|
240
|
+
}
|
241
|
+
}
|
242
|
+
}, {
|
243
|
+
key: "handleArraySegment",
|
244
|
+
value: function handleArraySegment(currentSchema, remainingSegments, meta) {
|
245
|
+
// 当前节点应该是数组类型
|
246
|
+
if (!currentSchema.items) {
|
247
|
+
currentSchema.type = 'array';
|
248
|
+
currentSchema.items = {
|
249
|
+
type: 'object',
|
250
|
+
properties: {}
|
251
|
+
};
|
252
|
+
}
|
253
|
+
this.mergeSchema(currentSchema.items, remainingSegments, meta);
|
254
|
+
}
|
255
|
+
}, {
|
256
|
+
key: "handleObjectProperty",
|
257
|
+
value: function handleObjectProperty(currentSchema, propertyName, remainingSegments, meta) {
|
258
|
+
// 确保当前节点有 properties
|
259
|
+
if (!currentSchema.properties) {
|
260
|
+
currentSchema.properties = {};
|
261
|
+
}
|
262
|
+
|
263
|
+
// 如果属性不存在,创建它
|
264
|
+
if (!currentSchema.properties[propertyName]) {
|
265
|
+
currentSchema.properties[propertyName] = remainingSegments.length > 0 ? {
|
266
|
+
type: 'object'
|
267
|
+
} : {};
|
268
|
+
}
|
269
|
+
if (remainingSegments.length === 0) {
|
270
|
+
// 叶子节点,应用元数据并处理 required
|
271
|
+
var required = meta.required,
|
272
|
+
restMeta = _objectWithoutProperties(meta, _excluded);
|
273
|
+
Object.assign(currentSchema.properties[propertyName], restMeta);
|
274
|
+
if (typeof required === 'boolean') {
|
275
|
+
this.handleRequired(currentSchema, propertyName, required);
|
276
|
+
}
|
277
|
+
} else {
|
278
|
+
// 继续递归
|
279
|
+
this.mergeSchema(currentSchema.properties[propertyName], remainingSegments, meta);
|
280
|
+
}
|
281
|
+
}
|
282
|
+
}, {
|
283
|
+
key: "handleRequired",
|
284
|
+
value: function handleRequired(parentSchema, propertyName, isRequired) {
|
285
|
+
// 如果required是布尔值,转换为数组形式
|
286
|
+
if (typeof parentSchema.required === 'boolean') {
|
287
|
+
return;
|
288
|
+
}
|
289
|
+
if (!parentSchema.required) {
|
290
|
+
parentSchema.required = [];
|
291
|
+
}
|
292
|
+
var requiredIndex = parentSchema.required.indexOf(propertyName);
|
293
|
+
if (isRequired && requiredIndex === -1) {
|
294
|
+
parentSchema.required.push(propertyName);
|
295
|
+
} else if (!isRequired && requiredIndex !== -1) {
|
296
|
+
parentSchema.required.splice(requiredIndex, 1);
|
297
|
+
}
|
298
|
+
|
299
|
+
// 如果 required 数组为空,删除它
|
300
|
+
if (parentSchema.required.length === 0) {
|
301
|
+
delete parentSchema.required;
|
302
|
+
}
|
303
|
+
}
|
304
|
+
}, {
|
305
|
+
key: "getFormSchema",
|
306
|
+
value: function getFormSchema() {
|
307
|
+
return this.schema;
|
308
|
+
}
|
309
|
+
}]);
|
310
|
+
return SchemaBuilder;
|
311
|
+
}();
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
"use client";
|
3
|
+
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
Object.defineProperty(exports, "SchemaBuilder", {
|
8
|
+
enumerable: true,
|
9
|
+
get: function get() {
|
10
|
+
return _formSchemaBuilder.SchemaBuilder;
|
11
|
+
}
|
12
|
+
});
|
13
|
+
var _formSchemaBuilder = require("./form-schema-builder");
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { SchemaBuilder } from './use-form-schema/form-schema-builder';
|
1
2
|
import { ProviderProps, UseFormProps, UseFormSlotProps, ValidateFnConfig } from './use-form.type';
|
2
3
|
import { ObjectType } from '../../common/type';
|
3
4
|
declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
@@ -24,7 +25,9 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
24
25
|
insertError: (name: string, index: number, error?: Error) => void;
|
25
26
|
spliceError: (name: string, index: number) => void;
|
26
27
|
scrollToField: (name: string, scrollIntoViewOptions?: ScrollIntoViewOptions) => void;
|
28
|
+
getFormSchema: () => import("./use-form-schema/form-schema-builder").SchemaProperty | undefined;
|
27
29
|
};
|
30
|
+
formSchema: SchemaBuilder | null;
|
28
31
|
};
|
29
32
|
formFunc: {
|
30
33
|
setValue: (vals: {
|
@@ -44,6 +47,7 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
44
47
|
insertError: (name: string, index: number, error?: Error) => void;
|
45
48
|
spliceError: (name: string, index: number) => void;
|
46
49
|
scrollToField: (name: string, scrollIntoViewOptions?: ScrollIntoViewOptions) => void;
|
50
|
+
getFormSchema: () => import("./use-form-schema/form-schema-builder").SchemaProperty | undefined;
|
47
51
|
};
|
48
52
|
};
|
49
53
|
export default useForm;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AA2BtE,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGhB,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAqSC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,WAAW,CAAC,EAAE,OAAO,CAAA;aAAE;8BArPnB,MAAM;oCAoUD,OAAO,aAAoB,MAAM,IAAI;;6BAf3C,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCA/RxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;qCAkWvB,MAAM,WAAW,gBAAgB;gCAhDzB,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;kCArJpD,MAAM,0BAAyB,qBAAqB;;;;;;;;oBA2EjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,WAAW,CAAC,EAAE,OAAO,CAAA;SAAE;0BArPnB,MAAM;gCAoUD,OAAO,aAAoB,MAAM,IAAI;;yBAf3C,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCA/RxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;iCAkWvB,MAAM,WAAW,gBAAgB;4BAhDzB,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;8BArJpD,MAAM,0BAAyB,qBAAqB;;;CA4b9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|