@pushwoosh/kit-helpers 4.4.1 → 4.6.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/grid.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare const GridContainer: import("styled-components").StyledComponent<
3
3
  $alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
4
4
  $alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
5
5
  $gap?: string | number | undefined;
6
+ $gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
6
7
  $justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
7
8
  $justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
8
9
  $margin?: string | number | undefined;
@@ -13,6 +14,7 @@ export declare const Columns: import("styled-components").StyledComponent<"div",
13
14
  $alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
14
15
  $alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
15
16
  $gap?: string | number | undefined;
17
+ $gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
16
18
  $justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
17
19
  $justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
18
20
  $margin?: string | number | undefined;
@@ -25,6 +27,7 @@ export declare const Rows: import("styled-components").StyledComponent<"div", an
25
27
  $alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
26
28
  $alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
27
29
  $gap?: string | number | undefined;
30
+ $gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
28
31
  $justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
29
32
  $justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
30
33
  $margin?: string | number | undefined;
@@ -37,19 +40,25 @@ export declare const Horizontal: import("styled-components").StyledComponent<"di
37
40
  $alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
38
41
  $alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
39
42
  $gap?: string | number | undefined;
43
+ $gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
40
44
  $justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
41
45
  $justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
42
46
  $margin?: string | number | undefined;
43
47
  $padding?: string | number | undefined;
44
48
  $placeItems?: "end" | "start" | "center" | "stretch" | undefined;
45
- }, never>;
49
+ } & {
50
+ $gridAutoFlow: string;
51
+ }, "$gridAutoFlow">;
46
52
  export declare const Vertical: import("styled-components").StyledComponent<"div", any, {
47
53
  $alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
48
54
  $alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
49
55
  $gap?: string | number | undefined;
56
+ $gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
50
57
  $justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
51
58
  $justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
52
59
  $margin?: string | number | undefined;
53
60
  $padding?: string | number | undefined;
54
61
  $placeItems?: "end" | "start" | "center" | "stretch" | undefined;
55
- }, never>;
62
+ } & {
63
+ $gridAutoFlow: string;
64
+ }, "$gridAutoFlow">;
package/grid.js CHANGED
@@ -11,7 +11,7 @@ const createCssDeclaration = (property, value, valueConvert) => {
11
11
  export const GridContainer = styled.div.withConfig({
12
12
  displayName: "GridContainer",
13
13
  componentId: "sc-1mpmh7u-0"
14
- })(["display:grid;", " ", " ", " ", " ", " ", " ", " ", ""], props => createCssDeclaration('align-content', props.$alignContent), props => createCssDeclaration('align-items', props.$alignItems), props => createCssDeclaration('gap', props.$gap, toCssValue), props => createCssDeclaration('justify-content', props.$justifyContent), props => createCssDeclaration('justify-items', props.$justifyItems), props => createCssDeclaration('margin', props.$margin, toCssValue), props => createCssDeclaration('padding', props.$padding, toCssValue), props => createCssDeclaration('place-items', props.$placeItems));
14
+ })(["display:grid;", " ", " ", " ", " ", " ", " ", " ", " ", ""], props => createCssDeclaration('align-content', props.$alignContent), props => createCssDeclaration('align-items', props.$alignItems), props => createCssDeclaration('gap', props.$gap, toCssValue), props => createCssDeclaration('grid-auto-flow', props.$gridAutoFlow), props => createCssDeclaration('justify-content', props.$justifyContent), props => createCssDeclaration('justify-items', props.$justifyItems), props => createCssDeclaration('margin', props.$margin, toCssValue), props => createCssDeclaration('padding', props.$padding, toCssValue), props => createCssDeclaration('place-items', props.$placeItems));
15
15
  export const Columns = styled(GridContainer).withConfig({
16
16
  displayName: "Columns",
17
17
  componentId: "sc-1mpmh7u-1"
@@ -20,11 +20,15 @@ export const Rows = styled(GridContainer).withConfig({
20
20
  displayName: "Rows",
21
21
  componentId: "sc-1mpmh7u-2"
22
22
  })(["grid-template-rows:", ";"], props => gridTemplate(props.$sizes));
23
- export const Horizontal = styled(GridContainer).withConfig({
23
+ export const Horizontal = styled(GridContainer).attrs({
24
+ $gridAutoFlow: 'column'
25
+ }).withConfig({
24
26
  displayName: "Horizontal",
25
27
  componentId: "sc-1mpmh7u-3"
26
- })(["grid-auto-flow:column;"]);
27
- export const Vertical = styled(GridContainer).withConfig({
28
+ })([""]);
29
+ export const Vertical = styled(GridContainer).attrs({
30
+ $gridAutoFlow: 'row'
31
+ }).withConfig({
28
32
  displayName: "Vertical",
29
33
  componentId: "sc-1mpmh7u-4"
30
- })(["grid-auto-flow:row;"]);
34
+ })([""]);
@@ -22,5 +22,8 @@ export type AsyncFnReturn<T extends FunctionReturningPromise = FunctionReturning
22
22
  StateFromFunctionReturningPromise<T>,
23
23
  T
24
24
  ];
25
+ export type CallbackParams = {
26
+ reset?: boolean;
27
+ };
25
28
  export default function useAsyncFn<T extends FunctionReturningPromise>(fn: T, deps?: DependencyList, initialState?: StateFromFunctionReturningPromise<T> | (() => StateFromFunctionReturningPromise<T>)): AsyncFnReturn<T>;
26
29
  export {};
@@ -7,17 +7,21 @@ export default function useAsyncFn(fn, deps = [], initialState = getDefaultState
7
7
  const lastCallId = useRef(0);
8
8
  const isMounted = useMountedState();
9
9
  const [state, setState] = useState(initialState);
10
- const callback = useCallback((...args) => {
10
+ const callback = useCallback(({
11
+ reset
12
+ } = {}) => {
11
13
  // eslint-disable-next-line no-plusplus
12
14
  const callId = ++lastCallId.current;
13
15
  const canSet = () => isMounted() && callId === lastCallId.current;
14
16
  if (canSet()) {
15
- setState(prevState => ({
17
+ setState(prevState => reset ? {
18
+ loading: true
19
+ } : {
16
20
  ...prevState,
17
21
  loading: true
18
- }));
22
+ });
19
23
  }
20
- return fn(...args).then(value => {
24
+ return fn().then(value => {
21
25
  if (canSet()) {
22
26
  setState({
23
27
  value,
@@ -1,2 +1,3 @@
1
- declare const useDelayedEffect: (effect: () => void, deps: any[], delay: number) => void;
1
+ import { type DependencyList } from 'react';
2
+ declare const useDelayedEffect: (effect: () => void, deps: DependencyList, delay: number) => void;
2
3
  export default useDelayedEffect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/kit-helpers",
3
- "version": "4.4.1",
3
+ "version": "4.6.0",
4
4
  "description": "React component for build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",