@ahooksjs/use-filter-plugin
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -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 @@ } |
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" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8699
133