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

@ahooksjs/use-filter-plugin

Package Overview
Dependencies
Maintainers
5
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ahooksjs/use-filter-plugin - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

20

es/index.js

@@ -9,2 +9,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

export var FILTER_PLUGIN_SYMBOL = Symbol.for('FILTER_PLUGIN_SYMBOL');
var REFRESH_FILTER_METHOD = 'REFRESH_FILTER_METHOD';

@@ -20,10 +21,19 @@ var propsToParams = function propsToParams(props) {

var filterRef = useRef({});
var transformer = options.transformer || function (res) {
var _options$transformer = options.transformer,
transformer = _options$transformer === void 0 ? function (res) {
return res;
};
} : _options$transformer,
_options$resetWhenQue = options.resetWhenQuery,
resetWhenQuery = _options$resetWhenQue === void 0 ? true : _options$resetWhenQue;
return {
pluginType: FILTER_PLUGIN_SYMBOL,
middlewares: function middlewares(ctx, next) {
var meta = ctx.meta,
methods = ctx.methods;
var queryFrom = meta.queryFrom;
if ([methods.ON_FORM_SUBMIT, methods.ON_FORM_RESET].includes(queryFrom) && resetWhenQuery) {
filterRef.current = {};
}
var filterParams = propsToParams(filterRef.current);

@@ -42,2 +52,4 @@ ctx.params = _objectSpread(_objectSpread({}, ctx.params), transformer(filterParams, filterRef.current));

current: 1
}, {
queryFrom: REFRESH_FILTER_METHOD
});

@@ -44,0 +56,0 @@ }

1

es/type.d.ts
import { TableNormalPlugin } from '@ahooksjs/use-table';
export interface IOptions {
resetWhenQuery?: boolean;
transformer?: (params: any, filterParams: any) => any;
}
export declare type TUseFilterPlugin = (options?: IOptions) => TableNormalPlugin;

@@ -18,2 +18,3 @@ "use strict";

exports.FILTER_PLUGIN_SYMBOL = FILTER_PLUGIN_SYMBOL;
var REFRESH_FILTER_METHOD = 'REFRESH_FILTER_METHOD';

@@ -29,10 +30,19 @@ var propsToParams = function propsToParams(props) {

var filterRef = (0, _react.useRef)({});
var transformer = options.transformer || function (res) {
var _options$transformer = options.transformer,
transformer = _options$transformer === void 0 ? function (res) {
return res;
};
} : _options$transformer,
_options$resetWhenQue = options.resetWhenQuery,
resetWhenQuery = _options$resetWhenQue === void 0 ? true : _options$resetWhenQue;
return {
pluginType: FILTER_PLUGIN_SYMBOL,
middlewares: function middlewares(ctx, next) {
var meta = ctx.meta,
methods = ctx.methods;
var queryFrom = meta.queryFrom;
if ([methods.ON_FORM_SUBMIT, methods.ON_FORM_RESET].includes(queryFrom) && resetWhenQuery) {
filterRef.current = {};
}
var filterParams = propsToParams(filterRef.current);

@@ -51,2 +61,4 @@ ctx.params = _objectSpread(_objectSpread({}, ctx.params), transformer(filterParams, filterRef.current));

current: 1
}, {
queryFrom: REFRESH_FILTER_METHOD
});

@@ -53,0 +65,0 @@ }

import { TableNormalPlugin } from '@ahooksjs/use-table';
export interface IOptions {
resetWhenQuery?: boolean;
transformer?: (params: any, filterParams: any) => any;
}
export declare type TUseFilterPlugin = (options?: IOptions) => TableNormalPlugin;
{
"name": "@ahooksjs/use-filter-plugin",
"version": "0.2.6",
"version": "0.2.7",
"scripts": {

@@ -24,3 +24,3 @@ "build:tsc": "tsc --project tsconfig.build.json --declarationDir ./lib && tsc --project tsconfig.build.json --declarationDir ./es"

],
"gitHead": "4408938cba5dead278a310892e93a2a7b3b07f09"
"gitHead": "7dfeb776f13bc0b399bf43eccf7b0f2f889a431a"
}
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