@sheinx/hooks 3.8.0-beta.8 → 3.8.0-fix.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/common/use-filter/use-filter.d.ts.map +1 -1
- package/cjs/common/use-filter/use-filter.js +4 -1
- package/cjs/common/use-input-able/use-Input-able.d.ts.map +1 -1
- package/cjs/common/use-input-able/use-Input-able.js +6 -7
- package/cjs/common/use-position-style/check-border.d.ts +1 -0
- package/cjs/common/use-position-style/check-border.d.ts.map +1 -1
- package/cjs/common/use-position-style/check-border.js +2 -2
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +10 -4
- package/cjs/components/use-check/use-check.d.ts.map +1 -1
- package/cjs/components/use-check/use-check.js +10 -2
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.js +1 -0
- package/cjs/components/use-datepicker/use-time.d.ts +10 -8
- package/cjs/components/use-datepicker/use-time.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-time.js +19 -5
- package/cjs/components/use-datepicker/use-time.type.d.ts +5 -1
- package/cjs/components/use-datepicker/use-time.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/util.d.ts.map +1 -1
- package/cjs/components/use-datepicker/util.js +10 -1
- 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.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-context.js +11 -5
- 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-control/use-form-control.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-control/use-form-control.js +34 -4
- package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts +8 -2
- package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts +8 -0
- package/cjs/components/use-form/use-form-flow/use-form-datum.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-item/use-form-item.d.ts +1 -1
- package/cjs/components/use-form/use-form-schema/form-schema-builder.d.ts +50 -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 +377 -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 +19 -9
- package/cjs/components/use-form/use-form.type.d.ts +46 -39
- package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
- package/cjs/components/use-input/use-input-number.d.ts.map +1 -1
- package/cjs/components/use-input/use-input-number.js +3 -1
- package/cjs/components/use-input/use-input-number.type.d.ts +1 -1
- package/cjs/components/use-input/use-input-number.type.d.ts.map +1 -1
- package/cjs/components/use-input/use-input.d.ts.map +1 -1
- package/cjs/components/use-input/use-input.js +4 -1
- package/cjs/components/use-pagination/use-pagination.d.ts.map +1 -1
- package/cjs/components/use-pagination/use-pagination.js +2 -1
- package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
- package/cjs/components/use-popup/use-popup.js +12 -24
- package/cjs/components/use-select/use-select.type.d.ts +27 -18
- package/cjs/components/use-select/use-select.type.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-virtual.d.ts +6 -1
- package/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-virtual.js +5 -4
- package/cjs/components/use-table/use-table.type.d.ts +70 -92
- package/cjs/components/use-table/use-table.type.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree-node.d.ts +7 -1
- package/cjs/components/use-tree/use-tree-node.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree-node.js +19 -1
- package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree.js +26 -19
- package/cjs/components/use-tree/use-tree.type.d.ts +7 -1
- package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/cjs/utils/dom/document.d.ts +4 -0
- package/cjs/utils/dom/document.d.ts.map +1 -1
- package/cjs/utils/dom/document.js +19 -2
- 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/cjs/utils/highlight.d.ts.map +1 -1
- package/cjs/utils/highlight.js +24 -11
- package/cjs/utils/lazyload.d.ts.map +1 -1
- package/cjs/utils/lazyload.js +33 -1
- package/cjs/utils/object.d.ts +6 -0
- package/cjs/utils/object.d.ts.map +1 -1
- package/cjs/utils/object.js +21 -1
- package/esm/common/use-filter/use-filter.d.ts.map +1 -1
- package/esm/common/use-filter/use-filter.js +4 -1
- package/esm/common/use-input-able/use-Input-able.d.ts.map +1 -1
- package/esm/common/use-input-able/use-Input-able.js +7 -8
- package/esm/common/use-position-style/check-border.d.ts +1 -0
- package/esm/common/use-position-style/check-border.d.ts.map +1 -1
- package/esm/common/use-position-style/check-border.js +2 -2
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +11 -5
- package/esm/components/use-check/use-check.d.ts.map +1 -1
- package/esm/components/use-check/use-check.js +10 -2
- package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.js +1 -0
- package/esm/components/use-datepicker/use-time.d.ts +10 -8
- package/esm/components/use-datepicker/use-time.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-time.js +19 -5
- package/esm/components/use-datepicker/use-time.type.d.ts +5 -1
- package/esm/components/use-datepicker/use-time.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/util.d.ts.map +1 -1
- package/esm/components/use-datepicker/util.js +10 -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.d.ts.map +1 -1
- package/esm/components/use-form/use-form-context.js +11 -5
- 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-control/use-form-control.d.ts.map +1 -1
- package/esm/components/use-form/use-form-control/use-form-control.js +34 -4
- package/esm/components/use-form/use-form-control/use-form-control.type.d.ts +8 -2
- package/esm/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
- package/esm/components/use-form/use-form-flow/use-form-datum.d.ts +8 -0
- package/esm/components/use-form/use-form-flow/use-form-datum.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-item/use-form-item.d.ts +1 -1
- package/esm/components/use-form/use-form-schema/form-schema-builder.d.ts +50 -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 +371 -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 +19 -9
- package/esm/components/use-form/use-form.type.d.ts +46 -39
- package/esm/components/use-form/use-form.type.d.ts.map +1 -1
- package/esm/components/use-input/use-input-number.d.ts.map +1 -1
- package/esm/components/use-input/use-input-number.js +3 -1
- package/esm/components/use-input/use-input-number.type.d.ts +1 -1
- package/esm/components/use-input/use-input-number.type.d.ts.map +1 -1
- package/esm/components/use-input/use-input.d.ts.map +1 -1
- package/esm/components/use-input/use-input.js +4 -1
- package/esm/components/use-pagination/use-pagination.d.ts.map +1 -1
- package/esm/components/use-pagination/use-pagination.js +2 -1
- package/esm/components/use-popup/use-popup.d.ts.map +1 -1
- package/esm/components/use-popup/use-popup.js +12 -24
- package/esm/components/use-select/use-select.type.d.ts +27 -18
- package/esm/components/use-select/use-select.type.d.ts.map +1 -1
- package/esm/components/use-table/use-table-virtual.d.ts +6 -1
- package/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/esm/components/use-table/use-table-virtual.js +5 -4
- package/esm/components/use-table/use-table.type.d.ts +70 -92
- package/esm/components/use-table/use-table.type.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree-node.d.ts +7 -1
- package/esm/components/use-tree/use-tree-node.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree-node.js +19 -1
- package/esm/components/use-tree/use-tree.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree.js +26 -19
- package/esm/components/use-tree/use-tree.type.d.ts +7 -1
- package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/esm/utils/dom/document.d.ts +4 -0
- package/esm/utils/dom/document.d.ts.map +1 -1
- package/esm/utils/dom/document.js +18 -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/esm/utils/highlight.d.ts.map +1 -1
- package/esm/utils/highlight.js +24 -10
- package/esm/utils/lazyload.d.ts.map +1 -1
- package/esm/utils/lazyload.js +33 -1
- package/esm/utils/object.d.ts +6 -0
- package/esm/utils/object.d.ts.map +1 -1
- package/esm/utils/object.js +20 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-filter.d.ts","sourceRoot":"","sources":["use-filter.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,QAAA,MAAM,SAAS;;;;;;;;;;kCAmBkD,OAAO;
|
|
1
|
+
{"version":3,"file":"use-filter.d.ts","sourceRoot":"","sources":["use-filter.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,QAAA,MAAM,SAAS;;;;;;;;;;kCAmBkD,OAAO;sBAoB1C,MAAM;sBAKN,MAAM,SAAQ,MAAM;;;CAsGjD,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -58,7 +58,10 @@ var useFilter = function useFilter(props) {
|
|
|
58
58
|
return (0, _utils.getKey)(keygen, item) === key;
|
|
59
59
|
};
|
|
60
60
|
var handleClearCreatedData = function handleClearCreatedData() {
|
|
61
|
-
|
|
61
|
+
// why setTimeout: 避免回车时,新创建的数据走到了renderUnmatched逻辑中去
|
|
62
|
+
setTimeout(function () {
|
|
63
|
+
setCreatedData(undefined);
|
|
64
|
+
}, 0);
|
|
62
65
|
};
|
|
63
66
|
var handleCreate = function handleCreate(text) {
|
|
64
67
|
var createFn = typeof onCreate === 'boolean' ? function (t) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EA6E3F"}
|
|
@@ -46,19 +46,18 @@ function useInputAble(props) {
|
|
|
46
46
|
var render = (0, _useRender.useRender)(syncValue);
|
|
47
47
|
var shouldUseState = delay || !control;
|
|
48
48
|
var value = shouldUseState ? stateValue : valuePo;
|
|
49
|
-
(0, _react.
|
|
50
|
-
if (context.timer) {
|
|
51
|
-
clearTimeout(context.timer);
|
|
52
|
-
context.timer = null;
|
|
53
|
-
}
|
|
49
|
+
(0, _react.useLayoutEffect)(function () {
|
|
54
50
|
if (delay && control && props.value !== stateValue) {
|
|
55
51
|
changeStateValue(props.value);
|
|
52
|
+
} else if (context.timer) {
|
|
53
|
+
clearTimeout(context.timer);
|
|
54
|
+
context.timer = null;
|
|
56
55
|
}
|
|
57
56
|
}, [props.value, delay, control]);
|
|
58
57
|
var forceDelayChange = (0, _usePersistFn.default)(function () {
|
|
59
|
-
if (context.
|
|
58
|
+
if (context.delayChange) context.delayChange();
|
|
59
|
+
if (context.timer) {
|
|
60
60
|
clearTimeout(context.timer);
|
|
61
|
-
context.delayChange();
|
|
62
61
|
context.timer = null;
|
|
63
62
|
context.delayChange = null;
|
|
64
63
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface UseCheckElementBorderWidthOptions {
|
|
2
2
|
direction?: 'horizontal' | 'vertical';
|
|
3
|
+
enable?: boolean;
|
|
3
4
|
}
|
|
4
5
|
export declare const useCheckElementBorderWidth: (elementRef: React.RefObject<HTMLElement>, options?: UseCheckElementBorderWidthOptions) => number;
|
|
5
6
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-border.d.ts","sourceRoot":"","sources":["check-border.ts"],"names":[],"mappings":"AAEA,UAAU,iCAAiC;IAGzC,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"check-border.d.ts","sourceRoot":"","sources":["check-border.ts"],"names":[],"mappings":"AAEA,UAAU,iCAAiC;IAGzC,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAGD,eAAO,MAAM,0BAA0B,eACzB,MAAM,SAAS,CAAC,WAAW,CAAC,YAC/B,iCAAiC,KACzC,MAqBF,CAAC"}
|
|
@@ -20,14 +20,14 @@ var useCheckElementBorderWidth = exports.useCheckElementBorderWidth = function u
|
|
|
20
20
|
|
|
21
21
|
// 获取指定方向上的border宽度之和
|
|
22
22
|
var getBorderWidth = (0, _react.useCallback)(function () {
|
|
23
|
-
if (elementRef.current) {
|
|
23
|
+
if (elementRef.current && options.enable) {
|
|
24
24
|
var _options$direction = options.direction,
|
|
25
25
|
direction = _options$direction === void 0 ? 'horizontal' : _options$direction;
|
|
26
26
|
var style = window.getComputedStyle(elementRef.current);
|
|
27
27
|
var _borderWidth = direction === 'horizontal' ? parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth) : parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
|
28
28
|
setBorderWidth(_borderWidth);
|
|
29
29
|
}
|
|
30
|
-
}, [elementRef]);
|
|
30
|
+
}, [elementRef, options.enable]);
|
|
31
31
|
(0, _react.useEffect)(function () {
|
|
32
32
|
getBorderWidth();
|
|
33
33
|
}, [getBorderWidth]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAUpE,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,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CAAC,CAAC;CAC3B;AAsBD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA+S3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -88,7 +88,8 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
|
88
88
|
enable: show && adjust
|
|
89
89
|
});
|
|
90
90
|
var parentElBorderWidth = (0, _checkBorder.useCheckElementBorderWidth)(parentElRef, {
|
|
91
|
-
direction: 'horizontal'
|
|
91
|
+
direction: 'horizontal',
|
|
92
|
+
enable: show
|
|
92
93
|
});
|
|
93
94
|
var popupElSize = (0, _checkElementSize.useCheckElementSize)(popupElRef, {
|
|
94
95
|
enable: show
|
|
@@ -244,7 +245,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
|
244
245
|
_v = _targetPosition$split4[1];
|
|
245
246
|
if (_v === 'top') {
|
|
246
247
|
style.top = rect.top - containerRect.top + containerScroll.top - (offset ? offset[1] : 0);
|
|
247
|
-
setTransform(style, '');
|
|
248
|
+
setTransform(style, 'translateX(0%)');
|
|
248
249
|
} else if (_v === 'bottom') {
|
|
249
250
|
style.top = rect.bottom - containerRect.top + containerScroll.top + (offset ? offset[1] : 0);
|
|
250
251
|
setTransform(style, 'translateY(-100%)');
|
|
@@ -273,10 +274,13 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
|
273
274
|
};
|
|
274
275
|
var rect = context.parentRect;
|
|
275
276
|
var needCheck = !show || !(0, _shallowEqual.default)(context.prevParentPosition, parentElNewPosition);
|
|
277
|
+
var _getScrollPosition = (0, _utils.getScrollPosition)(scrollElRef === null || scrollElRef === void 0 ? void 0 : scrollElRef.current),
|
|
278
|
+
scrollTop = _getScrollPosition.scrollTop,
|
|
279
|
+
scrollLeft = _getScrollPosition.scrollLeft;
|
|
276
280
|
if (needCheck && scrollElRef !== null && scrollElRef !== void 0 && scrollElRef.current && (_scrollElRef$current = scrollElRef.current) !== null && _scrollElRef$current !== void 0 && _scrollElRef$current.contains(parentElRef.current)) {
|
|
277
281
|
var _scrollElRef$current2;
|
|
278
282
|
var visibleRect = ((_scrollElRef$current2 = scrollElRef.current) === null || _scrollElRef$current2 === void 0 ? void 0 : _scrollElRef$current2.getBoundingClientRect()) || {};
|
|
279
|
-
if (rect.bottom < visibleRect.top || rect.top > visibleRect.bottom || rect.right < visibleRect.left || rect.left > visibleRect.right) {
|
|
283
|
+
if (rect.bottom < visibleRect.top || rect.top > visibleRect.bottom + scrollTop || rect.right < visibleRect.left || rect.left > visibleRect.right + scrollLeft) {
|
|
280
284
|
return {
|
|
281
285
|
style: hideStyle
|
|
282
286
|
};
|
|
@@ -349,7 +353,9 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
|
349
353
|
}
|
|
350
354
|
|
|
351
355
|
// 当父元素的滚动容器滚动时,判断是否需要更新弹出层位置,包括是否隐藏弹出层(通过hideStyle隐藏,不是show状态)
|
|
352
|
-
|
|
356
|
+
if (show) {
|
|
357
|
+
context.prevParentPosition = parentElNewPosition;
|
|
358
|
+
}
|
|
353
359
|
});
|
|
354
360
|
(0, _react.useEffect)(updateStyle, [show, position, absolute, updateKey, fixedWidth, parentElNewPosition, popupElSize]);
|
|
355
361
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-check.d.ts","sourceRoot":"","sources":["use-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;
|
|
1
|
+
{"version":3,"file":"use-check.d.ts","sourceRoot":"","sources":["use-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;qBAgEpB,gBAAgB,CAAC,gBAAgB,CAAC;0BArBT,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;;;;;yBA5Ba,gBAAgB;;;;CA0E3G,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -46,11 +46,19 @@ var useCheck = function useCheck(props) {
|
|
|
46
46
|
var handleInputRef = (0, _useForkRef.default)(inputRef, inputRefPo);
|
|
47
47
|
var handleClick = function handleClick(otherHandlers, needStopPropagation) {
|
|
48
48
|
return function (event) {
|
|
49
|
-
var
|
|
49
|
+
var _otherHandlers$onClic;
|
|
50
50
|
if (needStopPropagation) {
|
|
51
51
|
event.stopPropagation();
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
|
|
54
|
+
// 检查是否被 label 元素包裹,如果是则不需要手动触发 input.click()
|
|
55
|
+
// 因为 label 会自动将点击事件传递给内部的 input 元素
|
|
56
|
+
var target = event.currentTarget;
|
|
57
|
+
var isInsideLabel = target.closest('label') !== null;
|
|
58
|
+
if (!isInsideLabel) {
|
|
59
|
+
var _inputRef$current;
|
|
60
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.click();
|
|
61
|
+
}
|
|
54
62
|
otherHandlers === null || otherHandlers === void 0 || (_otherHandlers$onClic = otherHandlers.onClick) === null || _otherHandlers$onClic === void 0 || _otherHandlers$onClic.call(otherHandlers, event);
|
|
55
63
|
};
|
|
56
64
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-datepicker-format.d.ts","sourceRoot":"","sources":["use-datepicker-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC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AAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3E,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,EAAE;QACP,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,SAAU,eAAe,2BAOtD,CAAC;AAEF,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;0BA0Ne,gBAAgB;sCAsEJ,MAAM;iCAlCX,MAAM,SAAS,MAAM,eAAe,OAAO;+BA8B7C,MAAM,SAAS,MAAM;yCAzOnD,OAAO,GAAG,KAAK,GAAG,SAAS,QAAQ,MAAM,UAAU,IAAI,KAAK,OAAO;uCAWvE,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC,QAC3B,MAAM;kBACG,MAAM,SAAS;mBAAS,GAAG;;+BA4CrC,IAAI,YAAY,OAAO,GAAG,KAAK,GAAG,SAAS,gBAAgB,MAAM;;CAiP3E,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -231,6 +231,7 @@ var useDatePickerFormat = function useDatePickerFormat(props) {
|
|
|
231
231
|
return getFormatValueArr(dateArr, props.formatResult);
|
|
232
232
|
} else if (typeof props.formatResult === 'function') {
|
|
233
233
|
return dateArr.map(function (item) {
|
|
234
|
+
if (!item) return '';
|
|
234
235
|
return props.formatResult(item);
|
|
235
236
|
});
|
|
236
237
|
} else {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { UseTimeProps } from './use-time.type';
|
|
2
|
-
|
|
2
|
+
type TimeType = 'H' | 'h' | 'm' | 's' | 'ampm';
|
|
3
|
+
type TimesType = {
|
|
4
|
+
mode: TimeType;
|
|
3
5
|
times: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
date: Date;
|
|
8
|
-
disabled: boolean;
|
|
9
|
-
}[];
|
|
10
|
-
currentIndex: number;
|
|
6
|
+
str: string;
|
|
7
|
+
date: Date;
|
|
8
|
+
disabled: boolean;
|
|
11
9
|
}[];
|
|
10
|
+
currentIndex: number;
|
|
11
|
+
};
|
|
12
|
+
declare const useTime: (props: UseTimeProps) => {
|
|
13
|
+
times: TimesType[];
|
|
12
14
|
func: {
|
|
13
15
|
handleChange: (date: Date) => void;
|
|
14
16
|
isDisabled: (date: Date, triggerType?: string) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-time.d.ts","sourceRoot":"","sources":["use-time.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-time.d.ts","sourceRoot":"","sources":["use-time.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,KAAK,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;AAC/C,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,IAAI,CAAC;QACX,QAAQ,EAAE,OAAO,CAAC;KACnB,EAAE,CAAC;IACJ,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAKF,QAAA,MAAM,OAAO,UAAW,YAAY;;;6BAkHN,IAAI;2BAlEN,IAAI,gBAAgB,MAAM;;CA8IrD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -7,6 +7,9 @@ exports.default = void 0;
|
|
|
7
7
|
var _useLatestObj = _interopRequireDefault(require("../../common/use-latest-obj"));
|
|
8
8
|
var _util = _interopRequireDefault(require("./util"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var getStepIndex = function getStepIndex(index, step) {
|
|
11
|
+
return Math.floor(index / step);
|
|
12
|
+
};
|
|
10
13
|
var useTime = function useTime(props) {
|
|
11
14
|
var options = props.options,
|
|
12
15
|
mi = props.min,
|
|
@@ -19,13 +22,24 @@ var useTime = function useTime(props) {
|
|
|
19
22
|
_props$secondStep = props.secondStep,
|
|
20
23
|
secondStep = _props$secondStep === void 0 ? 1 : _props$secondStep,
|
|
21
24
|
staticMin = props.staticMin,
|
|
22
|
-
staticMax = props.staticMax
|
|
25
|
+
staticMax = props.staticMax,
|
|
26
|
+
position = props.position,
|
|
27
|
+
rangeDate = props.rangeDate;
|
|
23
28
|
var min = _util.default.resetTimeByFormat(mi, format, options);
|
|
24
29
|
var max = _util.default.resetTimeByFormat(ma, format, options);
|
|
25
30
|
var current = props.value || _util.default.newDate(undefined, options);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
if (!props.value && typeof props.defaultTime === 'string' && /^\d{1,2}(:\d{2}(:\d{2})?)?$/.test(props.defaultTime)) {
|
|
32
|
+
var today = new Date();
|
|
33
|
+
var todayStr = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
|
|
34
|
+
var timesStr = props.defaultTime.split(':');
|
|
35
|
+
var hStr = timesStr[0];
|
|
36
|
+
var mStr = timesStr[1] || '00';
|
|
37
|
+
var sStr = timesStr[2] || '00';
|
|
38
|
+
var timeStr = hStr + ':' + mStr + ':' + sStr;
|
|
39
|
+
var dayStr = todayStr + ' ' + timeStr;
|
|
40
|
+
var val = new Date(dayStr);
|
|
41
|
+
if (val) current = val;
|
|
42
|
+
}
|
|
29
43
|
var time = {
|
|
30
44
|
hour: _util.default.getDateInfo(current, 'hour', options),
|
|
31
45
|
minute: _util.default.getDateInfo(current, 'minute', options),
|
|
@@ -45,7 +59,7 @@ var useTime = function useTime(props) {
|
|
|
45
59
|
disabledTime = props.disabledTime;
|
|
46
60
|
if (disabledTime) {
|
|
47
61
|
var _time = _util.default.format(date, _util.default.TIME_FORMAT, options);
|
|
48
|
-
if (typeof disabledTime === 'function') return disabledTime(_time);
|
|
62
|
+
if (typeof disabledTime === 'function') return disabledTime(_time, position, rangeDate === null || rangeDate === void 0 ? void 0 : rangeDate[0], rangeDate === null || rangeDate === void 0 ? void 0 : rangeDate[1]);
|
|
49
63
|
return disabledTime === _time;
|
|
50
64
|
}
|
|
51
65
|
var isDis = disabled && typeof disabled === 'function' ? disabled(date) : false;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DateTimeType } from "./util";
|
|
1
2
|
export interface UseTimeProps {
|
|
2
3
|
format: string;
|
|
3
4
|
options: {
|
|
@@ -11,9 +12,12 @@ export interface UseTimeProps {
|
|
|
11
12
|
staticMin?: Date;
|
|
12
13
|
staticMax?: Date;
|
|
13
14
|
disabled?: boolean | ((date: Date) => boolean);
|
|
14
|
-
disabledTime?: string | ((time: string) => boolean);
|
|
15
|
+
disabledTime?: string | ((time: string, type?: 'start' | 'end', value0?: Date, value1?: Date) => boolean);
|
|
15
16
|
minuteStep?: number;
|
|
16
17
|
hourStep?: number;
|
|
17
18
|
secondStep?: number;
|
|
19
|
+
position?: 'start' | 'end';
|
|
20
|
+
rangeDate?: Array<Date | undefined>;
|
|
21
|
+
defaultTime?: DateTimeType;
|
|
18
22
|
}
|
|
19
23
|
//# sourceMappingURL=use-time.type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-time.type.d.ts","sourceRoot":"","sources":["use-time.type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE;QACP,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,IAAI,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EAAE,IAAI,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,eAInF;AAED,iBAAS,SAAS,CAChB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,KAAK,MAAM,CAAC,EACxD,OAAO,EAAE,WAAW,UAKrB;AAED,iBAAS,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,UAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBD,wBAsCE"}
|
|
@@ -223,7 +223,16 @@ function toDate(day, options) {
|
|
|
223
223
|
if (!day) return new Date('');
|
|
224
224
|
if (day instanceof Date) return (0, _dayjs.default)(day).toDate();
|
|
225
225
|
if (typeof day === 'number') return new Date(day);
|
|
226
|
-
if (typeof day === 'string')
|
|
226
|
+
if (typeof day === 'string') {
|
|
227
|
+
// 当 day 只有时间部分,没有日期部分时
|
|
228
|
+
if (/^\d{1,2}(:\d{2}(:\d{2})?)?$/.test(day)) {
|
|
229
|
+
var today = new Date();
|
|
230
|
+
var todayStr = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
|
|
231
|
+
var dayStr = todayStr + ' ' + day;
|
|
232
|
+
return transDateWithZone((0, _dayjs.default)(dayStr).toDate(), options, true);
|
|
233
|
+
}
|
|
234
|
+
return transDateWithZone((0, _dayjs.default)(day).toDate(), options, true);
|
|
235
|
+
}
|
|
227
236
|
return (0, _dayjs.default)(day).toDate();
|
|
228
237
|
}
|
|
229
238
|
function getDaysOfMonth(dirtyDate, options) {
|
|
@@ -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-form-context.d.ts","sourceRoot":"","sources":["use-form-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,eAAO,MAAM,WAAW,oBAA+B,CAAC;AAExD,wBAAgB,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"use-form-context.d.ts","sourceRoot":"","sources":["use-form-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,eAAO,MAAM,WAAW,oBAA+B,CAAC;AAExD,wBAAgB,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAG7E;AAED,wBAAgB,eAAe,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAG/C"}
|
|
@@ -8,13 +8,19 @@ exports.useFormInstance = useFormInstance;
|
|
|
8
8
|
exports.useFormRef = useFormRef;
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
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."); }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
17
|
var FormContext = exports.FormContext = /*#__PURE__*/_react.default.createContext({});
|
|
12
18
|
function useFormRef() {
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return [
|
|
19
|
+
var _React$useState = _react.default.useState({}),
|
|
20
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
21
|
+
formRef = _React$useState2[0],
|
|
22
|
+
setFormRef = _React$useState2[1];
|
|
23
|
+
return [formRef, setFormRef];
|
|
18
24
|
}
|
|
19
25
|
function useFormInstance() {
|
|
20
26
|
var formCtx = _react.default.useContext(FormContext);
|
|
@@ -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,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;;;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":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,oBAAoB,EAAsB,MAAM,yBAAyB,CAAC;AA4BnF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;
|
|
1
|
+
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,oBAAoB,EAAsB,MAAM,yBAAyB,CAAC;AA4BnF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBA4JpC,CAAC,YAAY,GAAG,EAAE;;;;;EAiFrD"}
|
|
@@ -57,7 +57,8 @@ function useFormControl(props) {
|
|
|
57
57
|
defaultValue = props.defaultValue,
|
|
58
58
|
rules = props.rules,
|
|
59
59
|
onError = props.onError,
|
|
60
|
-
getValidateProps = props.getValidateProps
|
|
60
|
+
getValidateProps = props.getValidateProps,
|
|
61
|
+
clearToUndefined = props.clearToUndefined;
|
|
61
62
|
var _useFieldSetConsumer = (0, _fieldsetContext.useFieldSetConsumer)({
|
|
62
63
|
name: props.name,
|
|
63
64
|
bind: props.bind
|
|
@@ -104,7 +105,9 @@ function useFormControl(props) {
|
|
|
104
105
|
var errors = arguments.length > 1 ? arguments[1] : undefined;
|
|
105
106
|
var severErrors = arguments.length > 2 ? arguments[2] : undefined;
|
|
106
107
|
if (!name) return;
|
|
107
|
-
|
|
108
|
+
// 加入defaultValue的判断,让其只对 https://github.com/sheinsight/shineout-next/pull/742 的场景生效
|
|
109
|
+
// 如果不加入defaultValue的判断,会导致 8ea43144-36a5-403a-9147-59d54087a110 的问题
|
|
110
|
+
if ((0, _is.isArray)(name) && defaultValue !== undefined) {
|
|
108
111
|
var _value = getValue(name, formValue);
|
|
109
112
|
var _error = getError(name, errors, severErrors);
|
|
110
113
|
if (_error !== errorState) {
|
|
@@ -115,7 +118,11 @@ function useFormControl(props) {
|
|
|
115
118
|
var nextValue = [];
|
|
116
119
|
name.forEach(function (n, index) {
|
|
117
120
|
if (_value[index] === undefined && dv[index] !== undefined) {
|
|
118
|
-
|
|
121
|
+
if (clearToUndefined) {
|
|
122
|
+
nextValue[index] = undefined;
|
|
123
|
+
} else {
|
|
124
|
+
nextValue[index] = dv[index];
|
|
125
|
+
}
|
|
119
126
|
} else {
|
|
120
127
|
nextValue[index] = _value[index];
|
|
121
128
|
}
|
|
@@ -129,7 +136,11 @@ function useFormControl(props) {
|
|
|
129
136
|
}
|
|
130
137
|
if (!(0, _shallowEqual.shallowEqual)(_value2, latestInfo.valueState)) {
|
|
131
138
|
if (_value2 === undefined && defaultValue !== undefined) {
|
|
132
|
-
|
|
139
|
+
if (clearToUndefined) {
|
|
140
|
+
setValueState(undefined);
|
|
141
|
+
} else {
|
|
142
|
+
setValueState(defaultValue);
|
|
143
|
+
}
|
|
133
144
|
} else {
|
|
134
145
|
setValueState(_value2);
|
|
135
146
|
}
|
|
@@ -222,8 +233,27 @@ function useFormControl(props) {
|
|
|
222
233
|
if (onChangePo) onChangePo.apply(void 0, [v].concat(other));
|
|
223
234
|
if (validateFieldSet) validateFieldSet();
|
|
224
235
|
});
|
|
236
|
+
var initError = (0, _usePersistFn.default)(function () {
|
|
237
|
+
var errors = formFunc === null || formFunc === void 0 ? void 0 : formFunc.getErrors();
|
|
238
|
+
if ((0, _is.isArray)(name)) {
|
|
239
|
+
for (var i = 0; i < name.length; i++) {
|
|
240
|
+
var n = name[i];
|
|
241
|
+
var currentErrorInForm = errors === null || errors === void 0 ? void 0 : errors[n];
|
|
242
|
+
if (currentErrorInForm) {
|
|
243
|
+
setErrorState(currentErrorInForm);
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
var _currentErrorInForm = errors === null || errors === void 0 ? void 0 : errors[name];
|
|
249
|
+
if (_currentErrorInForm) {
|
|
250
|
+
setErrorState(_currentErrorInForm);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
});
|
|
225
254
|
(0, _react.useEffect)(function () {
|
|
226
255
|
if (inForm && controlFunc) {
|
|
256
|
+
initError();
|
|
227
257
|
if ((0, _is.isArray)(name)) {
|
|
228
258
|
var dv = (0, _is.isArray)(defaultValue) ? defaultValue : [];
|
|
229
259
|
name.forEach(function (n, index) {
|
|
@@ -24,14 +24,20 @@ export interface BaseFormControlProps<T> {
|
|
|
24
24
|
*/
|
|
25
25
|
onError: ((error: Error | undefined) => void) | undefined;
|
|
26
26
|
/**
|
|
27
|
-
* @en
|
|
28
|
-
* @cn
|
|
27
|
+
* @en Array of field names that should be re-validated when current field's value changes. Enables field linkage validation for dependent fields. Commonly used in scenarios like password confirmation, related dropdown selections, or interdependent form calculations
|
|
28
|
+
* @cn 当前字段值改变时需要重新校验的字段名称数组。启用字段间的联动校验功能。常用于密码确认、关联下拉选择或相互依赖的表单计算等场景
|
|
29
29
|
*/
|
|
30
30
|
bind: string[] | undefined;
|
|
31
31
|
/**
|
|
32
32
|
* @private 内部属性 for validate
|
|
33
33
|
*/
|
|
34
34
|
getValidateProps: (() => ObjectType) | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* @en If set to true, the form will not automatically delete the data after the component is uninstalled
|
|
37
|
+
* @cn 设置为 true 组件后,有defaultValue时,允许undefined作为最终值
|
|
38
|
+
* @version 3.8.0
|
|
39
|
+
*/
|
|
40
|
+
clearToUndefined?: boolean;
|
|
35
41
|
}
|
|
36
42
|
export interface FormControlContext {
|
|
37
43
|
mounted: boolean;
|