@sheinx/hooks 3.0.0-alpha.23 → 3.0.0-alpha.24
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/use-form-control/use-form-control.d.ts +1 -0
- package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-control/use-form-control.js +2 -1
- package/cjs/components/use-form/use-form-fieldset/fieldset-context.d.ts +1 -1
- package/cjs/components/use-form/use-form-fieldset/fieldset-context.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-fieldset/fieldset-context.js +15 -8
- package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.d.ts +1 -1
- package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.js +7 -15
- package/esm/components/use-form/use-form-control/use-form-control.d.ts +1 -0
- package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/esm/components/use-form/use-form-control/use-form-control.js +2 -1
- package/esm/components/use-form/use-form-fieldset/fieldset-context.d.ts +1 -1
- package/esm/components/use-form/use-form-fieldset/fieldset-context.d.ts.map +1 -1
- package/esm/components/use-form/use-form-fieldset/fieldset-context.js +15 -8
- package/esm/components/use-form/use-form-fieldset/use-form-fieldset.d.ts +1 -1
- package/esm/components/use-form/use-form-fieldset/use-form-fieldset.d.ts.map +1 -1
- package/esm/components/use-form/use-form-fieldset/use-form-fieldset.js +7 -15
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAwB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBAsFpC,CAAC,YAAY,GAAG,EAAE
|
1
|
+
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAwB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBAsFpC,CAAC,YAAY,GAAG,EAAE;;;;;EA8CrD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fieldset-context.d.ts","sourceRoot":"","sources":["fieldset-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,QAAA,MAAM,eAAe;;EAA8B,CAAC;AAEpD,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;
|
1
|
+
{"version":3,"file":"fieldset-context.d.ts","sourceRoot":"","sources":["fieldset-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,QAAA,MAAM,eAAe;;EAA8B,CAAC;AAEpD,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;AAiBD,eAAO,MAAM,mBAAmB;;;CAc/B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
'use client';
|
3
3
|
|
4
4
|
require("core-js/modules/es.array.filter.js");
|
5
5
|
require("core-js/modules/web.dom-collections.for-each.js");
|
@@ -14,8 +14,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
14
14
|
});
|
15
15
|
exports.useFieldSetConsumer = exports.default = void 0;
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
17
|
-
require("core-js/modules/es.array.concat.js");
|
18
17
|
require("core-js/modules/es.array.map.js");
|
18
|
+
require("core-js/modules/es.array.concat.js");
|
19
19
|
var _react = _interopRequireWildcard(require("react"));
|
20
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
21
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -24,6 +24,18 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
24
24
|
var FieldsetContext = /*#__PURE__*/(0, _react.createContext)({
|
25
25
|
path: ''
|
26
26
|
});
|
27
|
+
function extendName() {
|
28
|
+
var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
29
|
+
var name = arguments.length > 1 ? arguments[1] : undefined;
|
30
|
+
if (name === undefined) return undefined;
|
31
|
+
if (name === '') return path;
|
32
|
+
if (Array.isArray(name)) {
|
33
|
+
return name.map(function (n) {
|
34
|
+
return extendName(path, n);
|
35
|
+
});
|
36
|
+
}
|
37
|
+
return "".concat(path).concat(path.length > 0 ? '.' : '').concat(name);
|
38
|
+
}
|
27
39
|
var useFieldSetConsumer = function useFieldSetConsumer(props) {
|
28
40
|
var _React$useContext = _react.default.useContext(FieldsetContext),
|
29
41
|
path = _React$useContext.path;
|
@@ -31,12 +43,7 @@ var useFieldSetConsumer = function useFieldSetConsumer(props) {
|
|
31
43
|
return path ? (props.bind || []).concat(path) : props.bind;
|
32
44
|
}, [path, props.bind]);
|
33
45
|
var name = _react.default.useMemo(function () {
|
34
|
-
|
35
|
-
return props.name.map(function (item) {
|
36
|
-
return path ? "".concat(path, ".").concat(item) : item;
|
37
|
-
});
|
38
|
-
}
|
39
|
-
return path ? "".concat(path, ".").concat(props.name) : props.name;
|
46
|
+
return extendName(path, props.name);
|
40
47
|
}, [path, props.name]);
|
41
48
|
return _objectSpread(_objectSpread({}, props), {}, {
|
42
49
|
name: name,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-fieldset.d.ts","sourceRoot":"","sources":["use-form-fieldset.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"use-form-fieldset.d.ts","sourceRoot":"","sources":["use-form-fieldset.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAKjE,eAAO,MAAM,eAAe;;;;;;;;;;CA0B3B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -1,38 +1,30 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
require("
|
4
|
-
require("core-js/modules/es.weak-map.js");
|
5
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
6
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
7
4
|
Object.defineProperty(exports, "__esModule", {
|
8
5
|
value: true
|
9
6
|
});
|
10
7
|
exports.useFormFieldSet = exports.default = void 0;
|
11
|
-
var _fieldsetContext =
|
8
|
+
var _fieldsetContext = _interopRequireDefault(require("./fieldset-context"));
|
12
9
|
var _useFormControl2 = require("../use-form-control");
|
13
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
15
10
|
var emptyFunc = function emptyFunc() {};
|
11
|
+
var emptyArr = [];
|
16
12
|
var useFormFieldSet = function useFormFieldSet(props) {
|
17
|
-
var _useFieldSetConsumer = (0, _fieldsetContext.useFieldSetConsumer)({
|
18
|
-
name: props.name
|
19
|
-
}),
|
20
|
-
name = _useFieldSetConsumer.name,
|
21
|
-
bind = _useFieldSetConsumer.bind;
|
22
13
|
var _useFormControl = (0, _useFormControl2.useFormControl)({
|
23
|
-
name: name,
|
14
|
+
name: props.name,
|
24
15
|
defaultValue: props.defaultValue,
|
25
16
|
reserveAble: props.reserveAble,
|
26
17
|
rules: props.rules,
|
27
18
|
onError: props.onError,
|
28
|
-
bind:
|
19
|
+
bind: emptyArr,
|
29
20
|
onChange: emptyFunc,
|
30
21
|
getValidateProps: props.getValidateProps
|
31
22
|
}),
|
32
23
|
inForm = _useFormControl.inForm,
|
33
24
|
error = _useFormControl.error,
|
34
25
|
value = _useFormControl.value,
|
35
|
-
onChange = _useFormControl.onChange
|
26
|
+
onChange = _useFormControl.onChange,
|
27
|
+
name = _useFormControl.name;
|
36
28
|
if (!inForm) {
|
37
29
|
console.error('[FieldSet] should render in Form');
|
38
30
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAwB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBAsFpC,CAAC,YAAY,GAAG,EAAE
|
1
|
+
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAwB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBAsFpC,CAAC,YAAY,GAAG,EAAE;;;;;EA8CrD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fieldset-context.d.ts","sourceRoot":"","sources":["fieldset-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,QAAA,MAAM,eAAe;;EAA8B,CAAC;AAEpD,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;
|
1
|
+
{"version":3,"file":"fieldset-context.d.ts","sourceRoot":"","sources":["fieldset-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,QAAA,MAAM,eAAe;;EAA8B,CAAC;AAEpD,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;AAiBD,eAAO,MAAM,mBAAmB;;;CAc/B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
'use client';
|
3
3
|
|
4
4
|
require("core-js/modules/es.array.filter.js");
|
5
5
|
require("core-js/modules/web.dom-collections.for-each.js");
|
@@ -14,8 +14,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
14
14
|
});
|
15
15
|
exports.useFieldSetConsumer = exports.default = void 0;
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
17
|
-
require("core-js/modules/es.array.concat.js");
|
18
17
|
require("core-js/modules/es.array.map.js");
|
18
|
+
require("core-js/modules/es.array.concat.js");
|
19
19
|
var _react = _interopRequireWildcard(require("react"));
|
20
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
21
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -24,6 +24,18 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
24
24
|
var FieldsetContext = /*#__PURE__*/(0, _react.createContext)({
|
25
25
|
path: ''
|
26
26
|
});
|
27
|
+
function extendName() {
|
28
|
+
var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
29
|
+
var name = arguments.length > 1 ? arguments[1] : undefined;
|
30
|
+
if (name === undefined) return undefined;
|
31
|
+
if (name === '') return path;
|
32
|
+
if (Array.isArray(name)) {
|
33
|
+
return name.map(function (n) {
|
34
|
+
return extendName(path, n);
|
35
|
+
});
|
36
|
+
}
|
37
|
+
return "".concat(path).concat(path.length > 0 ? '.' : '').concat(name);
|
38
|
+
}
|
27
39
|
var useFieldSetConsumer = function useFieldSetConsumer(props) {
|
28
40
|
var _React$useContext = _react.default.useContext(FieldsetContext),
|
29
41
|
path = _React$useContext.path;
|
@@ -31,12 +43,7 @@ var useFieldSetConsumer = function useFieldSetConsumer(props) {
|
|
31
43
|
return path ? (props.bind || []).concat(path) : props.bind;
|
32
44
|
}, [path, props.bind]);
|
33
45
|
var name = _react.default.useMemo(function () {
|
34
|
-
|
35
|
-
return props.name.map(function (item) {
|
36
|
-
return path ? "".concat(path, ".").concat(item) : item;
|
37
|
-
});
|
38
|
-
}
|
39
|
-
return path ? "".concat(path, ".").concat(props.name) : props.name;
|
46
|
+
return extendName(path, props.name);
|
40
47
|
}, [path, props.name]);
|
41
48
|
return _objectSpread(_objectSpread({}, props), {}, {
|
42
49
|
name: name,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-fieldset.d.ts","sourceRoot":"","sources":["use-form-fieldset.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"use-form-fieldset.d.ts","sourceRoot":"","sources":["use-form-fieldset.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAKjE,eAAO,MAAM,eAAe;;;;;;;;;;CA0B3B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -1,38 +1,30 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
require("
|
4
|
-
require("core-js/modules/es.weak-map.js");
|
5
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
6
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
7
4
|
Object.defineProperty(exports, "__esModule", {
|
8
5
|
value: true
|
9
6
|
});
|
10
7
|
exports.useFormFieldSet = exports.default = void 0;
|
11
|
-
var _fieldsetContext =
|
8
|
+
var _fieldsetContext = _interopRequireDefault(require("./fieldset-context"));
|
12
9
|
var _useFormControl2 = require("../use-form-control");
|
13
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
15
10
|
var emptyFunc = function emptyFunc() {};
|
11
|
+
var emptyArr = [];
|
16
12
|
var useFormFieldSet = function useFormFieldSet(props) {
|
17
|
-
var _useFieldSetConsumer = (0, _fieldsetContext.useFieldSetConsumer)({
|
18
|
-
name: props.name
|
19
|
-
}),
|
20
|
-
name = _useFieldSetConsumer.name,
|
21
|
-
bind = _useFieldSetConsumer.bind;
|
22
13
|
var _useFormControl = (0, _useFormControl2.useFormControl)({
|
23
|
-
name: name,
|
14
|
+
name: props.name,
|
24
15
|
defaultValue: props.defaultValue,
|
25
16
|
reserveAble: props.reserveAble,
|
26
17
|
rules: props.rules,
|
27
18
|
onError: props.onError,
|
28
|
-
bind:
|
19
|
+
bind: emptyArr,
|
29
20
|
onChange: emptyFunc,
|
30
21
|
getValidateProps: props.getValidateProps
|
31
22
|
}),
|
32
23
|
inForm = _useFormControl.inForm,
|
33
24
|
error = _useFormControl.error,
|
34
25
|
value = _useFormControl.value,
|
35
|
-
onChange = _useFormControl.onChange
|
26
|
+
onChange = _useFormControl.onChange,
|
27
|
+
name = _useFormControl.name;
|
36
28
|
if (!inForm) {
|
37
29
|
console.error('[FieldSet] should render in Form');
|
38
30
|
}
|