studiokit-scaffolding-js 4.5.0 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentClass, ComponentType } from 'react';
|
|
2
2
|
import { Dispatch } from 'redux';
|
|
3
3
|
import { BaseReduxState, Search } from '../../types';
|
|
4
|
-
export interface SearchPersistorProps {
|
|
5
|
-
persistSearch: (search?:
|
|
6
|
-
persistedSearch:
|
|
4
|
+
export interface SearchPersistorProps<T extends Search = Search> {
|
|
5
|
+
persistSearch: (search?: T) => void;
|
|
6
|
+
persistedSearch: T;
|
|
7
7
|
}
|
|
8
|
-
interface
|
|
9
|
-
search:
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
export interface SearchPersistorMethods {
|
|
13
|
-
setSearchDefaults: (doSearch: () => void, search: Search) => void;
|
|
14
|
-
updateAndPersistSearch: (search?: Search, callback?: () => void) => void;
|
|
8
|
+
export interface SearchPersistorMethods<T extends Search = Search> {
|
|
9
|
+
setSearchDefaults: (doSearch: () => void, search: T) => void;
|
|
10
|
+
updateAndPersistSearch: (search?: Search | T, callback?: () => void) => void;
|
|
15
11
|
handleSearchClick: () => void;
|
|
16
12
|
handleChangeTab: (selectedTab: number) => void;
|
|
17
13
|
handleKeywordsChange: (event: any) => void;
|
|
@@ -19,48 +15,13 @@ export interface SearchPersistorMethods {
|
|
|
19
15
|
handleQueryAllChange: (event: any) => void;
|
|
20
16
|
resetSearch: () => void;
|
|
21
17
|
}
|
|
22
|
-
export interface SearchPersistorWrappedProps extends SearchPersistorProps
|
|
23
|
-
search?:
|
|
18
|
+
export interface SearchPersistorWrappedProps<T extends Search = Search> extends SearchPersistorProps<T>, SearchPersistorMethods<T> {
|
|
19
|
+
search?: T;
|
|
24
20
|
}
|
|
25
|
-
export declare function configureSearchPersistorComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & SearchPersistorWrappedProps>):
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
setSearchDefaults: (doSearch: () => void, search: Search) => void;
|
|
30
|
-
updateAndPersistSearch: (search?: Search | undefined, callback?: (() => void) | undefined) => void;
|
|
31
|
-
handleSearchClick: () => void;
|
|
32
|
-
handleChangeTab: (selectedTab: number) => void;
|
|
33
|
-
handleKeywordsChange: (event: any) => void;
|
|
34
|
-
handleKeywordsKeyDown: (event: any) => void;
|
|
35
|
-
handleQueryAllChange: (event: any) => void;
|
|
36
|
-
resetSearch: () => void;
|
|
37
|
-
render(): JSX.Element;
|
|
38
|
-
context: any;
|
|
39
|
-
setState<K extends "search" | "defaultSearch">(state: SearchPersistorState | ((prevState: Readonly<SearchPersistorState>, props: Readonly<TOwnProps & SearchPersistorProps>) => SearchPersistorState | Pick<SearchPersistorState, K> | null) | Pick<SearchPersistorState, K> | null, callback?: (() => void) | undefined): void;
|
|
40
|
-
forceUpdate(callback?: (() => void) | undefined): void;
|
|
41
|
-
readonly props: Readonly<TOwnProps & SearchPersistorProps> & Readonly<{
|
|
42
|
-
children?: React.ReactNode;
|
|
43
|
-
}>;
|
|
44
|
-
state: Readonly<SearchPersistorState>;
|
|
45
|
-
refs: {
|
|
46
|
-
[key: string]: React.ReactInstance;
|
|
47
|
-
};
|
|
48
|
-
shouldComponentUpdate?(nextProps: Readonly<TOwnProps & SearchPersistorProps>, nextState: Readonly<SearchPersistorState>, nextContext: any): boolean;
|
|
49
|
-
componentWillUnmount?(): void;
|
|
50
|
-
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
51
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<TOwnProps & SearchPersistorProps>, prevState: Readonly<SearchPersistorState>): any;
|
|
52
|
-
componentDidUpdate?(prevProps: Readonly<TOwnProps & SearchPersistorProps>, prevState: Readonly<SearchPersistorState>, snapshot?: any): void;
|
|
53
|
-
componentWillMount?(): void;
|
|
54
|
-
UNSAFE_componentWillMount?(): void;
|
|
55
|
-
componentWillReceiveProps?(nextProps: Readonly<TOwnProps & SearchPersistorProps>, nextContext: any): void;
|
|
56
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TOwnProps & SearchPersistorProps>, nextContext: any): void;
|
|
57
|
-
componentWillUpdate?(nextProps: Readonly<TOwnProps & SearchPersistorProps>, nextState: Readonly<SearchPersistorState>, nextContext: any): void;
|
|
58
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<TOwnProps & SearchPersistorProps>, nextState: Readonly<SearchPersistorState>, nextContext: any): void;
|
|
59
|
-
};
|
|
60
|
-
contextType?: React.Context<any> | undefined;
|
|
61
|
-
};
|
|
62
|
-
export declare const configureMapStateToProps: (key: string) => (state: BaseReduxState) => SearchPersistorProps;
|
|
63
|
-
export declare const configureMapDispatchToProps: (key: string) => (dispatch: Dispatch) => SearchPersistorProps;
|
|
21
|
+
export declare function configureSearchPersistorComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & SearchPersistorWrappedProps>): ComponentType<TOwnProps & SearchPersistorProps>;
|
|
22
|
+
export declare function configureSearchPersistorComponent<TOwnProps extends {}, TSearchType extends Search>(WrappedComponent: ComponentType<TOwnProps & SearchPersistorWrappedProps<TSearchType>>): ComponentType<TOwnProps & SearchPersistorProps<TSearchType>>;
|
|
23
|
+
export declare const configureMapStateToProps: <TSearchType extends Search>(key: string) => (state: BaseReduxState) => SearchPersistorProps<TSearchType>;
|
|
24
|
+
export declare const configureMapDispatchToProps: <TSearchType extends Search>(key: string) => (dispatch: Dispatch) => SearchPersistorProps<TSearchType>;
|
|
64
25
|
/**
|
|
65
26
|
* HOC to handle persistence and restoration of "Manage" components search parameters.
|
|
66
27
|
* Note: if you store a search date in a child component, make sure it’s called `date`.
|
|
@@ -82,4 +43,24 @@ export declare const configureMapDispatchToProps: (key: string) => (dispatch: Di
|
|
|
82
43
|
* @returns The wrapped component, passing down `search` and `persistSearch` as props
|
|
83
44
|
*/
|
|
84
45
|
export default function searchPersistorComponent<TOwnProps extends SearchPersistorWrappedProps>(WrappedComponent: ComponentType<TOwnProps>, key: string): ComponentClass<Omit<TOwnProps, keyof SearchPersistorWrappedProps>>;
|
|
85
|
-
|
|
46
|
+
/**
|
|
47
|
+
* HOC to handle persistence and restoration of "Manage" components search parameters.
|
|
48
|
+
* Note: if you store a search date in a child component, make sure it’s called `date`.
|
|
49
|
+
* Rehydration of dates doesn’t work as expected out of the box with redux-persist.
|
|
50
|
+
* Something more generic might be in order in the future.
|
|
51
|
+
*
|
|
52
|
+
* Note: this also uses the `configureX` pattern of declaration for testability.
|
|
53
|
+
*
|
|
54
|
+
* API for child components:
|
|
55
|
+
* - Call `setSearchDefaults(this.doSearch, this.getDefaultSearch())` in child’s `componentDidMount`
|
|
56
|
+
* - Implement `getDefaultSearch`
|
|
57
|
+
* - Call this HOC’s handlers as needed
|
|
58
|
+
* - Implement any additional child-specific handlers and call this HOC’s `updateAndPersistSearch` in them
|
|
59
|
+
* - Make sure your `doSearch` and `render` handle undefined search props
|
|
60
|
+
* - Avoid intoxicating substances and wash your hands regularly
|
|
61
|
+
*
|
|
62
|
+
* @param WrappedComponent The component to wrap
|
|
63
|
+
* @param key The key under "search" in redux where the component’s search params will be stored
|
|
64
|
+
* @returns The wrapped component, passing down `search` and `persistSearch` as props
|
|
65
|
+
*/
|
|
66
|
+
export default function searchPersistorComponent<TOwnProps extends SearchPersistorWrappedProps<TSearchType>, TSearchType extends Search>(WrappedComponent: ComponentType<TOwnProps>, key: string): ComponentClass<Omit<TOwnProps, keyof SearchPersistorWrappedProps<TSearchType>>>;
|
|
@@ -168,26 +168,6 @@ var configureMapDispatchToProps = function (key) { return function (dispatch) {
|
|
|
168
168
|
};
|
|
169
169
|
}; };
|
|
170
170
|
exports.configureMapDispatchToProps = configureMapDispatchToProps;
|
|
171
|
-
/**
|
|
172
|
-
* HOC to handle persistence and restoration of "Manage" components search parameters.
|
|
173
|
-
* Note: if you store a search date in a child component, make sure it’s called `date`.
|
|
174
|
-
* Rehydration of dates doesn’t work as expected out of the box with redux-persist.
|
|
175
|
-
* Something more generic might be in order in the future.
|
|
176
|
-
*
|
|
177
|
-
* Note: this also uses the `configureX` pattern of declaration for testability.
|
|
178
|
-
*
|
|
179
|
-
* API for child components:
|
|
180
|
-
* - Call `setSearchDefaults(this.doSearch, this.getDefaultSearch())` in child’s `componentDidMount`
|
|
181
|
-
* - Implement `getDefaultSearch`
|
|
182
|
-
* - Call this HOC’s handlers as needed
|
|
183
|
-
* - Implement any additional child-specific handlers and call this HOC’s `updateAndPersistSearch` in them
|
|
184
|
-
* - Make sure your `doSearch` and `render` handle undefined search props
|
|
185
|
-
* - Avoid intoxicating substances and wash your hands regularly
|
|
186
|
-
*
|
|
187
|
-
* @param WrappedComponent The component to wrap
|
|
188
|
-
* @param key The key under "search" in redux where the component’s search params will be stored
|
|
189
|
-
* @returns The wrapped component, passing down `search` and `persistSearch` as props
|
|
190
|
-
*/
|
|
191
171
|
function searchPersistorComponent(WrappedComponent, key) {
|
|
192
172
|
var SearchPersistorComponent = configureSearchPersistorComponent(WrappedComponent);
|
|
193
173
|
var mapStateToProps = exports.configureMapStateToProps(key);
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var lodash_1 =
|
|
3
|
+
var lodash_1 = require("lodash");
|
|
7
4
|
var actions_1 = require("../actions");
|
|
8
5
|
/**
|
|
9
6
|
* Store the state of a manage component's search parameters so the params can be
|
|
@@ -18,7 +15,7 @@ function searchReducer(state, action) {
|
|
|
18
15
|
if (state === void 0) { state = {}; }
|
|
19
16
|
switch (action.type) {
|
|
20
17
|
case actions_1.ACTION.PERSIST_SEARCH:
|
|
21
|
-
return lodash_1.
|
|
18
|
+
return lodash_1.mergeWith({}, state, action.data, function (target, source) { return (lodash_1.isArray(source) ? source : undefined); });
|
|
22
19
|
default:
|
|
23
20
|
return state;
|
|
24
21
|
}
|
package/package.json
CHANGED