@pushwoosh/kit-helpers 4.0.8 → 4.2.0
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.
- package/expand.js +2 -2
- package/grid.js +5 -5
- package/hooks/useAsync.js +4 -3
- package/hooks/useAsyncFn.d.ts +1 -1
- package/hooks/useAsyncFn.js +8 -7
- package/package.json +18 -42
package/expand.js
CHANGED
|
@@ -40,13 +40,13 @@ const ExpandTransitionComp = ({
|
|
|
40
40
|
};
|
|
41
41
|
const CollapseTransition = styled(ExpandTransitionComp).withConfig({
|
|
42
42
|
displayName: "CollapseTransition",
|
|
43
|
-
componentId: "sc-
|
|
43
|
+
componentId: "sc-k4fws9-0"
|
|
44
44
|
})(["transition:height var(--timeout) linear,opacity var(--timeout) linear;&-enter{overflow:hidden;opacity:0;height:0;}&-enter-active,&-exit{overflow:hidden;opacity:1;height:var(--height);}&-exit-active{overflow:hidden;opacity:0;height:0;}"]);
|
|
45
45
|
const enterExpandCss = css(["overflow:hidden;position:relative;width:1px;height:1px;& > *{position:absolute;top:calc(var(--height) / -2);left:calc(var(--width) / -2);}"]);
|
|
46
46
|
const exitExpandCss = css(["overflow:hidden;position:relative;width:var(--width);height:var(--height);& > *{position:absolute;top:0;left:0;}"]);
|
|
47
47
|
export const ExpandTransition = styled(ExpandTransitionComp).withConfig({
|
|
48
48
|
displayName: "ExpandTransition",
|
|
49
|
-
componentId: "sc-
|
|
49
|
+
componentId: "sc-k4fws9-1"
|
|
50
50
|
})(["transition:all var(--timeout) ease-out;& > *{transition:all var(--timeout) ease-out;}&-enter{", "}&-enter-active,&-exit{", "}&-exit-active{", "}"], enterExpandCss, exitExpandCss, enterExpandCss);
|
|
51
51
|
export const Collapse = ({
|
|
52
52
|
expanded,
|
package/grid.js
CHANGED
|
@@ -10,21 +10,21 @@ const createCssDeclaration = (property, value, valueConvert) => {
|
|
|
10
10
|
};
|
|
11
11
|
export const GridContainer = styled.div.withConfig({
|
|
12
12
|
displayName: "GridContainer",
|
|
13
|
-
componentId: "sc-
|
|
13
|
+
componentId: "sc-1mpmh7u-0"
|
|
14
14
|
})(["display:grid;", " ", " ", " ", " ", " ", " ", ""], props => createCssDeclaration('gap', props.$gap, toCssValue), props => createCssDeclaration('padding', props.$padding, toCssValue), props => createCssDeclaration('margin', props.$margin, toCssValue), props => createCssDeclaration('justify-content', props.$justifyContent), props => createCssDeclaration('justify-items', props.$justifyItems), props => createCssDeclaration('align-content', props.$alignContent), props => createCssDeclaration('align-items', props.$alignItems));
|
|
15
15
|
export const Columns = styled(GridContainer).withConfig({
|
|
16
16
|
displayName: "Columns",
|
|
17
|
-
componentId: "sc-
|
|
17
|
+
componentId: "sc-1mpmh7u-1"
|
|
18
18
|
})(["grid-template-columns:", ";"], props => gridTemplate(props.$sizes));
|
|
19
19
|
export const Rows = styled(GridContainer).withConfig({
|
|
20
20
|
displayName: "Rows",
|
|
21
|
-
componentId: "sc-
|
|
21
|
+
componentId: "sc-1mpmh7u-2"
|
|
22
22
|
})(["grid-template-rows:", ";"], props => gridTemplate(props.$sizes));
|
|
23
23
|
export const Horizontal = styled(GridContainer).withConfig({
|
|
24
24
|
displayName: "Horizontal",
|
|
25
|
-
componentId: "sc-
|
|
25
|
+
componentId: "sc-1mpmh7u-3"
|
|
26
26
|
})(["grid-auto-flow:column;"]);
|
|
27
27
|
export const Vertical = styled(GridContainer).withConfig({
|
|
28
28
|
displayName: "Vertical",
|
|
29
|
-
componentId: "sc-
|
|
29
|
+
componentId: "sc-1mpmh7u-4"
|
|
30
30
|
})(["grid-auto-flow:row;"]);
|
package/hooks/useAsync.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import useAsyncFn from './useAsyncFn';
|
|
3
|
+
const getInitialState = () => ({
|
|
4
|
+
loading: true
|
|
5
|
+
});
|
|
3
6
|
export default function useAsync(fn, deps = []) {
|
|
4
|
-
const [state, callback] = useAsyncFn(fn, deps,
|
|
5
|
-
loading: true
|
|
6
|
-
});
|
|
7
|
+
const [state, callback] = useAsyncFn(fn, deps, getInitialState);
|
|
7
8
|
useEffect(() => {
|
|
8
9
|
callback();
|
|
9
10
|
}, [callback]);
|
package/hooks/useAsyncFn.d.ts
CHANGED
|
@@ -22,5 +22,5 @@ export type AsyncFnReturn<T extends FunctionReturningPromise = FunctionReturning
|
|
|
22
22
|
StateFromFunctionReturningPromise<T>,
|
|
23
23
|
T
|
|
24
24
|
];
|
|
25
|
-
export default function useAsyncFn<T extends FunctionReturningPromise>(fn: T, deps?: DependencyList, initialState?: StateFromFunctionReturningPromise<T>): AsyncFnReturn<T>;
|
|
25
|
+
export default function useAsyncFn<T extends FunctionReturningPromise>(fn: T, deps?: DependencyList, initialState?: StateFromFunctionReturningPromise<T> | (() => StateFromFunctionReturningPromise<T>)): AsyncFnReturn<T>;
|
|
26
26
|
export {};
|
package/hooks/useAsyncFn.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { useCallback, useRef, useState } from 'react';
|
|
2
2
|
import useMountedState from './useMountedState';
|
|
3
|
-
|
|
3
|
+
const getDefaultState = () => ({
|
|
4
4
|
loading: false
|
|
5
|
-
})
|
|
5
|
+
});
|
|
6
|
+
export default function useAsyncFn(fn, deps = [], initialState = getDefaultState) {
|
|
6
7
|
const lastCallId = useRef(0);
|
|
7
8
|
const isMounted = useMountedState();
|
|
8
|
-
const [state,
|
|
9
|
+
const [state, setState] = useState(initialState);
|
|
9
10
|
const callback = useCallback((...args) => {
|
|
10
11
|
// eslint-disable-next-line no-plusplus
|
|
11
12
|
const callId = ++lastCallId.current;
|
|
12
13
|
const canSet = () => isMounted() && callId === lastCallId.current;
|
|
13
|
-
if (
|
|
14
|
-
|
|
14
|
+
if (canSet()) {
|
|
15
|
+
setState(prevState => ({
|
|
15
16
|
...prevState,
|
|
16
17
|
loading: true
|
|
17
18
|
}));
|
|
18
19
|
}
|
|
19
20
|
return fn(...args).then(value => {
|
|
20
21
|
if (canSet()) {
|
|
21
|
-
|
|
22
|
+
setState({
|
|
22
23
|
value,
|
|
23
24
|
loading: false
|
|
24
25
|
});
|
|
@@ -26,7 +27,7 @@ export default function useAsyncFn(fn, deps = [], initialState = {
|
|
|
26
27
|
return value;
|
|
27
28
|
}, error => {
|
|
28
29
|
if (canSet()) {
|
|
29
|
-
|
|
30
|
+
setState({
|
|
30
31
|
error,
|
|
31
32
|
loading: false
|
|
32
33
|
});
|
package/package.json
CHANGED
|
@@ -1,73 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/kit-helpers",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "React component for build Pushwoosh products",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"types": "index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
8
9
|
"scripts": {
|
|
9
|
-
"start": "
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"dev": "cross-env NODE_ENV=development webpack --config webpack.development.config.js",
|
|
13
|
-
"build:esm": "tsc -p ./tsconfig.library.json",
|
|
14
|
-
"build:babel": "babel ./lib --out-dir ./lib --extensions '.js' --config-file ./babel.compile.js",
|
|
15
|
-
"copy:pckg": "cp package.json lib/package.json && cp .npmrc lib/.npmrc",
|
|
10
|
+
"start": "npm run playground",
|
|
11
|
+
"build": "pushwoosh-engine lib:build",
|
|
12
|
+
"playground": "pushwoosh-engine lib:playground",
|
|
16
13
|
"check": "npm run check:lint && npm run check:types",
|
|
17
14
|
"check:lint": "echo \"Run check:lint\" && eslint .",
|
|
18
|
-
"check:types": "echo \"Run check:types\" &&
|
|
15
|
+
"check:types": "echo \"Run check:types\" && pushwoosh-engine lib:check-types"
|
|
19
16
|
},
|
|
20
17
|
"pre-commit": "check",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"react-transition-group": "^4.4.5"
|
|
20
|
+
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
25
|
-
"@babel/preset-env": "^7.15.8",
|
|
26
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
|
|
27
|
-
"@pushwoosh/kit-constants": "^1.5.0",
|
|
28
|
-
"@pushwoosh/kit-icons": "^1.4.2",
|
|
29
|
-
"@pushwoosh/kit-typography": "^1.4.0",
|
|
22
|
+
"@pushwoosh/frontend-builder-engine": "^0.1.2",
|
|
23
|
+
"@pushwoosh/kit-constants": "^1.6.0",
|
|
30
24
|
"@types/react": "^16.14.20",
|
|
31
25
|
"@types/react-dom": "^16.9.14",
|
|
32
|
-
"@types/react-transition-group": "^4.4.
|
|
33
|
-
"@types/styled-components": "^5.1.
|
|
34
|
-
"@
|
|
35
|
-
"@typescript-eslint/
|
|
36
|
-
"@typescript-eslint/parser": "^5.48.1",
|
|
37
|
-
"babel-loader": "^9.1.2",
|
|
38
|
-
"babel-plugin-styled-components": "^2.0.7",
|
|
39
|
-
"clean-webpack-plugin": "^4.0.0",
|
|
26
|
+
"@types/react-transition-group": "^4.4.10",
|
|
27
|
+
"@types/styled-components": "^5.1.34",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
|
29
|
+
"@typescript-eslint/parser": "^7.3.1",
|
|
40
30
|
"cross-env": "^7.0.3",
|
|
41
|
-
"dotenv": "^16.0.3",
|
|
42
31
|
"eslint": "^8.31.0",
|
|
43
32
|
"eslint-config-airbnb": "^19.0.4",
|
|
44
|
-
"eslint-config-airbnb-typescript": "^
|
|
33
|
+
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
45
34
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
46
35
|
"eslint-plugin-import": "^2.25.2",
|
|
47
36
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
48
37
|
"eslint-plugin-react": "^7.26.1",
|
|
49
38
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
50
|
-
"html-webpack-plugin": "^5.5.0",
|
|
51
39
|
"pre-commit": "^1.2.2",
|
|
52
40
|
"react": "^16.14.0",
|
|
53
41
|
"react-dom": "^16.14.0",
|
|
54
|
-
"
|
|
55
|
-
"react-transition-group": "^4.4.5",
|
|
56
|
-
"styled-components": "^5.3.3",
|
|
57
|
-
"terser-webpack-plugin": "^5.3.6",
|
|
58
|
-
"ts-loader": "^9.4.2",
|
|
59
|
-
"tslib": "^2.3.1",
|
|
60
|
-
"typescript": "^4.4.4",
|
|
61
|
-
"webpack": "^5.75.0",
|
|
62
|
-
"webpack-cli": "^5.0.1",
|
|
63
|
-
"webpack-dev-server": "^4.11.1",
|
|
64
|
-
"webpack-merge": "^5.8.0"
|
|
42
|
+
"styled-components": "^5.3.11"
|
|
65
43
|
},
|
|
66
44
|
"peerDependencies": {
|
|
67
45
|
"react": ">=16.14.0",
|
|
68
|
-
"
|
|
69
|
-
"styled-components": ">=5.3.3",
|
|
70
|
-
"tslib": "^2.3.1"
|
|
46
|
+
"styled-components": ">=5.3.3"
|
|
71
47
|
},
|
|
72
48
|
"engines": {
|
|
73
49
|
"node": ">= 18"
|