Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ahooks

Package Overview
Dependencies
Maintainers
4
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ahooks - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

es/useNetwork/index.d.ts

4

es/index.d.ts

@@ -50,3 +50,5 @@ import useRequest, { UseRequestProvider } from '@ahooksjs/use-request';

import useTitle from './useTitle';
import useNetwork from './useNetwork';
import useTimeout from './useTimeout';
declare const useControlledValue: typeof useControllableValue;
export { useControlledValue, useControllableValue, useDynamicList, useVirtualList, useResponsive, useEventEmitter, useLocalStorageState, useSessionStorageState, useSize, configResponsive, useUpdateEffect, useUpdateLayoutEffect, useBoolean, useToggle, useDocumentVisibility, useSelections, useThrottle, useThrottleFn, useThrottleEffect, useDebounce, useDebounceFn, useDebounceEffect, usePrevious, useMouse, useScroll, useClickAway, useFullscreen, useInViewport, useKeyPress, useEventListener, useHover, useRequest, UseRequestProvider, useAntdTable, useUnmount, useSet, usePersistFn, useMap, useCreation, useDrag, useDrop, useMount, useCounter, useUpdate, useTextSelection, useEventTarget, useHistoryTravel, useFusionTable, useCookieState, useSetState, useInterval, useWhyDidYouUpdate, useTitle, };
export { useControlledValue, useControllableValue, useDynamicList, useVirtualList, useResponsive, useEventEmitter, useLocalStorageState, useSessionStorageState, useSize, configResponsive, useUpdateEffect, useUpdateLayoutEffect, useBoolean, useToggle, useDocumentVisibility, useSelections, useThrottle, useThrottleFn, useThrottleEffect, useDebounce, useDebounceFn, useDebounceEffect, usePrevious, useMouse, useScroll, useClickAway, useFullscreen, useInViewport, useKeyPress, useEventListener, useHover, useRequest, UseRequestProvider, useAntdTable, useUnmount, useSet, usePersistFn, useMap, useCreation, useDrag, useDrop, useMount, useCounter, useUpdate, useTextSelection, useEventTarget, useHistoryTravel, useFusionTable, useCookieState, useSetState, useInterval, useWhyDidYouUpdate, useTitle, useNetwork, useTimeout, };

