@sheinx/hooks 3.1.9-beta.1 → 3.1.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,7 +28,7 @@ declare const useButton: (props?: BaseButtonProps) => {
28
28
  buttonRef?: React.Ref<HTMLButtonElement> | undefined;
29
29
  } & TOther_1 & {
30
30
  disabled: boolean | undefined;
31
- htmlType: "submit" | "reset" | "button" | undefined;
31
+ htmlType: "button" | "reset" | "submit" | undefined;
32
32
  onClick: (event: React.MouseEvent<HTMLButtonElement> | React.MouseEvent<HTMLAnchorElement>) => void;
33
33
  };
34
34
  getSpaceChildren: (children: React.ReactNode, space?: boolean, className?: string) => React.ReactNode;
@@ -4,7 +4,7 @@ declare const useDatePickerFormat: <Value extends DatePickerValueType>(props: Us
4
4
  resultArr: (string | undefined)[];
5
5
  targetResultArr: (string | undefined)[];
6
6
  dateArr: (Date | undefined)[];
7
- disabledStatus: "left" | "right" | "all" | undefined;
7
+ disabledStatus: "all" | "left" | "right" | undefined;
8
8
  currentArr: Date[];
9
9
  mode: DatePickerModeType[];
10
10
  isEmpty: boolean;
@@ -1,7 +1,7 @@
1
1
  export interface FormDatum {
2
2
  set: (vals: {
3
3
  [name: string]: any;
4
- }) => void;
4
+ } | string, value?: any) => void;
5
5
  get: (name?: string) => any;
6
6
  }
7
7
  declare const useFormDatum: () => FormDatum | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7C,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AACD,QAAA,MAAM,YAAY,6BAQjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AAED,QAAA,MAAM,YAAY,6BAgBjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -5,12 +5,24 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _useLatestObj = _interopRequireDefault(require("../../../common/use-latest-obj"));
8
+ var _usePersistFn = require("../../../common/use-persist-fn");
8
9
  var _formFuncContext = require("../form-func-context");
