@pushwoosh/dumb-components 1.0.17 → 1.0.19

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/Button/styles.js CHANGED
@@ -8,7 +8,7 @@ export const ButtonIcon = styled.div.withConfig({
8
8
  export const ButtonContent = styled.div.withConfig({
9
9
  displayName: "ButtonContent",
10
10
  componentId: "sc-qltvdl-1"
11
- })(["display:grid;justify-content:start;& > div{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}&:first-child{justify-content:center;}&:first-child:last-child{padding-left:", ";padding-right:", ";}&:last-child:not(:first-child){padding-right:", ";}"], Spacing.S2, Spacing.S2, Spacing.S2);
11
+ })(["display:grid;justify-content:start;& > div{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}&:first-child{justify-content:center;}&:first-child:last-child{padding-left:", ";padding-right:", ";}&:last-child:not(:first-child){padding-right:", ";}&:first-child:not(:last-child){padding-left:", ";}"], Spacing.S2, Spacing.S2, Spacing.S2, Spacing.S2);
12
12
  export const ButtonSpinner = styled.div.withConfig({
13
13
  displayName: "ButtonSpinner",
14
14
  componentId: "sc-qltvdl-2"
@@ -1,3 +1,2 @@
1
- export declare function pickBy<T extends Record<string, any>>(obj: T): Record<string, any>;
2
1
  export declare function mapKeys<T extends Record<string, any>, K extends string>(obj: T, mapper: (key: string) => K): Record<K, T[keyof T]>;
3
2
  export declare function shallowEqual<T extends Record<string, any>>(a: T, b: T): boolean;
@@ -1,6 +1,3 @@
1
- export function pickBy(obj) {
2
- return Object.fromEntries(Object.entries(obj).filter(([, value]) => !!value));
3
- }
4
1
  export function mapKeys(obj, mapper) {
5
2
  return Object.fromEntries(Object.entries(obj).map(([key, value]) => [mapper(key), value]));
6
3
  }
@@ -1,7 +1,7 @@
1
1
  import { useMemo, useRef } from 'react';
2
2
  import { useHistory, useLocation } from 'react-router-dom';
3
3
  import { usePersistentFunction } from '@pushwoosh/kit-helpers';
4
- import { mapKeys, pickBy, shallowEqual } from './helpers';
4
+ import { mapKeys, shallowEqual } from './helpers';
5
5
  export function useDataTableGetParams({
6
6
  defaultOrder,
7
7
  defaultDirection = 'asc',
@@ -37,10 +37,14 @@ export function useDataTableGetParams({
37
37
  }, [locationSearch, defaultDirection, defaultOrder, defaultPerPage, prefix]);
38
38
  const changeDataTableParams = usePersistentFunction(params => {
39
39
  const searchParams = new URLSearchParams(locationSearch);
40
- const paramsWithPrefix = pickBy(mapKeys(params, key => `${prefix}${key}`));
41
- Object.entries(paramsWithPrefix).forEach(([key, value]) => {
42
- searchParams.set(key, value);
43
- });
40
+ const paramsWithPrefix = mapKeys(params, key => `${prefix}${key}`);
41
+ for (const [key, value] of Object.entries(paramsWithPrefix)) {
42
+ if (value === undefined || value === null || value === '') {
43
+ searchParams.delete(key);
44
+ } else {
45
+ searchParams.set(key, String(value));
46
+ }
47
+ }
44
48
  history.push({
45
49
  search: searchParams.toString()
46
50
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",