@sheinx/hooks 3.7.0-beta.9 → 3.7.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-component-memo/index.d.ts +1 -1
- package/cjs/common/use-component-memo/index.d.ts.map +1 -1
- package/cjs/common/use-component-memo/index.js +2 -9
- package/cjs/common/use-component-memo/use-memo.d.ts +1 -1
- package/cjs/common/use-component-memo/use-memo.d.ts.map +1 -1
- package/cjs/common/use-component-memo/use-memo.js +2 -2
- package/cjs/common/use-filter/index.d.ts +1 -0
- package/cjs/common/use-filter/index.d.ts.map +1 -1
- package/cjs/common/use-filter/index.js +7 -0
- package/cjs/common/use-filter/use-filter-context.d.ts +7 -0
- package/cjs/common/use-filter/use-filter-context.d.ts.map +1 -0
- package/cjs/common/use-filter/use-filter-context.js +10 -0
- package/cjs/common/use-filter/use-filter.d.ts +1 -0
- package/cjs/common/use-filter/use-filter.d.ts.map +1 -1
- package/cjs/common/use-filter/use-filter.js +2 -0
- 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-element-size.d.ts +10 -0
- package/cjs/common/use-position-style/check-element-size.d.ts.map +1 -0
- package/cjs/common/use-position-style/check-element-size.js +65 -0
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +5 -1
- package/cjs/components/use-datepicker/index.d.ts +1 -1
- package/cjs/components/use-datepicker/index.d.ts.map +1 -1
- package/cjs/components/use-datepicker/index.js +23 -2
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts +17 -0
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.js +15 -3
- 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 +9 -4
- package/cjs/components/use-form/use-form.d.ts +4 -4
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +31 -25
- package/cjs/components/use-form/use-form.type.d.ts +8 -0
- package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
- package/cjs/components/use-image/use-image.d.ts +2 -0
- package/cjs/components/use-image/use-image.d.ts.map +1 -1
- package/cjs/components/use-image/use-image.js +40 -2
- package/cjs/components/use-popup/popup-context.d.ts +2 -0
- package/cjs/components/use-popup/popup-context.d.ts.map +1 -1
- package/cjs/components/use-popup/popup-context.js +2 -0
- package/cjs/components/use-popup/use-popup.d.ts +4 -0
- package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
- package/cjs/components/use-popup/use-popup.js +33 -13
- package/cjs/components/use-table/index.d.ts +1 -1
- package/cjs/components/use-table/index.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-filter.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-filter.js +2 -1
- package/cjs/components/use-table/use-table-group.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-group.js +3 -1
- package/cjs/components/use-table/use-table-layout.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-layout.js +0 -1
- package/cjs/components/use-table/use-table-virtual.js +1 -1
- package/cjs/components/use-table/use-table.type.d.ts +13 -21
- package/cjs/components/use-table/use-table.type.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree.js +25 -7
- package/cjs/components/use-tree/use-tree.type.d.ts +1 -0
- package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/cjs/components/use-upload/use-upload.d.ts.map +1 -1
- package/cjs/components/use-upload/use-upload.js +54 -34
- package/cjs/components/use-upload/use-upload.type.d.ts +7 -0
- package/cjs/components/use-upload/use-upload.type.d.ts.map +1 -1
- package/cjs/utils/clean-props.d.ts +11 -0
- package/cjs/utils/clean-props.d.ts.map +1 -0
- package/cjs/utils/clean-props.js +21 -0
- package/cjs/utils/highlight.d.ts +7 -0
- package/cjs/utils/highlight.d.ts.map +1 -0
- package/cjs/utils/highlight.js +67 -0
- package/cjs/utils/index.d.ts +2 -0
- package/cjs/utils/index.d.ts.map +1 -1
- package/cjs/utils/index.js +24 -0
- package/cjs/utils/string.d.ts +1 -0
- package/cjs/utils/string.d.ts.map +1 -1
- package/cjs/utils/string.js +13 -0
- package/esm/common/use-component-memo/index.d.ts +1 -1
- package/esm/common/use-component-memo/index.d.ts.map +1 -1
- package/esm/common/use-component-memo/index.js +1 -1
- package/esm/common/use-component-memo/use-memo.d.ts +1 -1
- package/esm/common/use-component-memo/use-memo.d.ts.map +1 -1
- package/esm/common/use-component-memo/use-memo.js +1 -1
- package/esm/common/use-filter/index.d.ts +1 -0
- package/esm/common/use-filter/index.d.ts.map +1 -1
- package/esm/common/use-filter/index.js +2 -1
- package/esm/common/use-filter/use-filter-context.d.ts +7 -0
- package/esm/common/use-filter/use-filter-context.d.ts.map +1 -0
- package/esm/common/use-filter/use-filter-context.js +3 -0
- package/esm/common/use-filter/use-filter.d.ts +1 -0
- package/esm/common/use-filter/use-filter.d.ts.map +1 -1
- package/esm/common/use-filter/use-filter.js +2 -0
- 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-element-size.d.ts +10 -0
- package/esm/common/use-position-style/check-element-size.d.ts.map +1 -0
- package/esm/common/use-position-style/check-element-size.js +59 -0
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +5 -1
- package/esm/components/use-datepicker/index.d.ts +1 -1
- package/esm/components/use-datepicker/index.d.ts.map +1 -1
- package/esm/components/use-datepicker/index.js +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.d.ts +17 -0
- package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.js +14 -2
- 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 +9 -4
- package/esm/components/use-form/use-form.d.ts +4 -4
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +31 -25
- package/esm/components/use-form/use-form.type.d.ts +8 -0
- package/esm/components/use-form/use-form.type.d.ts.map +1 -1
- package/esm/components/use-image/use-image.d.ts +2 -0
- package/esm/components/use-image/use-image.d.ts.map +1 -1
- package/esm/components/use-image/use-image.js +40 -2
- package/esm/components/use-popup/popup-context.d.ts +2 -0
- package/esm/components/use-popup/popup-context.d.ts.map +1 -1
- package/esm/components/use-popup/popup-context.js +2 -0
- package/esm/components/use-popup/use-popup.d.ts +4 -0
- package/esm/components/use-popup/use-popup.d.ts.map +1 -1
- package/esm/components/use-popup/use-popup.js +34 -14
- package/esm/components/use-table/index.d.ts +1 -1
- package/esm/components/use-table/index.d.ts.map +1 -1
- package/esm/components/use-table/use-table-filter.d.ts.map +1 -1
- package/esm/components/use-table/use-table-filter.js +2 -1
- package/esm/components/use-table/use-table-group.d.ts.map +1 -1
- package/esm/components/use-table/use-table-group.js +3 -1
- package/esm/components/use-table/use-table-layout.d.ts.map +1 -1
- package/esm/components/use-table/use-table-layout.js +0 -1
- package/esm/components/use-table/use-table-virtual.js +1 -1
- package/esm/components/use-table/use-table.type.d.ts +13 -21
- package/esm/components/use-table/use-table.type.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree.js +26 -8
- package/esm/components/use-tree/use-tree.type.d.ts +1 -0
- package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/esm/components/use-upload/use-upload.d.ts.map +1 -1
- package/esm/components/use-upload/use-upload.js +54 -34
- package/esm/components/use-upload/use-upload.type.d.ts +7 -0
- package/esm/components/use-upload/use-upload.type.d.ts.map +1 -1
- package/esm/utils/clean-props.d.ts +11 -0
- package/esm/utils/clean-props.d.ts.map +1 -0
- package/esm/utils/clean-props.js +15 -0
- package/esm/utils/highlight.d.ts +7 -0
- package/esm/utils/highlight.d.ts.map +1 -0
- package/esm/utils/highlight.js +59 -0
- package/esm/utils/index.d.ts +2 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +3 -1
- package/esm/utils/string.d.ts +1 -0
- package/esm/utils/string.d.ts.map +1 -1
- package/esm/utils/string.js +12 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { useComponentMemo } from './use-memo';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -4,17 +4,10 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
Object.defineProperty(exports, "default", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function get() {
|
|
10
|
-
return _useMemo.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
7
|
Object.defineProperty(exports, "useComponentMemo", {
|
|
14
8
|
enumerable: true,
|
|
15
9
|
get: function get() {
|
|
16
|
-
return _useMemo.
|
|
10
|
+
return _useMemo.useComponentMemo;
|
|
17
11
|
}
|
|
18
12
|
});
|
|
19
|
-
var _useMemo =
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
var _useMemo = require("./use-memo");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function useComponentMemo<Value, Condition = any[]>(getValue: () => Value, condition: Condition, shouldUpdate?: (prev: Condition, next: Condition) => boolean): Value | undefined;
|
|
2
2
|
//# sourceMappingURL=use-memo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-memo.d.ts","sourceRoot":"","sources":["use-memo.ts"],"names":[],"mappings":"AAQA,
|
|
1
|
+
{"version":3,"file":"use-memo.d.ts","sourceRoot":"","sources":["use-memo.ts"],"names":[],"mappings":"AAQA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,EAAE,EACvD,QAAQ,EAAE,MAAM,KAAK,EACrB,SAAS,EAAE,SAAS,EACpB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,KAAK,OAAO,qBAc7D"}
|
|
@@ -4,11 +4,11 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.useComponentMemo = useComponentMemo;
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
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); }
|
|
10
10
|
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; }
|
|
11
|
-
function
|
|
11
|
+
function useComponentMemo(getValue, condition, shouldUpdate) {
|
|
12
12
|
var cacheRef = React.useRef({});
|
|
13
13
|
if (!shouldUpdate) return getValue();
|
|
14
14
|
if (!('value' in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
Object.defineProperty(exports, "FilterContext", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _useFilterContext.FilterContext;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
7
13
|
Object.defineProperty(exports, "default", {
|
|
8
14
|
enumerable: true,
|
|
9
15
|
get: function get() {
|
|
@@ -17,4 +23,5 @@ Object.defineProperty(exports, "useFilter", {
|
|
|
17
23
|
}
|
|
18
24
|
});
|
|
19
25
|
var _useFilter = _interopRequireDefault(require("./use-filter"));
|
|
26
|
+
var _useFilterContext = require("./use-filter-context");
|
|
20
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-filter-context.d.ts","sourceRoot":"","sources":["use-filter-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAEzB,MAAM,WAAW,kBAAkB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,mCAA8C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FilterContext = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var FilterContext = exports.FilterContext = /*#__PURE__*/_react.default.createContext({});
|
|
10
|
+
FilterContext.displayName = 'FilterContext';
|
|
@@ -14,6 +14,7 @@ declare const useFilter: <DataItem>(props: UseFilterProps<DataItem>) => {
|
|
|
14
14
|
filterFunc: ((d: DataItem) => boolean) | undefined;
|
|
15
15
|
onCreate: ((text: string) => string | DataItem | undefined) | undefined;
|
|
16
16
|
onFilter: ((text: string, from?: string) => void) | undefined;
|
|
17
|
+
FilterProvider: import("react").Provider<import("./use-filter-context").FilterContextProps>;
|
|
17
18
|
onClearCreatedData: () => void;
|
|
18
19
|
};
|
|
19
20
|
export default useFilter;
|
|
@@ -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;
|
|
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;sBAiB1C,MAAM;sBAKN,MAAM,SAAQ,MAAM;;;CAsGjD,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
|
+
var _useFilterContext = require("./use-filter-context");
|
|
9
10
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
10
11
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
12
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -157,6 +158,7 @@ var useFilter = function useFilter(props) {
|
|
|
157
158
|
filterFunc: filterFunc,
|
|
158
159
|
onCreate: onCreate ? handleCreate : undefined,
|
|
159
160
|
onFilter: onFilter || onCreate ? handleFilter : undefined,
|
|
161
|
+
FilterProvider: _useFilterContext.FilterContext.Provider,
|
|
160
162
|
// onResetFilter: handleResetData,
|
|
161
163
|
onClearCreatedData: handleClearCreatedData
|
|
162
164
|
};
|
|
@@ -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;;;;EA0E3F"}
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface Size {
|
|
2
|
+
width?: number;
|
|
3
|
+
height?: number;
|
|
4
|
+
}
|
|
5
|
+
interface UseCheckElementSizeOptions {
|
|
6
|
+
enable?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const useCheckElementSize: (targetElementRef: React.RefObject<HTMLElement>, options?: UseCheckElementSizeOptions) => Size | null;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=check-element-size.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-element-size.d.ts","sourceRoot":"","sources":["check-element-size.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,IAAI;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,0BAA0B;IAElC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,qBACZ,MAAM,SAAS,CAAC,WAAW,CAAC,YACrC,0BAA0B,KAClC,IAAI,GAAG,IAmDT,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useCheckElementSize = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
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."); }
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
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; } }
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
var useCheckElementSize = exports.useCheckElementSize = function useCheckElementSize(targetElementRef) {
|
|
15
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
16
|
+
var enable = options.enable;
|
|
17
|
+
var _useState = (0, _react.useState)({
|
|
18
|
+
width: 0,
|
|
19
|
+
height: 0
|
|
20
|
+
}),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
size = _useState2[0],
|
|
23
|
+
setSize = _useState2[1];
|
|
24
|
+
var lastSize = (0, _react.useRef)({
|
|
25
|
+
width: 0,
|
|
26
|
+
height: 0
|
|
27
|
+
});
|
|
28
|
+
var checkSize = (0, _react.useCallback)(function () {
|
|
29
|
+
if (targetElementRef.current) {
|
|
30
|
+
var rect = targetElementRef.current.getBoundingClientRect();
|
|
31
|
+
var newSize = {
|
|
32
|
+
width: rect.width,
|
|
33
|
+
height: rect.height
|
|
34
|
+
};
|
|
35
|
+
if (newSize.width !== lastSize.current.width || newSize.height !== lastSize.current.height) {
|
|
36
|
+
setSize(newSize);
|
|
37
|
+
lastSize.current = newSize;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}, [targetElementRef]);
|
|
41
|
+
(0, _react.useEffect)(function () {
|
|
42
|
+
var _window;
|
|
43
|
+
if (!enable) return;
|
|
44
|
+
var element = targetElementRef.current;
|
|
45
|
+
if (!element) return;
|
|
46
|
+
|
|
47
|
+
// 初始检查
|
|
48
|
+
checkSize();
|
|
49
|
+
var resizeObserver = null;
|
|
50
|
+
if ((_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
|
|
51
|
+
resizeObserver = new ResizeObserver(checkSize);
|
|
52
|
+
resizeObserver.observe(element);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 清理函数
|
|
56
|
+
return function () {
|
|
57
|
+
var _resizeObserver;
|
|
58
|
+
(_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 || _resizeObserver.disconnect();
|
|
59
|
+
};
|
|
60
|
+
}, [enable, targetElementRef, checkSize]);
|
|
61
|
+
if (!enable || !targetElementRef) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return size;
|
|
65
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAUnD,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,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CAwR3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _getPositionStyle = require("./get-position-style");
|
|
11
11
|
var _checkPosition = require("./check-position");
|
|
12
12
|
var _checkBorder = require("./check-border");
|
|
13
|
+
var _checkElementSize = require("./check-element-size");
|
|
13
14
|
var _shallowEqual = _interopRequireDefault(require("../../utils/shallow-equal"));
|
|
14
15
|
var _usePersistFn = _interopRequireDefault(require("../use-persist-fn"));
|
|
15
16
|
var _utils = require("../../utils");
|
|
@@ -76,6 +77,9 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
|
76
77
|
var parentElBorderWidth = (0, _checkBorder.useCheckElementBorderWidth)(parentElRef, {
|
|
77
78
|
direction: 'horizontal'
|
|
78
79
|
});
|
|
80
|
+
var popupElSize = (0, _checkElementSize.useCheckElementSize)(popupElRef, {
|
|
81
|
+
enable: show
|
|
82
|
+
});
|
|
79
83
|
var adjustPosition = function adjustPosition(position) {
|
|
80
84
|
var winHeight = _utils.docSize.height;
|
|
81
85
|
if (!verticalPosition.includes(position)) return position;
|
|
@@ -312,7 +316,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
|
312
316
|
// 当父元素的滚动容器滚动时,判断是否需要更新弹出层位置,包括是否隐藏弹出层(通过hideStyle隐藏,不是show状态)
|
|
313
317
|
context.prevParentPosition = parentElNewPosition;
|
|
314
318
|
});
|
|
315
|
-
(0, _react.useEffect)(updateStyle, [show, position, absolute, updateKey, fixedWidth, parentElNewPosition]);
|
|
319
|
+
(0, _react.useEffect)(updateStyle, [show, position, absolute, updateKey, fixedWidth, parentElNewPosition, popupElSize]);
|
|
316
320
|
return {
|
|
317
321
|
style: style
|
|
318
322
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as useDatePickerFormat } from './use-datepicker-format';
|
|
1
|
+
export { default as useDatePickerFormat, getFormatValueArr, convertValueToDateArr, getFormat, } from './use-datepicker-format';
|
|
2
2
|
export { default as dateUtil } from './util';
|
|
3
3
|
export { default as useDatePick } from './use-date';
|
|
4
4
|
export { default as useYearPick } from './use-year';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,mBAAmB,EAC9B,iBAAiB,EACjB,qBAAqB,EACrB,SAAS,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACvE,YAAY,EACV,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACb,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
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); }
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
8
|
+
Object.defineProperty(exports, "convertValueToDateArr", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _useDatepickerFormat.convertValueToDateArr;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
7
14
|
Object.defineProperty(exports, "dateUtil", {
|
|
8
15
|
enumerable: true,
|
|
9
16
|
get: function get() {
|
|
10
17
|
return _util.default;
|
|
11
18
|
}
|
|
12
19
|
});
|
|
20
|
+
Object.defineProperty(exports, "getFormat", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _useDatepickerFormat.getFormat;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "getFormatValueArr", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return _useDatepickerFormat.getFormatValueArr;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
13
32
|
Object.defineProperty(exports, "useDatePick", {
|
|
14
33
|
enumerable: true,
|
|
15
34
|
get: function get() {
|
|
@@ -52,7 +71,7 @@ Object.defineProperty(exports, "useYearPick", {
|
|
|
52
71
|
return _useYear.default;
|
|
53
72
|
}
|
|
54
73
|
});
|
|
55
|
-
var _useDatepickerFormat =
|
|
74
|
+
var _useDatepickerFormat = _interopRequireWildcard(require("./use-datepicker-format"));
|
|
56
75
|
var _util = _interopRequireDefault(require("./util"));
|
|
57
76
|
var _useDate = _interopRequireDefault(require("./use-date"));
|
|
58
77
|
var _useYear = _interopRequireDefault(require("./use-year"));
|
|
@@ -60,4 +79,6 @@ var _useMonth = _interopRequireDefault(require("./use-month"));
|
|
|
60
79
|
var _useQuarter = _interopRequireDefault(require("./use-quarter"));
|
|
61
80
|
var _useTime = _interopRequireDefault(require("./use-time"));
|
|
62
81
|
var _useDatepickerRange = _interopRequireDefault(require("./use-datepicker-range"));
|
|
63
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
82
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
83
|
+
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); }
|
|
84
|
+
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; }
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DatePickerModeType, DatePickerValueType, UseDatePickerFormatProps } from './use-datepicker-format.type';
|
|
3
|
+
export declare const convertValueToDateArr: (value: DatePickerValueType, format: string, options: {
|
|
4
|
+
timeZone?: string;
|
|
5
|
+
weekStartsOn?: number;
|
|
6
|
+
}) => (Date | undefined)[];
|
|
7
|
+
export declare const getFormat: (format: string | undefined, type: string) => string;
|
|
8
|
+
interface FormatValueType {
|
|
9
|
+
dateArr: (Date | undefined)[];
|
|
10
|
+
format: string;
|
|
11
|
+
fmt?: string;
|
|
12
|
+
type: 'date' | 'datetime' | 'month' | 'time' | 'week' | 'year' | 'quarter';
|
|
13
|
+
clearWithUndefined?: boolean;
|
|
14
|
+
options: {
|
|
15
|
+
timeZone?: string;
|
|
16
|
+
weekStartsOn?: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare const getFormatValueArr: (opts: FormatValueType) => (string | undefined)[];
|
|
3
20
|
declare const useDatePickerFormat: <Value extends DatePickerValueType>(props: UseDatePickerFormatProps<Value>) => {
|
|
4
21
|
inputArr: (Date | undefined)[];
|
|
5
22
|
resultArr: (string | undefined)[];
|
|
@@ -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;
|
|
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;AAKtC,eAAO,MAAM,qBAAqB,UACzB,mBAAmB,UAClB,MAAM,WACL;IACP,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,yBAOF,CAAC;AAEF,eAAO,MAAM,SAAS,WAAY,MAAM,GAAG,SAAS,QAAQ,MAAM,WAkBjE,CAAC;AA4BF,UAAU,eAAe;IACvB,OAAO,EAAE,CAAC,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;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;;;;;;;;;;;;;;;;;0BA6Me,gBAAgB;sCAiEJ,MAAM;iCA7BX,MAAM,SAAS,MAAM;yCA9LrD,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;;CA8N3E,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.getFormatValueArr = exports.getFormat = exports.default = exports.convertValueToDateArr = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _util = _interopRequireDefault(require("./util"));
|
|
9
9
|
var _shallowEqual = _interopRequireDefault(require("../../utils/shallow-equal"));
|
|
@@ -20,14 +20,14 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
20
20
|
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; }
|
|
21
21
|
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; } }
|
|
22
22
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
-
var convertValueToDateArr = function convertValueToDateArr(value, format, options) {
|
|
23
|
+
var convertValueToDateArr = exports.convertValueToDateArr = function convertValueToDateArr(value, format, options) {
|
|
24
24
|
var valueArr = Array.isArray(value) ? value : [value];
|
|
25
25
|
return valueArr.map(function (item) {
|
|
26
26
|
if (!item) return undefined;
|
|
27
27
|
return _util.default.toDateWithFormat(item, format, undefined, options);
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
var getFormat = function getFormat(format, type) {
|
|
30
|
+
var getFormat = exports.getFormat = function getFormat(format, type) {
|
|
31
31
|
if (typeof format === 'string') return format;
|
|
32
32
|
switch (type) {
|
|
33
33
|
case 'datetime':
|
|
@@ -70,6 +70,18 @@ var getDefaultMode = function getDefaultMode(type) {
|
|
|
70
70
|
var mode = getTypeMode(type);
|
|
71
71
|
return [mode, mode];
|
|
72
72
|
};
|
|
73
|
+
var getFormatValueArr = exports.getFormatValueArr = function getFormatValueArr(opts) {
|
|
74
|
+
var dateArr = opts.dateArr,
|
|
75
|
+
format = opts.format,
|
|
76
|
+
clearWithUndefined = opts.clearWithUndefined,
|
|
77
|
+
options = opts.options,
|
|
78
|
+
type = opts.type;
|
|
79
|
+
var fmt = getFormat(format, type);
|
|
80
|
+
return dateArr.map(function (item) {
|
|
81
|
+
if (!item) return clearWithUndefined ? undefined : '';
|
|
82
|
+
return _util.default.format(item, fmt, options);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
73
85
|
var useDatePickerFormat = function useDatePickerFormat(props) {
|
|
74
86
|
var value = props.value,
|
|
75
87
|
onChange = props.onChange,
|
|
@@ -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;
|
|
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;;kBAiJpC,CAAC,YAAY,GAAG,EAAE;;;;;EA4DrD"}
|
|
@@ -17,6 +17,7 @@ var _shallowEqual = require("../../../utils/shallow-equal");
|
|
|
17
17
|
var _usePersistFn = _interopRequireDefault(require("../../../common/use-persist-fn"));
|
|
18
18
|
var _useLatestObj = _interopRequireDefault(require("../../../common/use-latest-obj"));
|
|
19
19
|
var _warning = require("../../../utils/warning");
|
|
20
|
+
var _cleanProps = require("../../../utils/clean-props");
|
|
20
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
22
|
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
23
|
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; }
|
|
@@ -157,7 +158,7 @@ function useFormControl(props) {
|
|
|
157
158
|
}
|
|
158
159
|
};
|
|
159
160
|
var fullRules = (controlFunc === null || controlFunc === void 0 ? void 0 : controlFunc.combineRules(name, rules || [])) || [];
|
|
160
|
-
return (0, _validate.validate)(v, formV, fullRules, validateProps).then(function (res) {
|
|
161
|
+
return (0, _validate.validate)(v, formV, fullRules, (0, _cleanProps.cleanProps)(validateProps)).then(function (res) {
|
|
161
162
|
var err = res === true ? undefined : res;
|
|
162
163
|
formFunc === null || formFunc === void 0 || formFunc.setError(name, err);
|
|
163
164
|
onError === null || onError === void 0 || onError(err);
|
|
@@ -184,7 +185,7 @@ function useFormControl(props) {
|
|
|
184
185
|
return e;
|
|
185
186
|
});
|
|
186
187
|
} else {
|
|
187
|
-
return (0, _validate.validate)(v, {}, rules || [],
|
|
188
|
+
return (0, _validate.validate)(v, {}, rules || [], (0, _cleanProps.cleanProps)(validateProps)).then(function (res) {
|
|
188
189
|
var err = res === true ? undefined : res;
|
|
189
190
|
setErrorState(err);
|
|
190
191
|
onError === null || onError === void 0 || onError(err);
|
|
@@ -226,10 +227,14 @@ function useFormControl(props) {
|
|
|
226
227
|
if ((0, _is.isArray)(name)) {
|
|
227
228
|
var dv = (0, _is.isArray)(defaultValue) ? defaultValue : [];
|
|
228
229
|
name.forEach(function (n, index) {
|
|
229
|
-
|
|
230
|
+
var v = formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue(n);
|
|
231
|
+
var bindedValue = v === undefined ? dv[index] : v;
|
|
232
|
+
controlFunc.bind(n, context.mounted ? bindedValue : dv[index], validateField, update);
|
|
230
233
|
});
|
|
231
234
|
} else {
|
|
232
|
-
|
|
235
|
+
var v = formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue(name);
|
|
236
|
+
var bindedValue = v === undefined ? defaultValue : v;
|
|
237
|
+
controlFunc.bind(name, context.mounted ? bindedValue : defaultValue, validateField, update);
|
|
233
238
|
}
|
|
234
239
|
if (context.mounted) {
|
|
235
240
|
_warning.devUseWarning.warn('Please avoid modifying the name property after the component has mounted, as this may result in unintended behavior or errors.');
|
|
@@ -11,10 +11,10 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
}, option?: {
|
|
13
13
|
validate?: boolean;
|
|
14
|
-
|
|
14
|
+
forceUpdate?: boolean;
|
|
15
15
|
}) => void;
|
|
16
16
|
getValue: (name?: string) => unknown;
|
|
17
|
-
submit: (withValidate?: boolean) => void;
|
|
17
|
+
submit: (withValidate?: boolean, callback?: () => void) => void;
|
|
18
18
|
reset: () => void;
|
|
19
19
|
setError: (name: string, e: Error | undefined) => void;
|
|
20
20
|
getErrors: () => ObjectType<Error | undefined>;
|
|
@@ -31,10 +31,10 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
|
31
31
|
[key: string]: any;
|
|
32
32
|
}, option?: {
|
|
33
33
|
validate?: boolean;
|
|
34
|
-
|
|
34
|
+
forceUpdate?: boolean;
|
|
35
35
|
}) => void;
|
|
36
36
|
getValue: (name?: string) => unknown;
|
|
37
|
-
submit: (withValidate?: boolean) => void;
|
|
37
|
+
submit: (withValidate?: boolean, callback?: () => void) => void;
|
|
38
38
|
reset: () => void;
|
|
39
39
|
setError: (name: string, e: Error | undefined) => void;
|
|
40
40
|
getErrors: () => ObjectType<Error | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AA+BA,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;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AA+BA,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;;;;;;;;;wBAgSC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,WAAW,CAAC,EAAE,OAAO,CAAA;aAAE;8BApKnB,MAAM;oCA+OD,OAAO,aAAoB,MAAM,IAAI;;6BAf3C,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCA1MxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;qCA6QvB,MAAM,WAAW,gBAAgB;gCAhDzB,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;kCAjJpD,MAAM,0BAAyB,qBAAqB;;;;;;oBA2EjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,WAAW,CAAC,EAAE,OAAO,CAAA;SAAE;0BApKnB,MAAM;gCA+OD,OAAO,aAAoB,MAAM,IAAI;;yBAf3C,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCA1MxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;iCA6QvB,MAAM,WAAW,gBAAgB;4BAhDzB,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;8BAjJpD,MAAM,0BAAyB,qBAAqB;;CAqb9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|