@ahooksjs/use-table
Advanced tools
+5
-0
| export declare const PREPARE = "prepare"; | ||
| export declare const DID_RENDER = "didRender"; | ||
| export declare const WILL_QUERY = "willQuery"; | ||
| export declare const YOUR_TURN = "yourTurn"; | ||
| export declare const QUERYING = "querying"; | ||
| export declare const DID_QUERY = "didQuery"; | ||
| export declare const timelines: string[]; | ||
@@ -3,0 +8,0 @@ export declare const defaults: { |
+6
-1
| export var PREPARE = 'prepare'; | ||
| export var timelines = ['didRender', 'willQuery', 'yourTurn', 'querying', 'didQuery']; | ||
| export var DID_RENDER = 'didRender'; | ||
| export var WILL_QUERY = 'willQuery'; | ||
| export var YOUR_TURN = 'yourTurn'; | ||
| export var QUERYING = 'querying'; | ||
| export var DID_QUERY = 'didQuery'; | ||
| export var timelines = [DID_RENDER, WILL_QUERY, YOUR_TURN, QUERYING, DID_QUERY]; | ||
| export var defaults = { | ||
@@ -4,0 +9,0 @@ current: 1, |
+2
-2
@@ -1,7 +0,7 @@ | ||
| import { methods, PREPARE } from './config'; | ||
| import { methods, PREPARE, WILL_QUERY } from './config'; | ||
| import { TUseTable } from './type'; | ||
| import { IS_NORMAL_SYMBOL } from './symbol'; | ||
| export * from './type'; | ||
| export { PREPARE, IS_NORMAL_SYMBOL, methods }; | ||
| export { PREPARE, WILL_QUERY, IS_NORMAL_SYMBOL, methods }; | ||
| declare const useTable: TUseTable; | ||
| export default useTable; |
+7
-5
@@ -25,3 +25,3 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
| import useQueryDisplay from '@ahooksjs/use-query-display'; | ||
| import { timelines, defaults, methods, PREPARE } from './config'; | ||
| import { timelines, defaults, methods, PREPARE, WILL_QUERY } from './config'; | ||
| import createStore from './store'; | ||
@@ -33,5 +33,5 @@ import middlewares from './middlewares/index'; | ||
| import { checkQueryFrom as _checkQueryFrom } from './helper'; | ||
| import { useMutableState, useMount, useUpdateEffect } from './use'; | ||
| import { useMutableState, useMount, useUpdateEffect, usePersistFn } from './use'; | ||
| export * from './type'; | ||
| export { PREPARE, IS_NORMAL_SYMBOL, methods }; | ||
| export { PREPARE, WILL_QUERY, IS_NORMAL_SYMBOL, methods }; | ||
@@ -70,2 +70,3 @@ var useTablePlugin = function useTablePlugin(options) { | ||
| ctx.methods = methods; | ||
| ctx.meta = _objectSpread(_objectSpread({}, ctx.meta), {}, _defineProperty({}, IS_NORMAL_SYMBOL, isNormal)); | ||
| ctx.helper = _objectSpread(_objectSpread({}, helper), {}, { | ||
@@ -76,5 +77,5 @@ checkQueryFrom: function checkQueryFrom() { | ||
| }); | ||
| ctx.meta = _objectSpread(_objectSpread({}, ctx.meta), {}, _defineProperty({}, IS_NORMAL_SYMBOL, isNormal)); | ||
| return next(); | ||
| }), middlewares), | ||
| // 返回 props | ||
| props: function props(_props) { | ||
@@ -110,2 +111,3 @@ var helper = app.helper; | ||
| }))]; | ||
| var persistedService = usePersistFn(service); | ||
@@ -115,3 +117,3 @@ var _useQueryDisplay = useQueryDisplay(_objectSpread(_objectSpread({ | ||
| }, options), {}, { | ||
| service: service | ||
| service: persistedService | ||
| }), plugin.concat(addYourMiddlewares(plugins))), | ||
@@ -118,0 +120,0 @@ _useQueryDisplay$prop = _useQueryDisplay.props, |
@@ -8,11 +8,9 @@ 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; } | ||
| var refreshPipe = function refreshPipe(ctx) { | ||
| var _ctx$config = ctx.config, | ||
| config = _ctx$config === void 0 ? {} : _ctx$config, | ||
| var _ctx$options = ctx.options, | ||
| options = _ctx$options === void 0 ? {} : _ctx$options, | ||
| store = ctx.store; | ||
| var _config$defaults = config.defaults, | ||
| defaults = _config$defaults === void 0 ? {} : _config$defaults; | ||
| var memoState = store.stateMap.get(); | ||
| var pagination = memoState.pagination; | ||
| var current = pagination.current || defaults.current; | ||
| var pageSize = pagination.pageSize || defaults.pageSize; | ||
| var current = pagination.current || options.current; | ||
| var pageSize = pagination.pageSize || options.pageSize; | ||
| ctx.params = _objectSpread(_objectSpread({}, ctx.params), {}, { | ||
@@ -19,0 +17,0 @@ current: current, |
@@ -19,6 +19,8 @@ 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; } | ||
| isObject = helper.isObject; | ||
| var ctxMap = store.ctxMap; | ||
| var nextParams = meta[IS_NORMAL_SYMBOL] ? params : ctxMap.get('prevParams'); // 局部的 transformer, 局部覆盖全局 | ||
| var paramMap = store.paramMap; | ||
| var nextParams = _objectSpread(_objectSpread({}, paramMap.get()), params); // 局部的 transformer, 局部覆盖全局 | ||
| // 需要把 transform 之后的值保留下来 | ||
| if (isFunction(payload)) { | ||
@@ -36,5 +38,2 @@ ctx.params = payload(nextParams, { | ||
| ctxMap.set({ | ||
| prevParams: ctx.params | ||
| }); | ||
| return ctx; | ||
@@ -41,0 +40,0 @@ }; |
@@ -49,6 +49,6 @@ 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; } | ||
| var pipeCompose = helper.pipeCompose; | ||
| var tablePluginProps = Array.isArray(props.tableProps) ? props.tableProps : [props.tableProps]; | ||
| var tablePropsOfPlugin = Array.isArray(props.tableProps) ? props.tableProps : [props.tableProps]; | ||
| var paginationPluginProps = Array.isArray(props.paginationProps) ? props.paginationProps : [props.paginationProps]; | ||
| var tableProps = _objectSpread(_objectSpread({}, pipeCompose(tablePluginProps)({})), {}, { | ||
| var tableProps = _objectSpread(_objectSpread({}, pipeCompose(tablePropsOfPlugin)({})), {}, { | ||
| dataSource: state.dataSource, | ||
@@ -55,0 +55,0 @@ loading: state.loading, |
+2
-2
@@ -1,2 +0,2 @@ | ||
| import { Obj, IApp, IHelper, IMiddlewareContext, NormalPlugin } from '@ahooksjs/use-query-display'; | ||
| import { Obj, IApp, IHelper, IMiddlewareContext, NormalPlugin, NativePlugin } from '@ahooksjs/use-query-display'; | ||
| export * from '@ahooksjs/use-query-display'; | ||
@@ -77,3 +77,3 @@ export declare type Pipe = (ctx: IMiddlewareContext) => Obj; | ||
| } | ||
| export declare type TableNormalPlugin<P = Obj> = NormalPlugin<IContext, P>; | ||
| export declare type TableNormalPlugin<P = Obj> = NormalPlugin<IContext, P> | NativePlugin<IContext, P>; | ||
| export interface Options { | ||
@@ -80,0 +80,0 @@ current?: number; |
+1
-0
@@ -6,1 +6,2 @@ import { Obj } from './type'; | ||
| export declare const useUpdateEffect: (fn: any, deps: any) => void; | ||
| export declare const usePersistFn: (fn: any) => (...args: any[]) => any; |
+11
-1
@@ -13,3 +13,3 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
| import { useMemo, useRef, useState, useEffect } from 'react'; | ||
| import { useMemo, useRef, useState, useEffect, useCallback } from 'react'; | ||
| export var useMutableState = function useMutableState() { | ||
@@ -49,2 +49,12 @@ var initalState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
| }, deps); | ||
| }; | ||
| export var usePersistFn = function usePersistFn(fn) { | ||
| var ref = useRef(function () { | ||
| throw new Error('Cannot call function while rendering.'); | ||
| }); | ||
| ref.current = fn; | ||
| var persistFn = useCallback(function () { | ||
| return ref.current.apply(ref, arguments); | ||
| }, [ref]); | ||
| return persistFn; | ||
| }; |
+5
-0
| export declare const PREPARE = "prepare"; | ||
| export declare const DID_RENDER = "didRender"; | ||
| export declare const WILL_QUERY = "willQuery"; | ||
| export declare const YOUR_TURN = "yourTurn"; | ||
| export declare const QUERYING = "querying"; | ||
| export declare const DID_QUERY = "didQuery"; | ||
| export declare const timelines: string[]; | ||
@@ -3,0 +8,0 @@ export declare const defaults: { |
+12
-2
@@ -6,6 +6,16 @@ "use strict"; | ||
| }); | ||
| exports.methods = exports.defaults = exports.timelines = exports.PREPARE = void 0; | ||
| exports.methods = exports.defaults = exports.timelines = exports.DID_QUERY = exports.QUERYING = exports.YOUR_TURN = exports.WILL_QUERY = exports.DID_RENDER = exports.PREPARE = void 0; | ||
| var PREPARE = 'prepare'; | ||
| exports.PREPARE = PREPARE; | ||
| var timelines = ['didRender', 'willQuery', 'yourTurn', 'querying', 'didQuery']; | ||
| var DID_RENDER = 'didRender'; | ||
| exports.DID_RENDER = DID_RENDER; | ||
| var WILL_QUERY = 'willQuery'; | ||
| exports.WILL_QUERY = WILL_QUERY; | ||
| var YOUR_TURN = 'yourTurn'; | ||
| exports.YOUR_TURN = YOUR_TURN; | ||
| var QUERYING = 'querying'; | ||
| exports.QUERYING = QUERYING; | ||
| var DID_QUERY = 'didQuery'; | ||
| exports.DID_QUERY = DID_QUERY; | ||
| var timelines = [DID_RENDER, WILL_QUERY, YOUR_TURN, QUERYING, DID_QUERY]; | ||
| exports.timelines = timelines; | ||
@@ -12,0 +22,0 @@ var defaults = { |
+2
-2
@@ -1,7 +0,7 @@ | ||
| import { methods, PREPARE } from './config'; | ||
| import { methods, PREPARE, WILL_QUERY } from './config'; | ||
| import { TUseTable } from './type'; | ||
| import { IS_NORMAL_SYMBOL } from './symbol'; | ||
| export * from './type'; | ||
| export { PREPARE, IS_NORMAL_SYMBOL, methods }; | ||
| export { PREPARE, WILL_QUERY, IS_NORMAL_SYMBOL, methods }; | ||
| declare const useTable: TUseTable; | ||
| export default useTable; |
+11
-2
@@ -9,2 +9,3 @@ "use strict"; | ||
| PREPARE: true, | ||
| WILL_QUERY: true, | ||
| IS_NORMAL_SYMBOL: true | ||
@@ -24,2 +25,8 @@ }; | ||
| }); | ||
| Object.defineProperty(exports, "WILL_QUERY", { | ||
| enumerable: true, | ||
| get: function get() { | ||
| return _config.WILL_QUERY; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "IS_NORMAL_SYMBOL", { | ||
@@ -122,2 +129,3 @@ enumerable: true, | ||
| ctx.methods = _config.methods; | ||
| ctx.meta = _objectSpread(_objectSpread({}, ctx.meta), {}, _defineProperty({}, _symbol.IS_NORMAL_SYMBOL, isNormal)); | ||
| ctx.helper = _objectSpread(_objectSpread({}, helper), {}, { | ||
@@ -128,5 +136,5 @@ checkQueryFrom: function checkQueryFrom() { | ||
| }); | ||
| ctx.meta = _objectSpread(_objectSpread({}, ctx.meta), {}, _defineProperty({}, _symbol.IS_NORMAL_SYMBOL, isNormal)); | ||
| return next(); | ||
| }), _index.default), | ||
| // 返回 props | ||
| props: function props(_props) { | ||
@@ -162,2 +170,3 @@ var helper = app.helper; | ||
| }))]; | ||
| var persistedService = (0, _use.usePersistFn)(service); | ||
@@ -167,3 +176,3 @@ var _useQueryDisplay = (0, _useQueryDisplay2.default)(_objectSpread(_objectSpread({ | ||
| }, options), {}, { | ||
| service: service | ||
| service: persistedService | ||
| }), plugin.concat((0, _shared.addYourMiddlewares)(plugins))), | ||
@@ -170,0 +179,0 @@ _useQueryDisplay$prop = _useQueryDisplay.props, |
@@ -15,11 +15,9 @@ "use strict"; | ||
| var refreshPipe = function refreshPipe(ctx) { | ||
| var _ctx$config = ctx.config, | ||
| config = _ctx$config === void 0 ? {} : _ctx$config, | ||
| var _ctx$options = ctx.options, | ||
| options = _ctx$options === void 0 ? {} : _ctx$options, | ||
| store = ctx.store; | ||
| var _config$defaults = config.defaults, | ||
| defaults = _config$defaults === void 0 ? {} : _config$defaults; | ||
| var memoState = store.stateMap.get(); | ||
| var pagination = memoState.pagination; | ||
| var current = pagination.current || defaults.current; | ||
| var pageSize = pagination.pageSize || defaults.pageSize; | ||
| var current = pagination.current || options.current; | ||
| var pageSize = pagination.pageSize || options.pageSize; | ||
| ctx.params = _objectSpread(_objectSpread({}, ctx.params), {}, { | ||
@@ -26,0 +24,0 @@ current: current, |
@@ -26,6 +26,8 @@ "use strict"; | ||
| isObject = helper.isObject; | ||
| var ctxMap = store.ctxMap; | ||
| var nextParams = meta[_symbol.IS_NORMAL_SYMBOL] ? params : ctxMap.get('prevParams'); // 局部的 transformer, 局部覆盖全局 | ||
| var paramMap = store.paramMap; | ||
| var nextParams = _objectSpread(_objectSpread({}, paramMap.get()), params); // 局部的 transformer, 局部覆盖全局 | ||
| // 需要把 transform 之后的值保留下来 | ||
| if (isFunction(payload)) { | ||
@@ -43,5 +45,2 @@ ctx.params = payload(nextParams, { | ||
| ctxMap.set({ | ||
| prevParams: ctx.params | ||
| }); | ||
| return ctx; | ||
@@ -48,0 +47,0 @@ }; |
@@ -58,6 +58,6 @@ "use strict"; | ||
| var pipeCompose = helper.pipeCompose; | ||
| var tablePluginProps = Array.isArray(props.tableProps) ? props.tableProps : [props.tableProps]; | ||
| var tablePropsOfPlugin = Array.isArray(props.tableProps) ? props.tableProps : [props.tableProps]; | ||
| var paginationPluginProps = Array.isArray(props.paginationProps) ? props.paginationProps : [props.paginationProps]; | ||
| var tableProps = _objectSpread(_objectSpread({}, pipeCompose(tablePluginProps)({})), {}, { | ||
| var tableProps = _objectSpread(_objectSpread({}, pipeCompose(tablePropsOfPlugin)({})), {}, { | ||
| dataSource: state.dataSource, | ||
@@ -64,0 +64,0 @@ loading: state.loading, |
+2
-2
@@ -1,2 +0,2 @@ | ||
| import { Obj, IApp, IHelper, IMiddlewareContext, NormalPlugin } from '@ahooksjs/use-query-display'; | ||
| import { Obj, IApp, IHelper, IMiddlewareContext, NormalPlugin, NativePlugin } from '@ahooksjs/use-query-display'; | ||
| export * from '@ahooksjs/use-query-display'; | ||
@@ -77,3 +77,3 @@ export declare type Pipe = (ctx: IMiddlewareContext) => Obj; | ||
| } | ||
| export declare type TableNormalPlugin<P = Obj> = NormalPlugin<IContext, P>; | ||
| export declare type TableNormalPlugin<P = Obj> = NormalPlugin<IContext, P> | NativePlugin<IContext, P>; | ||
| export interface Options { | ||
@@ -80,0 +80,0 @@ current?: number; |
+1
-0
@@ -6,1 +6,2 @@ import { Obj } from './type'; | ||
| export declare const useUpdateEffect: (fn: any, deps: any) => void; | ||
| export declare const usePersistFn: (fn: any) => (...args: any[]) => any; |
+15
-2
@@ -6,3 +6,3 @@ "use strict"; | ||
| }); | ||
| exports.useUpdateEffect = exports.useStateIsInit = exports.useMount = exports.useMutableState = void 0; | ||
| exports.usePersistFn = exports.useUpdateEffect = exports.useStateIsInit = exports.useMount = exports.useMutableState = void 0; | ||
@@ -68,2 +68,15 @@ var _react = require("react"); | ||
| exports.useUpdateEffect = useUpdateEffect; | ||
| exports.useUpdateEffect = useUpdateEffect; | ||
| var usePersistFn = function usePersistFn(fn) { | ||
| var ref = (0, _react.useRef)(function () { | ||
| throw new Error('Cannot call function while rendering.'); | ||
| }); | ||
| ref.current = fn; | ||
| var persistFn = (0, _react.useCallback)(function () { | ||
| return ref.current.apply(ref, arguments); | ||
| }, [ref]); | ||
| return persistFn; | ||
| }; | ||
| exports.usePersistFn = usePersistFn; |
+3
-3
| { | ||
| "name": "@ahooksjs/use-table", | ||
| "version": "0.0.3-alpha.0", | ||
| "version": "0.0.3-alpha.1", | ||
| "scripts": { | ||
@@ -10,3 +10,3 @@ "build:tsc": "tsc --project tsconfig.build.json --declarationDir ./lib && tsc --project tsconfig.build.json --declarationDir ./es" | ||
| "dependencies": { | ||
| "@ahooksjs/use-query-display": "^0.0.3-alpha.0" | ||
| "@ahooksjs/use-query-display": "^0.0.3-alpha.1" | ||
| }, | ||
@@ -20,3 +20,3 @@ "peerDependencies": { | ||
| ], | ||
| "gitHead": "66cf8d4c71cac6477d32df055785349db978125d" | ||
| "gitHead": "733696319adf031e32e3dcc6fec0c072e55fd160" | ||
| } |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
82942
2.53%1791
2.81%