9
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
+ 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); }
10
15
  var useFormDatum = function useFormDatum() {
11
16
  var formFunc = (0, _formFuncContext.useFormFunc)();
17
+ var set = (0, _usePersistFn.usePersistFn)(function (vals, value) {
18
+ if (_typeof(vals) === 'object') {
19
+ formFunc === null || formFunc === void 0 || formFunc.setValue(vals);
20
+ } else {
21
+ formFunc === null || formFunc === void 0 || formFunc.setValue(_defineProperty({}, vals, value));
22
+ }
23
+ });
12
24
  var func = (0, _useLatestObj.default)({
13
- set: formFunc === null || formFunc === void 0 ? void 0 : formFunc.setValue,
25
+ set: set,
14
26
  get: formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue
15
27
  });
16
28
  var datum = formFunc ? func : undefined;
@@ -10,7 +10,7 @@ declare const useImage: (props?: BaseImageProps) => {
10
10
  getRootProps: <TOther extends ObjectType = ObjectType>(externalProps?: TOther) => {
11
11
  [x: string]: (event: any) => void;
12
12
  } & TOther & {
13
- ref: React.RefObject<HTMLAnchorElement | HTMLDivElement>;
13
+ ref: React.RefObject<HTMLDivElement | HTMLAnchorElement>;
14
14
  onClick: (event: React.MouseEvent<HTMLImageElement | HTMLDivElement>) => void;
15
15
  };
16
16
  getImageProps: <TOther_1 extends ObjectType = ObjectType>(externalProps?: TOther_1) => {
@@ -7,7 +7,7 @@ declare const useNumberFormat: (props: InputNumberProps) => {
7
7
  onBlur: (e: React.FocusEvent<Element, Element>) => void;
8
8
  onFocus: (e: React.FocusEvent<Element, Element>) => void;
9
9
  value: string | undefined;
10
- type: "search" | "button" | "time" | "image" | "text" | (string & {}) | "checkbox" | "file" | "range" | "month" | "week" | "date" | "email" | "url" | "color" | "datetime-local" | "hidden" | "password" | "radio" | "reset" | "submit" | "tel" | undefined;
10
+ type: "search" | "color" | "button" | "time" | "image" | "text" | "reset" | "submit" | "email" | "url" | "range" | "tel" | (string & {}) | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "month" | "password" | "radio" | "week" | undefined;
11
11
  };
12
12
  export default useNumberFormat;
13
13
  //# sourceMappingURL=use-input-number.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const getPosition: (target: HTMLElement | null, priorityDirection: "auto" | "vertical" | "horizontal" | undefined, mode: 'popover' | 'menu' | 'list') => "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "left-top" | "left-bottom" | "right-top" | "right-bottom" | "top" | "bottom";
1
+ export declare const getPosition: (target: HTMLElement | null, priorityDirection: "vertical" | "horizontal" | "auto" | undefined, mode: 'popover' | 'menu' | 'list') => "bottom" | "left" | "right" | "top" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "left-top" | "left-bottom" | "right-top" | "right-bottom";
2
2
  //# sourceMappingURL=position.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { ObjectType } from '../../common/type';
2
2
  import { MessageType } from './rule.type';
3
- export declare const typeMessage: (props: ObjectType) => "$rules.reg" | "$rules.type";
3
+ export declare const typeMessage: (props: ObjectType) => "$rules.type" | "$rules.reg";
4
4
  declare const _default: (type: string, { message, tip }?: {
5
5
  message?: MessageType | undefined;
6
6
  tip?: string | undefined;
@@ -28,7 +28,7 @@ declare const useButton: (props?: BaseButtonProps) => {
28
28
  buttonRef?: React.Ref<HTMLButtonElement> | undefined;
29
29
  } & TOther_1 & {
30
30
  disabled: boolean | undefined;
31
- htmlType: "submit" | "reset" | "button" | undefined;
31
+ htmlType: "button" | "reset" | "submit" | undefined;
32
32
  onClick: (event: React.MouseEvent<HTMLButtonElement> | React.MouseEvent<HTMLAnchorElement>) => void;
33
33
  };
34
34
  getSpaceChildren: (children: React.ReactNode, space?: boolean, className?: string) => React.ReactNode;
@@ -4,7 +4,7 @@ declare const useDatePickerFormat: <Value extends DatePickerValueType>(props: Us
4
4
  resultArr: (string | undefined)[];
5
5
  targetResultArr: (string | undefined)[];
6
6
  dateArr: (Date | undefined)[];
7
- disabledStatus: "left" | "right" | "all" | undefined;
7
+ disabledStatus: "all" | "left" | "right" | undefined;
8
8
  currentArr: Date[];
9
9
  mode: DatePickerModeType[];
10
10
  isEmpty: boolean;
@@ -1,7 +1,7 @@
1
1
  export interface FormDatum {
2
2
  set: (vals: {
3
3
  [name: string]: any;
4
- }) => void;
4
+ } | string, value?: any) => void;
5
5
  get: (name?: string) => any;
6
6
  }
7
7
  declare const useFormDatum: () => FormDatum | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7C,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AACD,QAAA,MAAM,YAAY,6BAQjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AAED,QAAA,MAAM,YAAY,6BAgBjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,9 +1,21 @@
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
3
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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); }
1
5
  import useLatestObj from "../../../common/use-latest-obj";
6
+ import { usePersistFn } from "../../../common/use-persist-fn";
2
7
  import { useFormFunc } from "../form-func-context";
3
8
  var useFormDatum = function useFormDatum() {
4
9
  var formFunc = useFormFunc();
10
+ var set = usePersistFn(function (vals, value) {
11
+ if (_typeof(vals) === 'object') {
12
+ formFunc === null || formFunc === void 0 || formFunc.setValue(vals);
13
+ } else {
14
+ formFunc === null || formFunc === void 0 || formFunc.setValue(_defineProperty({}, vals, value));
15
+ }
16
+ });
5
17
  var func = useLatestObj({
6
- set: formFunc === null || formFunc === void 0 ? void 0 : formFunc.setValue,
18
+ set: set,
7
19
  get: formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue
8
20
  });
9
21
  var datum = formFunc ? func : undefined;
@@ -10,7 +10,7 @@ declare const useImage: (props?: BaseImageProps) => {
10
10
  getRootProps: <TOther extends ObjectType = ObjectType>(externalProps?: TOther) => {
11
11
  [x: string]: (event: any) => void;
12
12
  } & TOther & {
13
- ref: React.RefObject<HTMLAnchorElement | HTMLDivElement>;
13
+ ref: React.RefObject<HTMLDivElement | HTMLAnchorElement>;
14
14
  onClick: (event: React.MouseEvent<HTMLImageElement | HTMLDivElement>) => void;
15
15
  };
16
16
  getImageProps: <TOther_1 extends ObjectType = ObjectType>(externalProps?: TOther_1) => {
@@ -7,7 +7,7 @@ declare const useNumberFormat: (props: InputNumberProps) => {
7
7
  onBlur: (e: React.FocusEvent<Element, Element>) => void;
8
8
  onFocus: (e: React.FocusEvent<Element, Element>) => void;
9
9
  value: string | undefined;
10
- type: "search" | "button" | "time" | "image" | "text" | (string & {}) | "checkbox" | "file" | "range" | "month" | "week" | "date" | "email" | "url" | "color" | "datetime-local" | "hidden" | "password" | "radio" | "reset" | "submit" | "tel" | undefined;
10
+ type: "search" | "color" | "button" | "time" | "image" | "text" | "reset" | "submit" | "email" | "url" | "range" | "tel" | (string & {}) | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "month" | "password" | "radio" | "week" | undefined;
11
11
  };
12
12
  export default useNumberFormat;
13
13
  //# sourceMappingURL=use-input-number.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const getPosition: (target: HTMLElement | null, priorityDirection: "auto" | "vertical" | "horizontal" | undefined, mode: 'popover' | 'menu' | 'list') => "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "left-top" | "left-bottom" | "right-top" | "right-bottom" | "top" | "bottom";
1
+ export declare const getPosition: (target: HTMLElement | null, priorityDirection: "vertical" | "horizontal" | "auto" | undefined, mode: 'popover' | 'menu' | 'list') => "bottom" | "left" | "right" | "top" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "left-top" | "left-bottom" | "right-top" | "right-bottom";
2
2
  //# sourceMappingURL=position.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { ObjectType } from '../../common/type';
2
2
  import { MessageType } from './rule.type';
3
- export declare const typeMessage: (props: ObjectType) => "$rules.reg" | "$rules.type";
3
+ export declare const typeMessage: (props: ObjectType) => "$rules.type" | "$rules.reg";
4
4
  declare const _default: (type: string, { message, tip }?: {
5
5
  message?: MessageType | undefined;
6
6
  tip?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.1.9-beta.1",
3
+ "version": "3.1.10",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",