@@ -85,2 +85,4 @@ var __read = this && this.__read || function (o, n) {

import useTitle from './useTitle';
import useNetwork from './useNetwork';
import useTimeout from './useTimeout';

@@ -98,2 +100,2 @@ var useControlledValue = function useControlledValue() {

export { useControlledValue, useControllableValue, useDynamicList, useVirtualList, useResponsive, useEventEmitter, useLocalStorageState, useSessionStorageState, useSize, configResponsive, useUpdateEffect, useUpdateLayoutEffect, useBoolean, useToggle, useDocumentVisibility, useSelections, useThrottle, useThrottleFn, useThrottleEffect, useDebounce, useDebounceFn, useDebounceEffect, usePrevious, useMouse, useScroll, useClickAway, useFullscreen, useInViewport, useKeyPress, useEventListener, useHover, useRequest, UseRequestProvider, useAntdTable, useUnmount, useSet, usePersistFn, useMap, useCreation, useDrag, useDrop, useMount, useCounter, useUpdate, useTextSelection, useEventTarget, useHistoryTravel, useFusionTable, useCookieState, useSetState, useInterval, useWhyDidYouUpdate, useTitle };
export { useControlledValue, useControllableValue, useDynamicList, useVirtualList, useResponsive, useEventEmitter, useLocalStorageState, useSessionStorageState, useSize, configResponsive, useUpdateEffect, useUpdateLayoutEffect, useBoolean, useToggle, useDocumentVisibility, useSelections, useThrottle, useThrottleFn, useThrottleEffect, useDebounce, useDebounceFn, useDebounceEffect, usePrevious, useMouse, useScroll, useClickAway, useFullscreen, useInViewport, useKeyPress, useEventListener, useHover, useRequest, UseRequestProvider, useAntdTable, useUnmount, useSet, usePersistFn, useMap, useCreation, useDrag, useDrop, useMount, useCounter, useUpdate, useTextSelection, useEventTarget, useHistoryTravel, useFusionTable, useCookieState, useSetState, useInterval, useWhyDidYouUpdate, useTitle, useNetwork, useTimeout };

@@ -6,2 +6,4 @@ import { CombineService, PaginatedParams, BasePaginatedOptions, PaginatedOptionsWithFormat, PaginatedFormatReturn, PaginatedResult } from '@ahooksjs/use-request/lib/types';

}
declare type Antd3ValidateFields = (fieldNames: string[], callback: (errors: any, values: any) => void) => void;
declare type Antd4ValidateFields = (fieldNames?: string[]) => Promise<any>;
export interface UseAntdTableFormUtils {

@@ -12,2 +14,3 @@ getFieldInstance?: (name: string) => {};

resetFields: (...args: any) => void;
validateFields: Antd3ValidateFields | Antd4ValidateFields;
[key: string]: any;

@@ -14,0 +17,0 @@ }

@@ -163,26 +163,53 @@ var __assign = this && this.__assign || function () {

}, [type, allFormData, getActivetFieldValues]);
var validateFields = useCallback(function () {
var fieldValues = getActivetFieldValues();
if (!form) {
return Promise.resolve();
}
var fields = Object.keys(fieldValues);
if (!form.getInternalHooks) {
return new Promise(function (resolve, reject) {
form.validateFields(fields, function (errors, values) {
if (errors) {
reject(errors);
} else {
resolve(values);
}
});
});
}
return form.validateFields(fields);
}, [form]);
var _submit = useCallback(function (initParams) {
setTimeout(function () {
var activeFormData = getActivetFieldValues(); // 记录全量数据
validateFields().then(function () {
var activeFormData = getActivetFieldValues(); // 记录全量数据
var _allFormData = __assign(__assign({}, allFormData), activeFormData);
var _allFormData = __assign(__assign({}, allFormData), activeFormData);
setAllFormData(_allFormData); // has defaultParams
setAllFormData(_allFormData); // has defaultParams
if (initParams) {
run(initParams[0], activeFormData, {
if (initParams) {
run(initParams[0], activeFormData, {
allFormData: _allFormData,
type: type
});
return;
}
run(__assign(__assign({
pageSize: options.defaultPageSize || 10
}, params[0] || {}), {
current: 1
}), activeFormData, {
allFormData: _allFormData,
type: type
});
return;
}
run(__assign(__assign({
pageSize: options.defaultPageSize || 10
}, params[0] || {}), {
current: 1
}), activeFormData, {
allFormData: _allFormData,
type: type
})["catch"](function (err) {
return err;
});

@@ -189,0 +216,0 @@ });

import { BasicTarget } from '../utils/dom';
declare type EventType = MouseEvent | TouchEvent;
export default function useClickAway(onClickAway: (event: EventType) => void, target: BasicTarget, eventName?: string): void;
export default function useClickAway(onClickAway: (event: EventType) => void, target: BasicTarget | BasicTarget[], eventName?: string): void;
export {};

@@ -11,5 +11,10 @@ import { useEffect, useCallback } from 'react';

var handler = useCallback(function (event) {
var targetElement = getTargetElement(target);
var targets = Array.isArray(target) ? target : [target];
var targetElements = targets.map(function (targetItem) {
return getTargetElement(targetItem);
});
if (!targetElement || targetElement.contains(event.target)) {
if (targetElements.some(function (targetElement) {
return !targetElement || targetElement.contains(event.target);
})) {
return;

@@ -16,0 +21,0 @@ }

@@ -10,2 +10,3 @@ import { Field } from './index';

resetFields: (...args: any) => void;
validateFields: () => Promise<any>;
[key: string]: any;

@@ -12,0 +13,0 @@ }

@@ -24,3 +24,6 @@ var __assign = this && this.__assign || function () {

getFieldsValue: field.getValues,
resetFields: field.reset
resetFields: field.reset,
validateFields: function validateFields(fields, callback) {
field.validate(callback);
}
};

@@ -27,0 +30,0 @@ };

@@ -11,2 +11,3 @@ import { CombineService, PaginatedParams, BasePaginatedOptions, PaginatedOptionsWithFormat, PaginatedFormatReturn, PaginatedResult } from '@ahooksjs/use-request/lib/types';

reset: (...args: any) => void;
validate: (callback: (errors: any, values: any) => void) => void;
[key: string]: any;

@@ -13,0 +14,0 @@ }

@@ -17,3 +17,3 @@ var __assign = this && this.__assign || function () {

import { useAntdTable } from '..';
import useAntdTable from '../useAntdTable';
import { fieldAdapter, resultAdapter } from './fusionAdapter';

@@ -20,0 +20,0 @@

@@ -142,11 +142,13 @@ var __read = this && this.__read || function (o, n) {

var go = useCallback(function (step) {
if (step === 0) {
var stepNum = typeof step === 'number' ? step : Number(step);
if (stepNum === 0) {
return;
}
if (step > 0) {
return _forward(step);
if (stepNum > 0) {
return _forward(stepNum);
}
_backward(step);
_backward(stepNum);
}, [_backward, _forward]);

@@ -153,0 +155,0 @@ return {

@@ -57,3 +57,3 @@ var __values = this && this.__values || function (o) {

function init() {
if (info) return;
if (info || typeof window === "undefined") return;
info = {};

@@ -131,3 +131,6 @@ calculate();

var windowExists = typeof window !== "undefined";
useEffect(function () {
if (!windowExists) return;
var subscriber = function subscriber() {

@@ -141,4 +144,4 @@ setState(info);

};
}, []);
}, [windowExists]);
return state;
}

@@ -50,3 +50,5 @@ import useRequest, { UseRequestProvider } from '@ahooksjs/use-request';

import useTitle from './useTitle';
import useNetwork from './useNetwork';
import useTimeout from './useTimeout';
declare const useControlledValue: typeof useControllableValue;
export { useControlledValue, useControllableValue, useDynamicList, useVirtualList, useResponsive, useEventEmitter, useLocalStorageState, useSessionStorageState, useSize, configResponsive, useUpdateEffect, useUpdateLayoutEffect, useBoolean, useToggle, useDocumentVisibility, useSelections, useThrottle, useThrottleFn, useThrottleEffect, useDebounce, useDebounceFn, useDebounceEffect, usePrevious, useMouse, useScroll, useClickAway, useFullscreen, useInViewport, useKeyPress, useEventListener, useHover, useRequest, UseRequestProvider, useAntdTable, useUnmount, useSet, usePersistFn, useMap, useCreation, useDrag, useDrop, useMount, useCounter, useUpdate, useTextSelection, useEventTarget, useHistoryTravel, useFusionTable, useCookieState, useSetState, useInterval, useWhyDidYouUpdate, useTitle, };
export { useControlledValue, useControllableValue, useDynamicList, useVirtualList, useResponsive, useEventEmitter, useLocalStorageState, useSessionStorageState, useSize, configResponsive, useUpdateEffect, useUpdateLayoutEffect, useBoolean, useToggle, useDocumentVisibility, useSelections, useThrottle, useThrottleFn, useThrottleEffect, useDebounce, useDebounceFn, useDebounceEffect, usePrevious, useMouse, useScroll, useClickAway, useFullscreen, useInViewport, useKeyPress, useEventListener, useHover, useRequest, UseRequestProvider, useAntdTable, useUnmount, useSet, usePersistFn, useMap, useCreation, useDrag, useDrop, useMount, useCounter, useUpdate, useTextSelection, useEventTarget, useHistoryTravel, useFusionTable, useCookieState, useSetState, useInterval, useWhyDidYouUpdate, useTitle, useNetwork, useTimeout, };

@@ -81,3 +81,3 @@ "use strict";

});
exports.useTitle = exports.useWhyDidYouUpdate = exports.useInterval = exports.useSetState = exports.useCookieState = exports.useFusionTable = exports.useHistoryTravel = exports.useEventTarget = exports.useTextSelection = exports.useUpdate = exports.useCounter = exports.useMount = exports.useDrop = exports.useDrag = exports.useCreation = exports.useMap = exports.usePersistFn = exports.useSet = exports.useUnmount = exports.useAntdTable = exports.UseRequestProvider = exports.useRequest = exports.useHover = exports.useEventListener = exports.useKeyPress = exports.useInViewport = exports.useFullscreen = exports.useClickAway = exports.useScroll = exports.useMouse = exports.usePrevious = exports.useDebounceEffect = exports.useDebounceFn = exports.useDebounce = exports.useThrottleEffect = exports.useThrottleFn = exports.useThrottle = exports.useSelections = exports.useDocumentVisibility = exports.useToggle = exports.useBoolean = exports.useUpdateLayoutEffect = exports.useUpdateEffect = exports.configResponsive = exports.useSize = exports.useSessionStorageState = exports.useLocalStorageState = exports.useEventEmitter = exports.useResponsive = exports.useVirtualList = exports.useDynamicList = exports.useControllableValue = exports.useControlledValue = void 0;
exports.useTimeout = exports.useNetwork = exports.useTitle = exports.useWhyDidYouUpdate = exports.useInterval = exports.useSetState = exports.useCookieState = exports.useFusionTable = exports.useHistoryTravel = exports.useEventTarget = exports.useTextSelection = exports.useUpdate = exports.useCounter = exports.useMount = exports.useDrop = exports.useDrag = exports.useCreation = exports.useMap = exports.usePersistFn = exports.useSet = exports.useUnmount = exports.useAntdTable = exports.UseRequestProvider = exports.useRequest = exports.useHover = exports.useEventListener = exports.useKeyPress = exports.useInViewport = exports.useFullscreen = exports.useClickAway = exports.useScroll = exports.useMouse = exports.usePrevious = exports.useDebounceEffect = exports.useDebounceFn = exports.useDebounce = exports.useThrottleEffect = exports.useThrottleFn = exports.useThrottle = exports.useSelections = exports.useDocumentVisibility = exports.useToggle = exports.useBoolean = exports.useUpdateLayoutEffect = exports.useUpdateEffect = exports.configResponsive = exports.useSize = exports.useSessionStorageState = exports.useLocalStorageState = exports.useEventEmitter = exports.useResponsive = exports.useVirtualList = exports.useDynamicList = exports.useControllableValue = exports.useControlledValue = void 0;

@@ -308,2 +308,10 @@ var use_request_1 = __importStar(require("@ahooksjs/use-request"));

var useNetwork_1 = __importDefault(require("./useNetwork"));
exports.useNetwork = useNetwork_1["default"];
var useTimeout_1 = __importDefault(require("./useTimeout"));
exports.useTimeout = useTimeout_1["default"];
var useControlledValue = function useControlledValue() {

@@ -310,0 +318,0 @@ var args = [];

@@ -6,2 +6,4 @@ import { CombineService, PaginatedParams, BasePaginatedOptions, PaginatedOptionsWithFormat, PaginatedFormatReturn, PaginatedResult } from '@ahooksjs/use-request/lib/types';

}
declare type Antd3ValidateFields = (fieldNames: string[], callback: (errors: any, values: any) => void) => void;
declare type Antd4ValidateFields = (fieldNames?: string[]) => Promise<any>;
export interface UseAntdTableFormUtils {

@@ -12,2 +14,3 @@ getFieldInstance?: (name: string) => {};

resetFields: (...args: any) => void;
validateFields: Antd3ValidateFields | Antd4ValidateFields;
[key: string]: any;

@@ -14,0 +17,0 @@ }

@@ -178,26 +178,53 @@ "use strict";

}, [type, allFormData, getActivetFieldValues]);
var validateFields = react_1.useCallback(function () {
var fieldValues = getActivetFieldValues();
if (!form) {
return Promise.resolve();
}
var fields = Object.keys(fieldValues);
if (!form.getInternalHooks) {
return new Promise(function (resolve, reject) {
form.validateFields(fields, function (errors, values) {
if (errors) {
reject(errors);
} else {
resolve(values);
}
});
});
}
return form.validateFields(fields);
}, [form]);
var _submit = react_1.useCallback(function (initParams) {
setTimeout(function () {
var activeFormData = getActivetFieldValues(); // 记录全量数据
validateFields().then(function () {
var activeFormData = getActivetFieldValues(); // 记录全量数据
var _allFormData = __assign(__assign({}, allFormData), activeFormData);
var _allFormData = __assign(__assign({}, allFormData), activeFormData);
setAllFormData(_allFormData); // has defaultParams
setAllFormData(_allFormData); // has defaultParams
if (initParams) {
run(initParams[0], activeFormData, {
if (initParams) {
run(initParams[0], activeFormData, {
allFormData: _allFormData,
type: type
});
return;
}
run(__assign(__assign({
pageSize: options.defaultPageSize || 10
}, params[0] || {}), {
current: 1
}), activeFormData, {
allFormData: _allFormData,
type: type
});
return;
}
run(__assign(__assign({
pageSize: options.defaultPageSize || 10
}, params[0] || {}), {
current: 1
}), activeFormData, {
allFormData: _allFormData,
type: type
})["catch"](function (err) {
return err;
});

@@ -204,0 +231,0 @@ });

import { BasicTarget } from '../utils/dom';
declare type EventType = MouseEvent | TouchEvent;
export default function useClickAway(onClickAway: (event: EventType) => void, target: BasicTarget, eventName?: string): void;
export default function useClickAway(onClickAway: (event: EventType) => void, target: BasicTarget | BasicTarget[], eventName?: string): void;
export {};

@@ -20,5 +20,10 @@ "use strict";

var handler = react_1.useCallback(function (event) {
var targetElement = dom_1.getTargetElement(target);
var targets = Array.isArray(target) ? target : [target];
var targetElements = targets.map(function (targetItem) {
return dom_1.getTargetElement(targetItem);
});
if (!targetElement || targetElement.contains(event.target)) {
if (targetElements.some(function (targetElement) {
return !targetElement || targetElement.contains(event.target);
})) {
return;

@@ -25,0 +30,0 @@ }

@@ -10,2 +10,3 @@ import { Field } from './index';

resetFields: (...args: any) => void;
validateFields: () => Promise<any>;
[key: string]: any;

@@ -12,0 +13,0 @@ }

@@ -31,3 +31,6 @@ "use strict";

getFieldsValue: field.getValues,
resetFields: field.reset
resetFields: field.reset,
validateFields: function validateFields(fields, callback) {
field.validate(callback);
}
};

@@ -34,0 +37,0 @@ };

@@ -11,2 +11,3 @@ import { CombineService, PaginatedParams, BasePaginatedOptions, PaginatedOptionsWithFormat, PaginatedFormatReturn, PaginatedResult } from '@ahooksjs/use-request/lib/types';

reset: (...args: any) => void;
validate: (callback: (errors: any, values: any) => void) => void;
[key: string]: any;

@@ -13,0 +14,0 @@ }

@@ -19,2 +19,8 @@ "use strict";

var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {

@@ -24,3 +30,3 @@ value: true

var __1 = require("..");
var useAntdTable_1 = __importDefault(require("../useAntdTable"));

@@ -30,6 +36,5 @@ var fusionAdapter_1 = require("./fusionAdapter");

function useFusionTable(service, options) {
var ret = __1.useAntdTable(service, __assign(__assign({}, options), {
var ret = useAntdTable_1["default"](service, __assign(__assign({}, options), {
form: options.field ? fusionAdapter_1.fieldAdapter(options.field) : undefined
}));
return fusionAdapter_1.resultAdapter(ret);

@@ -36,0 +41,0 @@ }

@@ -148,11 +148,13 @@ "use strict";

var go = react_1.useCallback(function (step) {
if (step === 0) {
var stepNum = typeof step === 'number' ? step : Number(step);
if (stepNum === 0) {
return;
}
if (step > 0) {
return _forward(step);
if (stepNum > 0) {
return _forward(stepNum);
}
_backward(step);
_backward(stepNum);
}, [_backward, _forward]);

@@ -159,0 +161,0 @@ return {

@@ -65,3 +65,3 @@ "use strict";

function init() {
if (info) return;
if (info || typeof window === "undefined") return;
info = {};

@@ -142,3 +142,6 @@ calculate();

var windowExists = typeof window !== "undefined";
react_1.useEffect(function () {
if (!windowExists) return;
var subscriber = function subscriber() {

@@ -152,3 +155,3 @@ setState(info);

};
}, []);
}, [windowExists]);
return state;

@@ -155,0 +158,0 @@ }

{
"name": "ahooks",
"version": "2.4.0",
"version": "2.5.0",
"description": "react hooks library",

@@ -14,2 +14,3 @@ "keywords": [

"unpkg": "dist/ahooks.js",
"sideEffects": false,
"authors": {

@@ -16,0 +17,0 @@ "name": "brickspert",

@@ -11,11 +11,11 @@ English | [简体中文](https://github.com/alibaba/hooks/blob/master/README.zh-CN.md)

* [English](https://ahooks.js.org/)
* [中文](https://ahooks.js.org/zh-CN/)
- [English](https://ahooks.js.org/)
- [中文](https://ahooks.js.org/zh-CN/)
## ✨ Features
* Easy to learn and use.
* Contains a wealth of advanced Hooks that are refined from the app.
* Contains a wealth of basic Hooks.
* Written in TypeScript with predictable static types.
- Easy to learn and use.
- Contains a wealth of advanced Hooks that are refined from the app.
- Contains a wealth of basic Hooks.
- Written in TypeScript with predictable static types.

@@ -83,2 +83,3 @@ ## 📦 Install

```
Open your browser and visit http://127.0.0.1:8001 , see more at Development.

@@ -96,7 +97,5 @@

[1]: https://www.npmjs.com/package/ahooks
[2]: https://npmjs.org/package/ahooks
[image-1]: https://img.shields.io/npm/v/ahooks.svg?style=flat
[image-2]: https://img.shields.io/npm/dm/ahooks.svg?style=flat
[1]: https://www.npmjs.com/package/ahooks
[2]: https://npmjs.org/package/ahooks
[image-1]: https://img.shields.io/npm/v/ahooks.svg?style=flat
[image-2]: https://img.shields.io/npm/dm/ahooks.svg?style=flat

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc